Checkout for Pre-Authorization Payments

The imageCheckout integration enables you to create Pre-Authorization Payments, but not to capture the funds (see Next Step: Capturing the Funds).

Configuration Example for creating a Pre-Authorization Payment

Basic Settings

Payer Info and Custom Info

Optionally pre-fill fields and decide which input pages will be shown. See Pre-filling Fields of the Form for details.

Payment Settings

The payment amount to be held on the card:

paymentAuthorization object

After-Payment Settings

Specify the returnUrl or an onCompleteCallback handler. See After-Payment Settings for details.

Using callbacks is optional, but highly recommended.

Callbacks give you important updates about the status of the payment. See Payment Status Notifications for details.

var config = {
  env: "demo",
  recipientCode: "Your Flywire Portal Code",

  // Other checkout parameters (e.g. pass some payer info and set requestPayerInfo to true)
  firstName: "John",
  lastName: "Doe",
  requestPayerInfo: true,

  // The amount to be held
  amount: 210.00,

  // Mark this payment as a pre-authorization 
  paymentAuthorization: {
      type: "pre_auth"
  },
	
  // Specify the returnUrl or an onCompleteCallback handler
  returnUrl: "https://httpbin.org/get",
		
  // Callbacks are strongly recommended
  callbackId: "REF1234",
  callbackUrl: "https://api.yourdomain.com/flywire-notifications",
  callbackVersion: "2"
};

After Payment Completion

Information returned via returnUrl or onCompleteCallback handler

Once a the payer has successfully entered their details and the Checkout Experience form is closed, you receive information about the payment either via the returnUrl or the onCompleteCallback handler.

Example for response via returnUrl:

(Click to see the return URL in JSON formatting. For a detailed description of the parameters see the response via onCompleteCallback handler below.)

https://httpbin.org/get?reference=TVO817932102&status=success&amount=4000&payment_method=credit_card&sig=b1a30dbe88e65d1f5b055efa511a4c2094716ccd86c1a8b65c514b6e26fff8d7

Example for response via onCompleteCallback handler:

{
"args": {
	"amount": "4000",
	"payment_method": "credit_card",
	"reference": "TVO817932102",
	"sig": "b1a30dbe88e65d1f5b055efa511a4c2094716ccd86c1a8b65c514b6e26fff8d7",
	"status": "success"
},

Information returned via callback

After the payment is successfully created you'll receive two callbacks:

  1. Initiated (the usual callback for all new payments, see Payment Status Notifications for details)

  2. Authorized (a special callback just for Pre-Authorization Payments)

Callback for Status "Authorized"

data object

payment_method object

fields object

These are the fields of the recipient (also called "custom fields of a portal") . The fields are returned as pairs of the field id (for example booking_reference) and the value (for example ID123456). Which fields are returned depends on the individual configuration of the recipient.

payer object

The payer information is not automatically included. Returning payer information is disabled by default and needs to be enabled by Flywire.

Please reach out to your Flywire contact if you require payer information to be returned.

{
  "event_type": "authorized",
  "event_date": "2024-03-20T11:33:02Z",
  "event_resource": "charges",
  "data": {
    "payment_id": "PTU146221637",
    "amount_from": "4800",
    "currency_from": "EUR",
    "amount_to": "5000",
    "currency_to": "USD",
    "status": "authorized",
    "expiration_date": "2024-03-28T11:33:02Z",
    "external_reference": "a-reference",
    "country": "ES",
    "payment_method": {
      "type": "card"
    },
	"fields":{ 
		"booking_reference": "ID123456",
		"booking_description": "A description"
	}, 
	"payer": {
		"first_name": "Peter",
		"last_name": "Payer",
		"middle_name": null,		
		"address1": "789 Calle Mayor",
		"address2": null,
		"city": "Madrid",
		"country": "ES",
		"state": null,
		"zip": "28013",
		"phone": "0034912345678",
		"email": "[email protected]"
    },						
  }
}

Next Step: Capturing the Funds

Capturing the funds can be done via the imageFlywire API, see Capturing the Funds for a Pre-Authorization Payment.