Saferpay
See example of integrating Saferpay.
Last updated
Was this helpful?
See example of integrating Saferpay.
Last updated
Was this helpful?
Saferpay can be used if you want to have a solution that supports the post-checkout payments. It allows the users to pay after they submit the order, within the next 30 minutes.
It's not possible to use Saferpay for the payments done before the checkout is completed.
The diagram shows how Saferpay sequence looks like when it's integrated with Emporix:
To create the Spreedly receiver, execute the following request:
Result:
Save the token, it's needed for the payment mode configuration. Use this token as the {SPREEDLY_RECEIVER_ID} variable.
Create the new payment mode, execute the following request:
SPREEDLY_ENVIRONMENT_KEY - Spreedly environment key that you got from Emporix support team.
SPREEDLY_ACCESS_SECRET - Spreedly secret key that you got from Emporix support team.
SPREEDLY_RECEIVER_ID - The token from the receiver creation request.
SAFERPAY_BASIC_AUTH - The base64
of a user:password of Saferpay JSON API Basic Authentication.
You can create new credentials on the Saferpay page.
SAFERPAY_CUSTOMER_ID - The customer ID of your Saferpay account. You can find the information on the Saferpay page.
SAFERPAY_TERMINAL_ID - The terminal ID of your Saferpay account.
SAFERPAY_TEST_ENV : expected values: true or false. Indicates whether the configuration is related to the test account or not. Based on the flag the following url is used:
true - https://test.saferpay.com
false - https://saferpay.com
orderId
transactionId
paymentModeId
Saferpay is available only for the post-checkout approach, after the actual order is done.
Make sure that you have Spreedly scripts included in your index.html:
<script src="https://core.spreedly.com/iframe/express-3.min.js" id="express-script"></script>
<link id="spreedly-express-css-file" rel="stylesheet" type="text/css" href="https://core.spreedly.com/stylesheets/express-3.0.0.min.css">
In the html part, create two buttons needed for the Saferpay:
A button that opens Spreedly Express modal:
A button that triggers the payment process:
In the same html, add also the JS part:
Result: With this configuration, the user sees a button to provide their credit card data.
When a user completes the data, Spreedly sends a token via the onPaymentMethod
js callback.
Having this token, it's possible to display a button where the user can trigger the payment initialization, where ${initializePayment()}
is resolved to /payment-gateway/${getTenant()}/payment/frontend/initialize
. As a response you get an object that contains the externalPaymentRedirectURL
property.
You have to redirect the user to the URL. The user has to do the 3DS2 flow right on the Saferpay page.
After the operation, Saferpay redirects to the SAFERPAY_REDIRECT_URL
configured in payment-mode, with additional query parameters.
An example of the redirect page:
When the user is redirected to callback page, you should read query parameters related to the orderId
and paymentModeId
.
Having the two parameters, you can invoke the authorize method, where ${authorizePayment()}
is resolved to /payment-gateway/${getTenant()}/payment/frontend/authorize
.
Result:
If the 3DS2 finishes with success, then the authorization response is successful: true
.
If the 3DS2 doesn't finish with success, the authorization response is successful: false
.
SAFERPAY_REDIRECT_URL - The URL to which the user should be redirected after 3DS2 operation. Usually it’s the merchant's storefront. For example . The following query params are automatically attached to the :
You can find the examples in the repository.