Skip to content

Instantly share code, notes, and snippets.

@Sarfroz
Created December 5, 2019 10:56
Show Gist options
  • Save Sarfroz/00782cf4e14e83d80fb2ea817d32f34f to your computer and use it in GitHub Desktop.
Save Sarfroz/00782cf4e14e83d80fb2ea817d32f34f to your computer and use it in GitHub Desktop.

Revisions

  1. Sarfroz created this gist Dec 5, 2019.
    36 changes: 36 additions & 0 deletions php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    //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>