[{"data":1,"prerenderedAt":2067},["ShallowReactive",2],{"navigation_docs":3,"-sdks-python":132,"-sdks-python-surround":2062},[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":40,"body":134,"description":2056,"extension":2057,"links":2058,"meta":2059,"navigation":217,"path":41,"seo":2060,"stem":42,"__hash__":2061},"docs\u002F2.sdks\u002F2.python.md",{"type":135,"value":136,"toc":1997},"minimark",[137,141,146,191,195,200,236,243,272,276,303,306,309,316,320,373,377,401,405,434,438,498,502,511,515,544,548,554,558,639,643,652,656,671,675,690,693,713,717,769,773,792,796,811,815,824,828,852,856,874,878,942,946,969,973,993,997,1017,1021,1040,1044,1047,1051,1075,1079,1098,1102,1131,1134,1138,1158,1162,1205,1209,1261,1265,1347,1351,1411,1415,1424,1427,1456,1459,1469,1507,1515,1519,1526,1604,1608,1695,1699,1705,1783,1787,1811,1856,1860,1866,1912,1916,1967,1971,1993],[138,139,140],"p",{},"The PimaBill Python SDK provides a fully typed, Pythonic interface to the entire PimaBill API. It supports both synchronous and asynchronous usage, and responses are Pydantic models.",[142,143,145],"h2",{"id":144},"installation","Installation",[147,148,150,176],"code-group",{"sync":149},"pkg",[151,152,158],"pre",{"className":153,"code":154,"filename":155,"language":156,"meta":157,"style":157},"language-bash shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","pip install pimabill\n","pip","bash","",[159,160,161],"code",{"__ignoreMap":157},[162,163,166,169,173],"span",{"class":164,"line":165},"line",1,[162,167,155],{"class":168},"sBMFI",[162,170,172],{"class":171},"sfazB"," install",[162,174,175],{"class":171}," pimabill\n",[151,177,180],{"className":153,"code":178,"filename":179,"language":156,"meta":157,"style":157},"poetry add pimabill\n","poetry",[159,181,182],{"__ignoreMap":157},[162,183,184,186,189],{"class":164,"line":165},[162,185,179],{"class":168},[162,187,188],{"class":171}," add",[162,190,175],{"class":171},[142,192,194],{"id":193},"client-initialization","Client Initialization",[196,197,199],"h3",{"id":198},"synchronous-client","Synchronous Client",[151,201,205],{"className":202,"code":203,"language":204,"meta":157,"style":157},"language-python shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","import os\n\nfrom pimabill import PimaBillClient\n\nclient = PimaBillClient(token=os.environ[\"PIMABILL_API_KEY\"])\n","python",[159,206,207,212,219,225,230],{"__ignoreMap":157},[162,208,209],{"class":164,"line":165},[162,210,211],{},"import os\n",[162,213,215],{"class":164,"line":214},2,[162,216,218],{"emptyLinePlaceholder":217},true,"\n",[162,220,222],{"class":164,"line":221},3,[162,223,224],{},"from pimabill import PimaBillClient\n",[162,226,228],{"class":164,"line":227},4,[162,229,218],{"emptyLinePlaceholder":217},[162,231,233],{"class":164,"line":232},5,[162,234,235],{},"client = PimaBillClient(token=os.environ[\"PIMABILL_API_KEY\"])\n",[138,237,238,239,242],{},"The client talks to the hosted API (",[159,240,241],{},"https:\u002F\u002Fapi.pimabill.com",") unless told otherwise:",[151,244,246],{"className":202,"code":245,"language":204,"meta":157,"style":157},"from pimabill import PimaBillClient, PimaBillClientEnvironment\n\nsandbox = PimaBillClient(token=\"sk_test_...\", environment=PimaBillClientEnvironment.SANDBOX)  # https:\u002F\u002Fsandbox.pimabill.com\nlocal = PimaBillClient(token=\"sk_live_...\", environment=PimaBillClientEnvironment.LOCAL)  # http:\u002F\u002Flocalhost:4000\nself_hosted = PimaBillClient(token=\"sk_live_...\", base_url=\"https:\u002F\u002Fbilling.example.com\")\n",[159,247,248,253,257,262,267],{"__ignoreMap":157},[162,249,250],{"class":164,"line":165},[162,251,252],{},"from pimabill import PimaBillClient, PimaBillClientEnvironment\n",[162,254,255],{"class":164,"line":214},[162,256,218],{"emptyLinePlaceholder":217},[162,258,259],{"class":164,"line":221},[162,260,261],{},"sandbox = PimaBillClient(token=\"sk_test_...\", environment=PimaBillClientEnvironment.SANDBOX)  # https:\u002F\u002Fsandbox.pimabill.com\n",[162,263,264],{"class":164,"line":227},[162,265,266],{},"local = PimaBillClient(token=\"sk_live_...\", environment=PimaBillClientEnvironment.LOCAL)  # http:\u002F\u002Flocalhost:4000\n",[162,268,269],{"class":164,"line":232},[162,270,271],{},"self_hosted = PimaBillClient(token=\"sk_live_...\", base_url=\"https:\u002F\u002Fbilling.example.com\")\n",[196,273,275],{"id":274},"async-client","Async Client",[151,277,279],{"className":202,"code":278,"language":204,"meta":157,"style":157},"import os\n\nfrom pimabill import AsyncPimaBillClient\n\nclient = AsyncPimaBillClient(token=os.environ[\"PIMABILL_API_KEY\"])\n",[159,280,281,285,289,294,298],{"__ignoreMap":157},[162,282,283],{"class":164,"line":165},[162,284,211],{},[162,286,287],{"class":164,"line":214},[162,288,218],{"emptyLinePlaceholder":217},[162,290,291],{"class":164,"line":221},[162,292,293],{},"from pimabill import AsyncPimaBillClient\n",[162,295,296],{"class":164,"line":227},[162,297,218],{"emptyLinePlaceholder":217},[162,299,300],{"class":164,"line":232},[162,301,302],{},"client = AsyncPimaBillClient(token=os.environ[\"PIMABILL_API_KEY\"])\n",[138,304,305],{},"Every method takes keyword arguments; IDs in the path come first, positionally.",[142,307,53],{"id":308},"customers",[138,310,311,312,315],{},"Customers represent the people or businesses you bill. Every subscription, invoice, and payment is linked to a customer. ",[159,313,314],{},"external_id"," is your own ID for the customer and must be unique.",[196,317,319],{"id":318},"create-a-customer","Create a Customer",[151,321,323],{"className":202,"code":322,"language":204,"meta":157,"style":157},"customer = client.customers.create(\n    external_id=\"usr_12345\",\n    email=\"john@example.com\",\n    currency=\"NGN\",\n    name=\"John Doe\",\n    metadata={\"plan\": \"enterprise\"},\n)\n\nprint(f\"Created customer: {customer.id}\")\n",[159,324,325,330,335,340,345,350,356,362,367],{"__ignoreMap":157},[162,326,327],{"class":164,"line":165},[162,328,329],{},"customer = client.customers.create(\n",[162,331,332],{"class":164,"line":214},[162,333,334],{},"    external_id=\"usr_12345\",\n",[162,336,337],{"class":164,"line":221},[162,338,339],{},"    email=\"john@example.com\",\n",[162,341,342],{"class":164,"line":227},[162,343,344],{},"    currency=\"NGN\",\n",[162,346,347],{"class":164,"line":232},[162,348,349],{},"    name=\"John Doe\",\n",[162,351,353],{"class":164,"line":352},6,[162,354,355],{},"    metadata={\"plan\": \"enterprise\"},\n",[162,357,359],{"class":164,"line":358},7,[162,360,361],{},")\n",[162,363,365],{"class":164,"line":364},8,[162,366,218],{"emptyLinePlaceholder":217},[162,368,370],{"class":164,"line":369},9,[162,371,372],{},"print(f\"Created customer: {customer.id}\")\n",[196,374,376],{"id":375},"get-a-customer","Get a Customer",[151,378,380],{"className":202,"code":379,"language":204,"meta":157,"style":157},"customer = client.customers.get(\"cus_x1y2z3a4b5c6\")\n\nprint(f\"Name: {customer.name}\")\nprint(f\"Email: {customer.email}\")\n",[159,381,382,387,391,396],{"__ignoreMap":157},[162,383,384],{"class":164,"line":165},[162,385,386],{},"customer = client.customers.get(\"cus_x1y2z3a4b5c6\")\n",[162,388,389],{"class":164,"line":214},[162,390,218],{"emptyLinePlaceholder":217},[162,392,393],{"class":164,"line":221},[162,394,395],{},"print(f\"Name: {customer.name}\")\n",[162,397,398],{"class":164,"line":227},[162,399,400],{},"print(f\"Email: {customer.email}\")\n",[196,402,404],{"id":403},"update-a-customer","Update a Customer",[151,406,408],{"className":202,"code":407,"language":204,"meta":157,"style":157},"updated = client.customers.update(\n    \"cus_x1y2z3a4b5c6\",\n    name=\"John A. Doe\",\n    metadata={\"plan\": \"enterprise\", \"notes\": \"VIP customer\"},\n)\n",[159,409,410,415,420,425,430],{"__ignoreMap":157},[162,411,412],{"class":164,"line":165},[162,413,414],{},"updated = client.customers.update(\n",[162,416,417],{"class":164,"line":214},[162,418,419],{},"    \"cus_x1y2z3a4b5c6\",\n",[162,421,422],{"class":164,"line":221},[162,423,424],{},"    name=\"John A. Doe\",\n",[162,426,427],{"class":164,"line":227},[162,428,429],{},"    metadata={\"plan\": \"enterprise\", \"notes\": \"VIP customer\"},\n",[162,431,432],{"class":164,"line":232},[162,433,361],{},[196,435,437],{"id":436},"list-customers","List Customers",[151,439,441],{"className":202,"code":440,"language":204,"meta":157,"style":157},"customers = client.customers.list(\n    page=1,\n    limit=20,\n    search=\"john\",\n    sort_by=\"createdAt\",\n    sort_order=\"desc\",\n)\n\nprint(f\"Total customers: {customers.meta.total}\")\nfor customer in customers.data:\n    print(f\"{customer.name} ({customer.email})\")\n",[159,442,443,448,453,458,463,468,473,477,481,486,492],{"__ignoreMap":157},[162,444,445],{"class":164,"line":165},[162,446,447],{},"customers = client.customers.list(\n",[162,449,450],{"class":164,"line":214},[162,451,452],{},"    page=1,\n",[162,454,455],{"class":164,"line":221},[162,456,457],{},"    limit=20,\n",[162,459,460],{"class":164,"line":227},[162,461,462],{},"    search=\"john\",\n",[162,464,465],{"class":164,"line":232},[162,466,467],{},"    sort_by=\"createdAt\",\n",[162,469,470],{"class":164,"line":352},[162,471,472],{},"    sort_order=\"desc\",\n",[162,474,475],{"class":164,"line":358},[162,476,361],{},[162,478,479],{"class":164,"line":364},[162,480,218],{"emptyLinePlaceholder":217},[162,482,483],{"class":164,"line":369},[162,484,485],{},"print(f\"Total customers: {customers.meta.total}\")\n",[162,487,489],{"class":164,"line":488},10,[162,490,491],{},"for customer in customers.data:\n",[162,493,495],{"class":164,"line":494},11,[162,496,497],{},"    print(f\"{customer.name} ({customer.email})\")\n",[196,499,501],{"id":500},"delete-a-customer","Delete a Customer",[151,503,505],{"className":202,"code":504,"language":204,"meta":157,"style":157},"client.customers.delete(\"cus_x1y2z3a4b5c6\")\n",[159,506,507],{"__ignoreMap":157},[162,508,509],{"class":164,"line":165},[162,510,504],{},[196,512,514],{"id":513},"get-customer-subscriptions-and-invoices","Get Customer Subscriptions and Invoices",[151,516,518],{"className":202,"code":517,"language":204,"meta":157,"style":157},"for sub in client.customers.get_subscriptions(\"cus_x1y2z3a4b5c6\"):\n    print(f\"{sub.id}: {sub.status} - Plan: {sub.plan_id}\")\n\nfor invoice in client.customers.get_invoices(\"cus_x1y2z3a4b5c6\"):\n    print(f\"{invoice.invoice_number}: {invoice.status} - {invoice.currency} {invoice.amount}\")\n",[159,519,520,525,530,534,539],{"__ignoreMap":157},[162,521,522],{"class":164,"line":165},[162,523,524],{},"for sub in client.customers.get_subscriptions(\"cus_x1y2z3a4b5c6\"):\n",[162,526,527],{"class":164,"line":214},[162,528,529],{},"    print(f\"{sub.id}: {sub.status} - Plan: {sub.plan_id}\")\n",[162,531,532],{"class":164,"line":221},[162,533,218],{"emptyLinePlaceholder":217},[162,535,536],{"class":164,"line":227},[162,537,538],{},"for invoice in client.customers.get_invoices(\"cus_x1y2z3a4b5c6\"):\n",[162,540,541],{"class":164,"line":232},[162,542,543],{},"    print(f\"{invoice.invoice_number}: {invoice.status} - {invoice.currency} {invoice.amount}\")\n",[142,545,547],{"id":546},"plans","Plans",[138,549,550,551,553],{},"Plans define what you sell: the product tiers, billing frequency, and included features. Each plan has a unique ",[159,552,159],{}," and a price per currency.",[196,555,557],{"id":556},"create-a-plan","Create a Plan",[151,559,561],{"className":202,"code":560,"language":204,"meta":157,"style":157},"from pimabill import CreatePlanPriceDto\n\nplan = client.plans.create(\n    name=\"Pro Plan\",\n    code=\"pro_monthly\",\n    billing_interval=\"MONTHLY\",\n    description=\"Professional plan with advanced features\",\n    features=[\"Unlimited projects\", \"Priority support\", \"Advanced analytics\", \"API access\"],\n    prices=[\n        CreatePlanPriceDto(currency=\"NGN\", amount=15000),\n        CreatePlanPriceDto(currency=\"USD\", amount=29),\n    ],\n)\n\nprint(f\"Created plan: {plan.id}\")\n",[159,562,563,568,572,577,582,587,592,597,602,607,612,617,623,628,633],{"__ignoreMap":157},[162,564,565],{"class":164,"line":165},[162,566,567],{},"from pimabill import CreatePlanPriceDto\n",[162,569,570],{"class":164,"line":214},[162,571,218],{"emptyLinePlaceholder":217},[162,573,574],{"class":164,"line":221},[162,575,576],{},"plan = client.plans.create(\n",[162,578,579],{"class":164,"line":227},[162,580,581],{},"    name=\"Pro Plan\",\n",[162,583,584],{"class":164,"line":232},[162,585,586],{},"    code=\"pro_monthly\",\n",[162,588,589],{"class":164,"line":352},[162,590,591],{},"    billing_interval=\"MONTHLY\",\n",[162,593,594],{"class":164,"line":358},[162,595,596],{},"    description=\"Professional plan with advanced features\",\n",[162,598,599],{"class":164,"line":364},[162,600,601],{},"    features=[\"Unlimited projects\", \"Priority support\", \"Advanced analytics\", \"API access\"],\n",[162,603,604],{"class":164,"line":369},[162,605,606],{},"    prices=[\n",[162,608,609],{"class":164,"line":488},[162,610,611],{},"        CreatePlanPriceDto(currency=\"NGN\", amount=15000),\n",[162,613,614],{"class":164,"line":494},[162,615,616],{},"        CreatePlanPriceDto(currency=\"USD\", amount=29),\n",[162,618,620],{"class":164,"line":619},12,[162,621,622],{},"    ],\n",[162,624,626],{"class":164,"line":625},13,[162,627,361],{},[162,629,631],{"class":164,"line":630},14,[162,632,218],{"emptyLinePlaceholder":217},[162,634,636],{"class":164,"line":635},15,[162,637,638],{},"print(f\"Created plan: {plan.id}\")\n",[196,640,642],{"id":641},"add-a-price","Add a Price",[151,644,646],{"className":202,"code":645,"language":204,"meta":157,"style":157},"price = client.plans.add_price(\"pln_d7e8f9g0h1i2\", currency=\"KES\", amount=3500)\n",[159,647,648],{"__ignoreMap":157},[162,649,650],{"class":164,"line":165},[162,651,645],{},[196,653,655],{"id":654},"list-plans","List Plans",[151,657,659],{"className":202,"code":658,"language":204,"meta":157,"style":157},"for plan in client.plans.list(is_active=True):\n    print(f\"{plan.name}: {plan.code} ({plan.billing_interval})\")\n",[159,660,661,666],{"__ignoreMap":157},[162,662,663],{"class":164,"line":165},[162,664,665],{},"for plan in client.plans.list(is_active=True):\n",[162,667,668],{"class":164,"line":214},[162,669,670],{},"    print(f\"{plan.name}: {plan.code} ({plan.billing_interval})\")\n",[196,672,674],{"id":673},"update-or-deactivate-a-plan","Update or Deactivate a Plan",[151,676,678],{"className":202,"code":677,"language":204,"meta":157,"style":157},"client.plans.update(\"pln_d7e8f9g0h1i2\", name=\"Pro Plan v2\")\nclient.plans.update(\"pln_d7e8f9g0h1i2\", is_active=False)\n",[159,679,680,685],{"__ignoreMap":157},[162,681,682],{"class":164,"line":165},[162,683,684],{},"client.plans.update(\"pln_d7e8f9g0h1i2\", name=\"Pro Plan v2\")\n",[162,686,687],{"class":164,"line":214},[162,688,689],{},"client.plans.update(\"pln_d7e8f9g0h1i2\", is_active=False)\n",[142,691,101],{"id":692},"subscriptions",[138,694,695,696,699,700,699,703,699,706,699,709,712],{},"Subscriptions connect customers to plans and run the recurring billing: the current period, the status (",[159,697,698],{},"ACTIVE",", ",[159,701,702],{},"TRIALING",[159,704,705],{},"PAUSED",[159,707,708],{},"PAST_DUE",[159,710,711],{},"CANCELED",") and renewals.",[196,714,716],{"id":715},"create-a-subscription","Create a Subscription",[151,718,720],{"className":202,"code":719,"language":204,"meta":157,"style":157},"subscription = client.subscriptions.create(\n    customer_id=\"cus_x1y2z3a4b5c6\",\n    plan_id=\"pln_d7e8f9g0h1i2\",\n    currency=\"NGN\",\n    trial_days=14,\n    metadata={\"source\": \"website\"},\n)\n\nprint(f\"Status: {subscription.status}\")\nprint(f\"Current period ends: {subscription.current_period_end}\")\n",[159,721,722,727,732,737,741,746,751,755,759,764],{"__ignoreMap":157},[162,723,724],{"class":164,"line":165},[162,725,726],{},"subscription = client.subscriptions.create(\n",[162,728,729],{"class":164,"line":214},[162,730,731],{},"    customer_id=\"cus_x1y2z3a4b5c6\",\n",[162,733,734],{"class":164,"line":221},[162,735,736],{},"    plan_id=\"pln_d7e8f9g0h1i2\",\n",[162,738,739],{"class":164,"line":227},[162,740,344],{},[162,742,743],{"class":164,"line":232},[162,744,745],{},"    trial_days=14,\n",[162,747,748],{"class":164,"line":352},[162,749,750],{},"    metadata={\"source\": \"website\"},\n",[162,752,753],{"class":164,"line":358},[162,754,361],{},[162,756,757],{"class":164,"line":364},[162,758,218],{"emptyLinePlaceholder":217},[162,760,761],{"class":164,"line":369},[162,762,763],{},"print(f\"Status: {subscription.status}\")\n",[162,765,766],{"class":164,"line":488},[162,767,768],{},"print(f\"Current period ends: {subscription.current_period_end}\")\n",[196,770,772],{"id":771},"cancel-a-subscription","Cancel a Subscription",[151,774,776],{"className":202,"code":775,"language":204,"meta":157,"style":157},"canceled = client.subscriptions.cancel(\"sub_j3k4l5m6n7o8\", cancel_at=\"period_end\")  # or \"now\"\n\nprint(f\"Ends at: {canceled.cancel_at}\")\n",[159,777,778,783,787],{"__ignoreMap":157},[162,779,780],{"class":164,"line":165},[162,781,782],{},"canceled = client.subscriptions.cancel(\"sub_j3k4l5m6n7o8\", cancel_at=\"period_end\")  # or \"now\"\n",[162,784,785],{"class":164,"line":214},[162,786,218],{"emptyLinePlaceholder":217},[162,788,789],{"class":164,"line":221},[162,790,791],{},"print(f\"Ends at: {canceled.cancel_at}\")\n",[196,793,795],{"id":794},"pause-and-resume","Pause and Resume",[151,797,799],{"className":202,"code":798,"language":204,"meta":157,"style":157},"client.subscriptions.pause(\"sub_j3k4l5m6n7o8\")\nclient.subscriptions.resume(\"sub_j3k4l5m6n7o8\")\n",[159,800,801,806],{"__ignoreMap":157},[162,802,803],{"class":164,"line":165},[162,804,805],{},"client.subscriptions.pause(\"sub_j3k4l5m6n7o8\")\n",[162,807,808],{"class":164,"line":214},[162,809,810],{},"client.subscriptions.resume(\"sub_j3k4l5m6n7o8\")\n",[196,812,814],{"id":813},"change-plan","Change Plan",[151,816,818],{"className":202,"code":817,"language":204,"meta":157,"style":157},"updated = client.subscriptions.change_plan(\"sub_j3k4l5m6n7o8\", new_plan_id=\"pln_newplan123\", prorate=True)\n",[159,819,820],{"__ignoreMap":157},[162,821,822],{"class":164,"line":165},[162,823,817],{},[196,825,827],{"id":826},"list-subscriptions","List Subscriptions",[151,829,831],{"className":202,"code":830,"language":204,"meta":157,"style":157},"subscriptions = client.subscriptions.list(status=\"ACTIVE\", page=1, limit=50)\n\nfor sub in subscriptions.data:\n    print(f\"{sub.id}: {sub.customer_id} on {sub.plan_id}\")\n",[159,832,833,838,842,847],{"__ignoreMap":157},[162,834,835],{"class":164,"line":165},[162,836,837],{},"subscriptions = client.subscriptions.list(status=\"ACTIVE\", page=1, limit=50)\n",[162,839,840],{"class":164,"line":214},[162,841,218],{"emptyLinePlaceholder":217},[162,843,844],{"class":164,"line":221},[162,845,846],{},"for sub in subscriptions.data:\n",[162,848,849],{"class":164,"line":227},[162,850,851],{},"    print(f\"{sub.id}: {sub.customer_id} on {sub.plan_id}\")\n",[142,853,855],{"id":854},"invoices","Invoices",[138,857,858,859,699,862,699,865,699,868,699,871,873],{},"Invoices track what customers owe. They are created from subscriptions automatically, or by you for one-off charges. Statuses: ",[159,860,861],{},"DRAFT",[159,863,864],{},"PENDING",[159,866,867],{},"PAID",[159,869,870],{},"FAILED",[159,872,711],{},".",[196,875,877],{"id":876},"create-an-invoice","Create an Invoice",[151,879,881],{"className":202,"code":880,"language":204,"meta":157,"style":157},"from pimabill import InvoiceItemDto\n\ninvoice = client.invoices.create(\n    customer_id=\"cus_x1y2z3a4b5c6\",\n    currency=\"NGN\",\n    items=[\n        InvoiceItemDto(description=\"Pro Plan - Monthly\", quantity=1, unit_amount=15000),\n        InvoiceItemDto(description=\"Additional API calls (500)\", quantity=1, unit_amount=2500),\n    ],\n    due_date=\"2025-02-28T00:00:00Z\",\n)\n\nprint(f\"Invoice: {invoice.invoice_number}, total {invoice.currency} {invoice.amount}\")\n",[159,882,883,888,892,897,901,905,910,915,920,924,929,933,937],{"__ignoreMap":157},[162,884,885],{"class":164,"line":165},[162,886,887],{},"from pimabill import InvoiceItemDto\n",[162,889,890],{"class":164,"line":214},[162,891,218],{"emptyLinePlaceholder":217},[162,893,894],{"class":164,"line":221},[162,895,896],{},"invoice = client.invoices.create(\n",[162,898,899],{"class":164,"line":227},[162,900,731],{},[162,902,903],{"class":164,"line":232},[162,904,344],{},[162,906,907],{"class":164,"line":352},[162,908,909],{},"    items=[\n",[162,911,912],{"class":164,"line":358},[162,913,914],{},"        InvoiceItemDto(description=\"Pro Plan - Monthly\", quantity=1, unit_amount=15000),\n",[162,916,917],{"class":164,"line":364},[162,918,919],{},"        InvoiceItemDto(description=\"Additional API calls (500)\", quantity=1, unit_amount=2500),\n",[162,921,922],{"class":164,"line":369},[162,923,622],{},[162,925,926],{"class":164,"line":488},[162,927,928],{},"    due_date=\"2025-02-28T00:00:00Z\",\n",[162,930,931],{"class":164,"line":494},[162,932,361],{},[162,934,935],{"class":164,"line":619},[162,936,218],{"emptyLinePlaceholder":217},[162,938,939],{"class":164,"line":625},[162,940,941],{},"print(f\"Invoice: {invoice.invoice_number}, total {invoice.currency} {invoice.amount}\")\n",[196,943,945],{"id":944},"list-invoices","List Invoices",[151,947,949],{"className":202,"code":948,"language":204,"meta":157,"style":157},"invoices = client.invoices.list(customer_id=\"cus_x1y2z3a4b5c6\", status=\"PENDING\", page=1, limit=10)\n\nfor invoice in invoices.data:\n    print(f\"{invoice.invoice_number}: {invoice.status} - {invoice.currency} {invoice.amount}\")\n",[159,950,951,956,960,965],{"__ignoreMap":157},[162,952,953],{"class":164,"line":165},[162,954,955],{},"invoices = client.invoices.list(customer_id=\"cus_x1y2z3a4b5c6\", status=\"PENDING\", page=1, limit=10)\n",[162,957,958],{"class":164,"line":214},[162,959,218],{"emptyLinePlaceholder":217},[162,961,962],{"class":164,"line":221},[162,963,964],{},"for invoice in invoices.data:\n",[162,966,967],{"class":164,"line":227},[162,968,543],{},[196,970,972],{"id":971},"finalize-void-or-mark-as-paid","Finalize, Void, or Mark as Paid",[151,974,976],{"className":202,"code":975,"language":204,"meta":157,"style":157},"client.invoices.finalize(\"inv_p1q2r3s4t5u6\")\nclient.invoices.void(\"inv_p1q2r3s4t5u6\")\nclient.invoices.mark_paid(\"inv_p1q2r3s4t5u6\")\n",[159,977,978,983,988],{"__ignoreMap":157},[162,979,980],{"class":164,"line":165},[162,981,982],{},"client.invoices.finalize(\"inv_p1q2r3s4t5u6\")\n",[162,984,985],{"class":164,"line":214},[162,986,987],{},"client.invoices.void(\"inv_p1q2r3s4t5u6\")\n",[162,989,990],{"class":164,"line":221},[162,991,992],{},"client.invoices.mark_paid(\"inv_p1q2r3s4t5u6\")\n",[196,994,996],{"id":995},"get-invoice-pdf","Get Invoice PDF",[151,998,1000],{"className":202,"code":999,"language":204,"meta":157,"style":157},"with open(\"invoice.pdf\", \"wb\") as f:\n    for chunk in client.invoices.get_pdf(\"inv_p1q2r3s4t5u6\"):\n        f.write(chunk)\n",[159,1001,1002,1007,1012],{"__ignoreMap":157},[162,1003,1004],{"class":164,"line":165},[162,1005,1006],{},"with open(\"invoice.pdf\", \"wb\") as f:\n",[162,1008,1009],{"class":164,"line":214},[162,1010,1011],{},"    for chunk in client.invoices.get_pdf(\"inv_p1q2r3s4t5u6\"):\n",[162,1013,1014],{"class":164,"line":221},[162,1015,1016],{},"        f.write(chunk)\n",[196,1018,1020],{"id":1019},"hosted-checkout","Hosted Checkout",[151,1022,1024],{"className":202,"code":1023,"language":204,"meta":157,"style":157},"checkout = client.invoices.create_checkout(\"inv_p1q2r3s4t5u6\")\n\nprint(f\"Send the customer to: {checkout.checkout_url}\")\n",[159,1025,1026,1031,1035],{"__ignoreMap":157},[162,1027,1028],{"class":164,"line":165},[162,1029,1030],{},"checkout = client.invoices.create_checkout(\"inv_p1q2r3s4t5u6\")\n",[162,1032,1033],{"class":164,"line":214},[162,1034,218],{"emptyLinePlaceholder":217},[162,1036,1037],{"class":164,"line":221},[162,1038,1039],{},"print(f\"Send the customer to: {checkout.checkout_url}\")\n",[142,1041,1043],{"id":1042},"payments","Payments",[138,1045,1046],{},"Payments are created when invoices are paid through a payment provider. You can list, retrieve and refund them.",[196,1048,1050],{"id":1049},"list-payments","List Payments",[151,1052,1054],{"className":202,"code":1053,"language":204,"meta":157,"style":157},"payments = client.payments.list(status=\"SUCCEEDED\", page=1, limit=20)\n\nfor payment in payments.data:\n    print(f\"{payment.id}: {payment.currency} {payment.amount} - {payment.status}\")\n",[159,1055,1056,1061,1065,1070],{"__ignoreMap":157},[162,1057,1058],{"class":164,"line":165},[162,1059,1060],{},"payments = client.payments.list(status=\"SUCCEEDED\", page=1, limit=20)\n",[162,1062,1063],{"class":164,"line":214},[162,1064,218],{"emptyLinePlaceholder":217},[162,1066,1067],{"class":164,"line":221},[162,1068,1069],{},"for payment in payments.data:\n",[162,1071,1072],{"class":164,"line":227},[162,1073,1074],{},"    print(f\"{payment.id}: {payment.currency} {payment.amount} - {payment.status}\")\n",[196,1076,1078],{"id":1077},"get-a-payment","Get a Payment",[151,1080,1082],{"className":202,"code":1081,"language":204,"meta":157,"style":157},"payment = client.payments.get(\"pay_v1w2x3y4z5a6\")\n\nprint(f\"Amount: {payment.currency} {payment.amount}, status {payment.status}\")\n",[159,1083,1084,1089,1093],{"__ignoreMap":157},[162,1085,1086],{"class":164,"line":165},[162,1087,1088],{},"payment = client.payments.get(\"pay_v1w2x3y4z5a6\")\n",[162,1090,1091],{"class":164,"line":214},[162,1092,218],{"emptyLinePlaceholder":217},[162,1094,1095],{"class":164,"line":221},[162,1096,1097],{},"print(f\"Amount: {payment.currency} {payment.amount}, status {payment.status}\")\n",[196,1099,1101],{"id":1100},"refund-a-payment","Refund a Payment",[151,1103,1105],{"className":202,"code":1104,"language":204,"meta":157,"style":157},"refunded = client.payments.refund(\n    \"pay_v1w2x3y4z5a6\",\n    amount=15000,  # leave out for a full refund\n    reason=\"Customer requested plan downgrade\",\n)\n",[159,1106,1107,1112,1117,1122,1127],{"__ignoreMap":157},[162,1108,1109],{"class":164,"line":165},[162,1110,1111],{},"refunded = client.payments.refund(\n",[162,1113,1114],{"class":164,"line":214},[162,1115,1116],{},"    \"pay_v1w2x3y4z5a6\",\n",[162,1118,1119],{"class":164,"line":221},[162,1120,1121],{},"    amount=15000,  # leave out for a full refund\n",[162,1123,1124],{"class":164,"line":227},[162,1125,1126],{},"    reason=\"Customer requested plan downgrade\",\n",[162,1128,1129],{"class":164,"line":232},[162,1130,361],{},[142,1132,109],{"id":1133},"payment-providers",[196,1135,1137],{"id":1136},"list-payment-providers","List Payment Providers",[151,1139,1141],{"className":202,"code":1140,"language":204,"meta":157,"style":157},"for provider in client.payment_providers.list():\n    state = \"active\" if provider.is_active else \"inactive\"\n    print(f\"{provider.provider_name}: priority {provider.priority}, {state}\")\n",[159,1142,1143,1148,1153],{"__ignoreMap":157},[162,1144,1145],{"class":164,"line":165},[162,1146,1147],{},"for provider in client.payment_providers.list():\n",[162,1149,1150],{"class":164,"line":214},[162,1151,1152],{},"    state = \"active\" if provider.is_active else \"inactive\"\n",[162,1154,1155],{"class":164,"line":221},[162,1156,1157],{},"    print(f\"{provider.provider_name}: priority {provider.priority}, {state}\")\n",[196,1159,1161],{"id":1160},"configure-a-payment-provider","Configure a Payment Provider",[151,1163,1165],{"className":202,"code":1164,"language":204,"meta":157,"style":157},"provider = client.payment_providers.configure(\n    provider_name=\"stripe\",\n    credentials={\"secretKey\": \"sk_live_...\", \"webhookSecret\": \"whsec_...\"},\n    priority=1,\n)\n\ntest = client.payment_providers.test_connection(provider.id)\nprint(\"Connected\" if test.success else test.message)\n",[159,1166,1167,1172,1177,1182,1187,1191,1195,1200],{"__ignoreMap":157},[162,1168,1169],{"class":164,"line":165},[162,1170,1171],{},"provider = client.payment_providers.configure(\n",[162,1173,1174],{"class":164,"line":214},[162,1175,1176],{},"    provider_name=\"stripe\",\n",[162,1178,1179],{"class":164,"line":221},[162,1180,1181],{},"    credentials={\"secretKey\": \"sk_live_...\", \"webhookSecret\": \"whsec_...\"},\n",[162,1183,1184],{"class":164,"line":227},[162,1185,1186],{},"    priority=1,\n",[162,1188,1189],{"class":164,"line":232},[162,1190,361],{},[162,1192,1193],{"class":164,"line":352},[162,1194,218],{"emptyLinePlaceholder":217},[162,1196,1197],{"class":164,"line":358},[162,1198,1199],{},"test = client.payment_providers.test_connection(provider.id)\n",[162,1201,1202],{"class":164,"line":364},[162,1203,1204],{},"print(\"Connected\" if test.success else test.message)\n",[142,1206,1208],{"id":1207},"collections-payouts-and-transfers","Collections, Payouts and Transfers",[138,1210,1211,1212,1215,1216,1219,1220,1223,1224,1227,1228,1223,1231,1234,1235,1238,1239,1242,1243,699,1246,699,1249,699,1252,699,1255,1223,1258,873],{},"One-time money movement, separate from invoices. Each call returns a ",[159,1213,1214],{},"MoneyMovementResponse",", whose ",[159,1217,1218],{},"status"," moves from ",[159,1221,1222],{},"pending"," or ",[159,1225,1226],{},"processing"," to ",[159,1229,1230],{},"succeeded",[159,1232,1233],{},"failed",". A ",[159,1236,1237],{},"stuck"," movement is one the provider could not confirm: it is re-checked, never resent. Pass ",[159,1240,1241],{},"idempotency_key"," so a retried request cannot move money twice. Payers and payees are ",[159,1244,1245],{},"Party_MobileMoney",[159,1247,1248],{},"Party_Bank",[159,1250,1251],{},"Party_Paypal",[159,1253,1254],{},"Party_YoAccount",[159,1256,1257],{},"Party_Hosted",[159,1259,1260],{},"Party_Crypto",[196,1262,1264],{"id":1263},"collect-a-payment","Collect a Payment",[151,1266,1268],{"className":202,"code":1267,"language":204,"meta":157,"style":157},"from pimabill import Party_MobileMoney\n\ncollection = client.collections.create(\n    amount=\"50000\",\n    currency=\"UGX\",\n    payer=Party_MobileMoney(msisdn=\"256771234567\"),\n    description=\"Order #1042\",\n    reference=\"order-1042\",\n    idempotency_key=\"order-1042\",\n)\n\nif collection.payment_url:\n    print(f\"Send the payer to: {collection.payment_url}\")\n\nlatest = client.collections.refresh(collection.id)\nprint(latest.status)\n",[159,1269,1270,1275,1279,1284,1289,1294,1299,1304,1309,1314,1318,1322,1327,1332,1336,1341],{"__ignoreMap":157},[162,1271,1272],{"class":164,"line":165},[162,1273,1274],{},"from pimabill import Party_MobileMoney\n",[162,1276,1277],{"class":164,"line":214},[162,1278,218],{"emptyLinePlaceholder":217},[162,1280,1281],{"class":164,"line":221},[162,1282,1283],{},"collection = client.collections.create(\n",[162,1285,1286],{"class":164,"line":227},[162,1287,1288],{},"    amount=\"50000\",\n",[162,1290,1291],{"class":164,"line":232},[162,1292,1293],{},"    currency=\"UGX\",\n",[162,1295,1296],{"class":164,"line":352},[162,1297,1298],{},"    payer=Party_MobileMoney(msisdn=\"256771234567\"),\n",[162,1300,1301],{"class":164,"line":358},[162,1302,1303],{},"    description=\"Order #1042\",\n",[162,1305,1306],{"class":164,"line":364},[162,1307,1308],{},"    reference=\"order-1042\",\n",[162,1310,1311],{"class":164,"line":369},[162,1312,1313],{},"    idempotency_key=\"order-1042\",\n",[162,1315,1316],{"class":164,"line":488},[162,1317,361],{},[162,1319,1320],{"class":164,"line":494},[162,1321,218],{"emptyLinePlaceholder":217},[162,1323,1324],{"class":164,"line":619},[162,1325,1326],{},"if collection.payment_url:\n",[162,1328,1329],{"class":164,"line":625},[162,1330,1331],{},"    print(f\"Send the payer to: {collection.payment_url}\")\n",[162,1333,1334],{"class":164,"line":630},[162,1335,218],{"emptyLinePlaceholder":217},[162,1337,1338],{"class":164,"line":635},[162,1339,1340],{},"latest = client.collections.refresh(collection.id)\n",[162,1342,1344],{"class":164,"line":1343},16,[162,1345,1346],{},"print(latest.status)\n",[196,1348,1350],{"id":1349},"send-a-payout","Send a Payout",[151,1352,1354],{"className":202,"code":1353,"language":204,"meta":157,"style":157},"from pimabill import Party_MobileMoney\n\npayout = client.payouts.create(\n    amount=\"120000\",\n    currency=\"UGX\",\n    payee=Party_MobileMoney(msisdn=\"256771234567\", name=\"Jane Doe\"),\n    description=\"Commission for March\",\n    idempotency_key=\"commission-2025-03-jane\",\n)\n\nif payout.status == \"requires_approval\":\n    print(\"Waiting for approval in the dashboard\")\n",[159,1355,1356,1360,1364,1369,1374,1378,1383,1388,1393,1397,1401,1406],{"__ignoreMap":157},[162,1357,1358],{"class":164,"line":165},[162,1359,1274],{},[162,1361,1362],{"class":164,"line":214},[162,1363,218],{"emptyLinePlaceholder":217},[162,1365,1366],{"class":164,"line":221},[162,1367,1368],{},"payout = client.payouts.create(\n",[162,1370,1371],{"class":164,"line":227},[162,1372,1373],{},"    amount=\"120000\",\n",[162,1375,1376],{"class":164,"line":232},[162,1377,1293],{},[162,1379,1380],{"class":164,"line":352},[162,1381,1382],{},"    payee=Party_MobileMoney(msisdn=\"256771234567\", name=\"Jane Doe\"),\n",[162,1384,1385],{"class":164,"line":358},[162,1386,1387],{},"    description=\"Commission for March\",\n",[162,1389,1390],{"class":164,"line":364},[162,1391,1392],{},"    idempotency_key=\"commission-2025-03-jane\",\n",[162,1394,1395],{"class":164,"line":369},[162,1396,361],{},[162,1398,1399],{"class":164,"line":488},[162,1400,218],{"emptyLinePlaceholder":217},[162,1402,1403],{"class":164,"line":494},[162,1404,1405],{},"if payout.status == \"requires_approval\":\n",[162,1407,1408],{"class":164,"line":619},[162,1409,1410],{},"    print(\"Waiting for approval in the dashboard\")\n",[196,1412,1414],{"id":1413},"move-money-between-wallets","Move Money Between Wallets",[151,1416,1418],{"className":202,"code":1417,"language":204,"meta":157,"style":157},"transfer = client.transfers.create(from_wallet_id=\"wal_a1b2c3\", to_wallet_id=\"wal_d4e5f6\", amount=\"20000\")\n",[159,1419,1420],{"__ignoreMap":157},[162,1421,1422],{"class":164,"line":165},[162,1423,1417],{},[142,1425,77],{"id":1426},"ledger",[151,1428,1430],{"className":202,"code":1429,"language":204,"meta":157,"style":157},"for account in client.ledger.list_accounts(currency=\"UGX\"):\n    print(f\"{account.code}: {account.balance}\")\n\nhealth = client.ledger.get_health()\nprint(\"Balanced\" if health.balanced else [c.name for c in health.checks if not c.ok])\n",[159,1431,1432,1437,1442,1446,1451],{"__ignoreMap":157},[162,1433,1434],{"class":164,"line":165},[162,1435,1436],{},"for account in client.ledger.list_accounts(currency=\"UGX\"):\n",[162,1438,1439],{"class":164,"line":214},[162,1440,1441],{},"    print(f\"{account.code}: {account.balance}\")\n",[162,1443,1444],{"class":164,"line":221},[162,1445,218],{"emptyLinePlaceholder":217},[162,1447,1448],{"class":164,"line":227},[162,1449,1450],{},"health = client.ledger.get_health()\n",[162,1452,1453],{"class":164,"line":232},[162,1454,1455],{},"print(\"Balanced\" if health.balanced else [c.name for c in health.checks if not c.ok])\n",[142,1457,117],{"id":1458},"webhooks",[138,1460,1461,1462,1223,1465,1468],{},"PimaBill sends events (such as ",[159,1463,1464],{},"invoice.paid",[159,1466,1467],{},"collection.succeeded",") to one URL per organisation, signed with your webhook secret.",[151,1470,1472],{"className":202,"code":1471,"language":204,"meta":157,"style":157},"client.tenants.update_me(webhook_url=\"https:\u002F\u002Fapi.yourapp.com\u002Fwebhooks\u002Fpimabill\")\n\nsecret = client.tenants.get_me().webhook_secret\n\nlogs = client.tenants.get_webhook_logs(direction=\"outbound\", limit=20)\nfor log in logs.data:\n    print(f\"{log.event} -> {log.status_code} ({log.attempt_count} attempts)\")\n",[159,1473,1474,1479,1483,1488,1492,1497,1502],{"__ignoreMap":157},[162,1475,1476],{"class":164,"line":165},[162,1477,1478],{},"client.tenants.update_me(webhook_url=\"https:\u002F\u002Fapi.yourapp.com\u002Fwebhooks\u002Fpimabill\")\n",[162,1480,1481],{"class":164,"line":214},[162,1482,218],{"emptyLinePlaceholder":217},[162,1484,1485],{"class":164,"line":221},[162,1486,1487],{},"secret = client.tenants.get_me().webhook_secret\n",[162,1489,1490],{"class":164,"line":227},[162,1491,218],{"emptyLinePlaceholder":217},[162,1493,1494],{"class":164,"line":232},[162,1495,1496],{},"logs = client.tenants.get_webhook_logs(direction=\"outbound\", limit=20)\n",[162,1498,1499],{"class":164,"line":352},[162,1500,1501],{},"for log in logs.data:\n",[162,1503,1504],{"class":164,"line":358},[162,1505,1506],{},"    print(f\"{log.event} -> {log.status_code} ({log.attempt_count} attempts)\")\n",[138,1508,1509,1510,1514],{},"See the ",[1511,1512,1513],"a",{"href":118},"Webhooks guide"," for verifying signatures.",[142,1516,1518],{"id":1517},"error-handling","Error Handling",[138,1520,1521,1522,1525],{},"Failed requests raise an ",[159,1523,1524],{},"ApiError"," with the HTTP status and the response body. Statuses the API documents have their own subclasses.",[151,1527,1529],{"className":202,"code":1528,"language":204,"meta":157,"style":157},"from pimabill import BadRequestError, ConflictError, NotFoundError, PimaBillClient, UnauthorizedError\nfrom pimabill.core.api_error import ApiError\n\nclient = PimaBillClient(token=\"sk_live_...\")\n\ntry:\n    client.customers.get(\"cus_nonexistent\")\nexcept NotFoundError:\n    print(\"Customer not found\")\nexcept UnauthorizedError:\n    print(\"Check your API key\")\nexcept (BadRequestError, ConflictError) as e:\n    print(f\"Rejected: {e.body}\")\nexcept ApiError as e:\n    print(f\"API error {e.status_code}: {e.body}\")\n",[159,1530,1531,1536,1541,1545,1550,1554,1559,1564,1569,1574,1579,1584,1589,1594,1599],{"__ignoreMap":157},[162,1532,1533],{"class":164,"line":165},[162,1534,1535],{},"from pimabill import BadRequestError, ConflictError, NotFoundError, PimaBillClient, UnauthorizedError\n",[162,1537,1538],{"class":164,"line":214},[162,1539,1540],{},"from pimabill.core.api_error import ApiError\n",[162,1542,1543],{"class":164,"line":221},[162,1544,218],{"emptyLinePlaceholder":217},[162,1546,1547],{"class":164,"line":227},[162,1548,1549],{},"client = PimaBillClient(token=\"sk_live_...\")\n",[162,1551,1552],{"class":164,"line":232},[162,1553,218],{"emptyLinePlaceholder":217},[162,1555,1556],{"class":164,"line":352},[162,1557,1558],{},"try:\n",[162,1560,1561],{"class":164,"line":358},[162,1562,1563],{},"    client.customers.get(\"cus_nonexistent\")\n",[162,1565,1566],{"class":164,"line":364},[162,1567,1568],{},"except NotFoundError:\n",[162,1570,1571],{"class":164,"line":369},[162,1572,1573],{},"    print(\"Customer not found\")\n",[162,1575,1576],{"class":164,"line":488},[162,1577,1578],{},"except UnauthorizedError:\n",[162,1580,1581],{"class":164,"line":494},[162,1582,1583],{},"    print(\"Check your API key\")\n",[162,1585,1586],{"class":164,"line":619},[162,1587,1588],{},"except (BadRequestError, ConflictError) as e:\n",[162,1590,1591],{"class":164,"line":625},[162,1592,1593],{},"    print(f\"Rejected: {e.body}\")\n",[162,1595,1596],{"class":164,"line":630},[162,1597,1598],{},"except ApiError as e:\n",[162,1600,1601],{"class":164,"line":635},[162,1602,1603],{},"    print(f\"API error {e.status_code}: {e.body}\")\n",[196,1605,1607],{"id":1606},"error-types","Error Types",[1609,1610,1611,1627],"table",{},[1612,1613,1614],"thead",{},[1615,1616,1617,1621,1624],"tr",{},[1618,1619,1620],"th",{},"Exception",[1618,1622,1623],{},"HTTP Status",[1618,1625,1626],{},"Description",[1628,1629,1630,1644,1657,1670,1683],"tbody",{},[1615,1631,1632,1638,1641],{},[1633,1634,1635],"td",{},[159,1636,1637],{},"BadRequestError",[1633,1639,1640],{},"400",[1633,1642,1643],{},"Request body or parameters are invalid",[1615,1645,1646,1651,1654],{},[1633,1647,1648],{},[159,1649,1650],{},"UnauthorizedError",[1633,1652,1653],{},"401",[1633,1655,1656],{},"Missing or invalid credentials",[1615,1658,1659,1664,1667],{},[1633,1660,1661],{},[159,1662,1663],{},"NotFoundError",[1633,1665,1666],{},"404",[1633,1668,1669],{},"The resource does not exist",[1615,1671,1672,1677,1680],{},[1633,1673,1674],{},[159,1675,1676],{},"ConflictError",[1633,1678,1679],{},"409",[1633,1681,1682],{},"Conflicts with the current state (e.g. duplicate email)",[1615,1684,1685,1689,1692],{},[1633,1686,1687],{},[159,1688,1524],{},[1633,1690,1691],{},"Any",[1633,1693,1694],{},"Base class for all API errors",[142,1696,1698],{"id":1697},"async-support","Async Support",[138,1700,1701,1704],{},[159,1702,1703],{},"AsyncPimaBillClient"," has the same methods; await them.",[151,1706,1708],{"className":202,"code":1707,"language":204,"meta":157,"style":157},"import asyncio\n\nfrom pimabill import AsyncPimaBillClient\n\n\nasync def main() -> None:\n    client = AsyncPimaBillClient(token=\"sk_live_...\")\n\n    customers, plans = await asyncio.gather(\n        client.customers.list(limit=10),\n        client.plans.list(),\n    )\n    print(f\"{customers.meta.total} customers, {len(plans)} plans\")\n\n\nasyncio.run(main())\n",[159,1709,1710,1715,1719,1723,1727,1731,1736,1741,1745,1750,1755,1760,1765,1770,1774,1778],{"__ignoreMap":157},[162,1711,1712],{"class":164,"line":165},[162,1713,1714],{},"import asyncio\n",[162,1716,1717],{"class":164,"line":214},[162,1718,218],{"emptyLinePlaceholder":217},[162,1720,1721],{"class":164,"line":221},[162,1722,293],{},[162,1724,1725],{"class":164,"line":227},[162,1726,218],{"emptyLinePlaceholder":217},[162,1728,1729],{"class":164,"line":232},[162,1730,218],{"emptyLinePlaceholder":217},[162,1732,1733],{"class":164,"line":352},[162,1734,1735],{},"async def main() -> None:\n",[162,1737,1738],{"class":164,"line":358},[162,1739,1740],{},"    client = AsyncPimaBillClient(token=\"sk_live_...\")\n",[162,1742,1743],{"class":164,"line":364},[162,1744,218],{"emptyLinePlaceholder":217},[162,1746,1747],{"class":164,"line":369},[162,1748,1749],{},"    customers, plans = await asyncio.gather(\n",[162,1751,1752],{"class":164,"line":488},[162,1753,1754],{},"        client.customers.list(limit=10),\n",[162,1756,1757],{"class":164,"line":494},[162,1758,1759],{},"        client.plans.list(),\n",[162,1761,1762],{"class":164,"line":619},[162,1763,1764],{},"    )\n",[162,1766,1767],{"class":164,"line":625},[162,1768,1769],{},"    print(f\"{customers.meta.total} customers, {len(plans)} plans\")\n",[162,1771,1772],{"class":164,"line":630},[162,1773,218],{"emptyLinePlaceholder":217},[162,1775,1776],{"class":164,"line":635},[162,1777,218],{"emptyLinePlaceholder":217},[162,1779,1780],{"class":164,"line":1343},[162,1781,1782],{},"asyncio.run(main())\n",[142,1784,1786],{"id":1785},"pagination","Pagination",[138,1788,1789,1790,1793,1794,1797,1798,699,1801,699,1804,699,1807,1810],{},"Paginated lists return ",[159,1791,1792],{},"data"," and ",[159,1795,1796],{},"meta"," (",[159,1799,1800],{},"total",[159,1802,1803],{},"page",[159,1805,1806],{},"limit",[159,1808,1809],{},"total_pages",").",[151,1812,1814],{"className":202,"code":1813,"language":204,"meta":157,"style":157},"page = 1\nwhile True:\n    response = client.customers.list(page=page, limit=100)\n    for customer in response.data:\n        print(customer.name)\n    if page >= response.meta.total_pages:\n        break\n    page += 1\n",[159,1815,1816,1821,1826,1831,1836,1841,1846,1851],{"__ignoreMap":157},[162,1817,1818],{"class":164,"line":165},[162,1819,1820],{},"page = 1\n",[162,1822,1823],{"class":164,"line":214},[162,1824,1825],{},"while True:\n",[162,1827,1828],{"class":164,"line":221},[162,1829,1830],{},"    response = client.customers.list(page=page, limit=100)\n",[162,1832,1833],{"class":164,"line":227},[162,1834,1835],{},"    for customer in response.data:\n",[162,1837,1838],{"class":164,"line":232},[162,1839,1840],{},"        print(customer.name)\n",[162,1842,1843],{"class":164,"line":352},[162,1844,1845],{},"    if page >= response.meta.total_pages:\n",[162,1847,1848],{"class":164,"line":358},[162,1849,1850],{},"        break\n",[162,1852,1853],{"class":164,"line":364},[162,1854,1855],{},"    page += 1\n",[142,1857,1859],{"id":1858},"type-hints","Type Hints",[138,1861,1862,1863,873],{},"Request and response models are importable from ",[159,1864,1865],{},"pimabill",[151,1867,1869],{"className":202,"code":1868,"language":204,"meta":157,"style":157},"from pimabill import CustomerResponse, InvoiceResponse\n\n\ndef describe(customer: CustomerResponse) -> str:\n    return f\"{customer.name or customer.email} ({customer.id})\"\n\n\ndef is_overdue(invoice: InvoiceResponse) -> bool:\n    return invoice.status == \"PENDING\"\n",[159,1870,1871,1876,1880,1884,1889,1894,1898,1902,1907],{"__ignoreMap":157},[162,1872,1873],{"class":164,"line":165},[162,1874,1875],{},"from pimabill import CustomerResponse, InvoiceResponse\n",[162,1877,1878],{"class":164,"line":214},[162,1879,218],{"emptyLinePlaceholder":217},[162,1881,1882],{"class":164,"line":221},[162,1883,218],{"emptyLinePlaceholder":217},[162,1885,1886],{"class":164,"line":227},[162,1887,1888],{},"def describe(customer: CustomerResponse) -> str:\n",[162,1890,1891],{"class":164,"line":232},[162,1892,1893],{},"    return f\"{customer.name or customer.email} ({customer.id})\"\n",[162,1895,1896],{"class":164,"line":352},[162,1897,218],{"emptyLinePlaceholder":217},[162,1899,1900],{"class":164,"line":358},[162,1901,218],{"emptyLinePlaceholder":217},[162,1903,1904],{"class":164,"line":364},[162,1905,1906],{},"def is_overdue(invoice: InvoiceResponse) -> bool:\n",[162,1908,1909],{"class":164,"line":369},[162,1910,1911],{},"    return invoice.status == \"PENDING\"\n",[142,1913,1915],{"id":1914},"configuration-options","Configuration Options",[151,1917,1919],{"className":202,"code":1918,"language":204,"meta":157,"style":157},"from pimabill import PimaBillClient\n\nclient = PimaBillClient(\n    token=\"sk_live_...\",  # required\n    base_url=\"https:\u002F\u002Fbilling.example.com\",  # default: https:\u002F\u002Fapi.pimabill.com\n    timeout=60.0,  # seconds, default 60\n)\n\n# Per request:\nclient.customers.list(request_options={\"timeout_in_seconds\": 10, \"max_retries\": 0})\n",[159,1920,1921,1925,1929,1934,1939,1944,1949,1953,1957,1962],{"__ignoreMap":157},[162,1922,1923],{"class":164,"line":165},[162,1924,224],{},[162,1926,1927],{"class":164,"line":214},[162,1928,218],{"emptyLinePlaceholder":217},[162,1930,1931],{"class":164,"line":221},[162,1932,1933],{},"client = PimaBillClient(\n",[162,1935,1936],{"class":164,"line":227},[162,1937,1938],{},"    token=\"sk_live_...\",  # required\n",[162,1940,1941],{"class":164,"line":232},[162,1942,1943],{},"    base_url=\"https:\u002F\u002Fbilling.example.com\",  # default: https:\u002F\u002Fapi.pimabill.com\n",[162,1945,1946],{"class":164,"line":352},[162,1947,1948],{},"    timeout=60.0,  # seconds, default 60\n",[162,1950,1951],{"class":164,"line":358},[162,1952,361],{},[162,1954,1955],{"class":164,"line":364},[162,1956,218],{"emptyLinePlaceholder":217},[162,1958,1959],{"class":164,"line":369},[162,1960,1961],{},"# Per request:\n",[162,1963,1964],{"class":164,"line":488},[162,1965,1966],{},"client.customers.list(request_options={\"timeout_in_seconds\": 10, \"max_retries\": 0})\n",[142,1968,1970],{"id":1969},"next-steps","Next Steps",[1972,1973,1974,1981,1987],"ul",{},[1975,1976,1977,1978,1980],"li",{},"Explore the ",[1511,1979,36],{"href":37}," if you work with Node.js.",[1975,1982,1983,1984,1986],{},"Read the ",[1511,1985,48],{"href":54}," for in-depth usage patterns.",[1975,1988,1989,1990,1992],{},"Check the ",[1511,1991,129],{"href":130}," for all available endpoints.",[1994,1995,1996],"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":157,"searchDepth":214,"depth":214,"links":1998},[1999,2000,2004,2012,2018,2025,2032,2037,2041,2046,2047,2048,2051,2052,2053,2054,2055],{"id":144,"depth":214,"text":145},{"id":193,"depth":214,"text":194,"children":2001},[2002,2003],{"id":198,"depth":221,"text":199},{"id":274,"depth":221,"text":275},{"id":308,"depth":214,"text":53,"children":2005},[2006,2007,2008,2009,2010,2011],{"id":318,"depth":221,"text":319},{"id":375,"depth":221,"text":376},{"id":403,"depth":221,"text":404},{"id":436,"depth":221,"text":437},{"id":500,"depth":221,"text":501},{"id":513,"depth":221,"text":514},{"id":546,"depth":214,"text":547,"children":2013},[2014,2015,2016,2017],{"id":556,"depth":221,"text":557},{"id":641,"depth":221,"text":642},{"id":654,"depth":221,"text":655},{"id":673,"depth":221,"text":674},{"id":692,"depth":214,"text":101,"children":2019},[2020,2021,2022,2023,2024],{"id":715,"depth":221,"text":716},{"id":771,"depth":221,"text":772},{"id":794,"depth":221,"text":795},{"id":813,"depth":221,"text":814},{"id":826,"depth":221,"text":827},{"id":854,"depth":214,"text":855,"children":2026},[2027,2028,2029,2030,2031],{"id":876,"depth":221,"text":877},{"id":944,"depth":221,"text":945},{"id":971,"depth":221,"text":972},{"id":995,"depth":221,"text":996},{"id":1019,"depth":221,"text":1020},{"id":1042,"depth":214,"text":1043,"children":2033},[2034,2035,2036],{"id":1049,"depth":221,"text":1050},{"id":1077,"depth":221,"text":1078},{"id":1100,"depth":221,"text":1101},{"id":1133,"depth":214,"text":109,"children":2038},[2039,2040],{"id":1136,"depth":221,"text":1137},{"id":1160,"depth":221,"text":1161},{"id":1207,"depth":214,"text":1208,"children":2042},[2043,2044,2045],{"id":1263,"depth":221,"text":1264},{"id":1349,"depth":221,"text":1350},{"id":1413,"depth":221,"text":1414},{"id":1426,"depth":214,"text":77},{"id":1458,"depth":214,"text":117},{"id":1517,"depth":214,"text":1518,"children":2049},[2050],{"id":1606,"depth":221,"text":1607},{"id":1697,"depth":214,"text":1698},{"id":1785,"depth":214,"text":1786},{"id":1858,"depth":214,"text":1859},{"id":1914,"depth":214,"text":1915},{"id":1969,"depth":214,"text":1970},"Complete guide to using the PimaBill Python SDK with sync and async support.","md",null,{},{"title":40,"description":2056},"kp9LTWAxuwbAdI2LdDeO6DRq0NmDfWM7VHVL7In6kiU",[2063,2065],{"title":36,"path":37,"stem":38,"description":2064,"children":-1},"Complete guide to using the PimaBill TypeScript SDK for Node.js and browser environments.",{"title":44,"path":45,"stem":46,"description":2066,"children":-1},"Use the PimaBill API from PHP 8.1 or later.",1793401242783]