The so-called Sina callback interface, is when the capital recharge success, Sina will inform this website a message to inform already recharge success, and return a group of successful array, we based on this data to a local database synchronization operations, such as updating the local database to recharge the status of success, from unpaid to paid, And then show it on the website, and the funds will also be synchronized update, OK, the following summer blog to share the log, and then a new Sina payment interface, a simple Sina payment callback interface, this asynchronous callback information is generated through the log to the FTP below, according to the log for local updates.
First, look at the log file
Description: After the data submitted to Sina will generate Sina log file, as follows:
{"CTL": "Collocation", "act": "Response_sina", "Call": "Registercreditor", "Notify_time": "20160317112508", "Sign_type ":" RSA "," Notify_type ":" Trade_status_sync "," gmt_payment ":" 20160317111255 "," Trade_status ":" Pay_finished "," Version ":" 1.0 "," Sign ":" ulbwnfkn1dhf1z9m5daajhkcvlytchs1smh3o7amwaqnyylmqatfpnxzdlofh5r43cm3mtatuaaxeddsrckmbzemz+ Xlqecersu8x6ha0onizw5yvogqhpfnz4lbh3mc4yjxpzq9dqge\/fvlj+pwnaevtxjmiyrygohcdx+mt28= "," Gmt_create ":" 20160317111254 "," _input_charset ":" Utf-8 "," Outer_trade_no ":" 7l3no20160317111143 "," Trade_amount ":" 100.00 "," inner _trade_no ":" 101145818437424877398 "," notify_id ":" 82170F9981B84C40B50A634ED37A2AFD "}
Second, open the/app/lib/module/collocationmodule.class.php and find the Response_sina method as follows:
Public Function Response_sina ()
{
$content = $_request;
Error_log (Date ("[Ymdhis]"). " \ t ". Json_encode ($content). "\ r \ n", 3, ' ... /'. Date ("y-m-d"). '. Log1 ');
$class _name = Getcollname ();
Require_once App_root_path. " system/collocation/". $class _name." _collocation.php ";
$collocation _class = $class _name. " _collocation ";
$collocation _object = new $collocation _class ();
$collocation _code = $collocation _object->sinanotify ($_post,$_request);
}
Three, open the system/collocation/sina_collocation.php file, find the Sinanotify method, as follows:
function Sinanotify ($map, $data) {
$weibopay->write_log ("Get to Refund_status_sync result notification: Number:". Json_encode ($map). Json_encode ($data));
Ksort ($MAP);
$weibopay = new Weibopay ();
Error_log (Date ("[Ymdhis]"). " \ t ". Json_encode ($map). Json_encode ($data). "\ r \ n", 3, ' ... /'. Date ("y-m-d"). '. log10 ');
if ($weibopay->checksignmsg ($map, @ $map ["Sign_type"])) {
Switch ($map ["Notify_type"])
{
Trading Results Notice
Case "Trade_status_sync":
Tender Collection
if ($data [' Call ']== ' Registercreditor ') {
Require_once (app_root_path. ' system/collocation/sina/sinanotify.php ');
Registercreditor_status_sync ($MAP);
}
if ($data [' Call ']== ' Dotrtrade ') {
Error_log (Date ("[Ymdhis]"). " \ t ". Json_encode ($map). "\ r \ n", 4, ' ... /'. Date ("y-m-d"). '. Log4 ');
Require_once (app_root_path. ' system/collocation/sina/sinanotify.php ');
Dotrtrade_status_sync ($MAP);
}
if ($data [' Call ']== ' Dohktrade ') {
Error_log (Date ("[Ymdhis]"). " \ t ". Json_encode ($map). "\ r \ n", 5, ' ... /'. Date ("y-m-d"). '. Log41 ');
Require_once (app_root_path. ' system/collocation/sina/sinanotify.php ');
Dohktrade_status_sync ($MAP);
}
Get the corresponding parameters to save according to your business requirements
$weibopay->write_log ("Get to Trade_status_sync result notification: Time:". Date ("Ymdhis"));
$weibopay->write_log ("get to Trade_status_sync result notice: Number:". Json_encode ($_request));
Break
Transaction refund Results Notification
Case "Refund_status_sync":
Get the corresponding parameters to save according to your business requirements
$weibopay->write_log ("Get to Refund_status_sync result notification: Time:". Date ("Ymdhis"));
$weibopay->write_log ("get to Refund_status_sync result notice: Number:". Json_encode ($_request));
Break
Recharge Results Notice
Case "Deposit_status_sync":
Done
Require_once (app_root_path. ' system/collocation/sina/sinanotify.php ');
Deposit_status_sync ($MAP);
Break
Notice of the present result
Case "Withdraw_status_sync":
$weibopay->write_log ("Get to Batch_trade_status_sync result notification: Time:". Date ("Ymdhis"));
$weibopay->write_log ("get to Batch_trade_status_sync result notice: Number:". Json_encode ($_request));
Require_once (app_root_path. ' system/collocation/sina/sinanotify.php ');
Withdraw_status_sync ($MAP);
Break
Batch Payment result notice
Case "Batch_trade_status_sync":
Get the corresponding parameters to save according to your business requirements
$weibopay->write_log ("Get to Batch_trade_status_sync result notification: Time:". Date ("Ymdhis"));
$weibopay->write_log ("get to Batch_trade_status_sync result notice: Number:". Json_encode ($_request));
Break
Audit Results Notification
Case "Audit_status_sync":
Require_once (app_root_path. ' system/collocation/sina/sinanotify.php ');
Audit_status_sync ($MAP);
Get the corresponding parameters to save according to your business requirements
$weibopay->write_log ("Get to Audit_status_sync result notification: Time:". Date ("Ymdhis"));
$weibopay->write_log ("get to Audit_status_sync result notice: Number:". Json_encode ($_request));
Break
Default
$weibopay->write_log ("Get to unknown result notification: Time:". Date ("Ymdhis"));
$weibopay->write_log ("Get to unknown result notification: number:". Json_encode ($_request));
ECHO ' Notification type Error! ";
}
If the callback succeeds, you need to output success to inform Sina of the callback server and have received an asynchronous notification.
echo ' success ';
} else {
$msg = "Signature error or illegal request";
$weibopay->write_log ($msg);
Die ("sign Error");
}
}
Qualification Price Increase
Four, open the system/collocation/sina/sinanotify.php file, recharge callback.
if ($map [' Trade_status ']== ' pay_finished ') {
$pErrCode = ' mg00000f ';
$data [' perrcode '] = ' mg00000f ';
$data [' perrmsg '] = ' mg00000f ';;
}
Five, after the success of the following operation.