Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

PHP Question on Xenforo Payment process handling

Dnyan

Coder
Hello to all,

I would like to know more about or need a php file for doing redirection and sending the response for following case.

I saw all payment handling script in xenforo, the pre-configured xenforo payment profiles had almost following in common.

URL for returning after purchase
URL for Returning when purchase is cancel
AND the IPN or server to server call back during callback state.

In my case where i am trying to make an addon for payment profile, My payment server only sends signle response on a single url which i need to handle either it pass or fail or something else.

I wish to make that response a s a return page, this will be just a blank page with loader and message stating like please do not refresh, we are processing your payments........

Mean while i want a php to process the captured response by posting it to payment_callback.php and redirect user to either purchase complete or cancel or dynamic redirect as per error.

I wish to know, how i can make it work on xenforo

[CODE title="Process Chart"]1. User Click on Make payment and get redirected to payment provider page for doing payment (Happens as xF default system)

2. User does payment or cancel, Payment provider sends responce to single call back url with POST method ( I want a PHP file to handle that response)

3. IN PHP file
POST response recieved from the Payment provider will be sent to payment_callback.php for processing and logging the data
Base on Status in post data 'case' i would like to redirect user to purchase complete, cancel or dynamic redirect.

Meanwhile those process by PHP on redirect from payment provider, i would like to show a blank page with loader and message to wait.[/CODE]

any help on this would be much appreciated.

As i am not a coder, i might have express something wrongly in this.
 
XenForo has gateways for PayPal, Stripe, etc, so it shouldn't be too hard to build off of what is already there.

I have supplied some information down below to hopefully help you understand what's really going on, but basically you should be using your database to see if things are paid or not & just checking that information when pages are loaded. Ideally you should be building off of the gateways that XF provides instead of trying to change the way they work.
-----

What payment processor are you using?
I have created this exact type of flow with PayPal & Stripe, but it's pretty much the same for all of the various services.
You basically need to set up a PHP file/code that can add a new "pending payment" to the database.
For example, a user can press the button to buy a "shirt". Your database would then have a record that User 23 is purchasing "shirt" and the status_id would = 0, for not purchased.
Then the callback PHP file would update that record to status_id = 1 (for paid) when the service tells you they have paid.

You can check if the payment is made & redirect based on that.
It's incredibly hard for me to tell you exactly how to do it because you didn't say what service you are using, and its obviously even trickier to do it inside of XenForo. However, I know that this can be done relatively easily with PayPal IPN or similar services.

So for PayPal you could have something like this...
yoursite.com/checkout.php (shows the product they buy, amount, etc)
-> they click a product or something
-> generate a new payment & redirect to PayPal checkout page
-> you should have some sort of invoice or payment ID to identify the user's purchase

yoursite.com/callback.php (PayPal tells this page when user has paid)
-> this page will update the pending payment to = PAID in your database

yoursite.com/returnurl.php
-> this page checks to see if the product was paid for, if it was paid then it should say so & also trigger whatever it is you need done (ex: User is buying a VIP Role, or a Forum Shirt)

That's the general idea of what you need to do, but there's hundreds of pages of documentation for all the payment services, so I really can't fully explain it here - there's just too much to type.
 
Thank You for replying, actually i am trying to make an integration Paytm India Payment gateway.

Like Paypal, it is not redirect to different url for success or failure of transaction as it wont take it as parameter to process transaction.

there is a only one url which i can pass to receive a response from paytm server, user will be redirected to that URL after transaction (processed or cancelled or any status)

I manage to take response on my own custom call back file where i am redirecting it base on response to either purchase-process or to upgrade page using router.

initially i was thinking of making file to handle response and sending it to call back via POST method and redirect user to either of 2 possibilities, finally i made a custom call cack php
 
Thank You for replying, actually i am trying to make an integration Paytm India Payment gateway.
Like Paypal, it is not redirect to different url for success or failure of transaction as it wont take it as parameter to process transaction.
there is a only one url which i can pass to receive a response from paytm server, user will be redirected to that URL after transaction (processed or cancelled or any status)
I manage to take response on my own custom call back file where i am redirecting it base on response to either purchase-process or to upgrade page using router.
initially i was thinking of making file to handle response and sending it to call back via POST method and redirect user to either of 2 possibilities, finally i made a custom call cack php

Yeah, I would just store the result (paid / unpaid / cancelled) and then when the user is redirected, just look up the status of the transaction.
You can have a separate page for paid/unpaid/etc & just redirect them to that page once you receive the callback.
Your actual callback page that they initially go to can have some sort of 'Loading...' screen on it while your script looks up the status! :)
 
Yeah, I would just store the result (paid / unpaid / cancelled) and then when the user is redirected, just look up the status of the transaction.
You can have a separate page for paid/unpaid/etc & just redirect them to that page once you receive the callback.
Your actual callback page that they initially go to can have some sort of 'Loading...' screen on it while your script looks up the status! :)
Why? Most if not all payment services have an IPN which will send a request to the URL you provided which will contain information about the transaction based on the transaction id. That way you can create the transaction in your database, then if the transaction gets refunded or what not, they'll send another request to the URL you provided and you'd then update the existing row.
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom