|
|
|
@ -733,6 +733,58 @@ class Index extends CI_Controller {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 处理webhook
|
|
|
|
|
* * 把资源地址写入 GAI 表
|
|
|
|
|
* * * IPN先执行, 更新 GAI
|
|
|
|
|
* * * WB先执行, 需要等待IPN
|
|
|
|
|
*/
|
|
|
|
|
public function handle_webhook($item) {
|
|
|
|
|
$webhook_memo = json_decode($item->pn_memo);
|
|
|
|
|
$res_links = null;
|
|
|
|
|
$res_links = $webhook_memo->resource->links;
|
|
|
|
|
$res_links = json_encode($res_links, JSON_UNESCAPED_SLASHES);
|
|
|
|
|
|
|
|
|
|
$pn_txn_id = $item->pn_txn_id;
|
|
|
|
|
$orderid_info = $this->analysis_orderid($item->pn_invoice);
|
|
|
|
|
if (!empty($orderid_info)) {
|
|
|
|
|
$orderid_info = json_decode($orderid_info);
|
|
|
|
|
if ($orderid_info->ordertype === 'TP' || $orderid_info->ordertype === 'A') {
|
|
|
|
|
$orderid_info->ordertype = 'B';
|
|
|
|
|
}
|
|
|
|
|
$data_gai = null;
|
|
|
|
|
if ($orderid_info->ordertype === 'T') {
|
|
|
|
|
$data_gai = $this->Paypal_model->get_money_t($pn_txn_id);
|
|
|
|
|
if ( ! empty($data_gai)) {
|
|
|
|
|
$this->Paypal_model->update_money_api_t($pn_txn_id, $res_links);
|
|
|
|
|
$this->Note_model->update_send($item->pn_txn_id, 'send-wh-API', $item->pn_sn);
|
|
|
|
|
}
|
|
|
|
|
} elseif ($orderid_info->ordertype === 'B') {
|
|
|
|
|
$data_gai = $this->Paypal_model->get_money_b($pn_txn_id, false);
|
|
|
|
|
if ( ! empty($data_gai)) {
|
|
|
|
|
$this->Paypal_model->update_money_api_b($pn_txn_id, $res_links);
|
|
|
|
|
$this->Note_model->update_send($item->pn_txn_id, 'send-wh-API', $item->pn_sn);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $res_links;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function handle_webhook_batch() {
|
|
|
|
|
$data = array();
|
|
|
|
|
$data['notelist'] = $this->Note_model->notewebhooks(200, true);
|
|
|
|
|
$show_index = 0;
|
|
|
|
|
foreach ($data['notelist'] as $item) {
|
|
|
|
|
if ($item->pn_send === 'send-wh-API') {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
echo ++$show_index . ' ' . $item->pn_txn_id . ' ' . $item->pn_payment_date . '<br/>';
|
|
|
|
|
// $webhook_memo = json_decode($item->pn_memo);
|
|
|
|
|
$this->handle_webhook($item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//解析出订单号
|
|
|
|
|
public function analysis_orderid($note_invoice_string) {
|
|
|
|
|
$data = array();
|
|
|
|
@ -888,7 +940,8 @@ class Index extends CI_Controller {
|
|
|
|
|
$payment_fee = property_exists($webhook_memo, 'mc_fee') ? $webhook_memo->mc_fee : 0;
|
|
|
|
|
}
|
|
|
|
|
if (empty($pn_txn_id) && true === $is_webhook) {
|
|
|
|
|
$this->Note_model->update_send($item->pn_txn_id, 'send-wh', $item->pn_sn);
|
|
|
|
|
$this->handle_webhook($item);
|
|
|
|
|
// $this->Note_model->update_send($item->pn_txn_id, 'send-wh', $item->pn_sn);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1770,6 +1823,10 @@ class Index extends CI_Controller {
|
|
|
|
|
$pn_id = $this->input->post('pn_id');
|
|
|
|
|
$neworder = $this->input->post('pn_invoice');
|
|
|
|
|
|
|
|
|
|
// log_message('error','test: ' . __METHOD__ . ':' . __LINE__ . PHP_EOL . var_export(0, 1));
|
|
|
|
|
// $this->send_note($pn_txn_id, $old_ssje);
|
|
|
|
|
// return;
|
|
|
|
|
|
|
|
|
|
$data['note'] = $this->Note_model->note($pn_txn_id, $pn_id);
|
|
|
|
|
$orderid_info = $this->analysis_orderid($data['note']->pn_invoice);
|
|
|
|
|
if (!empty($orderid_info)) {
|
|
|
|
|