|
|
@ -632,35 +632,65 @@ class Index extends CI_Controller {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$post_data = json_decode($raw_post);
|
|
|
|
$post_data = json_decode($raw_post);
|
|
|
|
if ($post_data->event_type != 'PAYMENT.SALE.COMPLETED' && $post_data->event_type != 'PAYMENT.SALE.REFUNDED') {
|
|
|
|
if (
|
|
|
|
|
|
|
|
strpos($post_data->event_type, 'COMPLETED') === false
|
|
|
|
|
|
|
|
&& strpos($post_data->event_type, 'REFUNDED') === false
|
|
|
|
|
|
|
|
) {
|
|
|
|
log_message('error',"paypal_webhook" . var_export($raw_post, 1));
|
|
|
|
log_message('error',"paypal_webhook" . var_export($raw_post, 1));
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$pn_txn_id = $post_data->resource->id;
|
|
|
|
// 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));
|
|
|
|
$pn_invoice = $post_data->resource->invoice_number;
|
|
|
|
// return;
|
|
|
|
|
|
|
|
|
|
|
|
$pn_mc_gross = $post_data->resource->amount->total;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// $pn_item_name = $this->input->post('item_name');
|
|
|
|
|
|
|
|
// if (empty($pn_item_name)) {
|
|
|
|
|
|
|
|
// $pn_item_name = $this->input->post('item_name1'); //APP用SDK支付的话会是item_name1
|
|
|
|
|
|
|
|
// empty($pn_item_name) ? $pn_item_name = '' : false;
|
|
|
|
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
$pn_txn_id = $post_data->resource->id;
|
|
|
|
|
|
|
|
|
|
|
|
// $pn_item_number = $this->input->post('item_number');
|
|
|
|
$pn_invoice = '';
|
|
|
|
// if (empty($pn_item_number)) {
|
|
|
|
$pn_mc_gross = '';
|
|
|
|
// $pn_item_number = $this->input->post('item_number1'); //APP用SDK支付的话会是item_number1
|
|
|
|
$pn_mc_currency = '';
|
|
|
|
// empty($pn_item_number) ? $pn_item_number = '' : false;
|
|
|
|
switch ($post_data->event_type) {
|
|
|
|
|
|
|
|
case 'PAYMENT.SALE.COMPLETED':
|
|
|
|
|
|
|
|
$pn_invoice = $post_data->resource->invoice_number;
|
|
|
|
|
|
|
|
$pn_mc_gross = $post_data->resource->amount->total;
|
|
|
|
|
|
|
|
$pn_mc_currency = $post_data->resource->amount->currency;
|
|
|
|
|
|
|
|
$pn_payment_status = $post_data->resource->state;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'PAYMENT.SALE.REFUNDED':
|
|
|
|
|
|
|
|
$pn_payment_status = 'Refunded';
|
|
|
|
|
|
|
|
$pn_mc_gross = '-' . $post_data->resource->amount->total;
|
|
|
|
|
|
|
|
$post_data->parent_txn_id = $post_data->resource->sale_id;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 'PAYMENT.CAPTURE.COMPLETED':
|
|
|
|
|
|
|
|
$pn_invoice = $post_data->resource->invoice_id;
|
|
|
|
|
|
|
|
$pn_mc_gross = $post_data->resource->amount->value;
|
|
|
|
|
|
|
|
$pn_mc_currency = $post_data->resource->amount->currency_code;
|
|
|
|
|
|
|
|
$pn_payment_status = $post_data->resource->status;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'PAYMENT.CAPTURE.REFUNDED':
|
|
|
|
|
|
|
|
$pn_invoice = $post_data->resource->invoice_id;
|
|
|
|
|
|
|
|
$pn_mc_currency = $post_data->resource->amount->currency_code;
|
|
|
|
|
|
|
|
$pn_mc_gross = '-' . $post_data->resource->amount->value;
|
|
|
|
|
|
|
|
$pn_payment_status = 'Refunded';
|
|
|
|
|
|
|
|
// $post_data->parent_txn_id = $post_data->resource->sale_id;
|
|
|
|
|
|
|
|
$parent_link = $post_data->resource->links[1]->href;
|
|
|
|
|
|
|
|
$parent_path = parse_url($parent_link, PHP_URL_PATH); // Get the path from the URL
|
|
|
|
|
|
|
|
$post_data->parent_txn_id = basename($parent_path);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
default: // capture COMPLETED
|
|
|
|
|
|
|
|
$pn_invoice = $post_data->resource->invoice_id;
|
|
|
|
|
|
|
|
$pn_mc_gross = $post_data->resource->amount->value;
|
|
|
|
|
|
|
|
$pn_mc_currency = $post_data->resource->amount->currency_code;
|
|
|
|
|
|
|
|
$pn_payment_status = $post_data->resource->status;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if ($post_data->event_type == 'PAYMENT.SALE.REFUNDED') {
|
|
|
|
|
|
|
|
// $pn_payment_status = 'Refunded';
|
|
|
|
|
|
|
|
// $pn_mc_gross = '-' . $post_data->resource->amount->total;
|
|
|
|
|
|
|
|
// $post_data->parent_txn_id = $post_data->resource->sale_id;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
$pn_mc_currency = $post_data->resource->amount->currency;
|
|
|
|
|
|
|
|
$pn_payment_status = $post_data->resource->state;
|
|
|
|
|
|
|
|
if ($post_data->event_type == 'PAYMENT.SALE.REFUNDED') {
|
|
|
|
|
|
|
|
$pn_payment_status = 'Refunded';
|
|
|
|
|
|
|
|
$pn_mc_gross = '-' . $post_data->resource->amount->total;
|
|
|
|
|
|
|
|
$post_data->parent_txn_id = $post_data->resource->sale_id;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$pn_payment_date = $post_data->resource->update_time;
|
|
|
|
$pn_payment_date = $post_data->resource->update_time;
|
|
|
|
// $pn_payer = $post_data->resource->amount->currency;
|
|
|
|
// $pn_payer = $post_data->resource->amount->currency;
|
|
|
|
// $pn_payer_email = $post_data->resource->amount->currency;
|
|
|
|
// $pn_payer_email = $post_data->resource->amount->currency;
|
|
|
|