UseePay Open API
UseePay PortalMechant Dashboard
Product Docs
Product Docs
  • V2.0
  • V1.0
UseePay PortalMechant Dashboard
Product Docs
Product Docs
  • V2.0
  • V1.0
  1. Embedded Checkout
  • Integration
    • Welcome to the UseePay Demo Page
    • About Payment Methods
      • Card
      • Apple Pay Web Integration (API Integration)
      • Apple Pay(Hosted Checkout)
      • Google Pay
      • Klarna
      • Naver pay
      • Kakao Pay
      • Toss Pay
      • Payco
      • Affirm
      • Blik
      • trustly
      • Cashapp
    • subscription
      • Get started with Subscription
    • online payment
      • Get started with online payments
    • Payment Capabilities
      • Adaptive Price
      • Supported Payment Methods for Checkout
    • checkout session
      • Checkout Session Guide
  • developer
    • Introduction
    • Authentication
    • Errors
    • error code
      • last_payment_error documentation
    • Best Integration
      • Quickly create a paymentIntent for a subscription
      • Auto-Charge Subscription Guide
    • Payment Intents
      • Payment Intent Overview
      • Quickly create a paymentIntent
      • Create a PaymentIntent
      • Retrieve a PaymentIntent
      • Update a PaymentIntent
      • Confirm a PaymentIntent
      • Cancel a PaymentIntent
      • Capture a PaymentIntent
      • List all payment intents
    • Customers
      • Create a customer
      • Retrieves a customer
      • Update a customer
      • List all customers
    • Subscriptions
      • Create a subscription
      • Retrieves a subscription
      • Update a subscription
      • List all subscriptions
      • Cancel a subscription
    • Invoices
      • Create a invoice
      • Retrieves a invoice
      • List all invoices
      • Pay a invoice
    • Payment Methods
      • Create a payment method
      • Retieve Payment Method Session
      • Retrieves a payment method
      • Update a payment method
      • List all payment methods
    • Mandates
      • Create a mandate
      • Retrieves a mandate
      • List all mandates
    • Refunds
      • Create a refund
      • Retrieves a refund
      • List all refunds
    • Webhooks
      • Webhook events
      • Webhook Activation/Signature Verification Steps
      • Webhook Events Documentation (testing)
      • Create a webhook
      • Retrieves a webhook
      • Update a webhook
      • List all webhooks
    • Embedded Checkout
      • Payment Elements
      • Express Checkout Elements
      • Checkout Session Element
    • case
    • objects
    • About Testing
      • Test Cards
      • ApplePay&GooglePay
    • Payment Method Configuration
      • Retieve Payment Method Configuration
    • Checkout Session
      • Create Checkout Session
      • Retrieve Checkout Session
    • Trackers
      • upload trackers
      • Retrieve a tracker
    • Schemas
      • CheckoutSessionCreateRequest
      • LineItem
      • Customer
      • Address
      • ProductData
      • Shipping
      • SubscriptionData
      • Error
      • DiscountPeriodConfig
      • DeviceData
      • CheckoutSessionResponse
      • ErrorResponse
      • Order
      • Product
      • PaymentMethodOptions
      • RiskControlOptions
      • Mandate
      • PaymentIntent
      • PaymentMethod
      • Billing
      • Card
      • AliPay
      • Wallet
      • Klarna
      • WechatPay
      • Refund
      • Subscription
      • Recurring
      • PriceData
      • SubscriptionItem
      • Invoice
      • NextAction
      • Webhook
      • CollectableOptions
      • PaymentLink
      • last_payment_error
      • discount_period_config
      • CreatePaymentIntentRequest
  • message
    • Messaging Element
  • FAQ
    • Unable to receive Webhook notifications
UseePay PortalMechant Dashboard
Product Docs
Product Docs
  • V2.0
  • V1.0
UseePay PortalMechant Dashboard
Product Docs
Product Docs
  • V2.0
  • V1.0
  1. Embedded Checkout

Checkout Session Element

UseePay Checkout Session Usage Guide#

Product Illustration#

image.png

Table of Contents#

Overview
Quick Start
Complete Flow Diagram
API Reference
Best Practices
FAQ

Overview#

Checkout Session is a simplified payment integration method provided by UseePay SDK. By creating a Checkout Session on the server side in advance, the frontend only needs to use checkoutSessionId and clientSecret to quickly integrate payment functionality without handling complex payment parameter configurations.

Key Features#

Simplified Integration: Server creates the Session, frontend only needs ID and secret
High Security: Sensitive information is configured on the server, frontend only holds temporary credentials
Centralized Management: Payment configuration, amount, currency and other information are managed uniformly on the server

Quick Start#

1. Include SDK#

The sdk url for the production environment has not been launched yet. Below is the address for the sandbox environment

2. Initialize UseePay#

3. Initialize Checkout#

checkout_session.client_secret and checkout_session.id are available after the checkout session is successfully created.
eg:

4. Create and Mount Payment Element#

5. Load Actions and Confirm Payment#


Complete Flow Diagram#

Flow Description#

1.
Server Creates Session: Merchant server calls UseePay API to create Checkout Session, obtaining checkoutSessionId and clientSecret
2.
Frontend Initialization: Frontend initializes SDK with publishable key and initializes Checkout with Session credentials
3.
Create Payment Element: Call createPaymentElement() to create payment form component
4.
Mount to Page: Mount payment element to specified DOM container
5.
Load Actions Object: Call loadActions() to get payment action methods
6.
User Action: User fills in payment information (card number, expiration date, etc.)
7.
Confirm Payment: Call actions.confirm() to submit payment
8.
3DS Verification (if required): SDK automatically handles 3D Secure verification flow
9.
Return Result: After payment completion, return result for frontend to handle accordingly

API Reference#

UseePay(apiKey)#

Initialize UseePay SDK instance.
Parameters:
ParameterTypeRequiredDescription
apiKeystring✅Publishable key, format: UseePay_PK_*** or UseePay_PK_TEST_***
Returns: UseePay instance
Example:

useepay.initCheckout(options)#

Initialize Checkout Session.
Parameters:
ParameterTypeRequiredDescription
optionsInitCheckoutOptions✅Checkout configuration object
options.checkoutSessionIdstring✅Checkout Session ID, format: cs_xxxxxxxxxxxx
options.clientSecretstring✅Client secret, format: cs_xxxxxxxxxxxx_xxxxxxxxxxxxxxx
Returns: Checkout instance
Example:
Important Notes:
checkoutSessionId and clientSecret must be obtained from server
Each Session can only be used once, must recreate after payment completion
clientSecret has expiration time, need to recreate Session after expiration

checkout.createPaymentElement()#

Create standard payment element.
Returns: PaymentElement instance
Example:
Important Notes:
Each Checkout instance can only create one Payment Element
Repeated calls will throw an error
Must call mount() method after creation to display

paymentElement.mount(domId)#

Mount payment element to specified DOM element.
Parameters:
ParameterTypeRequiredDescription
domIdstring✅DOM element ID (without # prefix)
Returns: void
Example:
Important Notes:
DOM element must already exist on the page
Recommended to set appropriate width for container (e.g., width: 60vw)
Payment form will automatically load after mounting

paymentElement.unmount()#

Unmount payment element.
Returns: void
Example:
Important Notes:
Element is removed from DOM after unmounting
Can call mount() again to remount

checkout.loadActions()#

Load payment actions object.
Returns: Promise<LoadActionsResult>
LoadActionsResult Type:
Example:
Important Notes:
Must be called after creating payment element
Returned actions object contains confirm() method
Recommended to call this method when page loads

actions.confirm()#

Confirm and submit payment.
Returns: Promise<{ session?: CheckoutSession; error?: Error }>
Return Value Description:
FieldTypeDescription
sessionobjectSession object returned on successful payment
session.checkout_session_idstringCheckout Session ID
session.payment_statusstringPayment status: 'paid', 'un_paid', etc.
session.payment_intent_idstringPayment Intent ID for tracking payment intent
session.payment_intent_statusstringPayment Intent status
session.statusstringOverall Checkout Session status
errorobjectError information on payment failure
error.messagestringError description
error.typestringError type (optional)
Complete session Object Structure:
Example:
Important Notes:
Ensure user has filled in complete payment information before calling
May trigger 3DS verification, SDK handles automatically
Do not call this method repeatedly during payment process

Best Practices#

1. Security#

✅ Must use HTTPS: Production environment must use HTTPS protocol
✅ Secret Management: Do not expose clientSecret in public code repositories
✅ Server Verification: Must verify payment status on server after payment completion

2. Performance Optimization#

Load SDK script in advance to avoid blocking page rendering
Call loadActions() when page loads, don't wait for user to click payment button
Set appropriate container width to avoid frequent repaints

3. User Experience#

Display loading state during payment process to avoid user repeated clicks
Provide clear error messages
Redirect or display success page promptly after successful payment
Do not close or refresh page during 3DS verification

4. Compatibility#

Apple Pay: Only available on Safari browser and supported iOS devices
Google Pay: Requires user to be logged into Google account
Browser Requirements: Recommended to use modern browsers (Chrome 90+, Safari 14+, Firefox 88+)

5. Debugging Tips#

Use test environment API Key (UseePay_PK_TEST_***) for development
Check SDK output logs in browser console
Use test card numbers for testing (obtain from UseePay documentation)

6. FAQ#

Q: Can each Checkout instance create multiple Payment Elements?
A: No. Each Checkout instance can only create one Payment Element.
Q: Can Sessions be reused?
A: No. Each Session can only be used once, must recreate after payment completion.
Q: How to handle 3DS verification?
A: SDK automatically handles 3DS verification flow, no additional code needed.
Q: Can payment amount be modified on frontend?
A: No. Payment amount is determined when creating Session on server, frontend cannot modify.
Modified at 2026-01-27 05:16:01
Previous
Express Checkout Elements
Next
Test Cards
Built with