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
Configuration
| Option | Required | Default | Notes |
|---|---|---|---|
publishableKey | Yes | - | Business publishable key. It starts with cope_pk_ and is safe to use in browser code. |
baseUrl | No | COPE production API | Override only when COPE support gives you an environment-specific API URL. |
checkoutBaseUrl | No | The baseUrl origin | Used to validate checkout URLs returned by the API. |
http://localhost during development.
Basic redirect flow
success_url with order_id appended:
Embedded checkout
To keep the buyer on your page, create checkout withembed_origin and mount it with mountCheckout().
Core methods
| Method | Purpose |
|---|---|
getProduct(productId) | Fetch public product details and payment plans. |
createCart(payload) | Create a cart and store the checkout credential needed for later cart updates. |
addLine(cartId, payload) | Add a product, payment plan, and quantity. |
setBuyerIdentity(cartId, payload) | Set buyer location and contact data for tax and checkout. |
reprice(cartId) | Calculate taxes, shipping, discounts, and final totals. |
checkout(cartId, payload) | Create a hosted checkout session. |
redirectToCheckout(checkout) | Navigate the browser to hosted checkout. |
mountCheckout(target, checkout, options) | Mount hosted checkout inside an iframe. |
cancelCheckout(checkoutId) | Cancel an open checkout session. |
destroy() | Abort in-flight requests, remove mounted iframes, and clear SDK cart state. |