Dyneti Checkout
Dyneti Checkout is the only hosted payment page that keeps your application out of PCI scope while delivering a built-in credit card scanner that increases conversion by up to 26%. Dyneti Checkout is compatible with any payment processor.
Prerequisites
- Request both a Shareable API Key and a Payment Token API Key from Dyneti.
- Provide Dyneti with the Worldpay user/password pair you would like to use to tokenize the card number.
- Provide the domains on which the integration will be hosted to Dyneti.
- Add the DyScan Forms client script to your page
<script src="https://dyscanweb.dyneti.com/static/front_end/dist/form-client.js"></script>
1. Create the form
const form = DyScan.Form({
key: shareableApiKey,
config: config
});
We recommend including {uiVersion: 2, showExplanation: false, showResult: false}
in the config
object. For more information about the options available for the config
object, see here. Additional optional properties that can be supplied are
callback
type (formId: string, responseCode?: string) => any
optional: yes
You can supply a callback function that will be called when getId()
is called. The received response code indicates the validation of the form.
Response Code | Meaning |
---|---|
"870" | Form validated successfully. |
"871" | Credit card number invalid by Luhn algorithm. |
"872" | Credit card number too short. |
"873" | Credit card number too long. |
"874" | Credit card number not numeric. |
"881" | CVV not numeric. |
"882" | CVV too short. |
"883" | CVV too long. |
"886" | Expiration date invalid. |
customerId
type string
optional: yes
maximum length: 50
A customer ID that will be passed to the Worldpay tokenization request in the customerId
attribute of the <registerTokenRequest>
tag. Note that Worldpay supports a maximum length of 50 characters.
id
type string
optional: yes
maximum length: 25
An ID that will be passed to the Worldpay tokenization request in the id
attribute of the <registerTokenRequest>
tag. If not supplied a random identifier will be generated. Note that Worldpay supports a maximum length of 25 characters.
reportGroup
type string
optional: yes
This will be passed along to the Worldpay tokenization request in the id
attribute of the <registerTokenRequest>
tag. If not supplied, a default will be used.
2. Attach the form to your checkout form
JS/XHR form submission
If you are using Javascript/XHR to submit your checkout values to the backend you can read the form id from the form
object via the getId()
method:
<html lang="en">
<head></head>
<body>
<h2>Checkout flow</h2>
<div id="attach-dyneti-form-here"></div>
<input id="email" type="email"/>
<input id="submit-form" type="submit"/>
</body>
</html>
Now create a client and attach it to the HTML element using the attach
method.
const form = DyScan.Form({
key: shareableApiKey,
config: config
});
const attachmentEl = document.getElementById("attach-dyneti-form-here");
form.attach(attachmentEl);
To submit the information in the form and obtain a form id, use the getId
method. For example,
const submitButton = document.getElementById('submit-form')
submitButton.onclick((ev)=> {
const data = {
email: document.getElementById('email').value,
dynetiFormId: form.getId()
}
fetch('/checkout', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
})
})
The form id will be returned from getId()
even if the input to the form is invalid. To check for validated results, attach a callback to the form client as described here and check the status code. A code of "870"
indicates a validated submission.
3. Exchange the Dyneti Form ID for a Worldpay Token
Make a request to Dyneti's server from your backend server to exchange the Dyneti Form ID for a Worldpay token.
import requests
PAYMENT_TOKEN_API_KEY = 'example-key-abcd-1234'
def exchange_token(dyneti_token):
response = requests.get(f'https://dyscanweb.dyneti.com/api/v1/worldpay/form/{dyneti_token}', headers={
'X-API-KEY': PAYMENT_TOKEN_API_KEY
})
worldpay_token = response.json().get('token')
return worldpay_token
- Python
- Node
- curl
import requests
form_id = '3d581785-2be8-44da-b6bf-7757e7553537'
endpoint = 'https://dyscanweb.dyneti.com/api/v1/worldpay/form/%s' % form_id
payment_token_api_key = 'example_0123456789u0ALMrmV2RXa7YZMdZjAOoTxjM3EbVnRz6SQ5TFzY1'
r=requests.get(
endpoint,
headers={
"X-API-KEY": payment_token_api_key
}
)
r.json()
const axios = require('axios');
const formId = '3d581785-2be8-44da-b6bf-7757e7553537';
const endpoint = 'https://dyscanweb.dyneti.com/api/v1/worldpay/form/' + formId;
const paymentTokenApiKey = 'example_0123456789u0ALMrmV2RXa7YZMdZjAOoTxjM3EbVnRz6SQ5TFzY1';
axios.get(endpoint, {
headers: {
'X-API-KEY': paymentTokenApiKey
}
}).then(response => {
console.log(response.data);
}).catch(error => {
console.error(error);
});
Response
{
"token": "exampleTokenResponseValue"
}
curl -X GET \
-H "X-API-KEY: example_0123456789u0ALMrmV2RXa7YZMdZjAOoTxjM3EbVnRz6SQ5TFzY1" \
"https://dyscanweb.dyneti.com/api/v1/worldpay/form/3d581785-2be8-44da-b6bf-7757e7553537"
No OpenAPI specification URL provided