Smart2Pay JS – SDK Instructions

Smart2Pay JS – SDK is available here: https://github.com/Smart2Pay/js-sdk.

The interaction flow is described next:

  1. Upon order initiation from the customer
  2. 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=
  3. 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": []
        }
      }
    }
  4. The temporary API Key must be passed to the site.
  5. 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))
    

  6. Our SDK sends these details to our server.
  7. The server responds with a token to our SDK.
  8. Our SDK makes the credit card token available inside the tokenizeCard_fetch promise’s response.
  9. The order can now be submitted from the site to your server together with the token.
  10. 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.
  11. Our server responds to your server with the Authorization result. Upon a successful result you can release the goods or services.
  12. You pass the payment result to your site.

SDK is now fully functional in your app!