LogoLogo
CommunitySupport PortalYouTubeStart a free trial
  • Welcome
  • Commerce Engine
  • Orchestration Engine
  • API Documentation
  • Release Notes
  • Changelog
  • Commerce Engine
  • Getting Started
    • General Concepts of Emporix
    • Creating your first tenant
    • Developer Portal
      • Manage Users
      • Manage API Keys
      • Tenant List
      • My Account
      • Manage Showcase and Sample Data
  • Customer Use Cases
    • Commerce Use Cases
      • Quote Process
      • Orders
      • Coupons and Redeeming Rewards
      • Returns
      • Payments
      • User Management and Approvals
      • Customer Social Login
      • Personalized Commerce - Customer Segments
      • Company Shared Orders and Customer Groups
    • Automated Use Cases
      • First Registration Coupon
      • Availability and Warehouse Assignment
      • Quote and Order Entry Automation
  • System Management
    • Introduction
    • Authentication and Authorization
      • Identity and Access Management (IAM)
      • Auth0
      • Emporix Single Sign-On (SSO)
    • Webhook Event Publishing
      • HTTP Webhook Strategy - HMAC Configuration
      • HTTP Webhook Strategy - Integration with Azure Service Bus
      • HTTP Webhook Strategy - Integration with Amazon Simple Queue Service (SQS)
    • Search
      • Universal Search Connector
      • Search Configuration
      • Indexing Service
    • Optimistic Locking
  • Extensibility and Integrations
    • Extensibility Cases
      • External Products, Pricing and Fees
      • Enabling Custom Extensions
    • Integrations
      • SAP Integration
    • Payment Systems
      • PayPal
      • Saferpay
      • Spreedly Gateway
      • Unzer
    • Third Party Add-Ons
      • Emporix Contentful App
      • Emporix Builder.io Plugin
      • Magnolia Emporix Connector
      • Zendesk Emporix Connect
    • Powered by AI
      • AI Smart Config
      • AI Smart Import
  • Core Commerce
    • Introduction
    • AI Assistance
    • Carts
    • Catalogs
    • Categories
    • Coupons
    • Customer Management
      • Approvals
      • Assisted Buying
      • Customer Groups
      • Customer Segments
    • Data Localization
    • Delivery Cycle Management
    • Mixin Schemas
    • Media Management
    • Orders
      • Shared Orders
    • Pricing
      • Pricing (Legacy)
    • Products
      • Availability, location, and stock levels
      • Brands
      • Labels
    • Quotes
    • Returns
    • Reward Points Management
    • Sites
    • Tax Classes
      • Tax classes (Legacy)
    • Measurement Units
  • Management Dashboard
    • Introduction
    • Customer Management
      • Companies
      • Customers
      • Groups
      • Segments
      • Coupons
    • Quotes
      • Quotes
      • Status Codes
    • Orders
      • Orders
      • SEPA
      • Returns
    • Catalogs
      • Catalogs
      • Categories
    • Products
      • Products
      • Product Templates
      • Labels
      • Suppliers
      • Brands
      • AI for a Product Description
    • Pricing
      • Price Models
      • Price Lists
    • Settings
      • Sites
      • Shipping Zones and Methods
      • Delivery Times
      • Units
      • Tax
      • Countries
      • Currencies
      • Languages
      • System Preferences
      • Custom Entities
      • Mixin Schemas
    • Administration
      • Users and Groups
      • Extensions
      • API Statistics
      • Webhooks
    • Extensions
    • Custom Instances
  • Additional Resources
    • Glossary
    • Videos
    • Emporix Community
Powered by GitBook
LogoLogo

Resources

  • Emporix.com
  • Developer Policy
  • Terms of Use

Find us

  • LinkedIn

© 2025 Emporix. All Rights Reserved.

On this page
  • Introduction
  • Gateway configuration
  • Storefront implementation

Was this helpful?

Export as PDF
  1. Extensibility and Integrations
  2. Payment Systems

Saferpay

See example of integrating Saferpay.

PreviousPayPalNextSpreedly Gateway

Last updated 1 month ago

Was this helpful?

Introduction

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:

Gateway configuration

  1. To create the Spreedly receiver, execute the following request:

curl --location --request POST 'https://core.spreedly.com/v1/receivers.json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic {SPREEDLY_BASIC_AUTH}' \
--data-raw '{
        "receiver": {
          "receiver_type": "saferpay",
          "hostnames": "https://test.saferpay.com",
          "credentials": [
          ]
        }
      }'

Result:

{
    "receiver": {
        "company_name": "SIX Payment Services",
        "receiver_type": "saferpay",
        "token": "CwFlWAMQaOfUqcsP8Gce2iyzNIU",
        "hostnames": "https://test.saferpay.com,https://www.saferpay.com",
        "sub_merchant_key": null,
        "state": "retained",
        "created_at": "2023-07-16T20:18:48Z",
        "updated_at": "2023-07-16T20:18:48Z",
        "credentials": [

        ],
        "ssl_certificate_token": null
    }
}

Save the token, it's needed for the payment mode configuration. Use this token as the {SPREEDLY_RECEIVER_ID} variable.

  1. Create the new payment mode, execute the following request:

curl --location --request POST 'https://api.emporix.io/payment-gateway/{TENANT}/paymentmodes/config' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {EMPORIX_AUTH_TOKEN}' \
--data-raw '{
    "code": "saferpay",
    "active": true,
    "provider": "SPREEDLY_SAFERPAY",
    "configuration": {
        "Spreedly/EnvironmentKey": "{SPREEDLY_ENV_KEY}",
        "Spreedly/AccessSecret": "{SPREEDLY_ACCESS_SECRET}",
        "Spreedly/ReceiverId" : "{SPREEDLY_RECEIVER_ID}",
        "Saferpay/BasicAuth" : "{SAFERPAY_BASIC_AUTH}",
        "Saferpay/CustomerId" : "{SAFERPAY_CUSTOMER_ID}",
        "Saferpay/TerminalId" : "{SAFERPAY_TERMINAL_ID}",
        "Saferpay/TestEnvironment" : "{SAFERPAY_TEST_ENV}",
        "Saferpay/RedirectUrl" : "{SAFERPAY_REDIRECT_URL}"
    }
}'
  • 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

Storefront implementation

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">

  1. In the html part, create two buttons needed for the Saferpay:

  • A button that opens Spreedly Express modal:

<button className='large-primary-btn' onClick={openModal}>Enter Payment Info</button>
  • A button that triggers the payment process:

<FilledButton
  onClick={executePayment}
  className="mt-4 w-auto bg-yellow text-eerieBlack">
      PAY via Saferpay
</FilledButton>
  1. In the same html, add also the JS part:

const [spreedlyToken, setSpreedlyToken ] = useState(null)

useEffect(() => {
      window['SpreedlyExpress'].init(paymentMode.environmentKey, {
        "amount": props.grossValue + ' ' + props.currency,
        "company_name": "PowerZone",
        "sidebar_bottom_description": "Total Price",
      }, {
        "customerId": props.customerId
      });

      window['SpreedlyExpress'].onPaymentMethod(function(token, paymentMethod) {
        setSpreedlyToken(token)
        window['SpreedlyExpress'].unload()
      });
    }
  }, [])

  const openModal = (e) => {
    window['SpreedlyExpress'].openView()
  }

  const executePayment = async () => {
    const accessToken = localStorage.getItem(ACCESS_TOKEN)
    const headers = {
      Authorization: `Bearer ${accessToken}`
    }
    const body = {
      order : {
        id : props.orderId
      },
      paymentModeId: paymentMode.id,
      creditCardToken: spreedlyToken
    }
    const res = await api.post(`${initializePayment()}`, body, { headers })
    window.location.replace(res.data.externalPaymentRedirectURL)
  }

Result: With this configuration, the user sees a button to provide their credit card data.

  1. When a user completes the data, Spreedly sends a token via the onPaymentMethod js callback.

  2. 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.

  3. You have to redirect the user to the URL. The user has to do the 3DS2 flow right on the Saferpay page.

  4. After the operation, Saferpay redirects to the SAFERPAY_REDIRECT_URL configured in payment-mode, with additional query parameters.

An example of the redirect page:

{!authorizationFinished ? 
    (
      <>We're authorizing the request...</>
    ) : 
    (
      <>
        {authorizationSuccess ? (
          <>
            Authorization finished with success <br/>
            <button className="bg-primaryBlue text-[white] px-6 py-0 h-[50px] text-[14px] leading-[14px] md:w-[400px] w-full" 
              onClick={() => {
                navigate(`/${tenant}/my-account/my-orders`)
              }}>
              CHECK YOUR ORDERS
            </button>
           
           </>
          ) : (<>Authorization failed</>)} 
        </>
    ) 
} 
const authorize = async (orderId, paymentModeId) => {
    const accessToken = localStorage.getItem(ACCESS_TOKEN)
    const headers = {
      Authorization: `Bearer ${accessToken}`
    }
    const body = {
      order : {
        id : orderId
      },
      paymentModeId: paymentModeId
    }
    try {
      const res = await api.post(`${authorizePayment()}`, body, { headers })
      setAuthorizationFinished(true)
      setAuthorizationSuccess(res.data.successful)
    } catch(ex) {
      setAuthorizationFinished(true)
      setAuthorizationSuccess(false)
    }
  }

  useEffect(() => {
      const orderId = searchParams.get('orderId')
      const paymentModeId = searchParams.get('paymentModeId')
      authorize(orderId, paymentModeId)
  },[])
  1. When the user is redirected to callback page, you should read query parameters related to the orderId and paymentModeId.

  2. 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.

Emporix Demo Storefront
redirect URL
Emporix B2B Showcase