Nuvei JS – SDK is available here: https://github.com/Smart2Pay/js-sdk.
The interaction flow is described next:
- Upon order initiation from the customer
- Your server asks our server for a temporary API Key at entry point api/authorization/apikey:
Request:
POST https://securetest.smart2pay.com/v1/authorization/apikey Authorization: Basic MzAyMDE6aEo1Um9iWXg5cjdGZk53Q3ZIWTlMWEhxcXIrRkV6cmM3YUp2UVFrNEdhejFtZzdSeXk=
- Our server responds with a temporary API Key:
Response:
HTTP/1.1 201 Created Content-Type: application/json; charset=utf-8 { "ApiKey": { "Value": "MzAwMDc6M2FkODVhYzctNjhlNS00MTA2LTliNjctNTg3MmM1ZmI2ZDNiLTYzMzA=", "Created": "20181206141407", "LifeTime": 30, "AccessCounterLimit": 10, "Status": { "ID": 2, "Info": "Success", "Reasons": [] } } }
- The temporary API Key must be passed to the site.
- Collect from your site the credit card details from which you build a cardDetails object and pass it to our SDK together with the temporary API key obtained in the previous step. Any error will be available inside the promise’s catch method.
tokenizeCard_fetch({ apiKey: '<apikey string>', environment: '<environment string>', cardDetails: '<cardDetails object>', }) .then(CreditCardToken => console.log(CreditCardToken)) .catch(err => console.error(err))
- Our SDK sends these details to our server.
- The server responds with a token to our SDK.
- Our SDK makes the credit card token available inside the tokenizeCard_fetch promise’s response.
- The order can now be submitted from the site to your server together with the token.
- A credit card transaction using the token is now initiated from your server. For more details go to: Recurring Card Payments section. You can store the token on your server for subsequent purchases.
- Our server responds to your server with the Authorization result. Upon a successful result you can release the goods or services.
- You pass the payment result to your site.
SDK is now fully functional in your app!