Skip to main content

Overview

Ealyx lets merchants offer their customers the option to trade in used items as payment for new purchases. The integration involves four main phases which are covered in section 3 (Shopper Journey Implementation):

  1. Discovery - Display trade-in teasers across your site
  2. Valuation - Customer values their device via Ealyx WebApp
  3. Payment - Process payment with or without Ealyx Pay
  4. Post-Purchase - Sync order status changes with Ealyx

Before You Start: Critical Integration Rules

Read This First

These three rules cause 90% of integration failures. Read them before writing any code.

1. All Monetary Values Are in Cents

All prices, taxes, and discounts must be integers in cents, not decimal values.

PriceCorrectWrong
€99.99999999.99
€1.501501.50
€0.50500.50

Using decimal values will cause cryptic API errors. Always multiply by 100.

2. Webhook Secret = USER_ID-MERCHANT_ID

The secret for validating webhook signatures is {USER_ID}-{MERCHANT_ID}.

CorrectWrong
user_12345-merchant_67890your_client_secret

3. Use Raw Body for Signature Validation

When validating webhook signatures:

CorrectWrong
Raw request body bytesParsed JSON object
request.body (before parsing)JSON.stringify(parsedData)

Different frameworks access raw body differently. Parsing and re-serializing changes the bytes and breaks validation.


Integration Architecture

Endpoints Overview

Understanding which endpoints you implement vs which you call is crucial:

Endpoints You Must Implement

These endpoints live on your server. The Ealyx SDK calls them:

EndpointMethodWhen CalledWhat It Returns
{MERCHANT_CALLBACKS_BASE}/shopper_dataGETSDK loads on any pageCustomer info + session hash
{MERCHANT_CALLBACKS_BASE}/purchase_dataGETCustomer reaches checkoutFull cart, billing, shipping
{MERCHANT_WEBHOOK_BASE}/orderPOSTEalyx Pay payment completesReturn HTTP 200 to confirm

Ealyx API Endpoints You Call

These endpoints live on Ealyx servers. Your backend calls them:

EndpointMethodWhen to CallWhat You Get
/oauth2/token/POSTInitial auth & token refreshAccess token, merchant_id, user_id
/core/merchants/GETDuring setup (optional)Merchant configuration
/core/sessions/{hash}/GETVerify session existsSession details
/register-purchasePOSTAfter payment (Other Methods only)Purchase confirmation
/payments/orders/updatePOSTOrder status changes (Ealyx Pay only)Update confirmation

Complete Flow Sequence

Ealyx Pay vs Other Payment Methods

There are two ways to offer trade-in benefits to your customers:

  1. Ealyx Pay Integration: Integrate Ealyx Pay as a new payment method on checkout. Shoppers benefit from an instant discount based on the trade-in valuation, or
  2. Other Payment Methods: Skip Ealyx Pay and let shoppers use your existing payment methods. They receive a payback (refund) once the trade-in process is completed.

Even if you integrate Ealyx Pay, shoppers can still choose to use other payment methods and benefit from the trade-in program.

FeatureEalyx PayOther Payment Methods
Payment ProcessingEalyx processes paymentYour payment gateway
Instant DiscountYesNo (refund after)
Webhook IntegrationYesNo
Order Status UpdatesYes (POST /payments/orders/update)No
Integration EffortMediumLow
Testing DifficultyMediumLow

System Requirements

RequirementDetails
Programming LanguageAny language with HTTP client support
HTTP Clientcurl, httpx, axios, requests, fetch, etc.
OAuth 2.0 SupportAbility to make authenticated HTTP requests
Token StorageDatabase or secure cache to store access tokens
HTTPSRequired for production (TLS 1.2 or higher)
Data EncodingSupport for JSON, URL-encoded form data, and Base64

Environment-Specific Configuration

All Ealyx integrations require configuration for a specific environment. Choose your environment and set the corresponding URLs:

Staging/Sandbox Environment

Use this environment for testing and development:

ServiceBase URL
APIhttps://api.stg.ealyx.tech
Assets/SDKhttps://cdn.stg.ealyx.tech
CredentialsUse sandbox test credentials from Ealyx

Production Environment

Use this environment for live transactions:

ServiceBase URL
APIhttps://api.ealyx.tech
Assets/SDKhttps://cdn.ealyx.tech
CredentialsUse your live production credentials

Configuration Setup

Define these base URLs in your environment or configuration file. Throughout this guide, examples use placeholders like {API_BASE_URL} which you replace with the appropriate value:

Option 1: Environment Variables (Recommended)

# staging/sandbox
export API_BASE_URL="https://api.stg.ealyx.tech"
export ASSETS_URL="https://cdn.stg.ealyx.tech"

# OR for production
export API_BASE_URL="https://api.ealyx.tech"
export ASSETS_URL="https://cdn.ealyx.tech"

Option 2: Configuration File

# ealyx-config.sh (source this file in your scripts)
API_BASE_URL="https://api.stg.ealyx.tech"
ASSETS_URL="https://cdn.stg.ealyx.tech"

# Source in your scripts:
source ealyx-config.sh

Option 3: Application Configuration

Store environment-specific URLs in your application's config (.env file, database, configuration management system, etc.):

EALYX_API_BASE_URL=https://api.stg.ealyx.tech
EALYX_ASSETS_URL=https://cdn.stg.ealyx.tech

Quick Switch: Staging → Production

When you're ready to move from staging to production, simply update your configuration:

  • Replace api.stg.ealyx.tech with api.ealyx.tech (remove .stg)
  • Replace cdn.stg.ealyx.tech with cdn.ealyx.tech (remove .stg)
  • Update your credentials to production credentials

That's it! No other code changes required.

Placeholder Reference

Throughout this guide, examples use placeholders in curly braces to represent values you need to fill in. This section explains what each placeholder means and how to use them.

Environment Configuration Placeholders

These are set once in your configuration and used in all examples:

PlaceholderTypeValueExample
{API_BASE_URL}EnvironmentEalyx API base URLhttps://api.stg.ealyx.tech (staging) or https://api.ealyx.tech (production)
{ASSETS_URL}EnvironmentEalyx Assets/CDN base URLhttps://cdn.stg.ealyx.tech (staging) or https://cdn.ealyx.tech (production)

Merchant Configuration Placeholders

These are specific to your merchant account and application:

PlaceholderTypeValuePurpose
{CLIENT_ID}CredentialFrom Ealyx (merchant account)OAuth Basic Auth
{CLIENT_SECRET}CredentialFrom Ealyx (merchant account)OAuth Basic Auth
{USERNAME}CredentialFrom Ealyx (merchant account)OAuth password grant
{PASSWORD}CredentialFrom Ealyx (merchant account)OAuth password grant
{MERCHANT_WEBHOOK_BASE}CustomYour webhook URLe.g., https://yoursite.com/ealyx/webhooks
{MERCHANT_CALLBACKS_BASE}CustomYour callbacks base URLe.g., https://yoursite.com/ealyx/callbacks
{MERCHANT_SUCCESS_URL}CustomYour order success pagee.g., https://yoursite.com/order-success

Dynamic Data Placeholders

These are obtained from API responses during integration:

PlaceholderTypeValueSource
{ACCESS_TOKEN}Auth TokenBearer token for API requestsPOST /oauth2/token/ response
{REFRESH_TOKEN}Auth TokenToken to refresh access tokenPOST /oauth2/token/ response
{USER_ID}Merchant IDYour user identifierPOST /oauth2/token/ response
{MERCHANT_ID}Merchant IDYour merchant identifierPOST /oauth2/token/ response
{SESSION_ID}Session DataYour internal session identifierGenerated by your e-commerce platform
{SESSION_HASH}Session DataHMAC-SHA256 hash of session ID + saltComputed before sending to Ealyx
{SALT}SecurityRandom salt value for session hashingGenerated with each session for security
{CUSTOMER_ID}Customer DataYour internal customer identifierFrom your e-commerce platform
{TRADE_IN_ID}Trade-in DataIdentifier of trade-in itemFrom Ealyx API responses
{ORDER_ID}Order DataYour order identifierGenerated by your system

How to Use Placeholders

When you see an example like this:

curl -X POST '{API_BASE_URL}/oauth2/token/' \
-H 'Authorization: Basic '$(echo -n "{CLIENT_ID}:{CLIENT_SECRET}" | base64) \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'username={USERNAME}' \
-d 'password={PASSWORD}'

Replace each placeholder with your actual value. If you set your configuration as environment variables (recommended), you can use them directly:

curl -X POST "$API_BASE_URL/oauth2/token/" \
-H "Authorization: Basic $(echo -n "$CLIENT_ID:$CLIENT_SECRET" | base64)" \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d "username=$USERNAME" \
-d "password=$PASSWORD"

Or replace them manually in your code:

curl -X POST 'https://api.stg.ealyx.tech/oauth2/token/' \
-H 'Authorization: Basic '$(echo -n "your_client_id:your_client_secret" | base64) \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'username=your_username' \
-d 'password=your_password'