Skip to main content

Overview

Generate secure checkout URLs to direct customers to a payment page for your offerings. The checkout functionality allows you to create customized payment flows with optional billing intervals and pre-filled customer information.

SDK available in

Javascript | Ruby | cURL | Python | PHP | Go | Java

Basic Checkout URL Generation

The simplest way to generate a checkout URL is by providing the offering key for customers who are already signed up in your system:
const client = window.metrifoxClient; // or your stored client instance

// Generate a checkout url
await client.checkout.url({
  offeringKey: "your_offering_key", // Key of the offering the customer will purchase
  billingInterval: "billing_interval", // Billing interval: e.g. "monthly", "yearly", or "quarterly". This is optional for offerings that do not have billing intervals
  customerKey: "customer_key", // Key of the customer making the purchase
});

Handling Customer Signup from Metrifox Checkout

If you’re using Metrifox’s pricing page but want to handle customer verification yourself, follow these steps:

Step 1: Configure Your Signup URL

Set your signup URL in the Checkout section of your dashboard settings.

Step 2: Extract Parameters and Handle Customer Signup

On your signup/login page (the URL configured above), extract the offering_key and billing_interval query parameters from the URL. These are included when a customer is redirected from the Metrifox checkout page.
const client = window.metrifoxClient; // or your stored client instance

const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const offeringKey = urlParams.get('offering_key');
const billingInterval = urlParams.get('billing_interval');
// Store the extracted params above if your customer would navigate from the initial url

const customerSignUp = async () => {
  try {
    const customerDetails = await mockCustomerSignUp() // Replace with your actual signup/login function

    if (customerDetails) {
      const customerKey = customerDetails.customer_key
      if (offeringKey) {
        const checkoutUrl = await client.checkout.url({
          customerKey,
          offeringKey,
          billingInterval
        })
        window.open(checkoutUrl, "_blank", "noopener,noreferrer") // Open the URL in a new tab or handle as needed
      }
    }
  } catch (error) {
    // handle error
  } finally {
    // cleanup
  }
};

Step 3: Sync Customer with Metrifox

After verifying the customer, retrieve the customer_key which is the unique identifier of the customer on your platform, and use it along with the extracted parameters to generate a checkout URL. Remember to sync your new customer with Metrifox using customer.create from the SDK.

Step 4: Complete the Purchase

Redirect the customer to the generated URL so they can complete their order.

Parameters

ParameterTypeRequiredDescription
offeringKeystringYesThe unique identifier for the offering to checkout
billingIntervalstringNoBilling frequency (e.g., “monthly”, “yearly”)
customerKeystringYesUnique identifier of the customer making the purchase
When using a customerKey, the checkout page will be pre-filled with the customer’s information, reducing friction and improving conversion rates.
Checkout URLs are secure and time-limited. Generate them when needed rather than storing them for extended periods.