Skip to main content

Checkout SDK

The COPE Checkout SDK is a browser SDK for buyer checkout flows. It lets you fetch product data, build a cart, calculate final prices, create a hosted checkout session, and either redirect the buyer to COPE checkout or mount that checkout inside your page. Use the SDK when your site owns the product page or shopping experience and COPE owns payment collection, tax calculation, order creation, and payment lifecycle events.

Install

For pages without a bundler, load the global build:

Configuration

The SDK requires HTTPS except for http://localhost during development.

Basic redirect flow

After successful payment, COPE redirects to success_url with order_id appended:

Redirect URLs

success_url and cancel_url must be registered for the business before you can pass them to checkout(). Register them in the COPE dashboard under Settings → SDK, on the API Settings page, in the Redirect URLs section — up to 10 of each. Passing a URL that is not registered fails the checkout call with 422 and a field error per offending value. The message points at the same screen:

Matching is exact

A registered entry is compared to the value you send as a complete URL string. It is not an origin match and not a path prefix, so every one of these is rejected when only https://shop.example.com/thank-you is registered: If your landing page needs its own query parameters, register the full URL including them. You do not need to register the ?order_id= variant: COPE appends order_id after the value has been matched.

What you can register

  • HTTPS only. http:// is rejected, including http://localhost, so redirect URLs cannot point at a local development server even though the SDK itself accepts http://localhost as a page origin.
  • A public host. Loopback and private addresses such as localhost, 127.0.0.1, 10.x.x.x, 172.16-31.x.x, 192.168.x.x, and IPv6 ::1 or unique-local addresses are rejected.
  • No credentials in the URL (https://user:pass@…) and no backslashes.
To exercise redirect completion from a development machine, use an HTTPS tunnel and register the tunnel URL.

Omitting them

success_url and cancel_url are optional on checkout(). When you omit one, COPE uses the first URL registered for that field. When you send one, it must be registered. Embedded checkout signals completion through postMessage events rather than a redirect, so iframe integrations can omit both. Keep at least one of each registered anyway: when mountCheckout() falls back with fallback: "redirect", the buyer continues on COPE hosted checkout, and that page still needs a success and cancel destination to return them to afterwards.

Embedded checkout

To keep the buyer on your page, create checkout with embed_origin and mount it with mountCheckout().
Read the full embedded checkout guide before launching iframe checkout. It covers registered embed origins, iframe security, postMessage events, and fallback behavior.

Core methods

Errors

The SDK exposes typed errors:
Treat 4xx API errors as permanent for the same payload. Fix the input and retry with a new request. The SDK retries selected transient network or server failures with backoff.