Skip to main content

Overview

By embedding ZAFA PAY’s checkout page in an iframe, you can complete payments within your site without redirecting users.

Result Notification Methods

There are two methods for receiving payment results.
The notification method is configured per merchant. Contact support if you need to change it.

Implementation Steps

1. Create Payment Request

Create a payment request using POST /v1/payments as usual. Get the payment_url from the response.

2. Embed in iframe

Add the ?mode=embedded parameter to the payment_url and set it in the iframe.
The mode=embedded parameter is required. Without it, a redirect will occur when the payment is completed.

postMessage Method

When postMessage method is configured, payment results are sent to the parent window via JavaScript postMessage.

Receive Events

Event Types

payment_success

Sent when payment completes successfully.

payment_failed

Sent when payment fails.

payment_cancel

Sent when user clicks “Cancel and return to site”.

redirect_required

Sent when redirect is required for 3D Secure authentication etc.
This event only occurs for specific payment methods. Depending on the payment method, authentication may be handled automatically, and this event may not occur.
When redirect is required, open it in a new tab/window or navigate the parent window. Redirects within the iframe may not work due to security restrictions.

Complete Implementation Example

Security Considerations

1

Origin Verification

Always verify event.origin when receiving postMessage.
2

HTTPS Required

Iframe embedding only works on HTTPS sites.
3

Use with Webhooks

For payment confirmation, always receive and verify webhooks on your server in addition to postMessage.

Redirect Method

When redirect method is configured, payment results are notified by redirecting the parent window.

Redirect URL

Users are redirected to the success_redirect_url, failure_redirect_url, or cancel_redirect_url specified when creating the payment.

URL Parameters

  • Cancel does not include transaction_id because the payment was not initiated.
  • If cancel_redirect_url is not set, cancellations will redirect to failure_redirect_url.

Parameter Details

Implementation Example

For payment confirmation, always receive and verify webhooks on your server in addition to URL parameters. URL parameters can be tampered with.

Testing

When testing in the Sandbox environment, you can use the following test cards. Use any future date for expiry and any 3 digits for CVC.