In this guide, you'll learn how to integrate Paystack payment system on your website.
This guide is comprehensive, so you should go through every...
For further actions, you may consider blocking this person and/or reporting abuse
I want to add paystack to my site. It got to a point where I don't know what's next.
I don't know where to add the files
Did you follow the steps? Explain your situation.
The problem is I don't even know how to start.
Can you give me a tutorial on how to start from scratch?. I already created a button to redirect to paystack but I don't know what to add and where to place the yabacon php files
If you know how to set up a PHP project, then simply follow the tutorial from the beginning.
Ignore the yabacon PHP files for now, and follow the tutorial.
How do I know my site callback url
I want the money to be added to the user wallet after successful payment. How do I add that?
In this case where I want user wallet to be updated, which method is best. Inline or standard. Or both
Both are fine.
The inline method is great for user experience if you're comfortable with AJAX.
The callback_url is for the standard method. This is the PHP file paystack will redirect the user to after making a payment.
In this page, you confirm the user payment and update the user wallet.
How do I update the wallet?
Is there a special code for that or I'll be the one to write it,
I think my site already has d callback but I don't know where it will be.
You'll have to do that yourself, or if you need help, you can message me on telegram, I actually wrote a wallet example.
Username not found on telegram
Let's chat via Twitter then @knightsgram
Oh, I made a typo, You can try it t.me/ijsucceed
You said $email is my customer's email. So I tried getting my user's email from $_POST but each time I refer to $_POST anywhere in initialize.php I get a redirection error from browser "Page isn't redirecting properly"
This also means I can't pass the amount user is willing to pay via post in initialize.php
This is super weird and annoying. I'll appreciate any help please. Thanks
"Page isn't redirecting properly"? Uncommon. Try clearing your cache and cookie(important).
Each time you refer to $_POST, what do you mean?
Try isseting if the $_POST request was sent to see where the problem is coming from.
You can engage with me live on twitter, that will be faster.
Your prompt response already makes me feel better :)
BTW, I was using Firefox on Android, I switched to Chrome... It worked. Back to Firefox and it worked too!
I don't know how, but I think the issue is resolved. Thanks.
One more thing...
For production, after replacing test_key with my real secret key, would PayStack override my callback_url? Or is it compulsory to set the callback_url in the field provided the Developer Dashboard?
I passed a $_GET parameter to the callback url containing specific subscription plans I offer so I could update the my DB with the parameter (plan) on success.
Is there a better way to do this?
Thanks once again
No, Pat, as long as you set the callback_url in your code, then you're fine.
Thanks man. You're za best!
Pleasure, thanks.
same here..but the values for $email and $amount in stored in sessions.
I get undefined _session variables..
Do i have to session_start()in both initialize.php and callback.php?
Don't worry...i've DONE IT
yo, please how did you solve this
using JS and I keep getting undefined
I have successfully added paystack to my plugin but i cannot update the plugin with payment information.
How can i add this code to the paystack file to be able to increase cause with payment details?
thanks very much jeremiah, you provide what i have been looking for. please i still have a little problem. the code work successfully, but know, i need php code to insert the figure to the user wallet or account. so that he can confirm the transaction he made. regards
Which user wallet are you referring to? is it that of Paystack or your own platform. Please specify.
I'm talking about my platform. Take for example, a user login to his/her account in my platform, and deposit money, using the paystack payment gateway.. Now I'm looking for the php script to give the user value, (e.g. he/she deposits #500 using paystack, and it was successful,, when he/she come back to my platform, he/she has to see the #500 in her account, to confirm that the payment he/she made was successful)
You're to write the script yourself. You do that in the callback file.
if('success' == $tranx->data->status){
// transaction was successful...
// send the value the user made to the database and redirect back to any
// file you want.
}
Hope you get it?
that is my issue now. have write many php script code with the little knowledge i have, but nothing happen. please i need a sample of already working php code, to learn from. i will be glad if anyone can share with me. regards
you need to create a webhook url where paystack sends a charge.success event to, if the payment was made successfully. It's in that webhook file you can update the users wallet if a charge.success event was received. Visit paystack documentation page for a better understanding.
Good afternoon @ijsucceed .
I really love your code for it simplicity. However, i did love to make some corrections starting with the initialize.php.
// this part of the code is wrong since an array is returned, so it should not be
if(!$tranx->status){
// there was an error from the API
print_r('API returned error: ' . $tranx['message']);
}
// the corrected version
if(!$tranx['status']){
print_r('API returned error: ' . $tranx['message']);
}
Thank you.
You're right @holynation .
I just ran some few tests. The actual issue came from the Paystack documentation.
Though it will be hard for one to notice ( including Paystack developers) since the page gets redirected to the checkout form.
Thanks.
That is true. I have actually been looking for that too in their documentation.
Also i wanna ask again, how do i send phone number and fullname along side the initialize.php api
For those that will like to test these on local host server
you should follow the steps below
Wow, Love this detailed tutorials @ijsucceed . Please am faced with a challenge.
i want to make for recurring debit but i was not able to retrieve "authentication code and card last four digits" after the successful payment. Help me out sir.
please see developers.paystack.co/reference#c...
.....
"gateway_response": "Successful",
"authorization": {
"authorization_code": "AUTH_72btv547",
"card_type": "mastercard",
"last4": "1839",
........
Sorry, bro. I have no experience working on the recurring payment API.
Thanks for your prompt reply sir.
Hi IJ
I would like to know if there is a way of adding customer details to this specific way of integrating. I have tried several times but i cannot seem to get it right.
Late reply, but you can pass customer details through the metadata:
I hope you got it.
Is there a way to create a form to enable customers input their details instead of having a predefined details on the dashboard?
Nice and clear explanation.
My problem is that the call back function does not provide the payment details (I.e the customer email) so as to insert in it MySQLi data base.
Or I'm to use session to keep the record
The payment details are usually sent (as JSON) to your webhook url.
But, just like you said, you should use the user session, then make sure you verify the session with the user details in your database.
Please I have an ecomerce site and I want a paystack pay button but I want the script that you will take any sum from the total cost on the cart and show to the customer as what to pay rather than me adding the price please
You'll have to do that yourself, or if you need help, you can message me on telegram.
Hi Jeremiah.
Thanks for the detailed instructions.
I've been able to implement Paystack gateway successfully and gets a redirect to the specified callback URL.
But I'm having issues transferring data from the payment page to the webook URL specified on the Paystack dashboard.
Any hint on how that can be achieved?
Thank you.
Welcome! Have you taken a look at this?
Hi, @ijsucceed , Thanks for the tuts. It really helped a lot as it is simple and detailed.
I have been able to integrate and I can successfully pay. Thumbs Up to you!.
but I want to be able to add other specific information to the API endpoint and also retrieve it at callback.php for further details verification before giving value to the customer.
I'm giving multiple values to different tables in the DB. e.g after successful payment, a customer is getting point value, product value, and an additional bonus value.
All these will have to verify the transaction match with their tables respectively before I can give value to the customer...
I tried adding extra form data to the form that is sent to initialize.php. but I'm not able to get those values, and I can't retrieve them from the API as well since it wasn't sent in the first place.
Okay, getting you clearly, you want to pass some extra but important data to the API. And you want to get this extra data during the verification.
If that's the case:
Kindly contact me on Telegram or WhatsApp so we do a live session.
Thanks for this post, really helpful, but please do you have any idea on how to integrate Paystack into Django WebApps? I have been looking for a way around this for days now, any help will be appreciated. Thanks in anticipation.
Not really. I never built anything with Django before. Thank you.
has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
please I keep getting this error, what can I do, I get it when it goes to the
header('Location: ' . $tranx['data']['authorization_url']);
got this error:
API returned error: Authorization URL createdArray ( [status] => 1 [message] => Authorization URL created [data] => Array ( [authorization_url] => checkout.paystack.com/...............
Whats the problem
Be sure your secret key is used in both initialization and verification. And if you're on live mode, then you have to be on a live server too.
Jeremy pls help
Hello, I'm new here, I need help on how to integrate paystack standard to my ecommerce website which was written in django. I want to know which folder to place the initialize.php file in the django, also can i use include command to include it to checkout.HTML file that already exit, also do I need to create a model.py for the php file. I need your help thanks
Hi Jeremiah,
i am getting this error in test mode after initiating a transaction "API returned error: Authorization URL created" am I doing something wrong.
Are you on a Live server or Local? The callback.php should be on a live server.
I am on a live server and the callback.php is also on the live server.
Since the error is from the API, I suggest you do it again.
Can you help me please? I want to be able to submit a form on the basis of a successful paystack payment, is there any way to go about this>
Sure, you can do that by passing those form data through the metadata array during initialization:
Are you using laravel??
Hi Jeremiah.
Thanks for the detailed instructions.
I've been able to implement Paystack gateway successfully and gets a redirect to the specified callback URL.
But i have question.... if i want to use my custom form for the payment checkout in the sense that remember that if the -> *initialise *<-endpoint is sucessful, we direct a user to a {paystack checkout page}..
let assume that i am not using paystack checkout if i want to send user account details to the initialise endpoint, what parameter would i send for the account details or can i just declare a parameter of my choice the details and
Thank you.
If you're looking to pass custom information, what you do is to pass those information in a property called
meta
.@ijsucceed Thanks for the tutorial. Its very detailed. But am unable to get it redirect back to my site(the callback url). I don't know why. What version is the tutorial based on(Mine is version2+)
Did you set the callback_url?
Yes, I did
I don't suggest version 2, it's currently in Beta. Money here, hackers everywhere.
Good day sir. please i really need your help. Am using Paystack Inline but the list of banks i need are not in the list already made in the Api. please is there anyway i can add mine.
th Api IS giving an error
: Invalid keyArray ( [status] => [message] => Invalid key )
Warning: Undefined array key "data" in C:\Users\ABDUL\Desktop\exam\nms-online-compedium-1\backend\server\phppages\subscription\initialize.php on line 47
How do I retrieve list of transaction or transaction history with paystack API
Is it necessary I purchase SSL for my site when using standard?
Sure! Will you want to make a payment on a site that shows "site not secure"?.
As stated in the Paystack Standard Prerequisites:
Very good intro for me. Thank you for this cool post! :)
Thank you.
Followed the procedures as outlined and got the expected result.
But found out that the paystack popui takes time to load. Is there a way I can make it load faster?
hi is there a way we can redefine the "var handler" line as wordpress is flagging it. I am trying to edit a plugin to include the paystack button
pls help me out here, whenever i press the html button i get this
"The requested URL was not found on this server."
what does this mean
Hello bro, thanks for this post please is there a way to get the transaction details, i mean the email, amount and transaction id?
The inline code actually works well. Except that the payer can't generate their details. It pays with details already generated.
thanks so much for your explanation but can i use the inline method with php or only the standard method
Thank you very much
Oluwaseun, thanks for reading.
well detailed analogy... God bless you man!
Amen, thanks.
i want to use the utility api for electricity and cable tv, what do i need to do or get
Can you please help with "Ensure CORS response headers are valid". It's not redirecting to checkout.paystack.com/...
I am using the Standard paystack
How can I send buyer a file they bought immediately and also allow them to download it immediately the payment goes through.
Thanks
That thank you paragraph yyou echo in your sample is not working mine. It stopped when paystack marked that the payment is successful. What could be the problem please?
Pls sir i need some help on this topic, my php ecommerce website had product page each product contain different price, pls sir how can i use above code to get payment on each product
I keep getting "Curl returned error: SSL certificate problem: unable to get local issuer certificate" please what do I do. I'm using WAMP Server
please it's not redirecting me to the callback.php page, and I specified the url in the initialize.php page can you please help me