|
|
|
|
@ -476,26 +476,47 @@ class PaymentService extends CI_Controller {
|
|
|
|
|
}
|
|
|
|
|
protected function get_paypal_order($paypal_order, $paypal_account)
|
|
|
|
|
{
|
|
|
|
|
$url = "https://secure.chinahighlights.com/pay/paypalservice/get_v2/order/$paypal_order/$paypal_account";
|
|
|
|
|
$order_str = get_url_contents($url);
|
|
|
|
|
// log_message('error','test: ' . __METHOD__ . ': ' . __LINE__ . ' ' . PHP_EOL . var_export($order_str, 1));
|
|
|
|
|
$order = json_decode($order_str, true);
|
|
|
|
|
if ( ! isset($order['payment_source'])) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
$payment_source = $order['payment_source'];
|
|
|
|
|
$type = array_keys($payment_source)[0];
|
|
|
|
|
$type = '';
|
|
|
|
|
$description = '';
|
|
|
|
|
$item_number = '';
|
|
|
|
|
$payer = new stdClass();
|
|
|
|
|
|
|
|
|
|
$purchase_units = $order['purchase_units'];
|
|
|
|
|
$description = isset($purchase_units[0]['description']) ? $purchase_units[0]['description'] : (isset($purchase_units[0]['items']) ? $purchase_units[0]['items'][0]['name'] : '');
|
|
|
|
|
$item_number = !isset($purchase_units[0]['invoice_id']) ? $description : '';
|
|
|
|
|
// 获取paypal订单信息 从数据库记录的授权事件
|
|
|
|
|
$paypal_order_rows = $this->note_model->get_note_where([
|
|
|
|
|
'OPN_transactionId' => ['=', $paypal_order],
|
|
|
|
|
'OPN_noticeType' => ['=', 'paypal.order'],
|
|
|
|
|
'OPN_accountMethod' => ['=', 15002],
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$payer = new stdClass();
|
|
|
|
|
if (isset($order['payer'])) {
|
|
|
|
|
$payer = (object) $order['payer'];
|
|
|
|
|
$payer->fullname = $payer->name['given_name'] . ' ' . $payer->name['surname'];
|
|
|
|
|
if (empty($paypal_order_rows)) {
|
|
|
|
|
// 获取paypal订单信息 从API
|
|
|
|
|
$url = "https://secure.chinahighlights.com/pay/paypalservice/get_v2/order/$paypal_order/$paypal_account";
|
|
|
|
|
$order_str = get_url_contents($url);
|
|
|
|
|
// log_message('error','test: ' . __METHOD__ . ': ' . __LINE__ . ' ' . PHP_EOL . var_export($order_str, 1));
|
|
|
|
|
$order = json_decode($order_str, true);
|
|
|
|
|
if ( ! isset($order['payment_source'])) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
$payment_source = $order['payment_source'];
|
|
|
|
|
$type = array_keys($payment_source)[0];
|
|
|
|
|
|
|
|
|
|
$purchase_units = $order['purchase_units'];
|
|
|
|
|
$description = isset($purchase_units[0]['description']) ? $purchase_units[0]['description'] : (isset($purchase_units[0]['items']) ? $purchase_units[0]['items'][0]['name'] : '');
|
|
|
|
|
$item_number = !isset($purchase_units[0]['invoice_id']) ? $description : '';
|
|
|
|
|
|
|
|
|
|
if (isset($order['payer'])) {
|
|
|
|
|
$payer = (object) $order['payer'];
|
|
|
|
|
$payer->fullname = $payer->name['given_name'] . ' ' . $payer->name['surname'];
|
|
|
|
|
} else {
|
|
|
|
|
$payer->fullname = $payment_source[$type]['name'];
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$payer->fullname = $payment_source[$type]['name'];
|
|
|
|
|
$type = $paypal_order_rows[0]->OPN_paymentSource;
|
|
|
|
|
$description = $paypal_order_rows[0]->OPN_remark;
|
|
|
|
|
$item_number = $paypal_order_rows[0]->OPN_subject;
|
|
|
|
|
$payer->fullname = $paypal_order_rows[0]->OPN_payerName;
|
|
|
|
|
$payer->payer_id = $paypal_order_rows[0]->OPN_payerLogId;
|
|
|
|
|
$payer->email_address = $paypal_order_rows[0]->OPN_payerEmail;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$ret = new stdClass();
|
|
|
|
|
|