[{"data":1,"prerenderedAt":508},["ShallowReactive",2],{"navigation_docs":3,"-sdks-php":132,"-sdks-php-surround":503},[4,30,47,128],{"title":5,"path":6,"stem":7,"children":8,"page":29},"Getting Started","\u002Fgetting-started","1.getting-started",[9,13,17,21,25],{"title":10,"path":11,"stem":12},"Introduction","\u002Fgetting-started\u002Fintroduction","1.getting-started\u002F1.introduction",{"title":14,"path":15,"stem":16},"Quickstart","\u002Fgetting-started\u002Fquickstart","1.getting-started\u002F2.quickstart",{"title":18,"path":19,"stem":20},"Authentication","\u002Fgetting-started\u002Fauthentication","1.getting-started\u002F3.authentication",{"title":22,"path":23,"stem":24},"Self-Hosting","\u002Fgetting-started\u002Fself-hosting","1.getting-started\u002F4.self-hosting",{"title":26,"path":27,"stem":28},"Build an Integration","\u002Fgetting-started\u002Fbuild-an-integration","1.getting-started\u002F5.build-an-integration",false,{"title":31,"path":32,"stem":33,"children":34,"page":29},"Sdks","\u002Fsdks","2.sdks",[35,39,43],{"title":36,"path":37,"stem":38},"TypeScript SDK","\u002Fsdks\u002Ftypescript","2.sdks\u002F1.typescript",{"title":40,"path":41,"stem":42},"Python SDK","\u002Fsdks\u002Fpython","2.sdks\u002F2.python",{"title":44,"path":45,"stem":46},"PHP SDK","\u002Fsdks\u002Fphp","2.sdks\u002F3.php",{"title":48,"path":49,"stem":50,"children":51,"page":29},"Guides","\u002Fguides","3.guides",[52,56,60,64,68,72,76,80,84,88,92,96,100,104,108,112,116,120,124],{"title":53,"path":54,"stem":55},"Customers","\u002Fguides\u002Fcustomers","3.guides\u002F1.customers",{"title":57,"path":58,"stem":59},"Usage-Based Billing","\u002Fguides\u002Fusage-billing","3.guides\u002F10.usage-billing",{"title":61,"path":62,"stem":63},"Wallets","\u002Fguides\u002Fwallets","3.guides\u002F11.wallets",{"title":65,"path":66,"stem":67},"Coupons, Add-ons and Credit Notes","\u002Fguides\u002Fcoupons-add-ons-credit-notes","3.guides\u002F12.coupons-add-ons-credit-notes",{"title":69,"path":70,"stem":71},"Taxes","\u002Fguides\u002Ftaxes","3.guides\u002F13.taxes",{"title":73,"path":74,"stem":75},"Customer Portal","\u002Fguides\u002Fcustomer-portal","3.guides\u002F14.customer-portal",{"title":77,"path":78,"stem":79},"Ledger","\u002Fguides\u002Fledger","3.guides\u002F15.ledger",{"title":81,"path":82,"stem":83},"Plan Limits and Access","\u002Fguides\u002Fplan-limits-and-access","3.guides\u002F16.plan-limits-and-access",{"title":85,"path":86,"stem":87},"Currencies and Exchange Rates","\u002Fguides\u002Fcurrencies","3.guides\u002F17.currencies",{"title":89,"path":90,"stem":91},"Charge a Customer","\u002Fguides\u002Fcharge-a-customer","3.guides\u002F18.charge-a-customer",{"title":93,"path":94,"stem":95},"One-time Products & Partial Payments","\u002Fguides\u002Fone-time-products-and-partial-payments","3.guides\u002F19.one-time-products-and-partial-payments",{"title":97,"path":98,"stem":99},"Plans & Pricing","\u002Fguides\u002Fplans-and-pricing","3.guides\u002F2.plans-and-pricing",{"title":101,"path":102,"stem":103},"Subscriptions","\u002Fguides\u002Fsubscriptions","3.guides\u002F3.subscriptions",{"title":105,"path":106,"stem":107},"Invoices & Payments","\u002Fguides\u002Finvoices-and-payments","3.guides\u002F4.invoices-and-payments",{"title":109,"path":110,"stem":111},"Payment Providers","\u002Fguides\u002Fpayment-providers","3.guides\u002F5.payment-providers",{"title":113,"path":114,"stem":115},"Analytics","\u002Fguides\u002Fanalytics","3.guides\u002F6.analytics",{"title":117,"path":118,"stem":119},"Webhooks","\u002Fguides\u002Fwebhooks","3.guides\u002F7.webhooks",{"title":121,"path":122,"stem":123},"Sandbox","\u002Fguides\u002Fsandbox","3.guides\u002F8.sandbox",{"title":125,"path":126,"stem":127},"Money Movement","\u002Fguides\u002Fmoney-movement","3.guides\u002F9.money-movement",{"title":129,"path":130,"stem":131},"API Reference","\u002Fapi-reference","4.api-reference",{"id":133,"title":44,"body":134,"description":497,"extension":498,"links":499,"meta":500,"navigation":193,"path":45,"seo":501,"stem":46,"__hash__":502},"docs\u002F2.sdks\u002F3.php.md",{"type":135,"value":136,"toc":489},"minimark",[137,141,146,172,176,212,219,247,250,253,317,321,332,384,388,395,439,449,453,478,485],[138,139,140],"p",{},"The PimaBill PHP SDK covers the whole API with typed request and response classes. It needs PHP 8.1 or later and any PSR-18 HTTP client (Guzzle, Symfony HttpClient and others are found automatically).",[142,143,145],"h2",{"id":144},"installation","Installation",[147,148,153],"pre",{"className":149,"code":150,"language":151,"meta":152,"style":152},"language-bash shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","composer require pimabill\u002Fpimabill-php\n","bash","",[154,155,156],"code",{"__ignoreMap":152},[157,158,161,165,169],"span",{"class":159,"line":160},"line",1,[157,162,164],{"class":163},"sBMFI","composer",[157,166,168],{"class":167},"sfazB"," require",[157,170,171],{"class":167}," pimabill\u002Fpimabill-php\n",[142,173,175],{"id":174},"client-initialization","Client Initialization",[147,177,181],{"className":178,"code":179,"language":180,"meta":152,"style":152},"language-php shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","\u003C?php\n\nuse PimaBill\\PimaBillClient;\n\n$client = new PimaBillClient(token: getenv('PIMABILL_API_KEY'));\n","php",[154,182,183,188,195,201,206],{"__ignoreMap":152},[157,184,185],{"class":159,"line":160},[157,186,187],{},"\u003C?php\n",[157,189,191],{"class":159,"line":190},2,[157,192,194],{"emptyLinePlaceholder":193},true,"\n",[157,196,198],{"class":159,"line":197},3,[157,199,200],{},"use PimaBill\\PimaBillClient;\n",[157,202,204],{"class":159,"line":203},4,[157,205,194],{"emptyLinePlaceholder":193},[157,207,209],{"class":159,"line":208},5,[157,210,211],{},"$client = new PimaBillClient(token: getenv('PIMABILL_API_KEY'));\n",[138,213,214,215,218],{},"The client talks to the hosted API (",[154,216,217],{},"https:\u002F\u002Fapi.pimabill.com",") unless told otherwise:",[147,220,222],{"className":178,"code":221,"language":180,"meta":152,"style":152},"use PimaBill\\Environments;\nuse PimaBill\\PimaBillClient;\n\n$sandbox = new PimaBillClient(token: 'sk_test_...', options: ['baseUrl' => Environments::Sandbox->value]);\n$selfHosted = new PimaBillClient(token: 'sk_live_...', options: ['baseUrl' => 'https:\u002F\u002Fbilling.example.com']);\n",[154,223,224,229,233,237,242],{"__ignoreMap":152},[157,225,226],{"class":159,"line":160},[157,227,228],{},"use PimaBill\\Environments;\n",[157,230,231],{"class":159,"line":190},[157,232,200],{},[157,234,235],{"class":159,"line":197},[157,236,194],{"emptyLinePlaceholder":193},[157,238,239],{"class":159,"line":203},[157,240,241],{},"$sandbox = new PimaBillClient(token: 'sk_test_...', options: ['baseUrl' => Environments::Sandbox->value]);\n",[157,243,244],{"class":159,"line":208},[157,245,246],{},"$selfHosted = new PimaBillClient(token: 'sk_live_...', options: ['baseUrl' => 'https:\u002F\u002Fbilling.example.com']);\n",[138,248,249],{},"Requests take a typed request object; responses are typed objects.",[142,251,53],{"id":252},"customers",[147,254,256],{"className":178,"code":255,"language":180,"meta":152,"style":152},"use PimaBill\\Customers\\Requests\\CreateCustomerDto;\n\n$customer = $client->customers->create(new CreateCustomerDto([\n    'externalId' => 'usr_98765',\n    'email' => 'sarah@kampaltech.ug',\n    'name' => 'Nakato Sarah',\n    'country' => 'UG',\n    'currency' => 'UGX',\n]));\n\necho $customer->id;\n",[154,257,258,263,267,272,277,282,288,294,300,306,311],{"__ignoreMap":152},[157,259,260],{"class":159,"line":160},[157,261,262],{},"use PimaBill\\Customers\\Requests\\CreateCustomerDto;\n",[157,264,265],{"class":159,"line":190},[157,266,194],{"emptyLinePlaceholder":193},[157,268,269],{"class":159,"line":197},[157,270,271],{},"$customer = $client->customers->create(new CreateCustomerDto([\n",[157,273,274],{"class":159,"line":203},[157,275,276],{},"    'externalId' => 'usr_98765',\n",[157,278,279],{"class":159,"line":208},[157,280,281],{},"    'email' => 'sarah@kampaltech.ug',\n",[157,283,285],{"class":159,"line":284},6,[157,286,287],{},"    'name' => 'Nakato Sarah',\n",[157,289,291],{"class":159,"line":290},7,[157,292,293],{},"    'country' => 'UG',\n",[157,295,297],{"class":159,"line":296},8,[157,298,299],{},"    'currency' => 'UGX',\n",[157,301,303],{"class":159,"line":302},9,[157,304,305],{},"]));\n",[157,307,309],{"class":159,"line":308},10,[157,310,194],{"emptyLinePlaceholder":193},[157,312,314],{"class":159,"line":313},11,[157,315,316],{},"echo $customer->id;\n",[142,318,320],{"id":319},"collecting-a-payment","Collecting a payment",[138,322,323,324,327,328,331],{},"A mobile money prompt to the payer's phone; the result arrives on your webhook as ",[154,325,326],{},"collection.succeeded"," or ",[154,329,330],{},"collection.failed",".",[147,333,335],{"className":178,"code":334,"language":180,"meta":152,"style":152},"use PimaBill\\Collections\\Requests\\CreateCollectionDto;\nuse PimaBill\\Types\\MobileMoneyParty;\nuse PimaBill\\Types\\Party;\n\n$collection = $client->collections->create(new CreateCollectionDto([\n    'amount' => '50000',\n    'currency' => 'UGX',\n    'payer' => Party::mobileMoney(new MobileMoneyParty(['msisdn' => '256771234567'])),\n    'reference' => 'order-1042',\n]));\n",[154,336,337,342,347,352,356,361,366,370,375,380],{"__ignoreMap":152},[157,338,339],{"class":159,"line":160},[157,340,341],{},"use PimaBill\\Collections\\Requests\\CreateCollectionDto;\n",[157,343,344],{"class":159,"line":190},[157,345,346],{},"use PimaBill\\Types\\MobileMoneyParty;\n",[157,348,349],{"class":159,"line":197},[157,350,351],{},"use PimaBill\\Types\\Party;\n",[157,353,354],{"class":159,"line":203},[157,355,194],{"emptyLinePlaceholder":193},[157,357,358],{"class":159,"line":208},[157,359,360],{},"$collection = $client->collections->create(new CreateCollectionDto([\n",[157,362,363],{"class":159,"line":284},[157,364,365],{},"    'amount' => '50000',\n",[157,367,368],{"class":159,"line":290},[157,369,299],{},[157,371,372],{"class":159,"line":296},[157,373,374],{},"    'payer' => Party::mobileMoney(new MobileMoneyParty(['msisdn' => '256771234567'])),\n",[157,376,377],{"class":159,"line":302},[157,378,379],{},"    'reference' => 'order-1042',\n",[157,381,382],{"class":159,"line":308},[157,383,305],{},[142,385,387],{"id":386},"errors","Errors",[138,389,390,391,394],{},"Every non-2xx response throws ",[154,392,393],{},"PimabillApiException",", with the status code and response body:",[147,396,398],{"className":178,"code":397,"language":180,"meta":152,"style":152},"use PimaBill\\Exceptions\\PimabillApiException;\n\ntry {\n    $client->customers->get('cus_missing');\n} catch (PimabillApiException $e) {\n    echo $e->getCode();     \u002F\u002F e.g. 404\n    echo $e->getBody();     \u002F\u002F the API's error message\n}\n",[154,399,400,405,409,414,419,424,429,434],{"__ignoreMap":152},[157,401,402],{"class":159,"line":160},[157,403,404],{},"use PimaBill\\Exceptions\\PimabillApiException;\n",[157,406,407],{"class":159,"line":190},[157,408,194],{"emptyLinePlaceholder":193},[157,410,411],{"class":159,"line":197},[157,412,413],{},"try {\n",[157,415,416],{"class":159,"line":203},[157,417,418],{},"    $client->customers->get('cus_missing');\n",[157,420,421],{"class":159,"line":208},[157,422,423],{},"} catch (PimabillApiException $e) {\n",[157,425,426],{"class":159,"line":284},[157,427,428],{},"    echo $e->getCode();     \u002F\u002F e.g. 404\n",[157,430,431],{"class":159,"line":290},[157,432,433],{},"    echo $e->getBody();     \u002F\u002F the API's error message\n",[157,435,436],{"class":159,"line":296},[157,437,438],{},"}\n",[138,440,441,442,445,446,331],{},"The exception classes are spelled ",[154,443,444],{},"Pimabill…",", after the generator's organisation name; the client is ",[154,447,448],{},"PimaBillClient",[142,450,452],{"id":451},"retries-and-timeouts","Retries and timeouts",[147,454,456],{"className":178,"code":455,"language":180,"meta":152,"style":152},"$client = new PimaBillClient(token: getenv('PIMABILL_API_KEY'), options: [\n    'maxRetries' => 2,\n    'timeout' => 30.0,\n]);\n",[154,457,458,463,468,473],{"__ignoreMap":152},[157,459,460],{"class":159,"line":160},[157,461,462],{},"$client = new PimaBillClient(token: getenv('PIMABILL_API_KEY'), options: [\n",[157,464,465],{"class":159,"line":190},[157,466,467],{},"    'maxRetries' => 2,\n",[157,469,470],{"class":159,"line":197},[157,471,472],{},"    'timeout' => 30.0,\n",[157,474,475],{"class":159,"line":203},[157,476,477],{},"]);\n",[138,479,480,481,331],{},"Money-moving requests accept an idempotency key, so a retried request never charges or pays twice. See ",[482,483,484],"a",{"href":126},"Money movement",[486,487,488],"style",{},"html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}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":152,"searchDepth":190,"depth":190,"links":490},[491,492,493,494,495,496],{"id":144,"depth":190,"text":145},{"id":174,"depth":190,"text":175},{"id":252,"depth":190,"text":53},{"id":319,"depth":190,"text":320},{"id":386,"depth":190,"text":387},{"id":451,"depth":190,"text":452},"Use the PimaBill API from PHP 8.1 or later.","md",null,{},{"title":44,"description":497},"PlisA2A5S2IM1ZcZj4Z9pkBV6a6JXVC2QK6aYnFHKf0",[504,506],{"title":40,"path":41,"stem":42,"description":505,"children":-1},"Complete guide to using the PimaBill Python SDK with sync and async support.",{"title":53,"path":54,"stem":55,"description":507,"children":-1},"Learn how to create, manage, and query customers in PimaBill.",1793401244653]