ed44rf Posted September 26, 2016 Share Posted September 26, 2016 Hi First say I don't have experience with prestashop. I need fix payment module goopay, I need create order only if success payment here is code of module http://prestashop-forum.ru/redgo.php?url=https://yadi.sk/d/enAbfdM5vbBnr here is some area of code which can be usefull function parseResponse($goopay, $resp){ $verify_result = $resp['Succeed']; $out_trade_no = $resp['BillNo']; //获取订单号 $Result = $resp['Result']; if (isset($out_trade_no)) { $out_trade_no = substr($out_trade_no, 2); } //获取订单号 //echo $out_trade_no; $order = new Order((int)$out_trade_no); if($verify_result == '88') { //验证成功 $goopay->saveStatus($out_trade_no, Goopay::WAIT_SELLER_SEND_GOODS, $out_trade_no, $Result, 'update'); $history = new OrderHistory(); $history->id_order = (int)($out_trade_no); $history->changeIdOrderState(_PS_OS_PAYMENT_, intval($out_trade_no)); $history->add(); } else { // echo $goopay->l("交易失败"); $goopay->saveStatus($out_trade_no, goopay::NOTIFY_VERIFY_ERROR, $out_trade_no, $Result, 'update'); $history = new OrderHistory(); $history->id_order = $out_trade_no; $history->changeIdOrderState(_PS_OS_ERROR_, intval($out_trade_no)); $history->add(); } $customer = new Customer(intval($order->id_customer)); //redirect to payment confirm page $key = (isset($order)?$order->secure_key:pSQL($customer->secure_key)); Tools::redirect('index.php?controller=order-confirmation&id_cart='.$order->id_cart.'&id_module='.$goopay->id.'&id_order='.$out_trade_no.'&key='.$key); } status 88 is the success payment the problem-I don't have an idea what to fix maybe remove second part of condition or maybe move line $order = new Order((int)$out_trade_no); inside if($verify_result == '88') I need creating order only if payment was success (status 88) Link to comment Share on other sites More sharing options...
shokinro Posted September 27, 2016 Share Posted September 27, 2016 You said you want to create Order only when payment success, but from your code, it seems that the order has been created before, you are just update the order status. $verify_result = $resp['Succeed']; $out_trade_no = $resp['BillNo']; //获取订单号 .... $order = new Order((int)$out_trade_no); If you want create Order only when payment success, you should get payment info from Shopping cart, and then process payment, and then verify the payment result, if payment success then you call validateOrder() method (inherits from PaymentModule class) to of the payment module to create the order. You may try to find sample from existing payment modules. Link to comment Share on other sites More sharing options...
ed44rf Posted September 27, 2016 Author Share Posted September 27, 2016 can you give some code example because not clear here is another area of code with validateOrder public function execPayment($cart, $addtions) { global $cookie, $smarty; $currencies = $this->getCurrency(); $cny = null; $convert_cny = false; if (isset($currencies)) { foreach($currencies as $ccy) { if ($ccy['iso_code'] == 'CNY') $cny = $ccy; } } //如果购物车不是RMB,将其进行转换 $convert_ccy = false; $cart_ccy = new Currency($cart->id_currency); // if (isset($cny) && $cart_ccy->iso_code != 'CNY') { // error_log('update cart'); // $cookie->id_currency = (int)($cny['id_currency']); // $cart->id_lang = (int)($cookie->id_lang); // $cart->id_currency = (int)($cookie->id_currency); // $cart->update(); // $convert_ccy = true; // } $errors = array(); $form_params = $this->generateOrder($cart, $errors, $addtions); $params = array ( 'interface_type' => $this->interface, 'form_content' => $form_params, 'this_path' => $this->_path ); if ($convert_ccy) { $params['cart_ccy'] = $cart_ccy; } return $form_params; // $smarty->assign($params); // return $this->display(__FILE__, 'payment_execution.tpl'); } public function generateOrder($cart, &$errors, $addtions) { global $cookie, $smarty; if ($cart->id_customer != $cookie->id_customer) { die("Invalid request"); } $currency_order = new Currency(intval($cart->id_currency)); $currency_module = $this->getCurrency(); $assign_values['currency_order'] = $currency_order->iso_code; //$assign_values['currency_module'] = $currency_module->iso_code; //generate order before send to goopay $v_amount = Tools::ps_round(floatval($cart->getOrderTotal(true, 3)), 2); $assign_values['v_amount'] = $v_amount; //必填参数// $v_body = $this->getBody($cart); $v_logistics_fee = $cart->getOrderTotal(true, Cart::ONLY_SHIPPING); //物流费用,即运费。 $v_logistics_type = "EXPRESS"; //物流类型,三个值可选:EXPRESS(快递)、POST(平邮)、EMS(EMS) $v_logistics_payment = "BUYER_PAY"; //物流支付方式,两个值可选:SELLER_PAY(卖家承担运费)、BUYER_PAY(买家承担运费) $delivery_addr = new Address(intval($cart->id_address_delivery), 1); $id_order = Order::getOrderByCartId($cart->id); if ($id_order) { $order = new Order($id_order); } else { $this->validateOrder($cart->id, _PS_OS_PREPARATION_, $v_amount, $this->displayName, $this->l("Waiting for payment")); $order = new Order($this->currentOrder); $id_order = $this->currentOrder; } Link to comment Share on other sites More sharing options...
shokinro Posted September 28, 2016 Share Posted September 28, 2016 Here is very simple logic flow ==> Collect payment info like credit cart info from customer ==> Get order total and other required info from shopping cart and pass them to payment gateway via API $total = $cart->getOrderTotal(true, Cart::BOTH); ..... => Check the payment result if the payment success $this->validateOrder(....) // create order else show payment error. Link to comment Share on other sites More sharing options...
unused_username Posted January 12, 2017 Share Posted January 12, 2017 Greetings everyone! Do you know any payment module that doesn't require actual payment? So client will see his cart and a phone number to call us for checkout? Link to comment Share on other sites More sharing options...
shokinro Posted January 12, 2017 Share Posted January 12, 2017 You can just override payment select page to show a message and phone number. It does not need a module. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now