After long time back, we have posted an article for how to integrate stripe payment gateway in PHP source code.
It also a one of the payment gateway as like Paypal but its very easy to setup in our application.
See our demo video on Youtube:
Stripe Integration Steps:
First thing, we have to create an account on stripe.com
Then login into your account.
Get a API key from your account.
Integrate for checkout from stripe documentation
Install stripe vendor files via composer to using below command.
composer require stripe/stripe-php
Create index.php paste below code in that file.
<form action="/your-server-side-code" method="POST"> <script src="https://checkout.stripe.com/checkout.js" class="stripe-button" data-key="pk_test_d8GOWxzerUcB34ENyGG4fGi6" data-amount="999" data-name="John" data-description="Widget" data-image="https://stripe.com/img/documentation/checkout/marketplace.png" data-locale="auto"> </script> </form>
Create charge.php for server side code implementation
// Set your secret key: remember to change this to your live secret key in production // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey("sk_test_jXnbWYmNh6227VACFxp1gJog"); // Token is created using Checkout or Elements! // Get the payment token ID submitted by the form: $token = $_POST['stripeToken']; // Charge the user's card: $charge = \Stripe\Charge::create(array( "amount" => 1000, "currency" => "usd", "description" => "Example charge", "source" => $token, ));
Note that the above requests expect to receive the token ID (e.g., tok_KPte7942xySKBKyrBu11yEpf) for the value of the
Click here to download files from github.
Thanks for reading this article.
If you are like this post and please share this post and comment your thoughts in the box.