Set up automatic payment for a service
Overview
Starts automatic payment setup for a service that has no subscription. Unless a saved method is named (below), the customer must finish setup on the page checkoutUrl opens before the subscription appears. environment says whether that page takes live (production) or test (sandbox) payments.
Where more than one payment option can renew automatically, send option with the value of a recurring option from the checkout options list; the first one offered is used otherwise. To charge each renewal to a saved card or PayPal account, send its uuid as payment_card or paypal_account, from the automatic payments list. Automatic payments are then on straight away: active is true and checkoutUrl is null. With no saved method named, checkoutUrl opens a page to add a new card (with the card option) or PayPal account (with the PayPal option) for this service. resumed is always false.
Use chargesNow to tell the customer whether setup will charge them immediately. A paid service is not charged until its next due date. An overdue service is charged immediately. firstChargeAt gives the first payment date.
Permissions
Requires the account permission billing.manage (Manage billing).
Authorization
Your API key, sent as a bearer token. Create one in the control panel under API Keys, give it only the permissions the integration needs, and copy it when it is created. It cannot be shown again. Each key is restricted to one owned team. The key determines the team for every request.
Send it as Bearer <token>.
Path parameters
The service ID returned by the billing endpoints.
Body
application/jsonThe value of option.
One of: stripe_once, stripe_subscription, stripe_checkout, paypal_once, paypal_subscription, btcpay_once, nowpayments_once, null
The value of paypal_account.
The value of payment_card.
Response 200
application/jsonThe record, as a JSON object. There is no envelope.
The value of checkout_url.
The value of environment.
The value of charges_now.
The date and time for first charge at, in UTC.
The value of resumed.
Autopay is already on, from a saved PayPal account, so there is no page to open.
Errors
- 401
- The key was missing, malformed, revoked, or belongs to an account that no longer exists.
- 403
- Access denied. Check the key's team, permissions and allowed IP addresses. Some actions, such as managing API keys, require a browser session. The response message explains the reason.
- 404
- The resource was not found in the selected team. Resources in another account or team also return 404.
- 422
- A field is missing or invalid, or the resource cannot accept this change in its current state. Check
messagefor details. Field validation also includes anerrorsobject keyed by field name. - 429
- Too many requests. The
Retry-Afterheader says how many seconds to wait. Limits are per account, so several keys on one account share them.
Still stuck? Contact our team
View as Markdown