Payfast payment gateway ITN rersponse in php [closed]

南楼画角 提交于 2019-12-12 04:34:01

问题


I have integrated payfast payment gateway. I did not get any response from payfast after redirecting success page and notify page. What are the response parameters and how to store transaction details in the database?


回答1:


PayFast will return their return variables to your system via the ITN callback after a successful payment has been made.

These return variables will only be returned to your notify_url if it returns a header 200 response as per their documentation.

Receive the payment information from PayFast and then tell PayFast that this page is reachable by triggering a header 200, the payment engine will make a few attempts, one immediately and then one after 10 minutes again, then exponentially at longer intervals, until it receives an OK 200 from your web server.

You will be able to access the returned values via the $_POST variable and use these to update your database.

// Notify PayFast that information has been received
header( 'HTTP/1.0 200 OK' );
flush();

// Posted variables from ITN
$pfData = $_POST;

//update db
switch( $pfData['payment_status'] )
{
 case 'COMPLETE':
    // If complete, update your application, email the buyer and process the transaction as paid                    
 break;
 case 'FAILED':                    
    // There was an error, update your application
 break;
 default:
    // If unknown status, do nothing (safest course of action)
 break;
}

You can view the PayFast sample PHP ITN code here.



来源:https://stackoverflow.com/questions/40542863/payfast-payment-gateway-itn-rersponse-in-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!