Skip to main content
Version: Lab (preview)

Cash Payments

This guide will show you how to accept cash payments online with Pay Theory’s checkout as well as how to handle barcodes that are generated at checkout.

Before you start

To use cash you will need to make sure the transact function is enabled in order to accept cash payments online.

Transact function

Using the transact function​

This function is used to submit a payment to Pay Theory or generate a barcode using Pay Theory’s cash fields. It returns a Promise with the result or an error.

paytheory.js
//Amount passed in is in cents
const AMOUNT = 1000

// optionally provide details about the payor
const PAYOR_INFO = {
"first_name": "Some",
"last_name": "Body",
"email": "somebody@gmail.com",
"phone": "3335554444",
"personal_address": {
"city": "Somewhere",
"country": "USA",
"region": "OH,
}
}

const BILLING_INFO = {
name: "Some Body",
address: {
line1: "123 Street St",
line2: "Apartment 17",
city: "Somewhere",
country: "USA"
}
}

const PAYMENT_METADATA = {
"student-name": "Pat Theodore"
};

// Parameters that you will pass into the transact function. More details below.
const TRANSACTING_PARAMETERS = {
amount: AMOUNT,
payorInfo: PAYOR_INFO,
metadata: PAYMENT_METADATA, // optional
}

paytheory.transact(TRANSACTING_PARAMETERS)

The following are values that you can pass into the transact function to customize the payment. The only required key is amount.

Keytypedescription
amountintIt represents the amount to be charged in cents.
payorInfoobjectRefer to payor info here payorinfo

The function returns a Promise that will contain an object with a key of type. You can expect the following values for type:

Typedescription
CASHThe transact call successfully generated a barcode and the barcode details will be in the body key.
ERRORThe transact call had an error while processing and the error details will be in the error key.

Cash response​

This is the value of the body key in the response if the type is CASH:

While generating the Barcode it will use the geolocation to return a map url for the user's specific location. If this is the first time it has been requested the user will have the opportunity to accept or decline the request.

Keytypedescription
barcodeURLstringThe url for the barcode image.
mapURLstringThe url for the map to find the retail locations to pay the barcode.

Error response​

This is the value of the error key in the response if the type is ERROR:

Keytypedescription
messagestringThe error message.

Cash Fields​

You can customize your cash fields based on your requirements and desired user experience. These fields are all required to collect cash information from the user.

javascript
<form>
<div id = "pay-theory-cash-name"></div>
<div id = "pay-theory-cash-contact"></div>
</form>

Next Steps​

You can also refer to different payment modes like ACH functionality and QRCode functionality.