ornusweb Posted November 21, 2012 Share Posted November 21, 2012 Hello All, I have an issue setting the phone_mobile value to a variable which I want to call in a CURL method in the AuthController.php file. This is what I have tried: $mobilephone = (Tools::getValue('phone_mobile')); and I even tried getting the value by using: $customer->phone_mobile both attempts failed!! Could someone please tell me how to set the customer's mobile phone to a variable? Version: PrestaShop™ 1.4.7.3 Any help would be appreciated by this noob Link to comment Share on other sites More sharing options...
Alex Simonchik BelVG Posted November 21, 2012 Share Posted November 21, 2012 Hi, phone_mobile is not a value of the "Customer" class. You need to get customer address where you can use the phone_mobile value Regards 1 Link to comment Share on other sites More sharing options...
ornusweb Posted November 22, 2012 Author Share Posted November 22, 2012 You are a LIFE SAVER! thank you, That was a push in the right direction, I used $address->phone_mobile and it worked. Regards! BTW do you know how I can mark this topic as SOLVED? Link to comment Share on other sites More sharing options...
ornusweb Posted December 17, 2012 Author Share Posted December 17, 2012 Hey Alex, Could you please help me on how to fetch more variables? I have 3 different payment methods incorporated in the website. One of them is called EBS which allows payment via credit card. I would like to get the following variables called for this payment method. 1. customer's mobile number (I tried using the address class $address->phone_mobile; , but it didnt work) 2. customer's first and last name 3. customer's city and 4. total amount The EBS class extends the paymentmodule class however if i use the variables that work in the paymentmodule class, it doesn't work in the EBS class. Any ideas how I can get those variables? Thanks in advance! Link to comment Share on other sites More sharing options...
Alex Simonchik BelVG Posted December 17, 2012 Share Posted December 17, 2012 (edited) Hi again, what the method do you use? It is the "hookPayment" or ("hookPaymentReturn" or another)? Did you create new object $address = new Address(...) or use $this->address? Edited December 17, 2012 by Alexander Simonchik (see edit history) Link to comment Share on other sites More sharing options...
ornusweb Posted December 17, 2012 Author Share Posted December 17, 2012 For the EBS payment module, I am writing a curl where I need the variables under this function public function finalizeOrder($response) For the other 2 payment modules I am writing a curl where I need the variables under hookpaymentreturn, which is also not working. I need the same variables in all 3 modules. I have not created any new objects. Please let me know if you need to look at the code, I will attach it. Link to comment Share on other sites More sharing options...
Alex Simonchik BelVG Posted December 17, 2012 Share Posted December 17, 2012 (edited) Please let me know if you need to look at the code, I will attach it. And what is the finalizeOrder method? Is it your custom hook or maybe you invoke it via another defualt hook? I guess the code will help me to understand your problem Edited December 17, 2012 by Alexander Simonchik (see edit history) Link to comment Share on other sites More sharing options...
ornusweb Posted December 17, 2012 Author Share Posted December 17, 2012 Please see attached the EBS payment module file. the path of this file is /modules/EBS/ This is what I am trying to do, if the transaction goes through I want use a CURL method to send an SMS/text message to the customer and the client. So I am writing the CURL under the public function finalizeOrder($response) function. Thanks for your help! EBS.php Link to comment Share on other sites More sharing options...
Alex Simonchik BelVG Posted December 17, 2012 Share Posted December 17, 2012 Very strange... but where you invoke the finalizeOrder method? And what contains in the $response variable? Try to enable error_reporting in your dev server, your variable $address - it not undefined Link to comment Share on other sites More sharing options...
ornusweb Posted December 17, 2012 Author Share Posted December 17, 2012 finalizeorder method is used to capture the success or failure of a credit card payment from the payment gateway (bank). $response contains the number zero for success and 1 for failure. The SMS is being sent and I dont get a white screen, everything works except that in the SMS the variables value is blank. How do I turn on error reporting, I know I have to change something in /config/config-inc.php file. Link to comment Share on other sites More sharing options...
Alex Simonchik BelVG Posted December 17, 2012 Share Posted December 17, 2012 The best way is enable "developer mode" while you develop anywhere: error_reporting(E_ALL) ini_set('display_errors', 'on'); define('_PS_DEBUG_SQL_', TRUE); For getting address try the next code: $cart = new Cart(intval($response['MerchantRefNo'])); $address = new Address($cart->id_address_delivery); //OR $id_address_invoice for invoicing address print_r($address->phone_mobile); // now you can use it 1 Link to comment Share on other sites More sharing options...
ornusweb Posted December 17, 2012 Author Share Posted December 17, 2012 These lines are already in the file $address = new Address(intval($cart->id_address_invoice)); $ship_address = new Address(intval($cart->id_address_delivery)); //echo "<pre>";print_r($ship_address);echo "</pre>"; And print_r($address->phone_mobile); will only give me mobile number, I also need name and total amount, how do write that? any suggestions. Link to comment Share on other sites More sharing options...
Alex Simonchik BelVG Posted December 17, 2012 Share Posted December 17, 2012 For get lastname use it: $address->lastname for firstname: $address->firstname for amount: $order_id = Order::getOrderByCartId($cart->id); $order = new Order($order_id); print_r($order->total_paid) Link to comment Share on other sites More sharing options...
ornusweb Posted December 17, 2012 Author Share Posted December 17, 2012 When I print to check all of these variables print the correct value: $ship_address->phone_mobile $ship_address->firstname $ship_address->lastname $ship_address->city $amount but when I use them within another variable it doesnt work: $smsmsg .= "Dear%20$ship_address->firstname,%20your%20order%20of%20Rs.%20$amount,%20has%20been%20placed.%20Please%20call%20us%20on%20%2B919757143570%20if%20you%20have%20any%20questions.%20Regards,%20Team%20Aligns%20Health"; I even tried this: $smsmsg .= "Dear%20".$ship_address->firstname.",%20your%20order%20of%20Rs.%20".$amount.",%20has%20been%20placed.%20Please%20call%20us%20on%20%2B919757143570%20if%20you%20have%20any%20questions.%20Regards,%20Team%20Aligns%20Health"; This is what is happening, when the order is confirmed, the user is redirected to the payment gateway website (3rd party) and on completion of the transaction is redirected to the presta site and based on the $response a message is shown. Link to comment Share on other sites More sharing options...
Alex Simonchik BelVG Posted December 17, 2012 Share Posted December 17, 2012 Are you sure that you print_r this variables inside the same method? 1 Link to comment Share on other sites More sharing options...
ornusweb Posted December 17, 2012 Author Share Posted December 17, 2012 Sorry! I actually printed them in another method: public function execPayment($cart) This is where I want to use the variables and they are not working public function finalizeOrder($response){ global $smarty, $cart, $cookie; require(dirname(__FILE__).'/Rc43.php'); $DR=$response; $secret_key = Configuration::get('SECRET_KEY'); if(isset($DR)){ $DR = preg_replace("/\s/","+",$DR); $rc4 = new Crypt_RC4($secret_key); $QueryString = base64_decode($DR); $rc4->decrypt($QueryString); $QueryString = split('&',$QueryString); $response = array(); foreach($QueryString as $param){ $param = split('=',$param); $response[$param[0]] = urldecode($param[1]); } } $cartID=$response['MerchantRefNo']; //echo "<pre>";print_r($response);echo "</pre>"; if($response['ResponseCode'] == 0) {$responseMsg="Your Order has Been Processed"; //THIS IS WHERE I WANT MY CURL TO USE THE VARIABLES } else $responseMsg="Transaction Failed, Retry!!"; $cart = new Cart(intval($response['MerchantRefNo'])); if($response['ResponseCode'] == 0) $status= Configuration::get('EBS_ID_ORDER_SUCCESS'); else $status=Configuration::get('EBS_ID_ORDER_FAILED'); $this->validateOrder($response['MerchantRefNo'], $status, $response['Amount'], $this->displayName, $this->l('EBS transaction ID: ') . $response['PaymentID'], $response['ResponseMessage']); $smarty->assign(array('this_path' => $this->_path, 'responseMsg' => $responseMsg, 'this_path_ssl' => (Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://').htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8').__PS_BASE_URI__.'modules/'.$this->name.'/' )); } Link to comment Share on other sites More sharing options...
Alex Simonchik BelVG Posted December 17, 2012 Share Posted December 17, 2012 (edited) What is the variables don't working in the "finalizeOrder" method? Mark it lines with comment Edited December 17, 2012 by Alexander Simonchik (see edit history) Link to comment Share on other sites More sharing options...
ornusweb Posted December 17, 2012 Author Share Posted December 17, 2012 Sorry, I was not defining the cart and address in the finalizeOrder method. I did that by adding these lines: $cart = new Cart(intval($response['MerchantRefNo'])); $paidamount = $cart->getOrderTotal(true, Cart::BOTH); $address = new Address(intval($cart->id_address_invoice)); $ship_address = new Address(intval($cart->id_address_delivery)); Now I am getting all variables I want and the CURL is working seamlessly. Thanks Alex for your great help! I am now going to try to do the same in the other 2 payment modules. I will let you know if I get stuck thanks again!!!! Link to comment Share on other sites More sharing options...
Alex Simonchik BelVG Posted December 17, 2012 Share Posted December 17, 2012 OK, I really glad to hear it. Link to comment Share on other sites More sharing options...
ornusweb Posted December 18, 2012 Author Share Posted December 18, 2012 I am getting stuck on the other 2 payment modules cash on delivery and bankwire. I want to add my CURL to the method public function hookPaymentReturn($params) I am defining the cart and address like this: $cart = new Cart($params['cookie']->id_cart); $paidamount = $cart->getOrderTotal(true, Cart::BOTH); $address = new Address(intval($cart->id_address_invoice)); $ship_address = new Address(intval($cart->id_address_delivery)); But the variables are not working! any ideas why? I have attached the bankwire.php bankwire.php Link to comment Share on other sites More sharing options...
Alex Simonchik BelVG Posted December 18, 2012 Share Posted December 18, 2012 (edited) Hi, into function hookPaymentReturn variable $params contains the next data: Hook:paymentReturn() $cart = new Cart((int)$order->id_cart); $params['total_to_pay'] = $cart->getOrderTotal(); $params['currency'] = $currency->sign; $params['objOrder'] = $order; $params['currencyObj'] = $currency; return Hook::exec('paymentReturn', $params, (int)($id_module)); But you tried use $params['cookie']->id_cart. I recommend you using $params['objOrder']->id_cart Regards Edited December 18, 2012 by Alexander Simonchik (see edit history) Link to comment Share on other sites More sharing options...
ornusweb Posted December 19, 2012 Author Share Posted December 19, 2012 Your recommendation worked my friend, thanks a ton!!! 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