Create Payments

To successfully integrate card payments please follow the steps below:

  • Create a payment token.
  • Use the DMBPay Card JS SDK to display the form to the user on your website.
  • Redirect the user to Success or Failed page based on callbacks from the SDK.

Creating A Payment Token

  1. Create a payment request using the Create Payment Request existing format.
  2. Ensure you are providing a redirect_url parameter and a failed_url. Users will be redirected to these URLs based on the outcome of the transaction.
  3. Ensure you have provided a frame_domain value, this should be the domain of your website where you load the frame from (example: https://pay.dmbpay.com).

Example Request

{
"application_key": "{APPLICATION_KEY}",
"amount": "120",
"country_code": "GB",
"currency": "GBP",
"description" : "Product Description",
"options": "optional string",
"reference_id": 12312312,
"tokenize_payment": "1",
"customer_billing_email": "Joe Blogs",
"customer_billing_address": "123 Test Street",
"customer_billing_post_code": "AA1 1AA",
"frame_domain": "https://pay.dmbpay.com",
"redirect_url": "https://pay.dmbpay.com/payment-completed",
"failed_url": "https://pay.dmbpay.com/failed"
}

Response

{
    "token": "9931e428-27d2-400f-95ea-8c319517f7c0",
    "payment_request_id": 532,
    "meta": {
        "tracing_id": "9931e425-e2ea-42f4-a87a-0a2fed33fb1e"
    }
}

Displaying The Form

Add the following tags into your HTML page (please note that the CSS file is optional).

<link rel="stylesheet" href="https://secure.dmbpay.com/css/theme.css" />
<script src="https://secure.dmbpay.com/js/sdk.js"></script>

To specify placement of the payment form, add the following div.

<div id="card-wrapper" style="height: 400px; padding-bottom: 50px;"></div>

Insert the following script to the bottom of your page:

<script defer>
    new CardPortal()
        .setRequestToken('{REQUEST_TOKEN}')
        .setPublicKey('{CARD_CLIENT_KEY}')
        .isUnicre()
        .run();
</script>

JavaScript SDK Object

MethodParamsUsageRequired
setRequestTokenstringProvide the token given by the initial payment requesttrue
setPublicKeystringProvide the public APPLICATION_KEYtrue
isUnicrevoidSets SDK mode to Unicretrue
runvoidCreates the formtrue

Returned Postbacks