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

  1. 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.

  2. 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.

  3. Your provider redirects to x_url_complete with GET method and all required parameters. ShopBase will validate the data and create the Order.

  4. ShopBase will redirect to the Thank-you page to inform the buyer that the payment is complete.

  5. 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.

  6. ShopBase records the payment and responses with a 200 HTTP status to the provider.

2.2.2 Embeded Checkout

  1. 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.

  2. Your iframe should display the card element (or whatever element), so the buyer can interact with it.

  3. When the buyer provides card details and clicks Place Order, ShopBase will post a message into the iframe with request values.

  4. Your iframe should request your provider server to confirm payment and obtain gateway authorization reference

  5. Your iframe post message to ShopBase with required response values.

  6. ShopBase will request to ShopBase server to verify payment status with your provider server, then create an Order.

  7. ShopBase server displays the order information to the client with the Thank you page to indicate that the order has been paid successfully.

  8. 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 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.

Request values

Response values

Custom iframe message

The following messages can be posted from the iframe to the ShopBase window to modify the iframe container.

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

Response values

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

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

Response values

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

Response values

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

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 with x_ 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 provided x_signature values.

Assuming your HMAC key is iU44RWxeik, the signing mechanisms would look like this:

key = 'iU44RWxeik'
fields = {x_account_id: '10023456', x_amount: 89.99, x_currency: 'USD', x_gateway_reference: '123', x_reference: "19783", x_result: "completed", x_test: "true",  x_timestamp: '2014-03-24T12:15:41Z'}
=> {:x_account_id=>"10023456", :x_amount=>89.99, :x_currency=>"USD", :x_gateway_reference=>"123", :x_reference=>"19783", :x_result=>"completed", :x_test=>"true", :x_timestamp=>"2014-03-24T12:15:41Z"}
message = fields.sort.join
=> "x_account_id10023456x_amount89.99x_currencyUSDx_gateway_reference123x_reference19783x_resultcompletedx_testtruex_timestamp2014-03-24T12:15:41Z"
OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), key, message)
=> "49d3166063b4d881b50af0b4648c1244bfa9890a53ed6bce6d2386404b610777"

"x_signature=49d3166063b4d881b50af0b4648c1244bfa9890a53ed6bce6d2386404b610777"

Signature will be sent in HTTP header X-Signature of request.

3.8 Error codes

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

4. Testing (for ShopBase simulator)

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 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.

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