staqlydocs
REST APIAPI referenceBilling

A plan change waiting for its payment, read from Stripe

A plan change waiting for its payment, read from Stripe (account owner)

Every request sends Authorization: Bearer ...: the access token in local mode, an API key stk_... in cloud mode. Use Send to try it against your cloud instance with your API key.

GET
/v1/billing/pending-payment

Leaving Starter's trial for another plan is charged at once, and Stripe applies the change only when that payment goes through (until then it is the subscription's pending update and the trial stays). This reads from Stripe whether such a change waits and why it isn't paid: authentication_required (the bank asks the customer to confirm the payment: open pay_url, Stripe's hosted invoice page, to confirm and pay), a decline (card_declined, insufficient_funds, expired_card, incorrect_card_details: change the card in the billing portal and try again, or pay the invoice at pay_url with another card), processing (the payment is under way) or unknown. Once Stripe has the payment it applies the change; its webhook or POST /v1/billing/sync brings the new plan in. Payments happen on Stripe's pages only. {"pending": false} when nothing waits. 409 not_available when billing is off.

Authorization

headerAuthorizationBearer <token>

API key (stk_...), or in the Community Edition the access token (stk_local_...)

Response Body

Whether a plan change waits for its payment, and why

application/json
  1. response

A plan change waiting for its payment (leaving the trial is charged at once). Also the details of the 402 payment_failed that POST /v1/billing/checkout answers when that payment didn't go through (without pending).

pending*boolean

A plan change waits for its payment; false when none does (nothing else is set then)

reason?string

Why the payment hasn't gone through: authentication_required (the bank asks the customer to confirm it, 3-D Secure; confirm at pay_url), a decline (card_declined and the more precise insufficient_funds, expired_card, incorrect_card_details: another card is needed), processing (under way, nothing to do) or unknown (Stripe's answer couldn't be read).

Value in"authentication_required""card_declined""insufficient_funds""expired_card""incorrect_card_details""processing""unknown"
decline_code?string

Stripe's decline code or error code, as Stripe gives it

pay_url?string

Stripe's hosted invoice page for the unpaid invoice, where the customer confirms the payment with the bank or pays with another card. Absent when the invoice isn't open or has no such page.

Formaturi
plan?string

The plan waiting for the payment

expires_at?string

When Stripe drops the change if it is still unpaid

Formatdate-time
Example Request
curl -X GET 'https://staqly.example.com/v1/billing/pending-payment'
Example Response
{  "pending": true,  "reason": "authentication_required",  "decline_code": "insufficient_funds",  "pay_url": "https://invoice.stripe.com/i/acct_123/test_abc",  "plan": "pro",  "expires_at": "2019-08-24T14:15:22Z"}