Skip to main content

International Prayer Summit

'Invalid donation amount']); wp_die(); } // Square API credentials $access_token = 'YOUR_SQUARE_ACCESS_TOKEN'; $location_id = 'YOUR_LOCATION_ID'; $url = "https://connect.squareup.com/v2/payments"; $headers = [ "Authorization: Bearer $access_token", "Content-Type: application/json" ]; $body = json_encode([ "source_id" => "cnon:card-nonce-ok", // Replace with actual card nonce "amount_money" => [ "amount" => $amount * 100, "currency" => "USD" ], "location_id" => $location_id ]); $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $body); $response = curl_exec($ch); curl_close($ch); if ($response) { echo json_encode(['message' => 'Donation successful!']); } else { echo json_encode(['message' => 'Donation failed.']); } wp_die(); } add_action('wp_ajax_process_donation', 'process_donation'); add_action('wp_ajax_nopriv_process_donation', 'process_donation');