Checkout from your server
Available on staging; production release pending.
POST /v1/commerce/checkouts and GET /v1/commerce/checkouts/{id} are not in production yet.checkout_url for you to send the buyer to.
Unlike a prefilled checkout, which your page creates with the publishable key, a checkout created this way is the seller’s:
- The buyer cannot change the products, plans or quantities. Changing a line from the checkout page is refused with
lines_locked. - The buyer cannot change the email you set. The checkout page shows it read-only. The other details you send stay the buyer’s to correct, such as a postal code.
- Your
metadataandexternal_referencecannot be changed from the checkout page, and arrive on the order’s webhooks asorder.metadata. - Redirect URLs must be registered. A
success_urlorcancel_urlthat is not one of your registered redirect URLs is refused withinvalid_redirect_urlrather than ignored.
Create the checkout
checkout object. Send the buyer to its checkout_url. It comes only with the create response: the checkout keeps a digest of the link’s token, so retrieving the checkout later does not return it. A repeat of the create with the same Idempotency-Key within 24 hours replays the stored response, link included, so its status may be out of date and its link may already have expired: a checkout expires 30 minutes after it was created.
Idempotency-Keyis required. A repeat with the same key answers with the same checkout.- Ids are COPE’s public ids. A line’s
plan_idis the plan’splan_id frompayment_plans[].uuid; an integer is refused withvalidation_error. metadatais yours.external_reference,intended_payment_methodand the keys COPE reserves for itself are refused inside it withreserved_metadata_key.- A member the operation does not take is refused with
invalid_request(400). A checkout created from your server does not take buyer consents: the buyer gives them on the checkout page.
Confirm the order by the checkout’s id
Store thechk_ id. When the buyer has paid, GET /v1/commerce/checkouts/{id} names the order.
status reads completed whenever order is set. A checkout expires 30 minutes after you create it; create a new one for a buyer who comes back later.
Match the order in payment.sale.succeeded to that order.id before you fulfil, rather than matching on external_reference: a checkout link anyone can open can carry the same reference.
See the API reference for every member and error.