Overview
UniBee Payment supports iframe integration for seamless payment experiences. By settingPaymentUIMode
to "embedded"
in API requests, you can embed payment pages directly into your application using an iframe, eliminating the need for page redirects.
API Integration
Supported Endpoints
The following API endpoints support iframe integration:Endpoint | Description | PaymentUIMode Support |
---|---|---|
/checkout/subscription/create_submit | Create subscription (checkout) | ✅ |
/merchant/subscription/create_submit | Create subscription (merchant) | ✅ |
/merchant/subscription/update_submit | Update subscription (merchant) | ✅ |
/merchant/payment/new | Create one-time payment | ✅ |
Request Parameters
Add thePaymentUIMode
parameter to your API requests:
Response Structure
WhenPaymentUIMode
is set to "embedded"
, the API returns:
link
: The payment page URL to embed in iframepaymentId
: Unique payment identifierinvoiceId
: Unique invoice identifieraction
: Gateway-specific payment data
Frontend Integration
1. Basic iframe Setup
2. React Integration Example
Message Communication Protocol
Message Format
The iframe sends messages to the parent window in the following format:Message Types
Type | Description | Trigger |
---|---|---|
UniBee_PaymentSuccess | Payment successful | When payment status changes to success |
UniBee_PaymentFailed | Payment failed | When payment status changes to failed |
UniBee_PaymentCancelled | Payment cancelled | When payment status changes to cancelled |
Complete Integration Flow
1. Create Payment
2. Embed Payment Page
3. Listen for Messages
Security Considerations
1. Message Origin Verification
2. Message Content Validation
Best Practices
1. Responsive Design
2. Loading States
3. Timeout Handling
API Reference
PaymentUIMode Values
Value | Description |
---|---|
"hosted" | Redirect to hosted payment page (default) |
"embedded" | Return URL for iframe embedding |