Donate
 
<script>
window.alert("start");
var applicationId = '{{ sandbox-sq0idb-JbmhYwCtBdizAjslJy3-yw}}';
use Square\Models\Currency;
use Square\SquareClient;
use Square\Environment;

// Replace 'EAAAEC6DqMNNw9fuj3Ry7K6S687qBK0GfskdqfY43ME58zV0I2c03ByiDT_-IUjr' with an OAuth or your Personal Access Token
const SQUARE_ACCESS_TOKEN = 'EAAAEC6DqMNNw9fuj3Ry7K6S687qBK0GfskdqfY43ME58zV0I2c03ByiDT_-IUjr';

$client = new SquareClient([
    'accessToken' => SQUARE_ACCESS_TOKEN,
    'environment' => Environment::SANDBOX,
]);
// Package the charge amount and currency as a Money object
$sourceId = $_POST['nonce'];
$idempotencyKey = uniqid();
$amountMoney = new Money;
$amountMoney->setAmount($_POST['amount']);
$amountMoney->setCurrency(Currency::USD);

$paymentRequest = new CreatePaymentRequest(
    $sourceId,
    $idempotencyKey,
    $amountMoney
);
// Create a PaymentsApi client to charge the card using our form info
$paymentsApi = $client->getPaymentsApi();

// Call the PaymentsApi to create a payment using that card
try {
  $result = $paymentsApi->createPayment($paymentRequest);
window.alert("Gooood");
} catch (Exception $e) {
  // Handle the exception
}
</script>