Retrieve a Worldpay Token
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 Web client script to your page
<script src="https://dyscanweb.dyneti.com/static/front_end/dist/client.js"></script>
- Provide the domains on which the integration will be hosted to Dyneti.
Front-end Integration
1. Check if the user's device is able to scan
Check if scanning is available on the user's device. See Checking Scan Availability for details
2. Scan Configuration
Create a configuration object to customize the scanning UI.
See Scan Configuration for a complete explanation of the available options.
const config = {
logoUrl: "https://example.com/your-logo-url.png",
promptIfFewDigits: true,
};
3. Specify a blank verify dictionary
This dictionary is used for our Protect integration but in this use case it should be blank.
const verify = {}
4. Create a Scan Object
Provide your apiKey
and the config
object you to make a new scan object.
const scan = new DyScan.Scan({
key: apiKey,
config: config
});
5. Present the Scan Modal to the user
Call scan.present
to show the UI to the user and begin the scan and await
the result.
The userId
is echoed back to you in the result. See User ID for more details
const result = await scan.present(
userId,
verify,
);
6. Pass the scanId
to your backend
The awaited result
from step 5 will contain two attributes, data
and completed
.
data
is a Scan Status object. Please see the Scan Status document for an explanation of the returned fields.
completed
is a boolean
and indicates whether the user finished the scan flow. If they canceled the flow or it was unable to start completed
will be false
You can now pass the scanId
field from the data
object to your backend to be exchanged for a Worldpay Token
Retrieve the Worldpay token
From you backend server, make a GET
request to https://dyscanweb.dyneti.com/api/v1/worldpay/<scan_id_here>
Replace <scan_id_here>
with the scan id of the scan you want to get the token for.
Authenticate the request by setting the X-API-KEY
header to the Payment Token API Key provided by Dyneti in the prerequisites
The response will be a json object:
{
"token": "token_value_will_be_here"
}
- Python
- Node
- curl
import requests
scan_id = '3d581785-2be8-44da-b6bf-7757e7553537'
endpoint = 'https://dyscanweb.dyneti.com/api/v1/worldpay/%s' % scan_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 scanId = '3d581785-2be8-44da-b6bf-7757e7553537';
const endpoint = 'https://dyscanweb.dyneti.com/api/v1/worldpay/' + scanId;
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/3d581785-2be8-44da-b6bf-7757e7553537"
No OpenAPI specification URL provided