Orders

This resource is only relevant for 529 Payments.

List of endpoints

Description Endpoint

Creating an Order

POST/orders

Editing an Order

PATCH/orders/{orderId}

Charging an Order (Creating a Payment)

POST/orders/{orderId}/charge

What is an Order?

You can think of an order as like a "shopping cart" for your payment. It contains all the information needed to create a payment in Flywire, but you can go back and edit it before actually creating a payment with it.

An order contains:

  • the payer information

  • the recipient information

  • the offer chosen for this payment

  • optional: A notifications URL

What is the difference between an order and a payment?

An order is not a payment. An order is the final step before creating a payment.

You can think of an order as like a "shopping cart" for your payment. It contains all the information needed to create a payment in Flywire, but you can go back and edit it before actually creating a payment with it.

An order doesn't have a payment reference yet. As soon as you confirm (charge) an order, it gets a payment reference and turns into a payment.

Creating an Order

Request

This endpoint creates an order.

Creating an order does not create a payment. To create a payment, you have to charge the order you created.

 

Parameters for the Request Body

payer object

recipient object

fields array

It depends on the recipient which fields are optional or required. If a field is required, you must provide it here. Optional fields can be left out.

items array

offer object

fields array

Some countries' regulations require extra fields in order to process a payment depending on the selected offer. If an offer contains any extra fields, they are required fields.

metadata object

You can specify up to 20 metadata pairs.

Maximum length for keys: 40 characters

Maximum length for values: 500 characters

POST/orders

curl https://base-url-placeholder/orders
  -X POST
  -H "Content-Type: application/json"
  -H "X-Authentication-Key: {api_key}"
  -d '{
 	"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]"
    }, 
	"recipient": {
		"id": "FWU",
   		"fields": [
            {
                "id": "custom_field_1",
                "value": "ID12345"
            },
			{
				"id": "custom_field_2",
				"value": "2020"
			}
        ]
	},
	"items": [
		{
			"amount": 80000,
			"id": "tuition"
		},
		{
			"amount": 40000,
			"id": "housing"
		}
	],
	"offer": {
		"id": "MTAwMDAgcHRfYmFua190cmFuc2Zlcl9jYWQgRVM=",
		"fields": [
			{
				"id": "pan_number",
				"value": "12345678"
			}
		]
	},
	"notifications_url": "http://consumer-url.com/notifications",
	"external_reference": "xyz123456",
	"metadata": {
		"external_payment_id": "PAYd910447bbf9fed52e3131e"
		}
}'

Response

payer object

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

Please contact the Solutions team if you require payer information to be returned.

recipient object

fields array

items array

offer object

fields array

Some countries' regulations require extra fields in order to process a payment depending on the selected offer. If an offer contains any extra fields, they are required fields.

metadata object

There are different kinds of metadata for a payment:

Metadata added by Flywire

Not present for 529 Payments.

Metadata added by you

Only for 520 Payments and self-managed recurring payments. Not present for One Off Payments and Flywire-managed recurring payments.

Custom metadata is additional data entered by you when you create the payment, for example data you need to identify the payment in your system. Metadata can be useful when you want to add data that is not already covered by recipient fields, for example if you are not the one who set up the recipient and have no influence on the fields.

Metadata consist of pairs of keys and values, for example key Payer_ID_From_My_System and value ID12345.

{
	"id": "52c6a5df-b6c6-40bc-a71a-fefb82ad96b3",
	"created_at": "2020-10-20 17:41:27 UTC",
	"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]"
    }, 
	"recipient": {
		"id": "FWU",
   		"fields": [
            {
                "id": "custom_field_1",
                "value": "ID12345"
            },
			{
				"id": "custom_field_2",
				"value": "2020"
			}
        ]
	},
	"items": [
		{
			"amount": 80000,
			"id": "tuition"
		},
		{
			"amount": 40000,
			"id": "housing"
		}
	],
	"offer": {
		"id": "MTAwMDAgcHRfYmFua190cmFuc2Zlcl9jYWQgRVM=",
		"fields": [
			{
				"id": "pan_number",
				"value": "12345678"
			}
		]
	},
	"notifications_url": "http://consumer-url.com/notifications",
	"external_reference": "xyz123456",
	"metadata": {
		"external_payment_id": "PAYd910447bbf9fed52e3131e"
		}
}

Creating the order failed - invalid offer ID or invalid country

422 Error

When does this happen?

This error can have two different causes:

  1. The offer ID you used for creating the order is invalid. Ensure that the offer ID you are using is correct.

  2. You tried to create an order with a payer country that is different from the country you used when you were getting the offer for this order. You need to use the same country in both requests.

{
  "type": "https://developers.flywire.com",
  "status": 422,
  "title": "Bad Request",
  "detail":"Invalid parameters",
  "errors": [
    {
      "source": "/offer/id",
      "param": "id",
      "type": "invalid_param",
      "message": "is invalid"
    }

Creating the order failed - parameter item with invalid amount

422 Error

When does this happen?

You'll get this error when you try to create an order with a payment amount that is below or above the limits set in the settings object of a recipient (see Recipients - Settings ).

{
"type": "https://developers.flywire.com",
"title": "Bad Request",
"status": 422,
"detail": "Invalid parameters",
"errors": [
	{
	"source": "/recipient/items",
	"param": "items",
	"type": "invalid_param",
	"message": "Amount must be greater than $50.00"
	}
		]
}

Editing an Order

Request

This endpoint allows you to edit an order.

How to Resolve the Path Placeholders of the Endpoint

Exchange {orderId} in the endpoint with the order ID.

Parameters for the Request Body

You can edit all parameters of an existing order except the recipient ID.

Parameters you can edit:

payer object

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

Please contact the Solutions team if you require payer information to be returned.

recipient object

Contains the fields of the recipient.

Do not include the recipient ID in the recipient object.

When creating an order, the recipient is defined by the recipient ID, which can't be changed later. Including the recipient ID in the request body for editing will result in an error, even if it matches the original ID.

fields array

items array

offer object

fields array

Some countries' regulations require extra fields in order to process a payment depending on the selected offer. If an offer contains any extra fields, they are required fields.

metadata object

You can specify up to 20 metadata pairs.

Maximum length for keys: 40 characters

Maximum length for values: 500 characters

PATCH/orders/{orderId}

curl https://base-url-placeholder/orders
  -X POST
  -H "Content-Type: application/json"
  -H "X-Authentication-Key: {api_key}"
  -d '{
	"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]"
    }, 
	"recipient": {
   		"fields": [
            {
                "id": "custom_field_1",
                "value": "ID12345"
            },
			{
				"id": "custom_field_2",
				"value": "2020"
			}
        ]
	},         
	"items": [
		{
			"amount": 80000,
			"id": "tuition"
		},
		{
			"amount": 40000,
			"id": "housing"
		}
	],
	"offer": {
		"id": "MTAwMDAgcHRfYmFua190cmFuc2Zlcl9jYWQgRVM=",
		"fields": {
			"id": "pan_number",
			"value": "12345678"
			}
		},
	"notifications_url": "http://consumer-url.com/notifications",
	"external_reference": "xyz123456",
	"metadata": {
	"external_payment_id": "PAYd910447bbf9fed52e3131e"
	}
} 

Response

Editing an order does not generate a new order ID - the returned order ID is the order ID of the original order you edited.

payer object

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

Please contact the Solutions team if you require payer information to be returned.

recipient object

fields array

items array

offer object

fields array

Some countries' regulations require extra fields in order to process a payment depending on the selected offer. If an offer contains any extra fields, they are required fields.

metadata object

There are different kinds of metadata for a payment:

Metadata added by Flywire

Not present for 529 Payments.

Metadata added by you

Only for 520 Payments and self-managed recurring payments. Not present for One Off Payments and Flywire-managed recurring payments.

Custom metadata is additional data entered by you when you create the payment, for example data you need to identify the payment in your system. Metadata can be useful when you want to add data that is not already covered by recipient fields, for example if you are not the one who set up the recipient and have no influence on the fields.

Metadata consist of pairs of keys and values, for example key Payer_ID_From_My_System and value ID12345.

{
	"id": "52c6a5df-b6c6-40bc-a71a-fefb82ad96b3",
	"created_at": "2020-10-20 17:41:27 UTC",
	"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]"
    }, 
	"recipient": {
		"id": "FWU",
   		"fields": [
            {
                "id": "custom_field_1",
                "value": "ID12345"
            },
			{
				"id": "custom_field_2",
				"value": "2020"
			}
        ]
	},
	"items": [
		{
			"amount": 80000,
			"id": "tuition"
		},
		{
			"amount": 40000,
			"id": "housing"
		}
	],
	"offer": {
		"id": "MTAwMDAgcHRfYmFua190cmFuc2Zlcl9jYWQgRVM=",
		"fields": [
			{
				"id": "pan_number",
				"value": "12345678"
			}
		]
	},
	"notifications_url": "http://consumer-url.com/notifications",
	"external_reference": "xyz123456",
	"metadata": {
		"external_payment_id": "PAYd910447bbf9fed52e3131e"
		}
}

Editing the order failed - recipient ID cannot be updated

422 Error

When does this happen?

You included the recipient ID in the request to edit the order.

Do not include the recipient ID in the recipient object.

When creating an order, the recipient is defined by the recipient ID, which can't be changed later. Including the recipient ID in the request body for editing will result in an error, even if it matches the original ID.

{
    "type": "https://developers.flywire.com",
    "title": "Unprocessable entity",
    "status": 422,
    "detail": "Invalid parameters",
    "errors": [
        {
            "source": "/recipient/id",
            "param": "id",
            "type": "invalid_param",
            "message": "cannot be updated"
        }
    ]
}

Charging an Order (Creating a Payment)

Request

When you confirm ("charge") an order, it creates a payment in Flywire. Once the order is charged successfully, Flywire will return the payment reference to you via the payment_reference parameter.

 

Parameters for the Request Body

No request body needed.

How to Resolve the Path Placeholders of the Endpoint

Exchange {orderId} in the endpoint with the order ID.

POST/orders/{orderId}/charge

curl https://base-url-placeholder/orders/52c6a5df-b6c6-40bc-a71a-fefb82ad96b3/charge
  -X POST
  -H "Content-Type: application/json"
  -H "X-Authentication-Key: {api_key}"

Response

{
	"payment_reference": "FWU425810948",
    "amount_from": 30400,
    "currency_from": "EUR",
    "amount_to": 30200,
    "currency_to": "USD"
}