In the most basic terms, a hosted payment page (also known as External Checkout, Third-Party Checkout, External Payment Page or Checkout page) is one of the most common ways to accept online payments.
It is a third-party checkout web form that handles electronic transactions (payments made with credit and debit cards).
In exchange for a small transaction fee, these Hosted Checkout Pages will take care of the entire transaction process: payment information collection, sensitive data protection, and transaction security.
1.2 Embedded Checkout?
Embedded checkout gives the shopper the seamless appearance of staying on your site while they make payment.
The checkout page is embedded in your website using an HTML <iframe> tag. This tag creates a frame in your web page and then the checkout page is embedded within that frame.
2.1 Integration Flow
ShopBase partner will receive ShopBase Payment key after successfully registering Payment integration.
Partner's payment provider will use ShopBase Payment key for signing mechanism when send/receive requests to/from ShopBase
To start using the Payment Provider, merchants have to register with Payment Gateway and take Gateway's credentials. Merchants should enter those credentials to ShopBase payment settings.
ShopBase sends a request to endpoints of Payment Provider according to ShopBase format and Shopbase signing mechanism.
After taking the request, the Payment Provider can ask ShopBase to get Gateway's credentials and then send Gateway's requests to Gateway's format and Gateway's authenticate mechanism.
2.2 Sequence Diagram
2.2.1 Hosted Payment Page
First, the buyer needs to fulfill the information: shipping address, billing information, shipping method... and choose your provider as the payment method. When the buyer clicks the Place Order button, ShopBase submits to the Redirect API with the POST method and the x-www-form-urlencoded format.
Your provider performs a signature validation to ensure that the request is sent from ShopBase. Your provider displays on the checkout page and lets buyers confirm their payment.
Your provider redirects to x_url_complete with GET method and all required parameters. ShopBase will validate the data and create the Order.
ShopBase will redirect to the Thank-you page to inform the buyer that the payment is complete.
Your provider needs to make a POST request to x_url_callback. It informs ShopBase that the payment has completed with the same response parameters as when it was redirected. It also ensures that the Order will be created even if the buyer goes offline before being redirected to ShopBase.
ShopBase records the payment and responses with a 200 HTTP status to the provider.
2.2.2 Embeded Checkout
First, the buyer needs to fulfill the information: shipping address, billing information, shipping method... and choose your provider as the payment method. ShopBase will embed your Iframe Url to block Payment method on the checkout page.
Your iframe should display the card element (or whatever element), so the buyer can interact with it.
When the buyer provides card details and clicks Place Order, ShopBase will post a message into the iframe with request values.
Your iframe should request your provider server to confirm payment and obtain gateway authorization reference
ShopBase will request to ShopBase server to verify payment status with your provider server, then create an Order.
ShopBase server displays the order information to the client with the Thank you page to indicate that the order has been paid successfully.
We suggest your provider make a POST request to x_url_callback. It informs ShopBase that the payment has completed with the same response parameters when posting the message on iframe. It also ensures that the Order will be created even if the buyer loses the connection before the ShopBase Server receives the payment information.
What is post-purchase?
To help merchants who want to motivate customers after they bought something from the store. ShopBase designed a feature called Post-Purchase. This feature can re-engage customers who just complete a purchase and catch them on the site when they are most likely to buy or to comply with other requests.
How to implement it?
Almost, has the same normal flow, but still has some differences.
After the first purchase is completed, we will send a new authorization with x_reference has the same value with the first authorization and x_post_purchase is true. These have some different ways to process Post-Purchase, it depends on the flow which you choose for implementation.
For Hosted payment page flow, we will redirect the customer to Gateway payment page, and use Redirect API with the same x_reference and x_post_purchase is true.
For Embedded checkout flow, we will send update-authorization request use Order management API with the same x_reference and x_post_purchase is true.
At this step, the gateway needs to capture this second authorization and return a new transaction id. And note that, ShopBase only accepts the update-authorization once within 10 minutes after the first authorization. Authorization cannot be updated twice.
3. API reference
3.1 Redirect API + Iframe postMessage
It is used in the checkout flow to redirect to a hosted checkout page or embed an iframe in an embedded checkout page.
ShopBase payment account ID, for getting Gateway Credentials.
Time of transaction completion. UTC Time: YYYY-MM-DDTHH:MM:SSZ
Billing address could not be verified.
A custom error message displayed to the customer.
An error code to be log on ShopBase
3.3 Get transaction info API
This API is the endpoint to retrieve information on one transaction. Payment Provider needs to provide information in accordance with x_transaction_type (authorization, capture, refund or void) that ShopBase requests.
ShopBase payment account ID, for getting Gateway Credentials.
Checkout token or order id depends on x_transaction_type
Unique reference for payment issued by the payment processor.
Indicates whether or not this request should be processed in test mode (if supported).
The valid values are authorization, capture, refund, void
Valid values are completed, failed
Same as Redirect API Response value
3.4 Check Credentials API
The API is the endpoint to check the legitimacy of one set of gateway credentials (it can be used to make transactions and refund transactions). ShopBase will use this endpoint whenever the merchants activate your payment in the ShopBase dashboard.
The json object contains Payment Gateway credentials.
The valid values are valid, invalid, restricted.
3.5 Get Gateway Credentials
It provides gateway's credentials for your provider.
Signature will be sent in HTTP header X-Signature of request.
3.8 Error codes
Card declined by any reasons (anti-fraud, declined by bank..)
An error occurred while processing the card. Try again later or with a different payment method.
The card has been declined for an unknown reason. The customer needs to contact their card issuer for more information.
The customer's card issuer has declined the transaction and requested that the card be retained as the card may have been reported as lost or stolen
Does not support this payment for some reason.
Missing "x" params
3.9 Other notes
HTTP 200 indicates successful receipt of a callback by ShopBase. Otherwise, up to 5 retries with an interval of at least 60 seconds are recommended.
In case the merchant performs the capture/refund/void action from the payment provider dashboard, POST a callback asynchronously to ShopBase payment callback URL to notify ShopBase for syncing the order status.
ShopBase always double-validate all request calls between 2 sides: validate request payload + signature, and validate real data (using payment information from the Get Payment Info API to compare). All the data should be validated:
x_reference should similar to checkout token and order id of ShopBase
x_amount of transaction should matches with the amount of ShopBase
x_result should be completed
x_test, x_account_id should match with ShopBase's request
ShopBase payment key, Gateway's credentials are private and hidden in all APIs.
Messages posted via iFrame need to be defined protocol + host + port strictly to ensure no other parties can eavesdrop. When Payment Provider received the messages via iFrame, you also need to check the origin of the requests to ensure they are sent from ShopBase.
When handling requests from payment providers, ShopBase will have a process lock to avoid duplicating requests.
All the requests to payment providers will be logged by ShopBase (i.e. request, response, error rate, error code) to trace back the problems and statistics.
Embedded iframe needs to share the same style with ShopBase and support responsive.
You need to ensure rendering speed, API process speed.