From 883ad0d5c8cb2bf7146eed646f28394bdf485c4e Mon Sep 17 00:00:00 2001 From: jrangel Date: Sat, 23 Nov 2024 09:16:20 +0000 Subject: [PATCH] Initial --- Stripe/payments/index.php | 43 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 Stripe/payments/index.php diff --git a/Stripe/payments/index.php b/Stripe/payments/index.php new file mode 100644 index 0000000..9bdb21f --- /dev/null +++ b/Stripe/payments/index.php @@ -0,0 +1,43 @@ + 5000, // Amount in cents, e.g., $50.00 + 'currency' => 'usd', + 'description' => 'Example charge', + 'source' => $token, // The token generated on the client side + ]); + + // Check if the payment was successful + if ($charge->status == 'succeeded') { + echo 'Payment was successful!'; + } + } catch (\Stripe\Exception\CardException $e) { + // Handle error (card declined, etc.) + echo 'Error: ' . $e->getMessage(); + } catch (Exception $e) { + echo 'Error: ' . $e->getMessage(); + } +} + + +/* In the backend code of your plugin, initialize Stripe with your secret API key: */ +/* Needs to be stored in DB securely */ +\Stripe\Stripe::setApiKey('your_secret_key'); // Replace with your Stripe Secret Key + +