Request: Iframe Mode (framed, framed_return_parent, framed_return_top, framed_message_target)
This parameter ONLY working with those integration types (Hosted Payment Page, Invoices(Payment Endpoint)).
With our iFrame Mode
feature, you can enhance the checkout experience by keeping customers on your site throughout the payment process. Instead of redirecting them to a separate payment page, you can embed the hosted payment page directly within your site using an iframe HTML tag, providing a seamless and integrated experience.
Furthermore with customizing the hosted payment page to match your websiteβs design, ensuring consistency with your brand while maintaining a secure payment environment. iFrame Mode offers a smoother, more cohesive experience for your customers by eliminating the need for redirection during checkout. For more details about how to customize the UI please check How to customize the PayPage (Hosted Payment Page) UI?
How these parameters could benefit you?β
Here are some scenarios to help you understand when to use the iframe mode:
- Seamless Integration with Checkout Page: This helps to increase conversion rates by keeping the customer within the same checkout flow, minimizing distractions.
- Improved Control Over Customer Navigation: By ensuring that customers are redirected to a main page after payment, it keeps them focused on your site and reduces abandonment.
- Enhanced User Experience: Keeping the payment within the same page makes the experience smoother, reducing frustration and improving transaction completion rates.
- Flexible Redirection Options: Provides the flexibility to redirect customers as needed, aligning the checkout flow with your business strategy.
- Maintaining Parent Page Stability: Prevents disruptions by avoiding unnecessary reloads, helping maintain the consistency and reliability of your website during transactions.
- Efficient Response Handling: Helps streamline the backend process by efficiently handling payment responses, ensuring quick updates and reducing potential delays.
Limitationsβ
Unfortunately, not all payment methods support this feature due to their business/security flow. So here are the payment methods that support this feature. If you want a specific payment method that is not listed below, you will have to use our hosted payment page with redirecting mode.
- What are the payment methods that support the iFrame mode exclusively?
- All Types of Cards (such as MasterCard, Mada, Meeza ... etc)
- UnionPay
- STC Pay
- ValU
- Meeza QR
- Aman
How to Use?β
In order for you to start using the iFrame Mode
feature, you kindly need to follow the below simple steps:
- Framed
- Framed Return Top
- Framed Return Parent
- Framed Message Target
- Within the initiation of the request payload of the payment page/link in Step 3 via any of the supported integration types by this feature, you will use the optional parameter
framed
within the main request payload itself as shown below:{
.
.
"framed":true
.
.
} - Once you post your request, you will receive a response that includes a redirect URL like the following:
"redirect_url": "https://secure.paytabs.com/payment/page/599458B182E5B6B********************B4818688",
- Finally, you will need to embed this URL inside your checkout page using the iframe tag, as this is crucial for your customer to proceed through the payment process. You may need to check the customer experience after in the coming Expected Payment Flow Behavior.
- To use the
framed_return_top
parameter, include it in the request payload as shown below:{
.
.
"framed":true
"framed_return_top":true // "framed" is mandatory to use this field
.
.
} - When set to
true
, the customer will be redirected to the return URL outside the iframe. If you donβt include it or set it tofalse
, the return URL will be loaded inside the iframe, keeping the customer within the same frame. - This parameter allows you to control the redirection behavior after payment, ensuring a smooth flow and improving user experience.
- Once you post your request, you will receive a response that includes a redirect URL like the following:
"redirect_url": "https://secure.paytabs.com/payment/page/599458B182E5B6B********************B4818688",
- Finally, you will need to embed this URL inside your checkout page using the iframe tag, as this is crucial for your customer to proceed through the payment process. You may need to check the customer experience after in the coming Expected Payment Flow Behavior.
- The
framed_return_parent
parameter is used in nested frame mode to ensure the parent page remains intact while the payment page continues within the iframe. This prevents unnecessary reloads of the parent page during the payment process.
Include this parameter in the request payload as shown below:{
.
.
"framed":true,
"framed_return_parent":true /// "framed" is mandatory to use this field
.
.
} - In single iframe mode, this parameter is not needed, as the entire process happens within the same iframe.
- Using this parameter ensures a stable user experience by preventing disruptions to the parent page while the payment occurs in a nested frame.
- Once you post your request, you will receive a response that includes a redirect URL like the following:
"redirect_url": "https://secure.paytabs.com/payment/page/599458B182E5B6B********************B4818688",
- Finally, you will need to embed this URL inside your checkout page using the iframe tag, as this is crucial for your customer to proceed through the payment process. You may need to check the customer experience after in the coming Expected Payment Flow Behavior.
- The
framed_message_target
Theframed_message_target
will allow you safely cross-origin communication between your system webpage and PayTabs success PayPage after the transaction is completed.
Include it in the request payload as shown below:{
.
.
"framed":true,
"framed_message_target": "https://MERCHANT_WEBSITE.COM" /// "framed" is mandatory to use this field
.
.
} - This parameter allows you to listen to an event (JS postMessage) after the payment is compacted to take the next action, for example, make a service side check to verify the transaction status and then redirect the customer to the proper page success/failure, or even close the iFrame.
- Once you post your request, you will receive a response that includes a redirect URL like the following:
"redirect_url": "https://secure.paytabs.com/payment/page/599458B182E5B6B********************B4818688",
- Finally, you will need to embed this URL inside your checkout page using the iframe tag, as this is crucial for your customer to proceed through the payment process. You may need to check the customer experience after in the coming Expected Payment Flow Behavior.
Parameter Specificationsβ
Framed
Parameter |
| |||
---|---|---|---|---|
Description | Indicates whether to preview the payment page within the current check page instead of redirection or not. If β, preview the redirect URL sent in the response in '<iframe>' HTML tag, which will preview the whole payment page within this frame. To know more about this parameter please click here. | |||
Data Type | BOOLEAN | |||
Required | β | |||
Sample |
|
framed_return_top
Parameter |
| |||
---|---|---|---|---|
Description | Indicates whether to reload the whole page on redirections or just reload the current frame. To know more about this parameter please click here. | |||
Data Type | BOOLEAN | |||
Required | β | |||
Sample |
|
framed_return_parent
Parameter |
| |||
---|---|---|---|---|
Description | Indicates whether to reload the main base (could be div or another iFrame tag) that contained the payment page framed element. To know more about this parameter please click here. | |||
Data Type | BOOLEAN | |||
Required | β | |||
Sample |
|
framed_message_target
Parameter |
| |||
---|---|---|---|---|
Description | If you didn't have a return URL, PayTabs default return page (return: 'None'), to receive the message after the payment is done using the javascript, which gives your system the ability to close the iFrame after payment | |||
Data Type | URI | |||
Required | β | |||
Validation Rules | A valid HTTPS website URL of your domain (the recipient) that will receive the event. In order for the event to be dispatched, this domain must match exactly (including scheme, hostname, and port). | |||
Sample |
|
Request & Response Payloads Samplesβ
- Hosted Payment Page
- Invoices
The below sample request payload will show you how you can pass the above-mentioned required parameter/s, which are needed to be passed with valid values to perform a request. Along with the response payload received after using this request payload.
- Request Sample Payload
- Response Sample Payload
{
"profile_id": {{profile_id}},
"tran_type": "sale",
"tran_class": "ecom",
"cart_description": "Description of the items/services",
"cart_id": "Unique order reference00",
"cart_amount": 25000.2,
"cart_currency": "SAR",
"framed":true,
"framed_return_top": true,
"framed_return_parent": true,
"framed_message_target": "https://MERCHANT_WEBSITE.COM"
}
{
"tran_ref": "TST22********159",
"tran_type": "Sale",
"cart_id": "CART#1001",
"cart_description": "Description of the items/services",
"cart_currency": "SAR",
"cart_amount": "500.00",
"return": "none",
"redirect_url": "https://secure.paytabs.com/payment/page/599458B182E5B6B********************B4817FD44318539688688",
"serviceId": 2,
"profileId": 9*****4,
"merchantId": 1*****7,
"trace": "PMN****4.63****A8.00****C4"
}
The below sample request payload will show you how you can pass the above-mentioned required parameter/s, which are needed to be passed with valid values to perform a request. Along with the response payload received after using this request payload.
- Request Sample Payload
- Response Sample Payload
{
"profile_id": {{profile_id}},
"tran_type": "sale",
"tran_class": "ecom",
"cart_currency": SAR,
"cart_amount": "9.5",
"cart_id": "cart_12345_2",
"cart_description": "Test Description",
"hide_shipping": true,
"framed":true,
"framed_return_top": true,
"framed_return_parent": true,
"framed_message_target": "https://MERCHANT_WEBSITE.COM"
"invoice": {
"id": 3130066,
"shipping_charges": "0",
"extra_charges": "0",
"extra_discount": "0",
"total": "9.5",
"activation_date": 0,
"expiry_date": 0,
"due_date": 0,
"issue_date": 1733909180,
"line_items": [
{
"sku": "sku",
"description": "invoice item",
"url": "https://paytabs.com",
"unit_cost": "9.5",
"quantity": "1",
"net_total": "9.5",
"discount_rate": "0",
"discount_amount": "0",
"tax_rate": "0",
"tax_total": "0",
"total": "9.5"
}
]
},
}
{
"tran_ref": "TST22********159",
"tran_type": "Sale",
"cart_id": "CART#1001",
"cart_description": "Description of the items/services",
"cart_currency": "SAR",
"cart_amount": "9.5",
"return": "none",
"redirect_url": "https://secure.paytabs.com/payment/page/599458B182E5B6B********************B4817FD44318539688688",
"invoice": {
"id": 3130066,
"shipping_charges": "0",
"extra_charges": "0",
"extra_discount": "0",
"total": "9.5",
"activation_date": 0,
"expiry_date": 0,
"due_date": 0,
"issue_date": 1733909180,
"line_items": [
{
"sku": "sku",
"description": "invoice item",
"url": "https://paytabs.com",
"unit_cost": "9.5",
"quantity": "1",
"net_total": "9.5",
"discount_rate": "0",
"discount_amount": "0",
"tax_rate": "0",
"tax_total": "0",
"total": "9.5"
}
]
},
"serviceId": 2,
"profileId": 9*****4,
"merchantId": 1*****7,
"trace": "PMN****4.63****A8.00****C4"
}
Expected Payment Flow Behaviorβ
- All Integration Types
- As mentioned above in the How to use? section, As a merchant you would initiate a payment request per the above Specifications, same as the sample codes mentioned in the samples section above.
- Framed
- Framed Return Top
- Framed Return Parent
- Framed Message Target
- This behavior is about passing
framed
only.Additionally, let's assume that our Onboarding link is the return URL. ( just to show exact behavior){
.
.
"framed":true,
"return" : "https://site.paytabs.com/Onboarding/Technical-Onboarding.html",
.
.
} - Then, you will receive a response that includes redirect URL. This means you have initiated a correct payment request/page successfully.
"redirect_url": "https://secure.paytabs.com/payment/page/599458B182E5B6B********************B4818688",
- Next, you should embed this url inside your checkout page directly using the needed mark up tags
<iframe src="https://secure.paytabs.com/payment/page/599458B182E5B6B********************B4818688" width="" height="" > </iframe>
- Then,Then customer can proceed normally and adding his card information. However he can see the payment page embed in a frame like that( size of frame is depending on width and height you provide)
- Then, he will be redirected to his issuer bank 3DS/OTP page to authenticate the used card, inside the iframe
- After, the customer the payment and passes the 3Ds step, the return page will be shown inside the frame
If no return URL passed you will see PayTabs default page. inside the frame like this - Finally, you will be able to see his transaction on your merchant dashboard, whether it's accepted/authorized or not.
- This behavior is about passing
framed
andframed_return_top
only.Additionally, let's assume that our Onboarding link is the return URL. ( just to show exact behavior){
.
.
"framed":true,
"framed_return_top":true,
"return" : "https://site.paytabs.com/Onboarding/Technical-Onboarding.html",
.
.
} - Then, you will receive a response that includes redirect URL. This means you have initiated a correct payment request/page successfully.
"redirect_url": "https://secure.paytabs.com/payment/page/599458B182E5B6B********************B4818688",
- Next, you should embed this url inside your checkout page directly using the needed mark up tags
<iframe src="https://secure.paytabs.com/payment/page/599458B182E5B6B********************B4818688" width="" height="" > </iframe>
- Then,Then customer can proceed normally and adding his card information. However he can see the payment page embed in a frame like that( size of frame is depending on width and height you provide)
- Then, he will be redirected to his issuer bank 3DS/OTP page to authenticate the used card, inside the iframe
- After, the customer the payment and passes the 3Ds step, the return page will get out of the frame and shown full page
If no return URL passed you will see PayTabs default page. inside the frame like this - Finally, you will be able to see his transaction on your merchant dashboard, whether it's accepted/authorized or not.
- This behavior is about passing
framed
andframed_return_parent
only.Additionally, let's assume that our Onboarding link is the return URL. ( just to show exact behavior){
.
.
"framed":true,
"framed_return_parent":true,
"return" : "https://site.paytabs.com/Onboarding/Technical-Onboarding.html",
.
.
} - Then, you will receive a response that includes redirect URL. This means you have initiated a correct payment request/page successfully.
"redirect_url": "https://secure.paytabs.com/payment/page/599458B182E5B6B********************B4818688",
- Next, you should embed this url inside your checkout page directly using the needed mark up tags
<iframe src="https://secure.paytabs.com/payment/page/599458B182E5B6B********************B4818688" width="" height="" > </iframe>
- Then,Then customer can proceed normally and adding his card information. However he can see the payment page embed in a frame inside a frame to show the nested behavior( size of frame is depending on width and height you provide)
- Then, he will be redirected to his issuer bank 3DS/OTP page to authenticate the used card, inside the inner iframe
- After, the customer the payment and passes the 3Ds step, the return page will get out of the frame and shown inside the outer frame and reload the inner one
If no return URL passed you will see PayTabs default page. inside the inner frame like this - Finally, you will be able to see his transaction on your merchant dashboard, whether it's accepted/authorized or not.
- This behavior is set by passing
framed
andframed_message_target
only. Additionally, no return URL should be provided with your request, as this behavior is associated with the default post-payment page, and if you set the return URL your customer will redirected to this URL without passerby the default post-payment.{
.
.
"framed":true,
"framed_message_target":"**Valid Message URL**" // Must be the domain the merchant operates from (HTTPS only allowed)
.
.
} - Then, you will receive a response that includes redirect URL. This means you have initiated a correct payment request/page successfully.
"redirect_url": "https://secure.paytabs.com/payment/page/599458B182E5B6B********************B4818688",
- Next, you should embed this url inside your checkout page directly using the needed mark up tags
<iframe src="https://secure.paytabs.com/payment/page/599458B182E5B6B********************B4818688" width="" height="" > </iframe>
- Also, within the same page you have embedded the framed payment page, you can set the JS code that will listen to the post message after the payment is completed for example:
<script type="text/javascript">
window.addEventListener("message", function(event){
if (event.data == 'hppDone' && event.origin == 'https://secure.paytabs.com'){
//make action
}
})
</script> As you can see you need to make sure that the event data equal 'hppDone' and event.origin equal your integration region domain for example https://secure.paytabs.com, which is come from the PayTabs payment page.
- Then customer can proceed normally and adding his card information. However he can see the payment page embed in a frame like that( size of frame is depending on width and height you provide)
- Then, he will be redirected to his issuer bank 3DS/OTP page to authenticate the used card, inside the iframe
- After, the customer completed the payment and passes the 3Ds step, the default post-payment page will be seen inside the frame as following:
Continuing with this point the default post-payment page will trigger the following code, which will send the post message to your origin domain that you have set:
<script type="text/javascript">
window.parent.postMessage("hppDone","https://merchant-domain.com");
</script>Which will trigger the event listener you have in your page to let your system know that the payment process is completed, so you can handle the next step accordingly.
- Finally, you will be able to see his transaction on your merchant dashboard, whether it's accepted/authorized or not.