Исходный код метода:
$this->load->model('payment/pp_pro_iframe');
if (isset($this->request->post['custom'])) {
$order_id = $this->encryption->decrypt($this->request->post['custom']);
} else {
$order_id = 0;
}
$this->load->model('checkout/order');
$order_info = $this->model_checkout_order->getOrder($order_id);
if ($order_info) {
$request = 'cmd=_notify-validate';
foreach ($this->request->post as $key => $value) {
$request .= '&' . $key . '=' . urlencode(html_entity_decode($value, ENT_QUOTES, 'UTF-8'));
}
if (!$this->config->get('pp_pro_iframe_test')) {
$curl = curl_init('https://www.paypal.com/cgi-bin/webscr');
} else {
$curl = curl_init('https://www.sandbox.paypal.com/cgi-bin/webscr');
}
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $request);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($curl);
if (curl_errno($curl)) {
$this->model_payment_pp_pro_iframe->log('pp_pro_iframe_test :: CURL failed ' . curl_error($curl) . '(' . curl_errno($curl) . ')');
} else {
$this->model_payment_pp_pro_iframe->log('pp_pro_iframe_test :: IPN REQUEST: ' . $request);
$this->model_payment_pp_pro_iframe->log('pp_pro_iframe_test :: IPN RESPONSE: ' . $response);
if ((strcmp($response, 'VERIFIED') == 0 || strcmp($response, 'UNVERIFIED') == 0) && isset($this->request->post['payment_status'])) {
$order_status_id = $this->config->get('pp_pro_iframe_canceled_reversal_status_id');
switch ($this->request->post['payment_status']) {
case 'Canceled_Reversal':
$order_status_id = $this->config->get('pp_pro_iframe_canceled_reversal_status_id');
break;
case 'Completed':
$order_status_id = $this->config->get('pp_pro_iframe_completed_status_id');
break;
case 'Denied':
$order_status_id = $this->config->get('pp_pro_iframe_denied_status_id');
break;
case 'Expired':
$order_status_id = $this->config->get('pp_pro_iframe_expired_status_id');
break;
case 'Failed':
$order_status_id = $this->config->get('pp_pro_iframe_failed_status_id');
break;
case 'Pending':
$order_status_id = $this->config->get('pp_pro_iframe_pending_status_id');
break;
case 'Processed':
$order_status_id = $this->config->get('pp_pro_iframe_processed_status_id');
break;
case 'Refunded':
$order_status_id = $this->config->get('pp_pro_iframe_refunded_status_id');
break;
case 'Reversed':
$order_status_id = $this->config->get['pp_pro_iframe_reversed_status_id'];
break;
case 'Voided':
$order_status_id = $this->config->get('pp_pro_iframe_voided_status_id');
break;
}
if (!$order_info['order_status_id']) {
$paypal_order_data = array(
'order_id' => $order_id,
'capture_status' => ($this->config->get('pp_pro_iframe_transaction_method') == 'sale' ? 'Complete' : 'NotComplete'),
'currency_code' => $this->request->post['mc_currency'],
'authorization_id' => $this->request->post['txn_id'],
'total' => $this->request->post['mc_gross'],
);
$paypal_iframe_order_id = $this->model_payment_pp_pro_iframe->addOrder($paypal_order_data);
$paypal_transaction_data = array(
'paypal_iframe_order_id' => $paypal_iframe_order_id,
'transaction_id' => $this->request->post['txn_id'],
'parent_transaction_id' => '',
'note' => '',
'msgsubid' => '',
'receipt_id' => $this->request->post['receipt_id'],
'payment_type' => $this->request->post['payment_type'],
'payment_status' => $this->request->post['payment_status'],
'pending_reason' => (isset($this->request->post['pending_reason']) ? $this->request->post['pending_reason'] : ''),
'transaction_entity' => ($this->config->get('pp_pro_iframe_transaction_method') == 'sale' ? 'payment' : 'auth'),
'amount' => $this->request->post['mc_gross'],
'debug_data' => json_encode($this->request->post),
);
$this->model_payment_pp_pro_iframe->addTransaction($paypal_transaction_data);
$this->model_checkout_order->confirm($order_id, $order_status_id);
} else {
$this->model_checkout_order->update($order_id, $order_status_id);
}
} else {
$this->model_checkout_order->confirm($order_id, $this->config->get('config_order_status_id'));
}
}
curl_close($curl);
}