Use Case: Self-Managed Recurring Payments

With self-managed recurring payments, you define the plans yourself. You have complete freedom, for example regarding the number of installments and when payments are made.

Since Flywire doesn't know your settings, you have to manually initiate each payment for those plans yourself.

You also have to send mandatory emails to your payers that inform them about the recurring payments.

Available payment methods:

  • Card

  • Direct debit

Walkthrough

In this scenario, your payer chose on your website which plan they want to use. Now you want to let your payer choose how they want to pay the recurring payments. At this point, you need to display a UI form for either card or direct debit payments.

The following steps are necessary to create recurring payments with the Flywire API:

To be able to use the Flywire API, you need to be registered, and all requests to the Flywire API need to be authenticated, see Flywire API Basics

If you are just getting started and only have Sandbox credentials, you need to use the Sandbox environment. All request examples let you switch between the production and sandbox base URL.

  1. Implement a trigger on your website that sends an http request to your backend.

    The trigger could be a button like "Make Payment". The http request tells your backend to send a secure request to the Flywire API to create a Checkout Session.

  2. Create a Checkout Session via the API.

    From your backend, you can securely create a Checkout Session. You need to know which recipient you want to use for this request.

    See Creating a Checkout Session for details.
  3. Receive the URL for displaying the form.

    The response after creating Checkout Session will return a URL to you (as the value of the url parameter in the hosted_form object). This is the URL you need in order to display the UI form in an iframe on your website.

    When you are pre-filling the form, the response can contain warnings (in the warnings array) in case the pre-filling of any fields didn't pass the validation, see Field validation warnings after pre-filling a UI form for more details.

    You can decide which information from the response you want to filter out in your backend before passing the URL to your frontend.

  4. Display the form on your website.

    The form is where Flywire gathers the payer and payment information.

  5. Receive the URL for confirming the Checkout Session.

    There are many ways for your backend to receive the confirm URL. One option is to directly send it from the event listener you implemented on your website to your backend.

  6. Confirm the Checkout Session via the API.

    After the payer filled out the form you need to confirm the session as a security measure.

  7. Receive the payment method token and the mandate ID via the API.

    After you confirmed the session, you’ll receive a payment method token and a mandate ID in the API response. You need both of them to create payments.

    Payment method tokens and mandate IDs are sensitive data. Make sure sensitive data is handled in your backend, while the frontend only displays the form.
  8. Create a payment and charge the payer via the API.

    Create a payment that includes the payment method token and mandate ID. Keep creating the following payments in the same way until the recurring payments are done.

Essentials: Payment Method Token and Mandate ID

About the Payment Method Token

The payment method token is a unique string of numbers and characters that gets assigned to a card or bank account when they are stored. It identifies the payment method (e.g., last four digits of a card or bank account) and includes payer details, such as the cardholder or account owner. Note: the payer may differ from the purchaser, like a parent paying a student’s tuition.

Important Information

  1. One payment method token can be used for multiple mandate IDs.

  2. The payment method token needs to be included in each payment.

    Since the token already contains information about the payer, sending the token means that you don’t need to include payer information manually in a payment anymore.

  3. The payer information in the payment method token can be different from the payer information stored in your system.

    The token stores the information gathered in the UI form. Even if you pre-filled the form with data from your system, the payer might have edited the fields in the form. This can be the case when data in your system is wrong (misspelled names etc.) or when the actual payer is different from what your system considers a “payer” (for example, your system contains information about your students as “payers” but the actual payer (card holder or bank account owner) is a parent).

Where can I find the payment method token for a payer? 

The payment method token is returned to you in the response after you confirmed a Checkout Session.

You can also find all payment method tokens for a payer (identified by their payor_id) with this request:

GET/payors/{payorId}/payment_methods

For details see Getting a List of all stored Payment Methods for a Payer.

About the Mandate ID

The mandate ID is a Flywire-generated ID that represents the payer's consent for recurring payments, much like a signature authorizing future payments.

After tokenizing a card or bank account, the mandate ID is returned to you in the mandate_id parameter or in the id parameter inside the mandate object.

It is mandatory to include the mandate ID when charging the payment.

For bank accounts, the mandate is represented by the mandate ID and additionally in PDF form.

Storing the mandate ID

Each mandate ID belongs to a specific plan (an installment plan, a subscription, etc.). You need to store the mandate together with the information about the plan and its payments in your system to ensure that you will be able to identify it.

 

The mandate PDF for bank accounts has other specific policies for storing:

Direct debit mandates for SEPA and BACS have to be stored for 3 years. Since the emails with the mandate are managed by Flywire (for SEPA and ACH) or Finastra (for BACS), Flywire or Finastra will store the mandate for you.

Using the mandate ID for recurring payments

The mandate ID needs to be included in each payment that belongs to the same plan (for example, installments of an installment plan or payments for an ongoing subscription). If the payer wants to pay for a different plan, you need to generate a new mandate.

How do I generate a new mandate ID? 

  1. New card or bank account

    If a payer wants to use a new card or bank account for a plan, you have to save (and therefore tokenize) the card or bank account, as this will also give you a mandate.

  2. Existing card

    If a payer wants to use an existing card that is already tokenized, you can generate a new mandate for the new plan with this card.

Where do I find existing mandate IDs?

You can find all mandate IDs for a payment method token with this request:

GET/payors/{payorId}/payment_methods/{token}

For details see Getting the Mandate IDs for a Payment Method Token.