Initiating a Subscription

Method 1: Checkout Flow (Recommended)

The simplest way to initiate a subscription. Create a checkout session and redirect the customer.

From the Dashboard

  1. Go to Subscriptions > select an offer.
  2. Click Initiate Subscription.
  3. The customer is sent to the hosted checkout page.

Via the API

curl -X POST https://api.inflowpay.xyz/subscription/offer/{offerId}/initiate \
  -H "X-Inflow-Api-Key: your_private_key" \
  -H "Content-Type: application/json" \
  -d '{
    "customerEmail": "[email protected]",
    "successUrl": "https://yoursite.com/welcome",
    "cancelUrl": "https://yoursite.com/pricing",
    "metadatas": {
      "userId": "usr_123",
      "plan": "pro"
    }
  }'

Request Body

FieldTypeRequiredDescription
customerEmailstringNoPre-fill the customer's email
successUrlstringNoRedirect after successful payment
cancelUrlstringNoRedirect if customer cancels
metadatasobjectNoCustom key-value data
guestIdstringNoGuest identifier
paymentMethodRefstringNoPayment method reference (for waitlist-enabled offers)

Response

{
  "subscriptionId": "sub_abc123",
  "paymentId": "pay_abc123",
  "purchaseUrl": "https://checkout.inflowpay.com/..."
}

Redirect the customer to the purchaseUrl to complete the checkout.

Method 2: Server-to-Server

For direct card processing without redirecting the customer. Requires PCI-compliant infrastructure.

Important: Server-to-server integration requires sending card details to https://api-card.inflowpay.com, not the standard API URL.

curl -X POST https://api-card.inflowpay.com/subscription/offer/{offerId}/initiate-server \
  -H "X-Inflow-Api-Key: your_private_key" \
  -H "Content-Type: application/json" \
  -d '{
    "customerEmail": "[email protected]",
    "billingCountry": "FR",
    "purchasingAsBusiness": false,
    "firstName": "John",
    "lastName": "Doe",
    "card": {
      "number": "4242424242424242",
      "expMonth": 12,
      "expYear": 2027,
      "cvc": "123"
    },
    "autoConfirm": true,
    "metadatas": {
      "userId": "usr_123"
    }
  }'

Request Body

All fields from the checkout flow plus:

FieldTypeRequiredDescription
customerEmailstringYesCustomer email
billingCountrystringYesISO 3166-1 alpha-2 country code
purchasingAsBusinessbooleanYesBusiness purchase flag
businessNamestringIf businessBusiness name
taxIdstringIf businessBusiness tax ID
postalCodestringIf USBilling postal code
firstNamestringNoCustomer first name (recommended for 3DS)
lastNamestringNoCustomer last name (recommended for 3DS)
savePaymentMethodbooleanNoSave the card for future charges (default: false). For subscriptions, the card is typically saved automatically for renewals. Use this when you want to explicitly control saving.
useCustomerPaymentMethodbooleanNoUse the customer's last saved payment method (default: false). Use when the customer already has a card on file.
cardobjectNoCard details (number, expMonth, expYear, cvc)
autoConfirmbooleanNoProcess immediately if no 3DS required
pricingModestringNoTAX_EXCLUSIVE or TAX_INCLUSIVE
metadatasobjectNoCustom metadata

Response

{
  "payment": {
    "id": "pay_abc123",
    "status": "INITIATION",
    "amountInCents": 2999,
    "currency": "EUR"
  },
  "threeDsSessionUrl": null
}

If threeDsSessionUrl is not null, redirect the customer to complete 3D Secure authentication.

Saving and reusing payment methods for subscriptions

  • savePaymentMethod: true — Saves the card for future subscription charges. For most subscriptions, the card is saved automatically for renewals.
  • useCustomerPaymentMethod: true — Uses the customer's last saved card. Use when the customer already has a card on file (e.g. from a previous subscription or payment). The customer must be identified by the same customerEmail.

You cannot use both in the same request. If the customer has no saved card yet, useCustomerPaymentMethod: true will fail.

After Initiation

  • Waitlist enabled: The subscription enters pending_waitlist status. You must approve it from the Dashboard.
  • Trial period: The subscription becomes ACTIVE immediately, but the first charge happens after the trial ends.
  • Entry fee: The first payment uses the entry fee amount; subsequent payments use the regular amount.
  • Standard: The customer is charged immediately and the subscription becomes ACTIVE.