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
- Create a payment request using the Create Payment Request existing format.
- Ensure you are providing a
redirect_urlparameter and afailed_url. Users will be redirected to these URLs based on the outcome of the transaction. - Ensure you have provided a
frame_domainvalue, 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
| Method | Params | Usage | Required |
|---|---|---|---|
| setRequestToken | string | Provide the token given by the initial payment request | true |
| setPublicKey | string | Provide the public APPLICATION_KEY | true |
| isUnicre | void | Sets SDK mode to Unicre | true |
| run | void | Creates the form | true |
Returned Postbacks
card_payment_startedcard_payment_user_cancelled- If the user chooses to cancel the transaction.card_payment_completedORcard_payment_failedORcard_payment_request_forbiddencard_payment_updatedcard_payment_verifiedcard_payment_awaiting_capture
