Skip to main content
Version: Lab (preview)

Payment QR Code

qrCode starts a payment session from the checkoutDetails you pass and mounts a QR code in the pay-theory-checkout-qr hosted field. When the payor scans it, a Pay Theory checkout page opens on their phone where they pick a payment method and pay.


qrCode​

// Amount in cents
const AMOUNT = 1000

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

// Configures the checkout page that opens when the payor scans the code
const CHECKOUT_DETAILS = {
amount: AMOUNT,
paymentName: "School Technology Fees",
paymentDescription: "Technology fee for the 2026-2027 school year",
requirePhone: true,
callToAction: paytheory.DONATE,
acceptedPaymentMethods: paytheory.ONLY_CARD,
payorId: "ptl_pay_2NM2STwd3pWznLo1hGnUSc",
metadata: PAYMENT_METADATA,
feeMode: paytheory.MERCHANT_FEE,
accountCode: "code-123456789",
invoiceId: "ptl_inv_2O0yTY3k5AIyDc8NQ2SvhC",
}

const OPTIONS = {
apiKey: "YOUR_API_KEY",
checkoutDetails: CHECKOUT_DETAILS,
size: 150,
onReady: () => {},
onError: error => {},
onSuccess: result => {}
}

paytheory.qrCode(OPTIONS)

Pass qrCode one object with these keys.

Required

Keytypedescription
apiKeyStringYour Pay Theory API Key, from the Pay Theory portal.
checkoutDetailsCheckout detailsWhat the checkout page charges and shows.

Optional

Keytypedescription
sizeIntWidth and height of the QR code, in pixels. Defaults to 128. Values below 128 become 128 and values above 300 become 300.
onReadyFunctionCalled with true when the QR code is ready to scan.
onErrorFunctionCalled with an error string. The string starts with one of the error codes.
onSuccessFunctionCalled with the success response when the payment succeeds.

qrCode returns a Promise. If a parameter is invalid, it resolves to false and sends the error to onError.


Checkout details​

qrCode takes the same checkoutDetails as button.

Required

Keytypedescription
amountIntAmount of the payment, in cents.
paymentNameStringName shown on the checkout page. It's also saved as the transaction's reference.

Optional

Keytypedescription
paymentDescriptionStringDescription shown on the checkout page.
requirePhoneBooleanPass true to make the payor enter a phone number.
callToActionStringCall to action for the checkout. Defaults to paytheory.PAY. See call to action.
acceptedPaymentMethodsStringPayment methods the page offers. Defaults to paytheory.ALL. See accepted payment methods.
payorIdStringID of an existing payor. If you leave it out, Pay Theory creates a new payor.
metadataObjectKey-value data stored with the transaction.
feeModeStringpaytheory.MERCHANT_FEE (default) or paytheory.SERVICE_FEE.
accountCodeStringCode for tracking a payment or group of payments.
invoiceIdStringID of the invoice this payment pays. Don't combine with recurringId.
recurringIdStringID of the recurring payment this payment pays. The amount must be a multiple of the recurring amount per payment.
healthExpenseTypeStringHealthcare category: HEALTHCARE, RX, VISION, CLINICAL, COPAY, DENTAL or TRANSIT.
level3DataSummaryLevel 3 data summaryLevel 3 summary data for the transaction.

Success response​

onSuccess receives this object.

Keytypedescription
receipt_numberStringThe transaction ID.
amountIntAmount charged, in cents. Includes the service fee.
service_feeIntService fee, in cents.
last_fourStringLast four digits of the card or account number.
brandStringCard brand.
created_atStringWhen the transaction was created.
stateStringStatus of the transaction.
metadataObjectThe metadata you passed.
payor_idStringID of the payor.
payment_method_idStringID of the payment method token.

Call to action​

ValueButton text on the checkout pageConstant
PAYPay withpaytheory.PAY
DONATEDonate withpaytheory.DONATE
BOOKBook withpaytheory.BOOK

Accepted payment methods​

ValueThe page acceptsConstant
ALLCard, ACH and cashpaytheory.ALL
ONLY_CARDCardpaytheory.ONLY_CARD
ONLY_ACHACHpaytheory.ONLY_ACH
ONLY_CASHCashpaytheory.ONLY_CASH
NOT_CARDACH and cashpaytheory.NOT_CARD
NOT_ACHCard and cashpaytheory.NOT_ACH
NOT_CASHCard and ACHpaytheory.NOT_CASH