|
|
@ -643,6 +643,15 @@ class Index extends CI_Controller {
|
|
|
|
// log_message('error',"paypal_webhook" . var_export($raw_post, 1));
|
|
|
|
// log_message('error',"paypal_webhook" . var_export($raw_post, 1));
|
|
|
|
// return;
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$default_payee = new stdClass();
|
|
|
|
|
|
|
|
$default_payee->email_address = "pays@chinahighlights.com";
|
|
|
|
|
|
|
|
$default_payee->merchant_id = "JE4VX9SSVGTVN";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$tp_payee = new stdClass();
|
|
|
|
|
|
|
|
$tp_payee->email_address = "pay@trippest.com";
|
|
|
|
|
|
|
|
$tp_payee->merchant_id = "5FUTQ9SU5P7CJ";
|
|
|
|
|
|
|
|
|
|
|
|
$pn_txn_id = $post_data->resource->id;
|
|
|
|
$pn_txn_id = $post_data->resource->id;
|
|
|
|
|
|
|
|
|
|
|
|
$pn_invoice = '';
|
|
|
|
$pn_invoice = '';
|
|
|
@ -650,6 +659,7 @@ class Index extends CI_Controller {
|
|
|
|
$pn_mc_gross = '';
|
|
|
|
$pn_mc_gross = '';
|
|
|
|
$pn_mc_currency = '';
|
|
|
|
$pn_mc_currency = '';
|
|
|
|
$pn_mc_fee = '';
|
|
|
|
$pn_mc_fee = '';
|
|
|
|
|
|
|
|
$GAI_API = new stdClass();
|
|
|
|
switch ($post_data->event_type) {
|
|
|
|
switch ($post_data->event_type) {
|
|
|
|
case 'PAYMENT.SALE.COMPLETED':
|
|
|
|
case 'PAYMENT.SALE.COMPLETED':
|
|
|
|
$pn_invoice = $post_data->resource->invoice_number;
|
|
|
|
$pn_invoice = $post_data->resource->invoice_number;
|
|
|
@ -657,6 +667,16 @@ class Index extends CI_Controller {
|
|
|
|
$pn_mc_currency = $post_data->resource->amount->currency;
|
|
|
|
$pn_mc_currency = $post_data->resource->amount->currency;
|
|
|
|
$pn_payment_status = $post_data->resource->state;
|
|
|
|
$pn_payment_status = $post_data->resource->state;
|
|
|
|
$post_data->mc_fee = $post_data->resource->transaction_fee->value;
|
|
|
|
$post_data->mc_fee = $post_data->resource->transaction_fee->value;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$GAI_API->payee = new stdClass();
|
|
|
|
|
|
|
|
if (stripos($post_data->resource->soft_descriptor, 'CHINAHIG') !== false) {
|
|
|
|
|
|
|
|
$GAI_API->payee = $default_payee;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (stripos($post_data->resource->soft_descriptor, 'TRIPP') !== false) {
|
|
|
|
|
|
|
|
$GAI_API->payee = $tp_payee;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$GAI_API->res_links = $post_data->resource->links;
|
|
|
|
|
|
|
|
$post_data->GAI_API = $GAI_API;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 'PAYMENT.SALE.REFUNDED':
|
|
|
|
case 'PAYMENT.SALE.REFUNDED':
|
|
|
|
$pn_invoice = $post_data->resource->invoice_number;
|
|
|
|
$pn_invoice = $post_data->resource->invoice_number;
|
|
|
@ -666,6 +686,10 @@ class Index extends CI_Controller {
|
|
|
|
$post_data->parent_txn_id = $post_data->resource->sale_id;
|
|
|
|
$post_data->parent_txn_id = $post_data->resource->sale_id;
|
|
|
|
$pn_mc_fee = '-' . $post_data->resource->refund_from_transaction_fee->value;
|
|
|
|
$pn_mc_fee = '-' . $post_data->resource->refund_from_transaction_fee->value;
|
|
|
|
$post_data->mc_fee = $pn_mc_fee;
|
|
|
|
$post_data->mc_fee = $pn_mc_fee;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$GAI_API->payee = new stdClass();
|
|
|
|
|
|
|
|
$GAI_API->res_links = $post_data->resource->links;
|
|
|
|
|
|
|
|
$post_data->GAI_API = $GAI_API;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case 'PAYMENT.CAPTURE.COMPLETED':
|
|
|
|
case 'PAYMENT.CAPTURE.COMPLETED':
|
|
|
@ -675,6 +699,10 @@ class Index extends CI_Controller {
|
|
|
|
$pn_mc_currency = $post_data->resource->amount->currency_code;
|
|
|
|
$pn_mc_currency = $post_data->resource->amount->currency_code;
|
|
|
|
$pn_payment_status = $post_data->resource->status;
|
|
|
|
$pn_payment_status = $post_data->resource->status;
|
|
|
|
$post_data->mc_fee = $post_data->resource->seller_receivable_breakdown->paypal_fee->value;
|
|
|
|
$post_data->mc_fee = $post_data->resource->seller_receivable_breakdown->paypal_fee->value;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$GAI_API->payee = $post_data->resource->payee;
|
|
|
|
|
|
|
|
$GAI_API->res_links = $post_data->resource->links;
|
|
|
|
|
|
|
|
$post_data->GAI_API = $GAI_API;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 'PAYMENT.CAPTURE.REFUNDED':
|
|
|
|
case 'PAYMENT.CAPTURE.REFUNDED':
|
|
|
|
$pn_invoice = $post_data->resource->invoice_id;
|
|
|
|
$pn_invoice = $post_data->resource->invoice_id;
|
|
|
@ -690,6 +718,12 @@ class Index extends CI_Controller {
|
|
|
|
|
|
|
|
|
|
|
|
$pn_mc_fee = '-' . $post_data->resource->seller_payable_breakdown->paypal_fee->value;
|
|
|
|
$pn_mc_fee = '-' . $post_data->resource->seller_payable_breakdown->paypal_fee->value;
|
|
|
|
$post_data->mc_fee = $pn_mc_fee;
|
|
|
|
$post_data->mc_fee = $pn_mc_fee;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$GAI_API->payee = $post_data->resource->payer;
|
|
|
|
|
|
|
|
$GAI_API->res_links = $post_data->resource->links;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$post_data->GAI_API = $GAI_API;
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
default: // capture COMPLETED
|
|
|
|
default: // capture COMPLETED
|
|
|
@ -746,12 +780,13 @@ class Index extends CI_Controller {
|
|
|
|
$res_links = $webhook_memo->resource->links;
|
|
|
|
$res_links = $webhook_memo->resource->links;
|
|
|
|
// $res_links = json_encode($res_links, JSON_UNESCAPED_SLASHES);
|
|
|
|
// $res_links = json_encode($res_links, JSON_UNESCAPED_SLASHES);
|
|
|
|
|
|
|
|
|
|
|
|
$default_payee = new stdClass;
|
|
|
|
$default_payee = new stdClass();
|
|
|
|
$default_payee->email_address = "pays@chinahighlights.com";
|
|
|
|
$default_payee->email_address = "pays@chinahighlights.com";
|
|
|
|
$default_payee->merchant_id = "JE4VX9SSVGTVN";
|
|
|
|
$default_payee->merchant_id = "JE4VX9SSVGTVN";
|
|
|
|
$payee = isset($webhook_memo->resource->payee) ? $webhook_memo->resource->payee : $default_payee;
|
|
|
|
$payee = isset($webhook_memo->resource->payee) ? $webhook_memo->resource->payee : $default_payee;
|
|
|
|
|
|
|
|
$payee = property_exists($webhook_memo, 'GAI_API') ? $webhook_memo->GAI_API->payee : $payee;
|
|
|
|
|
|
|
|
|
|
|
|
$API = new stdClass;
|
|
|
|
$API = new stdClass();
|
|
|
|
$API->payee = $payee;
|
|
|
|
$API->payee = $payee;
|
|
|
|
$API->res_links = $res_links;
|
|
|
|
$API->res_links = $res_links;
|
|
|
|
|
|
|
|
|
|
|
@ -944,6 +979,7 @@ class Index extends CI_Controller {
|
|
|
|
echo ++$show_index . ' ' . $item->pn_txn_id . '<br/>';
|
|
|
|
echo ++$show_index . ' ' . $item->pn_txn_id . '<br/>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$GAI_API = null;
|
|
|
|
$payment_fee = 0;
|
|
|
|
$payment_fee = 0;
|
|
|
|
// webhook的跳过
|
|
|
|
// webhook的跳过
|
|
|
|
$webhook_memo = json_decode($item->pn_memo);
|
|
|
|
$webhook_memo = json_decode($item->pn_memo);
|
|
|
@ -951,6 +987,8 @@ class Index extends CI_Controller {
|
|
|
|
if (isset($webhook_memo->id) && substr($webhook_memo->id, 0, 2)==="WH") {
|
|
|
|
if (isset($webhook_memo->id) && substr($webhook_memo->id, 0, 2)==="WH") {
|
|
|
|
$is_webhook = true;
|
|
|
|
$is_webhook = true;
|
|
|
|
$payment_fee = property_exists($webhook_memo, 'mc_fee') ? $webhook_memo->mc_fee : $webhook_memo->resource->transaction_fee->value;
|
|
|
|
$payment_fee = property_exists($webhook_memo, 'mc_fee') ? $webhook_memo->mc_fee : $webhook_memo->resource->transaction_fee->value;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$GAI_API = property_exists($webhook_memo, 'GAI_API') ? $webhook_memo->GAI_API : null;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$payment_fee = property_exists($webhook_memo, 'mc_fee') ? $webhook_memo->mc_fee : 0;
|
|
|
|
$payment_fee = property_exists($webhook_memo, 'mc_fee') ? $webhook_memo->mc_fee : 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1080,7 +1118,7 @@ class Index extends CI_Controller {
|
|
|
|
$ht_memo = '交易号(自动录入):' . $item->pn_txn_id;
|
|
|
|
$ht_memo = '交易号(自动录入):' . $item->pn_txn_id;
|
|
|
|
//CHTAPP订单添加记录前判断是否有记录,以前的APP版本没有交易号,只能拿金额来判断
|
|
|
|
//CHTAPP订单添加记录前判断是否有记录,以前的APP版本没有交易号,只能拿金额来判断
|
|
|
|
if (substr($advisor_info->COLI_WebCode, 0, 6) == 'CHTAPP' && strstr($advisor_info->COLI_WebCode, "-") !== '-biz') {//只判断前6位字符,CHTAPP-fr CHTAPP-jp等各语种都属于APP订单
|
|
|
|
if (substr($advisor_info->COLI_WebCode, 0, 6) == 'CHTAPP' && strstr($advisor_info->COLI_WebCode, "-") !== '-biz') {//只判断前6位字符,CHTAPP-fr CHTAPP-jp等各语种都属于APP订单
|
|
|
|
$this->Paypal_model->add_account_info_forAPP($GAI_COLI_SN, $advisor_info->COLI_ID, $item->pn_mc_gross, $item->pn_payment_date, mb_strtoupper($item->pn_mc_currency), $ssje, $item->pn_payment_date, $item->pn_payment_date, $item->pn_payment_date, $item->pn_payer, $item->pn_payer_email, $item->pn_txn_id, $ht_memo);
|
|
|
|
$this->Paypal_model->add_account_info_forAPP($GAI_COLI_SN, $advisor_info->COLI_ID, $item->pn_mc_gross, $item->pn_payment_date, mb_strtoupper($item->pn_mc_currency), $ssje, $item->pn_payment_date, $item->pn_payment_date, $item->pn_payment_date, $item->pn_payer, $item->pn_payer_email, $item->pn_txn_id, $ht_memo, $GAI_API);
|
|
|
|
if ($advisor_info->COLI_WebCode == 'CHTAPP' && $advisor_info->COLI_State == 11) { //只修改APP组的订单状态,并且订单进度是我的订单
|
|
|
|
if ($advisor_info->COLI_WebCode == 'CHTAPP' && $advisor_info->COLI_State == 11) { //只修改APP组的订单状态,并且订单进度是我的订单
|
|
|
|
$this->Paypal_model->update_biz_coli_state($GAI_COLI_SN, 8); //把订单状态改为已付款
|
|
|
|
$this->Paypal_model->update_biz_coli_state($GAI_COLI_SN, 8); //把订单状态改为已付款
|
|
|
|
$this->Paypal_model->insert_biz_order_log($GAI_COLI_SN, 'BS8');
|
|
|
|
$this->Paypal_model->insert_biz_order_log($GAI_COLI_SN, 'BS8');
|
|
|
@ -1105,7 +1143,7 @@ class Index extends CI_Controller {
|
|
|
|
$item->pn_payer,
|
|
|
|
$item->pn_payer,
|
|
|
|
$item->pn_payer_email,
|
|
|
|
$item->pn_payer_email,
|
|
|
|
$item->pn_txn_id,
|
|
|
|
$item->pn_txn_id,
|
|
|
|
$ht_memo);
|
|
|
|
$ht_memo, $GAI_API);
|
|
|
|
// 更新订单主表付款方式,防止没访问thankyou-train.asp
|
|
|
|
// 更新订单主表付款方式,防止没访问thankyou-train.asp
|
|
|
|
$this->Paypal_model->update_paymanner($GAI_COLI_SN, '15010');
|
|
|
|
$this->Paypal_model->update_paymanner($GAI_COLI_SN, '15010');
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1114,7 +1152,7 @@ class Index extends CI_Controller {
|
|
|
|
elseif (isset($advisor_info->order_type) && $advisor_info->order_type == 1) {
|
|
|
|
elseif (isset($advisor_info->order_type) && $advisor_info->order_type == 1) {
|
|
|
|
$ht_memo = '交易号(自动录入):' . $item->pn_txn_id;
|
|
|
|
$ht_memo = '交易号(自动录入):' . $item->pn_txn_id;
|
|
|
|
$GAI_COLI_SN = isset($advisor_info->COLI_SN) ? $advisor_info->COLI_SN : 0;
|
|
|
|
$GAI_COLI_SN = isset($advisor_info->COLI_SN) ? $advisor_info->COLI_SN : 0;
|
|
|
|
$gai_sn = $this->Paypal_model->add_tour_account_info($GAI_COLI_SN, $item->pn_mc_gross, $item->pn_payment_date, mb_strtoupper($item->pn_mc_currency), $ssje, $item->pn_payment_date, $item->pn_payment_date, $item->pn_payment_date, $item->pn_payer, $item->pn_payer_email, $item->pn_txn_id, $ht_memo);
|
|
|
|
$gai_sn = $this->Paypal_model->add_tour_account_info($GAI_COLI_SN, $item->pn_mc_gross, $item->pn_payment_date, mb_strtoupper($item->pn_mc_currency), $ssje, $item->pn_payment_date, $item->pn_payment_date, $item->pn_payment_date, $item->pn_payer, $item->pn_payer_email, $item->pn_txn_id, $ht_memo, $GAI_API);
|
|
|
|
//添加汉特的订单提醒
|
|
|
|
//添加汉特的订单提醒
|
|
|
|
$this->Paypal_model->update_coli_introduction($GAI_COLI_SN, '已支付 ' . mb_strtoupper($item->pn_mc_currency) . $item->pn_mc_gross);
|
|
|
|
$this->Paypal_model->update_coli_introduction($GAI_COLI_SN, '已支付 ' . mb_strtoupper($item->pn_mc_currency) . $item->pn_mc_gross);
|
|
|
|
// 添加HT任务
|
|
|
|
// 添加HT任务
|
|
|
|