[{"data":1,"prerenderedAt":785},["ShallowReactive",2],{"navigation_docs":3,"-guides-external-payment-gateway":136,"-guides-external-payment-gateway-surround":780},[4,30,47,132],{"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,128],{"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},"External payment gateway","\u002Fguides\u002Fexternal-payment-gateway","3.guides\u002F20.external-payment-gateway",{"title":105,"path":106,"stem":107},"Subscriptions","\u002Fguides\u002Fsubscriptions","3.guides\u002F3.subscriptions",{"title":109,"path":110,"stem":111},"Invoices & Payments","\u002Fguides\u002Finvoices-and-payments","3.guides\u002F4.invoices-and-payments",{"title":113,"path":114,"stem":115},"Payment Providers","\u002Fguides\u002Fpayment-providers","3.guides\u002F5.payment-providers",{"title":117,"path":118,"stem":119},"Analytics","\u002Fguides\u002Fanalytics","3.guides\u002F6.analytics",{"title":121,"path":122,"stem":123},"Webhooks","\u002Fguides\u002Fwebhooks","3.guides\u002F7.webhooks",{"title":125,"path":126,"stem":127},"Sandbox","\u002Fguides\u002Fsandbox","3.guides\u002F8.sandbox",{"title":129,"path":130,"stem":131},"Money Movement","\u002Fguides\u002Fmoney-movement","3.guides\u002F9.money-movement",{"title":133,"path":134,"stem":135},"API Reference","\u002Fapi-reference","4.api-reference",{"id":137,"title":101,"body":138,"description":773,"extension":774,"links":775,"meta":776,"navigation":777,"path":102,"seo":778,"stem":103,"__hash__":779},"docs\u002F3.guides\u002F20.external-payment-gateway.md",{"type":139,"value":140,"toc":765},"minimark",[141,150,153,158,161,212,216,228,232,243,361,410,415,664,700,704,710,718,724,758,761],[142,143,144,145,149],"p",{},"Most organisations connect their own ",[146,147,148],"a",{"href":114},"payment providers",". A deployment can also connect one external gateway: a separate service that takes payments for its organisations and pays them out. Any service that implements the protocol below can be connected.",[142,151,152],{},"The gateway is optional and off by default. Without it, PimaBill works the same and shows nothing about it.",[154,155,157],"h2",{"id":156},"connect-a-gateway","Connect a gateway",[142,159,160],{},"Set these on the API and worker:",[162,163,164,177],"table",{},[165,166,167],"thead",{},[168,169,170,174],"tr",{},[171,172,173],"th",{},"Setting",[171,175,176],{},"Meaning",[178,179,180,192,202],"tbody",{},[168,181,182,189],{},[183,184,185],"td",{},[186,187,188],"code",{},"GATEWAY_URL",[183,190,191],{},"The gateway's base address",[168,193,194,199],{},[183,195,196],{},[186,197,198],{},"GATEWAY_API_KEY",[183,200,201],{},"The key that identifies this deployment",[168,203,204,209],{},[183,205,206],{},[186,207,208],{},"GATEWAY_WEBHOOK_SECRET",[183,210,211],{},"The secret the gateway signs notifications with",[154,213,215],{"id":214},"how-organisations-join","How organisations join",[142,217,218,219,223,224,227],{},"The gateway owns its application and account pages. When it says an organisation is eligible, the dashboard shows an ",[220,221,222],"strong",{},"Apply"," button in ",[220,225,226],{},"Settings → Payment providers",", which opens the gateway's page. Send a notification when the account opens, and PimaBill stores its id.",[154,229,231],{"id":230},"protocol","Protocol",[142,233,234,235,238,239,242],{},"Requests are JSON over HTTPS, with ",[186,236,237],{},"Authorization: Bearer \u003CGATEWAY_API_KEY>",". The gateway answers errors with a non-2xx status and ",[186,240,241],{},"{ \"message\": \"...\" }",".",[162,244,245,255],{},[165,246,247],{},[168,248,249,252],{},[171,250,251],{},"Request",[171,253,254],{},"Purpose",[178,256,257,271,295,324,334,351],{},[168,258,259,264],{},[183,260,261],{},[186,262,263],{},"GET \u002Fv1\u002Feligibility?externalId=:id",[183,265,266,267,270],{},"Answer ",[186,268,269],{},"{ \"eligible\": true }"," when this organisation may apply",[168,272,273,278],{},[183,274,275],{},[186,276,277],{},"POST \u002Fv1\u002Faccount-links",[183,279,266,280,283,284,287,288,291,292,242],{},[186,281,282],{},"{ \"url\", \"expiresAt\" }",": a short-lived link to your own page, where the organisation applies and manages its account. Sent with ",[186,285,286],{},"externalId",", ",[186,289,290],{},"notificationUrl"," and ",[186,293,294],{},"returnUrl",[168,296,297,302],{},[183,298,299],{},[186,300,301],{},"GET \u002Fv1\u002Faccounts\u002F:id",[183,303,304,305,287,308,287,311,314,315,287,318,291,321],{},"Read the account: ",[186,306,307],{},"id",[186,309,310],{},"status",[186,312,313],{},"methods",", and optional ",[186,316,317],{},"fee",[186,319,320],{},"wallets",[186,322,323],{},"balances",[168,325,326,331],{},[183,327,328],{},[186,329,330],{},"POST \u002Fv1\u002Faccounts\u002Fmirror",[183,332,333],{},"Sandbox only: return the account set up from the organisation's approved live one, or 404",[168,335,336,341],{},[183,337,338],{},[186,339,340],{},"POST \u002Fv1\u002Fcollections",[183,342,343,344,347,348,242],{},"Start a payment. Sent with an ",[186,345,346],{},"Idempotency-Key"," equal to ",[186,349,350],{},"reference",[168,352,353,358],{},[183,354,355],{},[186,356,357],{},"GET \u002Fv1\u002Fcollections\u002F:reference?account=:id",[183,359,360],{},"Read a payment",[142,362,363,364,366,367,287,370,287,373,376,377,380,381,383,384,287,387,291,390,380,393,395,396,380,399,401,402,405,406,409],{},"An account's ",[186,365,310],{}," is ",[186,368,369],{},"pending_review",[186,371,372],{},"active",[186,374,375],{},"rejected"," or ",[186,378,379],{},"suspended",". Its ",[186,382,313],{}," list what its customers can use: ",[186,385,386],{},"card",[186,388,389],{},"mobile_money",[186,391,392],{},"paypal",[186,394,320],{}," name mobile money wallets by currency, such as ",[186,397,398],{},"{ \"UGX\": [\"MTN\", \"Airtel\"] }",[186,400,323],{}," give the money you hold for the organisation per currency, such as ",[186,403,404],{},"{ \"UGX\": { \"available\": \"200000\", \"pending\": \"50000\" } }",", shown on the dashboard's ",[220,407,408],{},"Money"," page.",[411,412,414],"h3",{"id":413},"start-a-payment","Start a payment",[416,417,422],"pre",{"className":418,"code":419,"language":420,"meta":421,"style":421},"language-json shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","{\n  \"account\": \"acc_123\",\n  \"reference\": \"pay_456\",\n  \"amount\": \"50000\",\n  \"currency\": \"UGX\",\n  \"description\": \"Invoice INV-1001\",\n  \"method\": \"card\",\n  \"customer\": { \"email\": \"payer@example.com\", \"name\": \"A Payer\" },\n  \"redirectUrl\": \"https:\u002F\u002Fexample.com\u002Fdone\",\n  \"notificationUrl\": \"https:\u002F\u002Fapi.example.com\u002Fwebhooks\u002Fgateway\u002F\u003Corganisation id>\u002Fcallback\"\n}\n","json","",[186,423,424,433,461,481,502,523,544,564,618,639,658],{"__ignoreMap":421},[425,426,429],"span",{"class":427,"line":428},"line",1,[425,430,432],{"class":431},"sMK4o","{\n",[425,434,436,439,443,446,449,452,456,458],{"class":427,"line":435},2,[425,437,438],{"class":431},"  \"",[425,440,442],{"class":441},"spNyl","account",[425,444,445],{"class":431},"\"",[425,447,448],{"class":431},":",[425,450,451],{"class":431}," \"",[425,453,455],{"class":454},"sfazB","acc_123",[425,457,445],{"class":431},[425,459,460],{"class":431},",\n",[425,462,464,466,468,470,472,474,477,479],{"class":427,"line":463},3,[425,465,438],{"class":431},[425,467,350],{"class":441},[425,469,445],{"class":431},[425,471,448],{"class":431},[425,473,451],{"class":431},[425,475,476],{"class":454},"pay_456",[425,478,445],{"class":431},[425,480,460],{"class":431},[425,482,484,486,489,491,493,495,498,500],{"class":427,"line":483},4,[425,485,438],{"class":431},[425,487,488],{"class":441},"amount",[425,490,445],{"class":431},[425,492,448],{"class":431},[425,494,451],{"class":431},[425,496,497],{"class":454},"50000",[425,499,445],{"class":431},[425,501,460],{"class":431},[425,503,505,507,510,512,514,516,519,521],{"class":427,"line":504},5,[425,506,438],{"class":431},[425,508,509],{"class":441},"currency",[425,511,445],{"class":431},[425,513,448],{"class":431},[425,515,451],{"class":431},[425,517,518],{"class":454},"UGX",[425,520,445],{"class":431},[425,522,460],{"class":431},[425,524,526,528,531,533,535,537,540,542],{"class":427,"line":525},6,[425,527,438],{"class":431},[425,529,530],{"class":441},"description",[425,532,445],{"class":431},[425,534,448],{"class":431},[425,536,451],{"class":431},[425,538,539],{"class":454},"Invoice INV-1001",[425,541,445],{"class":431},[425,543,460],{"class":431},[425,545,547,549,552,554,556,558,560,562],{"class":427,"line":546},7,[425,548,438],{"class":431},[425,550,551],{"class":441},"method",[425,553,445],{"class":431},[425,555,448],{"class":431},[425,557,451],{"class":431},[425,559,386],{"class":454},[425,561,445],{"class":431},[425,563,460],{"class":431},[425,565,567,569,572,574,576,579,581,585,587,589,591,594,596,599,601,604,606,608,610,613,615],{"class":427,"line":566},8,[425,568,438],{"class":431},[425,570,571],{"class":441},"customer",[425,573,445],{"class":431},[425,575,448],{"class":431},[425,577,578],{"class":431}," {",[425,580,451],{"class":431},[425,582,584],{"class":583},"sBMFI","email",[425,586,445],{"class":431},[425,588,448],{"class":431},[425,590,451],{"class":431},[425,592,593],{"class":454},"payer@example.com",[425,595,445],{"class":431},[425,597,598],{"class":431},",",[425,600,451],{"class":431},[425,602,603],{"class":583},"name",[425,605,445],{"class":431},[425,607,448],{"class":431},[425,609,451],{"class":431},[425,611,612],{"class":454},"A Payer",[425,614,445],{"class":431},[425,616,617],{"class":431}," },\n",[425,619,621,623,626,628,630,632,635,637],{"class":427,"line":620},9,[425,622,438],{"class":431},[425,624,625],{"class":441},"redirectUrl",[425,627,445],{"class":431},[425,629,448],{"class":431},[425,631,451],{"class":431},[425,633,634],{"class":454},"https:\u002F\u002Fexample.com\u002Fdone",[425,636,445],{"class":431},[425,638,460],{"class":431},[425,640,642,644,646,648,650,652,655],{"class":427,"line":641},10,[425,643,438],{"class":431},[425,645,290],{"class":441},[425,647,445],{"class":431},[425,649,448],{"class":431},[425,651,451],{"class":431},[425,653,654],{"class":454},"https:\u002F\u002Fapi.example.com\u002Fwebhooks\u002Fgateway\u002F\u003Corganisation id>\u002Fcallback",[425,656,657],{"class":431},"\"\n",[425,659,661],{"class":427,"line":660},11,[425,662,663],{"class":431},"}\n",[142,665,666,667,287,669,671,672,287,675,376,678,681,682,287,684,686,687,690,691,287,694,291,697,242],{},"The response has ",[186,668,350],{},[186,670,310],{}," (",[186,673,674],{},"pending",[186,676,677],{},"succeeded",[186,679,680],{},"failed","), ",[186,683,488],{},[186,685,509],{},", and ",[186,688,689],{},"checkoutUrl"," when the payer has a page to visit. Reading a payment can also return ",[186,692,693],{},"providerReference",[186,695,696],{},"fees",[186,698,699],{},"failureReason",[411,701,703],{"id":702},"notifications","Notifications",[142,705,706,707,709],{},"The gateway posts to the ",[186,708,290],{}," it was given, with this header:",[416,711,716],{"className":712,"code":714,"language":715,"meta":421},[713],"language-text","X-Gateway-Signature: t=\u003Cunix seconds>,v1=\u003Chex HMAC-SHA256 of \"t.body\">\n","text",[186,717,714],{"__ignoreMap":421},[142,719,720,721,723],{},"The HMAC uses ",[186,722,208],{},". Signatures older than ten minutes are refused.",[162,725,726,736],{},[165,727,728],{},[168,729,730,733],{},[171,731,732],{},"Body",[171,734,735],{},"Effect",[178,737,738,748],{},[168,739,740,745],{},[183,741,742],{},[186,743,744],{},"{ \"id\": \"...\", \"account\": { \"id\": \"...\", \"externalId\": \"...\", \"status\": \"active\" } }",[183,746,747],{},"Stores a new account, and turns the organisation's gateway connection on or off with the status",[168,749,750,755],{},[183,751,752],{},[186,753,754],{},"{ \"id\": \"...\", \"collection\": { \"reference\": \"pay_456\" } }",[183,756,757],{},"PimaBill reads the payment from the gateway, then settles it",[142,759,760],{},"PimaBill never trusts the content of a payment notification. It always asks the gateway for the payment, and holds it for review when the amount paid differs from the amount asked.",[762,763,764],"style",{},"html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}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":421,"searchDepth":435,"depth":435,"links":766},[767,768,769],{"id":156,"depth":435,"text":157},{"id":214,"depth":435,"text":215},{"id":230,"depth":435,"text":231,"children":770},[771,772],{"id":413,"depth":463,"text":414},{"id":702,"depth":463,"text":703},"Connect a service that takes payments on behalf of your organisations, using a small public protocol.","md",null,{},true,{"title":101,"description":773},"k_m4dglnLAIxnXuu4WDQtIAvy-dPLPvBnC2VzzXgI3g",[781,783],{"title":97,"path":98,"stem":99,"description":782,"children":-1},"Create and manage subscription plans with multi-currency pricing and billing intervals.",{"title":105,"path":106,"stem":107,"description":784,"children":-1},"Manage the full subscription lifecycle including creation, pausing, cancellation, and plan changes.",1794114794414]