Jump to content

set mobile phone as a variable in AuthController.php


ornusweb

Recommended Posts

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 :P

Link to comment
Share on other sites

  • 4 weeks later...

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

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

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

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

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

  • Like 1
Link to comment
Share on other sites

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

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

<_< 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

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

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

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 by Alexander Simonchik (see edit history)
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...