Skip to content

Instantly share code, notes, and snippets.

@Sarfroz
Created December 5, 2019 10:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sarfroz/00782cf4e14e83d80fb2ea817d32f34f to your computer and use it in GitHub Desktop.
Save Sarfroz/00782cf4e14e83d80fb2ea817d32f34f to your computer and use it in GitHub Desktop.
Stripe Code For Indin Users
//Process.php
$txn='121221|544545'; // any value that you want to get in webhook
$sku='sku_G8srn2mAbnQI8k'; // get product id
$data=['sku'=>$sku,'email'=>$email,'txn'=>$txn]; // pass this values to php file
//redirect.php
<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