|
|
|
@ -646,9 +646,14 @@ class Index extends CI_Controller {
|
|
|
|
|
strpos($post_data->event_type, 'COMPLETED') === false
|
|
|
|
|
&& strpos($post_data->event_type, 'REFUNDED') === false
|
|
|
|
|
&& strpos($post_data->event_type, 'PAYMENT.CAPTURE.DECLINED') === false
|
|
|
|
|
&& strpos($post_data->event_type, 'PAYMENT.SALE.REVERSED') === false
|
|
|
|
|
) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if ($post_data->event_type === 'PAYMENT-NETWORKS.ALTERNATIVE-PAYMENT.COMPLETED') {
|
|
|
|
|
return ;
|
|
|
|
|
}
|
|
|
|
|
// todo: CUSTOMER.DISPUTE.CREATED
|
|
|
|
|
// if ($post_data->event_type != 'PAYMENT.SALE.COMPLETED' && $post_data->event_type != 'PAYMENT.SALE.REFUNDED') {
|
|
|
|
|
// log_message('error',"paypal_webhook" . var_export($raw_post, 1));
|
|
|
|
|
// return;
|
|
|
|
@ -678,9 +683,10 @@ class Index extends CI_Controller {
|
|
|
|
|
$net_amount = '';
|
|
|
|
|
$transaction_status = '';
|
|
|
|
|
switch ($post_data->event_type) {
|
|
|
|
|
case 'PAYMENT.SALE.COMPLETED':
|
|
|
|
|
case 'PAYMENT.SALE.COMPLETED': // todo: PAYMENT.SALE.DENIED
|
|
|
|
|
$fund_type = 'pay';
|
|
|
|
|
$pn_invoice = $post_data->resource->invoice_number;
|
|
|
|
|
$pn_custom = isset($post_data->resource->custom) ? $post_data->resource->custom : '';
|
|
|
|
|
$pn_mc_gross = $post_data->resource->amount->total;
|
|
|
|
|
$pn_mc_currency = $post_data->resource->amount->currency;
|
|
|
|
|
$pn_payment_status = $post_data->resource->state;
|
|
|
|
@ -689,18 +695,23 @@ class Index extends CI_Controller {
|
|
|
|
|
$net_amount = bcsub($pn_mc_gross, $post_data->mc_fee);
|
|
|
|
|
|
|
|
|
|
$GAI_API->payee = new stdClass();
|
|
|
|
|
if (stripos($post_data->resource->soft_descriptor, 'CHINAHIG') !== false) {
|
|
|
|
|
if (isset($post_data->resource->soft_descriptor)) {
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$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;
|
|
|
|
|
$pn_receiver_account = $GAI_API->payee->email_address;
|
|
|
|
|
$pn_receiver_account_name = $GAI_API->payee->merchant;
|
|
|
|
|
break;
|
|
|
|
|
case 'PAYMENT.SALE.REFUNDED':
|
|
|
|
|
case 'PAYMENT.SALE.REVERSED':
|
|
|
|
|
$pn_invoice = $post_data->resource->invoice_number;
|
|
|
|
|
$pn_mc_currency = $post_data->resource->amount->currency;
|
|
|
|
|
$fund_type = 'refund';
|
|
|
|
@ -712,13 +723,16 @@ class Index extends CI_Controller {
|
|
|
|
|
$post_data->mc_fee = $pn_mc_fee;
|
|
|
|
|
$net_amount = isset($post_data->resource->seller_receivable_breakdown) ? '-'.$post_data->resource->seller_receivable_breakdown->refund_from_received_amount->value : $pn_mc_gross;
|
|
|
|
|
|
|
|
|
|
// 'PAYMENT.SALE.REVERSED':
|
|
|
|
|
$net_amount = isset($post_data->resource->refund_from_received_amount) ? $post_data->resource->refund_from_received_amount : $net_amount;
|
|
|
|
|
|
|
|
|
|
$GAI_API->payee = new stdClass();
|
|
|
|
|
$GAI_API->res_links = $post_data->resource->links;
|
|
|
|
|
$post_data->GAI_API = $GAI_API;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'PAYMENT.CAPTURE.COMPLETED':
|
|
|
|
|
case 'PAYMENT.CAPTURE.DECLINED':
|
|
|
|
|
case 'PAYMENT.CAPTURE.DECLINED': // todo: CHECKOUT.PAYMENT-APPROVAL.REVERSED
|
|
|
|
|
$fund_type = 'pay';
|
|
|
|
|
$pn_invoice = $post_data->resource->invoice_id;
|
|
|
|
|
$pn_custom = $post_data->resource->custom_id;
|
|
|
|
@ -735,7 +749,7 @@ class Index extends CI_Controller {
|
|
|
|
|
$pn_receiver_account = $GAI_API->payee->email_address;
|
|
|
|
|
$pn_receiver_account_name = $pn_receiver_account===$default_payee->email_address ? $default_payee->merchant : $tp_payee->merchant;
|
|
|
|
|
break;
|
|
|
|
|
case 'PAYMENT.CAPTURE.REFUNDED':
|
|
|
|
|
case 'PAYMENT.CAPTURE.REFUNDED': // todo: PAYMENT.CAPTURE.REVERSED
|
|
|
|
|
$fund_type = 'refund';
|
|
|
|
|
$pn_invoice = $post_data->resource->invoice_id;
|
|
|
|
|
$pn_custom = $post_data->resource->custom_id;
|
|
|
|
|