Technical Specifications
1. Integration solutions
1.1 Hosted Payment Page?
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. FLOW
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.
Checkout flow:
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
Your iframe post message to ShopBase with required response values.
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.
2.2.3 Post-Purchase
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
andx_post_purchase
is true.For Embedded checkout flow, we will send
update-authorization
request use Order management API with the samex_reference
andx_post_purchase
istrue
.
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.
Request values
Key | Type | Example | |
| ascii string | 10023456 | ShopBase payment account ID, for getting Gateway Credentials. |
| decimal | 89.99 | |
| USD | ||
| ascii string | 19783 | Unique token for current checkout (checkout token) |
| unicode string | Widgets Inc | To display shop name on Hosted checkout page |
| true/false | true | Indicates whether or not this request should be processed in test mode (if supported). |
| url | URL to which a callback notification should be sent asynchronously. | |
Note: Optional with iframe | url | URL to which customer must be redirected when they wish to quit payment flow and return to the merchant's site. | |
Note: Optional with iframe | url | URL to which customer must be redirected upon successfully completing payment flow. | |
| true/false | false | Indicates whether or not this request is for making post purchase. |
| nested | [ { "name": "Shirt", "quantity": 2, "price": 10, "url": "https://q-payment-test.onshopbase.com/products/shirt-1", "image": "https://img.btdmp.com/10243/10243285/products/1636621679424.jpg", "options": [ { "label": "Size", "value": "L" }, { "label": "Color", "value": "Red" } ] } ] | To display purchase items on Hosted checkout page |
| unicode string | 241 Spadina Ave | |
| unicode string | ||
| unicode string | Toronto | |
| unicode string | ShopBase | |
| CA | ||
| unicode string | +1-613-987-6543 | |
| unicode string | ON | |
| unicode string | M5T 3A8 | |
| unicode string | boris.slobodin@example.com | |
| unicode string | Boris | |
| unicode string | Slobodin | |
| unicode string | +1-613-987-6543 | |
| unicode string | 241 Spadina Ave | |
| unicode string | ||
| unicode string | Toronto | |
| unicode string | ShopBase | |
| CA | ||
| unicode string | Boris | |
| unicode string | Slobodin | |
| unicode string | +1-416-123-4567 | |
| unicode string | ON | |
| unicode string | M5T 3A8 | |
Note: Require if using iframe flow | fixed choice | authorize | Possible values: |
Response values
Key | Type | Example | Note |
| ascii string | 10023456 | ShopBase payment account ID, for getting Gateway Credentials. |
| decimal | 89.99 | Echo request's |
| USD | Echo request's | |
| unicode string | 123 | Unique reference for payment issued by the payment processor. |
| ascii string | 19783 | Echo request's |
| fixed choice | authorization | The valid values are |
| fixed choice | completed | Valid values are |
| true/false | true | Echo request's |
| iso-8601 in UTC | 2014-03-24T12:15:41Z | Time of transaction completion. UTC Time: YYYY-MM-DDTHH:MM:SSZ |
| ascii string | Billing address could not be verified. | A custom error message displayed to the customer. |
| ascii string | ACCOUNT_RESTRICTED | An error code to be log on ShopBase |
Custom iframe message
The following messages can be posted from the iframe to the ShopBase window to modify the iframe container.
Key | Type | Example | |
| fixed choice | iframe_update | Update the iframe of the payment block |
| number | 100 | Resize iframe height to 100px |
3.2 Order management API
These are endpoints used to perform actions such as capture, refund, void order.
In the Embedded checkout flow, the Payment provider needs to provide more update-authorization endpoint to use in ShopBase's Post-Purchase feature.
Note:
Only accept the update-authorization once within 10 minutes after the first authorization. An authorization cannot be updated twice.
Request values
Key | Type | Example | |
| ascii string | 10023456 | ShopBase payment account ID, for getting Gateway Credentials |
| decimal | 89.99 | |
| USD | ||
| integer | 19783 | ShopBase order id |
| ascii string | 450789469 | Unique reference for payment issued by the payment processor. |
| true/false | true | Indicates whether or not this request should be processed in test mode (if supported). |
| url | URL to which a callback notification should be sent asynchronously. | |
| fixed choice | capture | The valid values are |
| unicode string | #123 | Only available on request type = |
| unicode string | admin refunded $150.00 USD | Only available on request type = |
Response values
Key | Type | Example | Note |
| unicode string | 123 | Unique reference for payment issued by the payment processor. |
| ascii string | 19783 | Echo request's |
| fixed choice | capture | The valid values are |
| fixed choice | completed | Valid values are |
| iso-8601 in UTC | 2014-03-24T12:15:41Z | Time of transaction completion. UTC Time: YYYY-MM-DDTHH:MM:SSZ |
| ascii string | Billing address could not be verified. | A custom error message displayed to the customer. |
| ascii string | ACCOUNT_RESTRICTED | 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.
Request values
Key | Type | Example | |
| ascii string | 10023456 | ShopBase payment account ID, for getting Gateway Credentials. |
| ascii string | 19783 | Checkout token or order id depends on |
| ascii string | 450789469 | Unique reference for payment issued by the payment processor. |
| true/false | true | Indicates whether or not this request should be processed in test mode (if supported). |
| fixed choice | capture | The valid values are |
| fixed choice | completed | Valid values are |
Response values
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.
Request values
Key | Type | Example | |
| json | The json object contains Payment Gateway credentials. |
Response values
Key | Type | Example | |
| fixed choice | valid | The valid values are valid, invalid, restricted. |
3.5 Get Gateway Credentials
It provides gateway's credentials for your provider.
Endpoint: https://api.shopbase.com/api/checkout/payment-credential.json
Request values
Key | Type | Example | |
| ascii string | 10023456 | ShopBase payment account ID, for getting Gateway Credentials. |
Response values
Key | Type | Example | |
| json | The json object contains Payment Gateway credentials. | |
| ascii string | Invalid signature | A custom readale error message. |
| ascii string | invalid_signature | An error code |
3.6 Asynchronous callback
It makes certain that all orders can be completed, even If your gateway and customer connection is disconnected. You can get the callback URL in
x_url_callback
param.In the Embedded checkout flow, If ShopBase's Post-Purchase feature is active, please note that will require a new transaction for second authorization.
Request values
Key | Type | Example | Note |
| string | 10023456 | ShopBase payment account ID, for getting Gateway Credentials. |
| decimal | 89.99 | Echo request's |
| USD | Echo request's | |
| ascii string | 123 | Unique reference for payment issued by the payment processor. |
| ascii string | 19783 | Echo request's |
| fixed choice | authorization | The valid values are |
| fixed choice | completed | Valid values are |
| true/false | true | Echo request's |
| iso-8601 in UTC | 2014-03-24T12:15:41Z | Time of transaction completion. UTC Time: YYYY-MM-DDTHH:MM:SSZ |
| ascii string | Billing address could not be verified. | A custom error message displayed to the customer. |
| ascii string | ACCOUNT_RESTRICTED | An error code to be log on ShopBase |
Response
If request success, Shopbase will return HTTP status 200. Otherwise, you should retry later with a delay time.
3.7 Signing mechanism
All requests and responses must be signed/verified using HMAC-SHA256, where:
key
is ShopBase Payment Key. If Provider uses more than 1 ShopBase Payment Key, ShopBase always uses the older one (compared by activated date).message
is a string of all key-value pairs that start withx_
prefix, sorted alphabetically and concatenated without separators.
Note:
The result codes must be hex-encoded and passed as the value of
x_signature
. Make sure to use case-insensitive comparison when verifying the providedx_signature
values.
Assuming your HMAC key is iU44RWxeik
, the signing mechanisms would look like this:
Signature will be sent in HTTP header X-Signature
of request.
3.8 Error codes
Error codes | Description | |
1 | card_declined | Card declined by any reasons (anti-fraud, declined by bank..) |
2 | processing_error | An error occurred while processing the card. Try again later or with a different payment method. |
3 | call_issuer | The card has been declined for an unknown reason. The customer needs to contact their card issuer for more information. |
4 | pick_up_card | 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 |
5 | invalid_signature | |
6 | account_restricted | |
7 | account_invalid | |
8 | payment_not_supported | Does not support this payment for some reason. |
9 | missing_param | 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 ignores duplicate requests.
Here are two git examples for reference
Full integrated gateway demo: https://github.com/ShopBaseCom/asiabill-sdk
4. Testing (for ShopBase simulator)
Transaction amount | Description | |
1 | 99.00~99.99 | processing_error when capture |
2 | 101.00~101.99 | processing_error when refund |
Credit card number | Description | |
1 | 4242 4242 4242 4242 | Payment success |
2 | Other | card_declined |
Account ID | Description | |
1 | invalid | Will be invalid when validate credentials |
2 | restricted | Will be restricted when validate credentials |
3 | restricted_payment | Will be restricted when authorize payment |
5. Technical requirements
Security
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 ShopBasex_amount
of transaction should matches with the amount of ShopBasex_result
should be completedx_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.
Stability
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.
Usability
Embedded iframe needs to share the same style with ShopBase and support responsive.
You need to ensure rendering speed, API process speed.
Last updated