-
-
Save Sarfroz/c8285e2801efaf073ca708dae59f57fb to your computer and use it in GitHub Desktop.
Stripe Code For Indian Users
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$txn='121221|544545'; // any value that you want to get in webhook | |
$sku='sku_G8srn2mAbnQI8k'; // get product id from stripe dashboard | |
$data=['sku'=>$sku,'email'=>$email,'txn'=>$txn]; // pass this values to php file | |
<? | |
<html> | |
<head> | |
<title> - Redirecting Please Wait...</title> | |
<!-- Load Stripe.js on your website. --> | |
<script src="https://js.stripe.com/v3"></script> | |
</head> | |
<body> | |
<script> | |
(function() { | |
var stripe = Stripe('');//live key | |
stripe.redirectToCheckout({ | |
items: [{sku: '<?= $data['sku'] ?>', quantity: 1}], | |
clientReferenceId:'<?=$data['txn']?>', // to get some values in webhook | |
customerEmail: '<?=$data['email']?>', // pass email value | |
billingAddressCollection: 'required', // must for indian users | |
successUrl: 'https://www.xyz.com/payments/orders/success', | |
cancelUrl: 'https://www.xyz.com/payments/cancel/true', | |
}) | |
.then(function (result) { | |
if (result.error) { | |
var displayError = document.getElementById('error-message'); | |
displayError.textContent = result.error.message; | |
} | |
}); | |
})(); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment