[{"data":1,"prerenderedAt":816},["ShallowReactive",2],{"/docs/scripts/free-phone/exports/billing-exports":3,"/docs/scripts/free-phone/exports/billing-exports-surround":804,"/docs/scripts/free-phone/exports/billing-exports-implemented-suggestions":815},{"id":4,"title":5,"body":6,"description":795,"extension":796,"head":797,"implementedSuggestions":797,"meta":798,"navigation":353,"path":799,"schemaOrg":797,"seo":800,"sitemap":801,"stem":802,"__hash__":803},"docs/1.docs/scripts/4.free-phone/3.exports/3.billing-exports.md","Billing Exports",{"type":7,"value":8,"toc":787},"minimark",[9,17,20,33,37,40,47,176,435,438,444,483,562,568,598,662,668,701,783],[10,11,12],"p",{},[13,14,16],"a",{"href":15},"/docs/scripts/free-phone/exports","All exports",[10,18,19],{},"This page documents the supported public integration calls. Client exports must run in a client\nscript and server exports must run in a server script. Internal NUI callbacks and net events are not\npublic APIs.",[21,22,25],"callout",{"color":23,"icon":24},"success","i-lucide-shield-check",[10,26,27,28,32],{},"Keep the resource folder named ",[29,30,31],"code",{},"sky_phone",". Validate every returned success value and keep money,\npermissions, ownership, and other authoritative changes on the server.",[34,35,5],"h2",{"id":36},"billing-exports",[10,38,39],{},"Billing exports are server-only and validate invoice state and monetary mutations inside Free\nPhone.",[41,42,44],"h3",{"id":43},"createinvoicedata",[29,45,46],{},"CreateInvoice(data)",[48,49,50,58,162],"ul",{},[51,52,53,57],"li",{},[54,55,56],"strong",{},"Purpose",": Creates a validated invoice for an online player or known character identifier.",[51,59,60,63,64],{},[54,61,62],{},"Arguments",":\n",[48,65,66],{},[51,67,68,71,72,75,76],{},[29,69,70],{},"data"," (",[29,73,74],{},"table","): Invoice definition.\n",[48,77,78,87,96,104,112,121,129,137,145,154],{},[51,79,80,71,83,86],{},[29,81,82],{},"recipientSource",[29,84,85],{},"number?","): Online recipient server ID.",[51,88,89,71,92,95],{},[29,90,91],{},"recipientIdentifier",[29,93,94],{},"string?","): Known character identifier when no source is supplied.",[51,97,98,71,101,103],{},[29,99,100],{},"issuerSource",[29,102,85],{},"): Online issuer server ID.",[51,105,106,71,109,111],{},[29,107,108],{},"issuerIdentifier",[29,110,94],{},"): Known issuer identifier.",[51,113,114,71,117,120],{},[29,115,116],{},"issuerAccount",[29,118,119],{},"string","): Account receiving paid funds.",[51,122,123,71,126,128],{},[29,124,125],{},"issuerLabel",[29,127,119],{},"): Display name shown to the recipient.",[51,130,131,71,134,136],{},[29,132,133],{},"title",[29,135,119],{},"): Invoice title.",[51,138,139,71,142,144],{},[29,140,141],{},"description",[29,143,94],{},"): Invoice details.",[51,146,147,71,150,153],{},[29,148,149],{},"amount",[29,151,152],{},"number","): Server-validated invoice amount.",[51,155,156,71,159,161],{},[29,157,158],{},"dueDays",[29,160,85],{},"): Optional payment period.",[51,163,164,167,168,171,172,175],{},[54,165,166],{},"Returns",": ",[29,169,170],{},"string | nil, string?"," — invoice ID or ",[29,173,174],{},"nil"," and an error code.",[177,178,184],"pre",{"className":179,"code":180,"filename":181,"language":182,"meta":183,"style":183},"language-lua shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","local invoice_id, error_code = exports[\"sky_phone\"]:CreateInvoice({\n    recipientSource = target_source,\n    issuerSource = source,\n    issuerAccount = \"ambulance\",\n    issuerLabel = \"Los Santos Medical\",\n    title = \"Medical treatment\",\n    description = \"Emergency treatment and medication.\",\n    amount = 1300,\n    dueDays = 7,\n})\n\nif not invoice_id then\n    print((\"[medical] Invoice failed: %s\"):format(error_code))\n    return\nend\n\nprint((\"[medical] Created invoice %s\"):format(invoice_id))\n","server.lua","lua","",[29,185,186,223,234,245,264,281,298,315,329,342,348,355,371,396,402,408,413],{"__ignoreMap":183},[187,188,191,195,199,202,205,208,211,213,216,220],"span",{"class":189,"line":190},"line",1,[187,192,194],{"class":193},"sMK4o","local",[187,196,198],{"class":197},"sTEyZ"," invoice_id, error_code ",[187,200,201],{"class":193},"=",[187,203,204],{"class":197}," exports[",[187,206,207],{"class":193},"\"",[187,209,31],{"class":210},"sfazB",[187,212,207],{"class":193},[187,214,215],{"class":197},"]:",[187,217,219],{"class":218},"s2Zo4","CreateInvoice",[187,221,222],{"class":197},"({\n",[187,224,226,229,231],{"class":189,"line":225},2,[187,227,228],{"class":197},"    recipientSource ",[187,230,201],{"class":193},[187,232,233],{"class":197}," target_source,\n",[187,235,237,240,242],{"class":189,"line":236},3,[187,238,239],{"class":197},"    issuerSource ",[187,241,201],{"class":193},[187,243,244],{"class":197}," source,\n",[187,246,248,251,253,256,259,261],{"class":189,"line":247},4,[187,249,250],{"class":197},"    issuerAccount ",[187,252,201],{"class":193},[187,254,255],{"class":193}," \"",[187,257,258],{"class":210},"ambulance",[187,260,207],{"class":193},[187,262,263],{"class":197},",\n",[187,265,267,270,272,274,277,279],{"class":189,"line":266},5,[187,268,269],{"class":197},"    issuerLabel ",[187,271,201],{"class":193},[187,273,255],{"class":193},[187,275,276],{"class":210},"Los Santos Medical",[187,278,207],{"class":193},[187,280,263],{"class":197},[187,282,284,287,289,291,294,296],{"class":189,"line":283},6,[187,285,286],{"class":197},"    title ",[187,288,201],{"class":193},[187,290,255],{"class":193},[187,292,293],{"class":210},"Medical treatment",[187,295,207],{"class":193},[187,297,263],{"class":197},[187,299,301,304,306,308,311,313],{"class":189,"line":300},7,[187,302,303],{"class":197},"    description ",[187,305,201],{"class":193},[187,307,255],{"class":193},[187,309,310],{"class":210},"Emergency treatment and medication.",[187,312,207],{"class":193},[187,314,263],{"class":197},[187,316,318,321,323,327],{"class":189,"line":317},8,[187,319,320],{"class":197},"    amount ",[187,322,201],{"class":193},[187,324,326],{"class":325},"sbssI"," 1300",[187,328,263],{"class":197},[187,330,332,335,337,340],{"class":189,"line":331},9,[187,333,334],{"class":197},"    dueDays ",[187,336,201],{"class":193},[187,338,339],{"class":325}," 7",[187,341,263],{"class":197},[187,343,345],{"class":189,"line":344},10,[187,346,347],{"class":197},"})\n",[187,349,351],{"class":189,"line":350},11,[187,352,354],{"emptyLinePlaceholder":353},true,"\n",[187,356,358,362,365,368],{"class":189,"line":357},12,[187,359,361],{"class":360},"s7zQu","if",[187,363,364],{"class":193}," not",[187,366,367],{"class":197}," invoice_id ",[187,369,370],{"class":360},"then\n",[187,372,374,377,380,382,385,387,390,393],{"class":189,"line":373},13,[187,375,376],{"class":218},"    print",[187,378,379],{"class":197},"((",[187,381,207],{"class":193},[187,383,384],{"class":210},"[medical] Invoice failed: %s",[187,386,207],{"class":193},[187,388,389],{"class":197},"):",[187,391,392],{"class":218},"format",[187,394,395],{"class":197},"(error_code))\n",[187,397,399],{"class":189,"line":398},14,[187,400,401],{"class":360},"    return\n",[187,403,405],{"class":189,"line":404},15,[187,406,407],{"class":360},"end\n",[187,409,411],{"class":189,"line":410},16,[187,412,354],{"emptyLinePlaceholder":353},[187,414,416,419,421,423,426,428,430,432],{"class":189,"line":415},17,[187,417,418],{"class":218},"print",[187,420,379],{"class":197},[187,422,207],{"class":193},[187,424,425],{"class":210},"[medical] Created invoice %s",[187,427,207],{"class":193},[187,429,389],{"class":197},[187,431,392],{"class":218},[187,433,434],{"class":197},"(invoice_id))\n",[10,436,437],{},"Never accept an invoice amount from an untrusted client without validating the service and price on\nthe server.",[41,439,441],{"id":440},"cancelinvoiceinvoiceid-actoridentifier",[29,442,443],{},"CancelInvoice(invoiceId, actorIdentifier)",[48,445,446,451,476],{},[51,447,448,450],{},[54,449,56],{},": Cancels an open invoice.",[51,452,453,63,455],{},[54,454,62],{},[48,456,457,468],{},[51,458,459,71,462,464,465,467],{},[29,460,461],{},"invoiceId",[29,463,119],{},"): Invoice ID returned by ",[29,466,219],{},".",[51,469,470,71,473,475],{},[29,471,472],{},"actorIdentifier",[29,474,119],{},"): Character or integration actor responsible for cancellation.",[51,477,478,167,480,467],{},[54,479,166],{},[29,481,482],{},"boolean",[177,484,486],{"className":179,"code":485,"filename":181,"language":182,"meta":183,"style":183},"local cancelled = exports[\"sky_phone\"]:CancelInvoice(\n    invoice_id,\n    issuer_identifier\n)\n\nif not cancelled then\n    print(\"Invoice could not be cancelled\")\nend\n",[29,487,488,513,518,523,528,532,542,558],{"__ignoreMap":183},[187,489,490,492,495,497,499,501,503,505,507,510],{"class":189,"line":190},[187,491,194],{"class":193},[187,493,494],{"class":197}," cancelled ",[187,496,201],{"class":193},[187,498,204],{"class":197},[187,500,207],{"class":193},[187,502,31],{"class":210},[187,504,207],{"class":193},[187,506,215],{"class":197},[187,508,509],{"class":218},"CancelInvoice",[187,511,512],{"class":197},"(\n",[187,514,515],{"class":189,"line":225},[187,516,517],{"class":197},"    invoice_id,\n",[187,519,520],{"class":189,"line":236},[187,521,522],{"class":197},"    issuer_identifier\n",[187,524,525],{"class":189,"line":247},[187,526,527],{"class":197},")\n",[187,529,530],{"class":189,"line":266},[187,531,354],{"emptyLinePlaceholder":353},[187,533,534,536,538,540],{"class":189,"line":283},[187,535,361],{"class":360},[187,537,364],{"class":193},[187,539,494],{"class":197},[187,541,370],{"class":360},[187,543,544,546,549,551,554,556],{"class":189,"line":300},[187,545,376],{"class":218},[187,547,548],{"class":197},"(",[187,550,207],{"class":193},[187,552,553],{"class":210},"Invoice could not be cancelled",[187,555,207],{"class":193},[187,557,527],{"class":197},[187,559,560],{"class":189,"line":317},[187,561,407],{"class":360},[41,563,565],{"id":564},"getbillingaccountbalanceaccountkey",[29,566,567],{},"GetBillingAccountBalance(accountKey)",[48,569,570,575,591],{},[51,571,572,574],{},[54,573,56],{},": Reads the current internal balance for a billing account.",[51,576,577,63,579],{},[54,578,62],{},[48,580,581],{},[51,582,583,71,586,588,589,467],{},[29,584,585],{},"accountKey",[29,587,119],{},"): Account key such as ",[29,590,258],{},[51,592,593,167,595,467],{},[54,594,166],{},[29,596,597],{},"number | nil",[177,599,601],{"className":179,"code":600,"filename":181,"language":182,"meta":183,"style":183},"local balance = exports[\"sky_phone\"]:GetBillingAccountBalance(\"ambulance\") or 0\nprint((\"Medical billing balance: $%s\"):format(balance))\n",[29,602,603,642],{"__ignoreMap":183},[187,604,605,607,610,612,614,616,618,620,622,625,627,629,631,633,636,639],{"class":189,"line":190},[187,606,194],{"class":193},[187,608,609],{"class":197}," balance ",[187,611,201],{"class":193},[187,613,204],{"class":197},[187,615,207],{"class":193},[187,617,31],{"class":210},[187,619,207],{"class":193},[187,621,215],{"class":197},[187,623,624],{"class":218},"GetBillingAccountBalance",[187,626,548],{"class":197},[187,628,207],{"class":193},[187,630,258],{"class":210},[187,632,207],{"class":193},[187,634,635],{"class":197},") ",[187,637,638],{"class":193},"or",[187,640,641],{"class":325}," 0\n",[187,643,644,646,648,650,653,655,657,659],{"class":189,"line":225},[187,645,418],{"class":218},[187,647,379],{"class":197},[187,649,207],{"class":193},[187,651,652],{"class":210},"Medical billing balance: $%s",[187,654,207],{"class":193},[187,656,389],{"class":197},[187,658,392],{"class":218},[187,660,661],{"class":197},"(balance))\n",[41,663,665],{"id":664},"removebillingaccountbalanceaccountkey-amount",[29,666,667],{},"RemoveBillingAccountBalance(accountKey, amount)",[48,669,670,675,695],{},[51,671,672,674],{},[54,673,56],{},": Atomically withdraws an amount when sufficient balance is available.",[51,676,677,63,679],{},[54,678,62],{},[48,680,681,688],{},[51,682,683,71,685,687],{},[29,684,585],{},[29,686,119],{},"): Billing account key.",[51,689,690,71,692,694],{},[29,691,149],{},[29,693,152],{},"): Positive server-calculated withdrawal amount.",[51,696,697,167,699,467],{},[54,698,166],{},[29,700,482],{},[177,702,704],{"className":179,"code":703,"filename":181,"language":182,"meta":183,"style":183},"local removed = exports[\"sky_phone\"]:RemoveBillingAccountBalance(\n    \"ambulance\",\n    5000\n)\n\nif not removed then\n    print(\"Insufficient billing balance or invalid request\")\nend\n",[29,705,706,730,741,746,750,754,764,779],{"__ignoreMap":183},[187,707,708,710,713,715,717,719,721,723,725,728],{"class":189,"line":190},[187,709,194],{"class":193},[187,711,712],{"class":197}," removed ",[187,714,201],{"class":193},[187,716,204],{"class":197},[187,718,207],{"class":193},[187,720,31],{"class":210},[187,722,207],{"class":193},[187,724,215],{"class":197},[187,726,727],{"class":218},"RemoveBillingAccountBalance",[187,729,512],{"class":197},[187,731,732,735,737,739],{"class":189,"line":225},[187,733,734],{"class":193},"    \"",[187,736,258],{"class":210},[187,738,207],{"class":193},[187,740,263],{"class":197},[187,742,743],{"class":189,"line":236},[187,744,745],{"class":325},"    5000\n",[187,747,748],{"class":189,"line":247},[187,749,527],{"class":197},[187,751,752],{"class":189,"line":266},[187,753,354],{"emptyLinePlaceholder":353},[187,755,756,758,760,762],{"class":189,"line":283},[187,757,361],{"class":360},[187,759,364],{"class":193},[187,761,712],{"class":197},[187,763,370],{"class":360},[187,765,766,768,770,772,775,777],{"class":189,"line":300},[187,767,376],{"class":218},[187,769,548],{"class":197},[187,771,207],{"class":193},[187,773,774],{"class":210},"Insufficient billing balance or invalid request",[187,776,207],{"class":193},[187,778,527],{"class":197},[187,780,781],{"class":189,"line":317},[187,782,407],{"class":360},[784,785,786],"style",{},"html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}html pre.shiki code .s7zQu, html code.shiki .s7zQu{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":183,"searchDepth":190,"depth":225,"links":788},[789],{"id":36,"depth":225,"text":5,"children":790},[791,792,793,794],{"id":43,"depth":236,"text":46},{"id":440,"depth":236,"text":443},{"id":564,"depth":236,"text":567},{"id":664,"depth":236,"text":667},"Billing Exports for the Free Phone custom-app, billing and CrewLink integrations.","md",null,{},"/docs/scripts/free-phone/exports/billing-exports",{"title":5,"description":795},{"loc":799},"1.docs/scripts/4.free-phone/3.exports/3.billing-exports","8LkrC9wH2GETPQPRbgJ2jl0eFapadTeTcb5NC-64-74",[805,810],{"title":806,"path":807,"stem":808,"description":809,"children":-1},"Server Exports","/docs/scripts/free-phone/exports/server-exports","1.docs/scripts/4.free-phone/3.exports/2.server-exports","Server Exports for the Free Phone custom-app, billing and CrewLink integrations.",{"title":811,"path":812,"stem":813,"description":814,"children":-1},"CrewLink Exports","/docs/scripts/free-phone/exports/crewlink-exports","1.docs/scripts/4.free-phone/3.exports/4.crewlink-exports","CrewLink Exports for the Free Phone custom-app, billing and CrewLink integrations.",[],1791814186219]