実際にPrestaShopで注文を作成する必要がある場合は、そのページにリダイレクトするローカル支払いモジュールを統合し、カードの詳細を入力して返品することを確認した後、注文を作成します。 私の問題は、支払いが拒否された場合(または支払いが支払いページで処理されているときにブラウザを閉じる場合)、注文はps_orderテーブルには作成されずカートが作成され、別のWEBサービス支払い応答はcart_idで成功し、id_orderは0、 ですが、ps_orderテーブルに作成されたps_orderテーブルには注文やエントリがありません。このシナリオを満たすには?prestashopのテーブルを作成する必要がある場合は、それを注文しますか?
支払処理の前に注文を作成(注文テーブルに挿入)し、current_stateフィールドを3としてください。ステータス3は、処理が進行中であることを意味し、支払いが成功した場合はcurrent_stateフィールドを変更します。
が、これはpayemntモジュールは、モジュールは通常持っているどのような支払い
if($reponseParameters[8]=='00000'){
// Update the Respose to the ps_networkonline_payment
$sql_response = " UPDATE `"._DB_PREFIX_."networkonline_payment` SET response = '".$text."' , `status` = '".$reponseParameters[4]."', error_code = '".$reponseParameters[8]."' WHERE order_id = '".$cart->id."' ";
Db::getInstance()->execute($sql_response);
// Create Order In prestashop pass the values to order-confrimation class
$total = (float)$cart->getOrderTotal(true, Cart::BOTH);
$this->module->validateOrder($cart->id, Configuration::get('PS_OS_PAYMENT'), $total, $this->module->displayName, 'Transaction Reference: ' . $reponseParameters[5], array(), (int)$currency->id, false, $customer->secure_key);
// Update the ps_order_payment table to make the PrestaShop Payment success
$q_orders = 'SELECT `reference` FROM ' . _DB_PREFIX_ . 'orders WHERE `id_cart` = ' . (int) $cart->id;
if ($r_orders = Db::getInstance()->getRow($q_orders)){
Db::getInstance()->execute('UPDATE `' . _DB_PREFIX_ . 'order_payment` SET `transaction_id` = \'' . pSQL($reponseParameters[5]) . '\' , `card_brand` = \'' . pSQL($reponseParameters[7]) . '\' WHERE `order_reference` = \'' . pSQL($r_orders['reference']) . '\'');
}
Tools::redirect('index.php?controller=order-confirmation&id_cart='.$cart->id.'&id_module='.$this->module->id.'&id_order='.$this->module->currentOrder.'&key='.$customer->secure_key);
return;
}else{
$this->error = $reponseParameters[9];//$this->module->getErrorMessage($object->error_code);
$total = (float)$cart->getOrderTotal(true, Cart::BOTH);
$this->module->validateOrder($cart->id, Configuration::get('PS_OS_ERROR'), $total, $this->module->displayName, $this->error, array(), (int)$currency->id, false, $customer->secure_key);
}
}else{
//fail
$this->error = $reponseParameters[9];//$this->module->getErrorMessage($object->error_code);
$total = (float)$cart->getOrderTotal(true, Cart::BOTH);
$this->module->validateOrder($cart->id, Configuration::get('PS_OS_ERROR'), $total, $this->module->displayName, $this->error, array(), (int)$currency->id, false, $customer->secure_key);
}
}
コード例では、同じコードの2つの "else"ブロックがありますが、2番目の "else"の "if"はありません。しかし、とにかく、私が正しく理解していれば、問題は外部サービスがエラーコードを返すときです、あなたのモジュールは注文を作成しません、そうですか? * PaymentModule :: validateOrder *メソッドで注文が作成されていますが、この部分をデバッグしようとしましたか?私はDBにデータがない場合、何かが間違って行く –
しかし、私の質問は、注文ページで注文ページが返ってくるとき、または支払いページに行く –
はい、注文を作成/検証してステータスを変更することができます。 –