-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpayment.php
More file actions
27 lines (22 loc) · 941 Bytes
/
Copy pathpayment.php
File metadata and controls
27 lines (22 loc) · 941 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
require "C:\Users\sansk\vendor\autoload.php"; // Load Composer's autoloader
// Set your Stripe Secret Key
\Stripe\Stripe::setApiKey('sk_test_51QZAZQFDu12sFaxLkSx6RbYSFiihYzyYYxfzXB1lPCCAwhbuXsB2UfS9FTpyNL1NPj5AQhmxBdn05PznyNTwlFFr00jJnudKZ0'); // Replace with your Secret Key
header('Content-Type: application/json'); // Ensure the response is in JSON format
try {
// Create a Payment Intent
$paymentIntent = \Stripe\PaymentIntent::create([
'amount' => 1000, // Amount in cents (e.g., $10.00)
'currency' => 'usd',
'payment_method_types' => ['card'],
]);
// Return the client secret as JSON
echo json_encode([
'clientSecret' => $paymentIntent->client_secret,
]);
exit; // Ensure no further code is executed
} catch (Exception $e) {
// Handle errors and return a JSON error message
http_response_code(500);
echo json_encode(['error' => $e->getMessage()]);
}