Create a Payment

Learn to make different types of payments using the Square API.

Whenever we buy something, we need to make a payment. We can make the payment via different channels depending on the nature of the purchase.

  • Online payment: The buyer visits the seller's web or mobile application and makes the payment within that application.

  • In-person payment: The buyer pays at the seller's physical location using the seller’s POS device, for example, an iPad.

The CreatePayment endpoint

Square's Payments API provides the CreatePayment endpoint, which can be used to either direct Square to take payments or record payments processed outside Square. To create any type of payment, we can use the following URL:

https://connect.squareupsandbox.com/v2/payments

Request parameters

An API call to this URL results in the creation of a Payment object which is returned in the response. The parameters that this API accepts are listed below:

Parameter

Type

Category

Description

amount_money

Object

Required

This is the Money object containing an integer amount, and a string, currency, representing the money to be accepted for this payment.

app_fee_money

Object

Optional

This is the Money object representing the money that the developer is charging as a fee for facilitating the payment on behalf of the seller.

autocomplete

Boolean

Optional

If this is set to true, this payment will be completed when possible. On the other hand, if it's set to false, this payment is held in an approved state until either explicitly completed or canceled.

billing_address

Object

Optional

This is the billing address of the buyer.

It's an Address object representing the address of the location. It consists of many strings like address_line_1, address_line_2, country, and postal_code.

buyer_email_address

String

Optional

This is the email address of the buyer.

idempotency_key

String

Required

This is a unique string that identifies the CreatePayment request.

The maximum length of the string can be 45 characters.

source_id

String

Required

This is the ID for the source of funds for this payment.

Depending upon the nature of the payment, it can either be a card nonce, CASH or EXTERNAL.

tip_money

Object

Optional

This is the Money object representing the amount designated as a tip, in addition to amount_money.

We can use the ...