Ledyer Developer Documentation

website·Indexed 33 days ago

https://developers.ledyer.com/docs

Developer resources for Ledyer's payment products, including Ledyer Checkout, tokenized payments for recurring purchases and subscriptions, and order management. Features documentation on session handling, order events, webhooks for order syncing, and API calls for creating, retrieving, and revoking customer tokens.

Tokens
9.7K
Snippets
53
Records
96
Agent score
55%

What's inside Ledyer

  1. Overview of Headless with Ledyer

    Headless with Ledyer provides a suite of building blocks that allow developers to create custom purchasing experiences and touchpoints. This approach enables customers to make purchases from virtually any interface, allowing for a secure purchasing experience that integrates seamlessly into a custom website to help increase conversion rates.
  2. Overview of Ledyer B2B Payment Integration Capabilities

    Ledyer provides a comprehensive API for building custom B2B payment integrations. The platform offers four primary integration paths:

    • Ledyer Access: Used to authenticate B2B customers.
    • Ledyer Payments: Integration of Ledyer as a B2B alternative payment method.
    • Ledyer Checkout: An inline checkout experience for B2B purchases.
    • Order Management: Tools to capture, refund, and manage the full lifecycle of orders.
  3. Overview of Ledyer Payments integration

    Ledyer Payments provides a checkout integration that allows developers to offer Ledyer as a payment option alongside other providers. After a purchase is initiated, Ledyer provides the customer's preferred next steps to complete the transaction. To maintain synchronization between the merchant and Ledyer, the system sends asynchronous notifications throughout the order's lifecycle to keep the merchant informed of key events.
  4. Overview of Ledyer Access onboarding and login

    Ledyer Access provides a seamless onboarding and login flow for websites, allowing users to verify their identity using well-known ID providers (such as BankId and FTN). The system automatically fetches user and company information to populate user accounts. Ledyer Access is built on standardized OAuth2 and OpenID Connect protocols.
  5. Implement Ledyer order notifications

    Ledyer uses notifications to inform a merchant's ERP or e-commerce platform about order events (e.g., order creation, status updates, or order line changes). Notifications do not contain sensitive data; they only provide the notification name and the order ID. Merchants must provide an open endpoint to receive these POST requests. Upon receiving a notification, the merchant should make an authorized request to the 'Get Order API' to retrieve the latest order details. If only the order status is required, the 'Payment Status API' is recommended instead.
  6. Understand Ledyer's notification workflow

    Ledyer uses notifications to alert a merchant's ERP or e-commerce platform about order events (e.g., creation, status updates). For security, notifications do not contain sensitive order data. The expected workflow is: 1. Ledyer posts a notification to the merchant's open endpoint. 2. The merchant receives the notification. 3. The merchant makes an authorized request to the Get Order API to retrieve the latest order details. If only the payment status is needed, the Payment Status API can be used instead.
  7. Implement a resilient order sync pattern using Ledyer webhooks

    To ensure data integrity and security, use Ledyer webhooks only as triggers to fetch the current state from the API, rather than relying on the data contained within the webhook payload. This prevents issues with spoofed data, out-of-order events, or outdated information.

    The recommended workflow is:

    1. Extract the orderId (or sessionId as a backup) from the webhook payload.
    2. Perform an idempotency check using the webhook event ID to avoid redundant processing.
    3. Call the Ledyer API (e.g., getPaymentStatus) to fetch the authoritative current state of the order.
    4. Update your internal system (ERP) based on the API response.
    5. Return a 200 status code to acknowledge receipt; any other status will trigger Ledyer's retry mechanism.
    app.post('/webhooks/ledyer', async (req, res) => {
    	try {
    		const { id, data } = req.body;
    		// Use sessionId as backup if orderId is not yet available
    		const orderId = data.orderId || data.sessionId;
    
    		// 1. Idempotency check
    		if (await isProcessed(id)) return res.sendStatus(200);
    
    		// 2. Fetch AUTHORITATIVE state from Ledyer API
    		const status = await ledyer.getPaymentStatus(orderId);
    
    		// 3. Update your system based on API data
    		await erp.syncOrder(orderId, status);
    
    		await markAsProcessed(id);
    		res.sendStatus(200);
    	} catch {
    		// Return 4xx/5xx to trigger Ledyer's retry mechanism
    		res.sendStatus(400);
    	}
    });
  8. Complete the Ledyer integration pre-deployment checklist

    To ensure a successful Ledyer integration, verify that the following business logic and synchronization requirements are implemented:

    1. Invoice Management: Prevent advance invoices from being marked as completed until payment has been received.
    2. Order Acknowledgement: Implement a mechanism to acknowledge orders originating from the Ledyer checkout.
    3. Data Synchronization: Ensure bidirectional sync between the Ledyer merchant portal and your ERP system. This must cover customer information updates and order status changes.
    4. Validation: Once the above are implemented, contact merchant@ledyer.com to validate the integration.
  9. Obtain an OAuth 2.0 access token for Ledyer API

    The Ledyer API uses the OAuth 2.0 client credentials protocol. To obtain an access token, send a POST request to the token URL with a base64 encoded clientId:clientSecret pair in a Basic authorization header and the form parameter grant_type=client_credentials.

    Tokens are valid for one hour (3600 seconds). All requests must be made over HTTPS. You must obtain your client credentials from Ledyer support.

    curl -X POST 
      -H 'authorization: Basic dGhpcy1pcy10aGUtY2xpZW50LWlkOnRoaXMtaXMtdGhlLXNlY3JldA==' 
      -H 'content-type: application/x-www-form-urlencoded' 
      -d grant_type=client_credentials 
      https://auth.sandbox.ledyer.com/oauth/token
  10. Complete the Ledyer payment integration checklist

    To ensure a successful Ledyer integration, verify the following requirements are met:

    1. Session Management: Save and reuse the session ID for the duration of the Ledyer interaction. Note that session IDs are valid for 7 days.
    2. Legal Compliance: Provide a Terms & Conditions link (and an optional Privacy URL) during the creation of the Ledyer session.
    3. Data Collection: Ensure all required customer and transaction data is collected before initiating the payment authorization process.
    4. UI Verification: Confirm that the Ledyer payment modal renders and displays correctly on your website.
    5. Final Validation: Contact merchant@ledyer.com to have your integration validated before going live.