Stats: 3,189,393 members, 7,937,194 topics. Date: Sunday, 01 September 2024 at 04:41 PM |
Nairaland Forum / Science/Technology / Webmasters / How To Integrate Paystack Payment Gateway In Website Using PHP and Mysql (1142 Views)
Five Important Rules In Website Design / Drupal: How To Integrate Bulk SMS To Work In Website? / What Is The Best Online Payment Gateway In Nigeria? (2) (3) (4)
(1) (Reply)
How To Integrate Paystack Payment Gateway In Website Using PHP and Mysql by mavigold: 10:23pm On Feb 06, 2022 |
How to integrate Paystack payment gateway in Website Using PHP and save in database What is Paystack? Paystack is an African payment gateway used by enterprises to accept payments from their customers. It is one of the most popular payment gateways in Africa, especially in Nigeria, Ghana and Kenya. It assists most E-commerce platforms, Educational Organizations and lots more to accept payment from their customers. To seamlessly integrate Paystack into PHP Applications, we must ensure our environment has the following in place: Paystack Account. Your Paystack account public key. A little knowledge of HTML, CSS & JavaScript Step 1: Sign Up with Paystack The first thing is to register your business account on Paystack’s website and verify your sign up using a verification link sent to your email. The next thing is to sign in to your new Paystack account. On your dashboard you will find your public and secret key. We will make use of the public and secret key for this tutorial. Step 2: Creating Our HTML, CSS Files Our HTML file will be the markup for our checkout page where customer pays for our product. This page will display the summary of what the customer purchased with a pay button. We also link our CSS and JavaScript file. The key element in our index. html file is the Pay Button with on-click attribute that triggers our JavaScript function payWithPaystack() . CheckOut with Paystack We also link the Paystack’s javascript library and our own javascript to this html file. Like this: ">">https://js.paystack.co/v1/inline.js">; You can find the structure of the checkout for and Css styles in the Source Code after Download Step 3: Creating Our JavaScript File JavaScript is is very important when connecting your website with paystack. Lets create our payWithPaystack() function. This function is were we finalize our payment setup before calling the Paystack’s payment modal. Setup includes adding your public key, your customer’s email, phone number and the amount the customer is supposed to pay. Remember to add/replace your own Paystack public key const paymentForm = document.getElementById('paymentForm'); paymentForm.addEventListener("submit", payWithPaystack, false); function payWithPaystack(e) { e.preventDefault(); let handler = PaystackPop.setup({ key: 'pk_live_4446f9704a9a592421a27cc0cd131f9dc0a982d5', // Replace with your public key email: document.getElementById("email" ![]() amount: document.getElementById("amount" ![]() firstname: document.getElementById("firstname" ![]() lastname: document.getElementById("lastname" ![]() ref: 'VS'+Math.floor((Math.random() * 1000000000) + 1), // generates a pseudo-unique reference. Please replace with a reference you generated. Or remove the line entirely so our API will generate one for you // label: "Optional string that replaces customer email" onClose: function(){ window.location = "index.php?transaction=cancel"; alert('Transaction Cancelled.'); }, callback: function(response){ let message = 'Payment complete! Take note of your Access Code: ' + response.reference; alert(message); window.location = "verify_transaction.php?reference=" + response.reference; } }); handler.openIframe(); } Lets talk about callback function. Inside this function is where we check if a customer was charged successfully or not by sending jquery post request using the transaction reference. Every transaction has its own unique key generated by the Paystack API. This callback function can be found in the verify_transaction.php file. After the Payment is successful. we will save the Payment information retrieved from Paystack in the database. Link to the Source Code: https://mavigoldsolutions.com/article/5/how-to-integrate-paystack-payment-gateway-in-website-using-php-and-verify-payment-transaction
|
Re: How To Integrate Paystack Payment Gateway In Website Using PHP and Mysql by Emekaojike6: 10:36pm On Mar 28 |
Please I need your help in setting this up, here is my number +23408169256910 please reach out to me |
(1) (Reply)
Which Web Hosting Platform Is The Best For Low Budget? / Website ! I Need You Comment / How Do You Drive Traffic To Your Site?
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 12 |