} } } } // If Previous steps succeed, ready (means 'ready to pay') will be set to true if ($ppec->ready && !empty($ppec->token) && (Tools::isSubmit('confirmation') || $ppec->type == 'payment_cart')) { // Check modification on the product cart / quantity if ($ppec->isProductsListStillRight()) { $order = null; $cart = $ppec->getContext()->cart; $customer = new Customer((int) $cart->id_customer); // When all information are checked before, we can validate the payment to paypal // and create the prestashop order $ppec->doExpressCheckout(); /// Check payment (real paid)) if ($ppec->hasSucceedRequest() && !empty($ppec->token) && ($amount_match = $ppec->rightPaymentProcess())) { if ((bool) Configuration::get('PAYPAL_CAPTURE')) { $payment_status = 'Pending_capture'; $message = $ppec->l('Pending payment capture.') . '<br />'; $payment_type = (int) Configuration::get('PS_OS_PAYPAL'); } else { $payment_status = $ppec->result['PAYMENTINFO_0_PAYMENTSTATUS']; $message = $ppec->l('Payment accepted.') . '<br />'; $payment_type = (int) Configuration::get('PS_OS_WS_PAYMENT'); } $transaction = array('id_transaction' => pSQL($ppec->result['PAYMENTINFO_0_TRANSACTIONID']), 'id_invoice' => null, 'currency' => pSQL($ppec->result['PAYMENTINFO_0_CURRENCYCODE']), 'total_paid' => (double) $ppec->result['PAYMENTINFO_0_AMT'], 'shipping' => (double) $ppec->result['PAYMENTREQUEST_0_SHIPPINGAMT'], 'payment_date' => pSQL($ppec->result['PAYMENTINFO_0_ORDERTIME']), 'payment_status' => pSQL($payment_status)); } else { $transaction = array(); $payment_type = (int) Configuration::get('PS_OS_ERROR'); if (!isset($amount_match) || $amount_match == true) { $message = implode('<br />', $ppec->logs) . '<br />';