Skip to main content

Create a Redirect Session for a new Transaction Intent

The Merchant must create a redirect session before redirecting the customer to Zastrpay website for generating a QR Code. For that purpose the following Merchant Backend -> Zastrpay Backend API call must be implemented:

PUT https://host.com/customer-authentication-service/v1/redirect-sessions/{redirectSessionId}
Content-Type: application/json
x-api-key: $apiKey
x-request-id: $requestId

{
"type": "NewTransactionIntent",
"customerId": "37257cd4-8ff1-46f7-bb20-0da4f954fede",
"transactionData": {
"currency": "EUR",
"amount": 50,
"direction": "CustomerToMerchant",
"externalReference": "1232"
},
"redirectData": {
"successUrl": "http://merchant-host.com/zastrpay-create-new-transaction-intent-success",
"failureUrl": "http://merchant-host.com/zastrpay-create-new-transaction-intent-failure",
"abortUrl": "http://merchant-host.com/zastrpay-create-new-transaction-intent-abort",
"qrCodeSuccessUrl": "http://merchant-host.com/zastrpay-create-new-transaction-intent-qr-code-success"
},
"locale": "de-DE"
}
note

Note that the Merchant has the following options for customerId or customerData attributes:

  1. No customerId, no customerData - the Merchant does not track whether a customer is registered or not at Zastrpay, and is not offering the option of sharing customer data with Zastrpay for initial customer registration
  2. customerId, no customerData - the Merchant is tracking customer registration at Zastrpay, and knows that the current customer is already registered at Zastrpay. The customerId submitted is the Zastrpay UUID/GUID of the customer, received and stored by the merchant previously
  3. No customerId, customerData - the Merchant is tracking customer registration at Zastrpay, and knows that the current customer is not registered at Zastrpay. The customer has agreed that the Merchant shares her/his data with Zastrpay for faster registration, that is why customerData is filled out
note

Note that the merchant can supply either transactionData.direction or transactionData.type, but not both. direction specifies the general direction of fund transfer with the exact transaction type being decided after the customer redirect, whereas type pins the exact transaction type before the customer redirect. It is recommended to use direction by default, unless the merchant wants to explicitly fix the transaction type.

The supported values for transactionData.direction are:

  • CustomerToMerchant
  • MerchantToCustomer

If transactionData.direction is set to CustomerToMerchant, then after redirect if the customer has enough wallet balance the transaction type will be automatically set to CustomerToMerchantTransfer, otherwise to CustomerToMerchantPassthrough.

If transactionData.direction is set to MerchantToCustomer, then after redirect if the customer will have to make an explicit choice (in the UI) whether he wants to money to be added to her/his wallet balance (MerchantToCustomerTransfer), or paid out in cash (MerchantToCustomerPassthrough).

The supported values for transactionData.type are:

  • CustomerToMerchantTransfer (payment of an order directly from the customer's Zastrpay wallet)
  • CustomerToMerchantPassthrough (payment of an order by cash - QR Code is generated and the customer needs to go to a Zastrpay shop)
  • MerchantToCustomerTransfer (payout directly to the customer's Zastrpay wallet)
  • MerchantToCustomerPassthrough (payout to cash - QR Code is generated and the customer needs to go to a Zastrpay shop)
  • PassthroughDeposit (do not use, to be decommissioned, superseded by CustomerToMerchantPassthrough)
  • PassthroughWithdrawal (do not use, to be decommissioned, superseded by MerchantToCustomerPassthrough)

The user is redirected to the specified URLs in redirectData in the following cases:

  1. successUrl - a Transaction is successfully completed from the current Redirect Session
  2. failureUrl - the created Transaction Intent (or corresponding Transaction) is declined or expired, or a general technical error occurred
  3. abortUrl - the created TransactionIntent is cancelled, or the user is closing the session before a Transaction Intent was created
  4. qrCodeSuccessUrl - the user is closing the session, but a Transaction Intent (= QR Code) was generated but not yet finalized. The Transaction Intent can be resumed by creating an ExistingTransactionIntent Redirect Session.

Zastrpay Backend will answer with the following response:

201 OK

{
"id": "bf050093-fce3-4013-8090-524799de3f69",
"type": "NewTransactionIntent",
"merchantId": "e51bc4a8-4263-11ea-b317-b7ad13e2406e",
"customerId": "37257cd4-8ff1-46f7-bb20-0da4f954fede",
"transactionData": {
"type": "PassthroughDeposit",
"amount": 50,
"currency": "EUR",
"externalReference": "1232"
},
"redirectData": {
"successUrl": "https://merchant-host.com/zastrpay-create-new-transaction-intent-success",
"failureUrl": "https://merchant-host.com/zastrpay-create-new-transaction-intent-failure",
"abortUrl": "https://merchant-host.com/zastrpay-create-new-transaction-intent-abort",
"qrCodeSuccessUrl": "http://merchant-host.com/zastrpay-create-new-transaction-intent-qr-code-success"
},
"createdOn": "2023-01-26T13:04:59.5633378Z",
"lastCorrelationId": "55a5c33e-9003-4ea7-8e31-cfe5e9acc008",
"token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IjU2ODc4YmZlNzZiNDQyMTVhZmVkYzFkMzQzYTQ0NjU0In0.eyJzaWQiOiJiZjA1MDA5My1mY2UzLTQwMTMtODA5MC01MjQ3OTlkZTNmNjkiLCJtZXJjaElkIjoiZTUxYmM0YTgtNDI2My0xMWVhLWIzMTctYjdhZDEzZTI0MDZlIiwiYXV0aCI6Im90cCIsImN1c3RJZCI6IjM3MjU3Y2Q0LThmZjEtNDZmNy1iYjIwLTBkYTRmOTU0ZmVkZSIsImV4cCI6MTY3NDc0MDA5OSwiaXNzIjoiaHR0cHM6Ly9wYXkuZGV2LmMyZHBheW1lbnQuY29tIiwiYXVkIjoiaHR0cHM6Ly9wYXkuZGV2LmMyZHBheW1lbnQuY29tIn0.LKktJ4j2B-6UXrOrfmHQnqfeWSOvWQFPZJ_j1lJbacOAo-5IaIEMW0XB5kXyZc6qdOCJmIhuYM30SyiVu5TG7zii9zFuWRrdnIDu0tu_K-OJDU9rwn0Dtc-zreUq4VxzJs8utzZ6C7J3RVz3OVUIiDeMINKR0PFq-an4Ht81FSikZAnCreGbFpwsSn5HD9rBwLyDhlp7Dwl71yIn0fKIfAdtcUB6QEPycQi9-qGxYi0BDwy21rWJWI_kOsMi_kAnajtYD3ZB_8DInvAHZilWfV3pL_PuTAoA7OdKztkegt9wUCBQr_EPHU5rGxpBrUJLsYLBTvBqsJZEkp6gepyxtQ",
"redirectUrl": "https://pay.dev.zastrpay.com"
}

The important response values to consider for the redirect are token and redirectUrl.

See Create Redirect Session API Reference for more information.

Next, let's see how to perform the customer browser redirect.