📃
Developer Docs
  • Overview
  • Integration Options
  • Webhooks
    • Build a webhook endpoint
    • Check signature
  • Getting Started
    • 1. Creating User Accounts
    • 2. User Account Types & Permissions
    • 3. Generate Access Tokens
    • 4. Choose Integration Options
    • 5. Securing Embedded UIs
      • 5a. Securing Embedded UIs Using HMAC (deprecated)
    • 6. Loading the frontend library
      • 6a. Preloading PayEngine Web-Component in SPA
    • 7. Custom styling the Web-Components
    • 8. Handling Callbacks from Web-Components
    • 9. Available Web-Components
    • 10. Available Webhooks
  • Merchant Onboarding
    • Overview
    • Integration Options
    • Onboarding/Payments Application Workflow
    • Embedded Onboarding UI
    • Merchant onboarding APIs
    • Partner's Onboarding UI
    • Merchant Lifecycle
    • Onboarding to Partner Relationships
  • Processing Payments
    • Introduction
      • Transaction Flow and Status
    • SecureFields JS
      • SecureFields Bank Account
      • Using tokens
    • Credit Card Form
    • Connect with Plaid
    • Connect Mailgun
    • 3D Secure
    • Payments API
    • Searching Transactions
    • Registering a cloud connected device
    • Apple Pay
      • Apple Pay in your native app
    • Google Payâ„¢
    • Level 2 and Level 3 Data
    • Fraud Prevention
    • Reporting
    • PCI Compliance
    • Address Verification Service (AVS) Check
    • Hosted Payments
    • Tap to Pay
  • Card Account Updater
  • ORCHESTRATION SYSTEM
    • Orchestration Overview
    • Onboarding Orchestration
    • Transactions Orchestration
    • Omnicommerce Orchestration
    • Merchant Servicing
    • Universal Reporting
  • TOKENIZATION
    • Automatic Network Tokenization
    • Token Migration Process
  • DISPUTE MANAGEMENT
    • Retrieval Requests & Chargebacks
  • Certification
    • Partner Certification
  • Data Sharing
    • Secure Data Sharing with PayEngine
  • eCommerce Integration
    • PayEngine Payment Gateway for WooCommerce
Powered by GitBook
On this page
  • Overview
  • Embedding
  • Authenticating Secure Setup
  1. Getting Started
  2. 5. Securing Embedded UIs

5a. Securing Embedded UIs Using HMAC (deprecated)

Previous5. Securing Embedded UIsNext6. Loading the frontend library

Last updated 13 days ago

HMAC-based security has been deprecated and will be removed in a future release. To secure your web components, please refer to the .

Overview

The Embedded UIs / Web-Components allow you to ease integration of our widgets to be used by your customers. Because it's provided for you via our web-components and tied directly to our server, you never have to worry about the heavy lift of UI development while maintaining full control over its theming and other customizations.

Our Embedded UIs / Web-Components have a simple HTML/Javascript embed so it can be embedded onto any part of your web applications that requires user interaction with payment-related parts of your system. It authorizes users with a security hash generated with the logged-in user's email. This method of authorization allows web-components to work with any authentication provider.

This platform uses two methods for securing web-components. Depending on the web-component and the type of data used, the implementation will vary between one or the other.

HMAC-based client side

HMAC is a computed "signature" sent along with some data. The HMAC is used to verify (authenticate) that the data has not been altered or replaced. The process involves an exchange of a secret key, which is then used to hash a message. The secret key should never be shared or made publicly available. This method ensures that the request information in fact was originated from your servers.

Webhooks-based data pinning

In addition to the HMAC method described above, some of our web-components also require data-pinning. For some of the components you will be expected to provide a self-generated reference ID which our webhooks system will then use on the back-end to retrieve additional information. An example of this is our payment form web-component, where it's essential that the users don't temper with the pre-set amounts they need to be charged. This will allow you to pass a reference ID to our payments for web component and expect a web-hooks API to exist within your system that will provide the actual amount that should be enforced on a transaction.

Embedding

Embedding the Embedded UIs / Web-Components is a two-step process.

  1. For the client side installation, just copy and paste the provided HTML snippet from your developer portal.

  2. The next step is to secure the setup.

Authenticating Secure Setup

The customer portal must be behind some kind of user authentication in order to safely show customers their payment information. This platform authenticates users with an HMAC hash generated for the logged-in user. This allows us to work with any authentication system.

Your code for generating an HMAC for your app must be placed in the back-end of your application. Grab the snippet from the developer dashboard to add to your server. You may generate the HMAC with the Merchant ID.

The HMAC generated will be passed to the client-side snippet to a property called 'hash'.

const crypto = require("crypto");
const merchant_id_hash = crypto.createHmac(
    "sha256",
    "YOUR_SECRET_KEY" // SECRET KEY (KEEP SAFE!)
).update(<merchant_id>).digest("hex") // PASS THIS TO FRONT-END
merchant_id_hash = OpenSSL::HMAC.hexdigest(
    'sha256', # HASH FUNCTION
    <YOUR_SECRET_KEY>, # SECRET KEY (KEEP SAFE!)
    <merchant_id>, # REPLACE WITH MERCHANT ID
) # PASS THIS TO FRONT-END
import hmac
import hashlib

merchant_id_hash = hmac.new(
    'YOUR_SECRET_KEY', # SECRET KEY (KEEP SAFE!)
    <merchant_id>, # REPLACE WITH MERCHANT ID
    digestmod=hashlib.sha256 # HASH FUNCTION
).hexdigest() # PASS THIS TO FRONT-END
$merchant_id_hash = hash_hmac(
    'sha256', // HASH FUNCTION
    <merchant_id>, // REPLACE WITH MERCHANT ID
    'YOUR_SECRET_KEY' // SECRET KEY (KEEP SAFE!)
); // PASS THIS TO FRONT-END

Generate an HMAC with SHA256 whenever a user logs into your app. Most web frameworks will have a method or library to help you do this. You'll need your app’s secret key and the Merchant ID.

Keep your secret key safe! Never commit it directly to a public repository, client-side code, or anywhere a third party can find it.

Embedded UIs using merchant session