Simple Examples
FR6 edited this page Mar 7, 2021
·
1 revision
Imagine we have the following data available (don't skip this part)
$amount = 5000; //Is in USD currency and is in smallest denomination (cents). ($amount = 5000 == 50 Dollars)
// nonce reference => https://developer.squareup.com/docs/payment-form/payment-form-walkthrough
// single-use token (nonce) generated by the client-side javascript library
$formNonce = 'some nonce';
$location_id = 'some location id'; //$location_id is id of a location from Square
// optional, default=USD
$currency = 'USD'; //available currencies => https://developer.squareup.com/reference/square/objects/Currency
// optional
$note = 'This is my first payment to Square with this library'; //note about this charge
// optional
$reference_id = '25'; //some kind of reference id to an object or resource
$options = [
'amount' => $amount,
'source_id' => $formNonce,
'location_id' => $location_id,
'currency' => $currency,
'note' => $note,
'reference_id' => $reference_id
];
Square::charge($options); // Simple charge