Magento SOAP login error - magento

I have configured Magento SOAP api to connect it with my android app, customers can login from android app into magento. The problem I am facing is when I send the request it shows the error - "Session expired".
this is my API.php file
<?php
// app/code/local/Anaqa/Customapimodule/Model/Login/Api.php
class Anaqa_Customapimodule_Model_Customerlogin_Api extends Mage_Api_Model_Resource_Abstract {
public function customerEntry($email) {
#Mage::app()->setCurrentStore($website);
# // Init a Magento session. This is super ultra important
#Mage::getSingleton('core/session');
// $customer Mage_Customer_Model_Customer
// We get an instance of the customer model for the actual website
$customer = Mage::getModel('customer/customer')
->setWebsiteId(Mage::app()->getStore()->getWebsiteId());
// Load the client with the appropriate email
$customer->loadByEmail($email);
return $customer;
}
/*
ini_set("soap.wsdl_cache_enabled", "0");
$client = new SoapClient('http://magentohost/api/soap/?wsdl', array('cache_wsdl' => WSDL_CACHE_NONE));
$session = $client->login('apiUser', 'apiKey');
$result = $client->call($session, 'product.list');
$client->endSession($session);
Mage::app()->setCurrentStore($website);
// Init a Magento session. This is super ultra important
Mage::getSingleton('core/session');
// $customer Mage_Customer_Model_Customer
// We get an instance of the customer model for the actual website
$customer = Mage::getModel('customer/customer')
->setWebsiteId(Mage::app()->getStore()->getWebsiteId());
// Load the client with the appropriate email
$customer->loadByEmail($email);
// Get a customer session
$session = Mage::getSingleton('customer/session');
$session->loginById($customer->getId());
if ($session->isLoggedIn()) {
return $session->getSessionId();
} else {
return null;
}
} */
}

I would use the customer/session model to access the customer.
$sessionCustomer = Mage::getSingleton('customer/session');
if($sessionCustomer->isLoggedIn()) {
$customer = Mage::getSingleton('customer/session')->getCustomer();
The wrinkle here is in order for magento to access the session data it needs to know the customer is logged in, otherwise you won't be able to return the customer data with the session data.

Related

How to generate PayPal order pay link to email

I'm trying to generate PayPal link to email, where user can pay for their order later. I'am using paypal/rest-api-sdk-php. For example using this route:
Route::get('/order/pay/{hash}', 'Frontend\PaymentController#orderPay')->name('order.pay');
My code for payment creation works (see code). When user cancel the payment or payment is unsuccessful, how can I return to the incomplete transaction and try to pay for it again? Should I create new payment everytime user goes to order pay route? Or can I simply identify the incomplete transaction in PayPal and redirect to some(?) PayPal link then?
use PayPal\Api\Payer;
use PayPal\Api\Item;
use PayPal\Api\ItemList;
use PayPal\Api\Details;
use PayPal\Api\Amount;
use PayPal\Api\Transaction;
use PayPal\Api\RedirectURLs;
use PayPal\Api\Payment;
/*
* #param \App\Order $order
* #return string
*/
public function createPayment($order)
{
$transaction = $this->getTransactionByOrderHash($order->hash);
if ($transaction) {
if ($transaction->is_refunded) {
return 'Paymant has already been refunded';
}
if ($transaction->is_payed) {
return 'Paymant has already been payed';
}
}
$price = $order->to_pay;
$currencyCode = $order->currency->iso_code;
try {
$payer = new Payer();
$payer->setPaymentMethod('paypal');
$item = new Item();
$item
->setName(__('invoice.pfa_title'))
->setCurrency($currencyCode)
->setQuantity(1)
->setSku($order->vs)
->setPrice($price);
$itemList = new ItemList();
$itemList->setItems([$item]);
$details = new Details();
$details
->setShipping(0)
->setTax(0)
->setSubtotal($price);
$amount = new Amount();
$amount
->setCurrency($currencyCode)
->setTotal($price)
->setDetails($details);
$transaction = new Transaction();
$transaction
->setAmount($amount)
->setItemList($itemList)
->setInvoiceNumber(uniqid());
$redirectUrls = new RedirectUrls();
$redirectUrls
->setReturnUrl(route('paypal.success', $order->hash))
->setCancelUrl(route('paypal.cancel'));
$payment = new Payment();
$payment
->setIntent('sale')
->setPayer($payer)
->setRedirectUrls($redirectUrls)
->setTransactions([$transaction]);
$payment->create($this->apiContext);
$approvalUrl = $this->getApprovalUrl($payment);
if ($approvalUrl) {
session([
'approval_url' => $approvalUrl,
'transaction_id' => $payment->getId(),
]);
return 'payment was successful';
}
} catch (PayPalConnectionException $ex) {
return json_decode($ex->getData());
} catch (Throwable $e) {
return $e->getMessage();
}
return 'payment was unsuccessful';
}
Why use the deprecated v1/payments PayPal-PHP-SDK, instead of the current v2/checkout/orders Checkout-PHP-SDK ?
In any case, yes you can create a new Payment/Order object everytime the customer attempts a checkout. Just set the invoice_id field to your own same but unique invoice/order number for the thing that customer is paying for, so that if the customer does happen to be trying to make a duplicate payment attempt for such a # that has already resulted in a successful transaction on your PayPal account before, it will be blocked by default (according to your PayPal account settings)

send transactional email magento

I'm trying to send a confirmation email when a subscription order is created in magento but is not sending anything.
i know email configuration its fine because when i buy a regular product i do receive the email.
i created a template on System -> Transactional Emails , template with id=12, then on code on class AW_Sarp2_Model_Checkout_Type_Onepage extends Mage_Checkout_Model_Type_Onepage i call to send subs email method but it never sends any email
class AW_Sarp2_Model_Checkout_Type_Onepage extends Mage_Checkout_Model_Type_Onepage
{
public function saveOrder()
{ Mage::log("checkout/onepage",null,"onepageemail.log");
$isQuoteHasSubscriptionProduct = Mage::helper('aw_sarp2/quote')->isQuoteHasSubscriptionProduct(
$this->getQuote()
);
if (!$isQuoteHasSubscriptionProduct) //HERE I ASK IF IS A SUBSCRIBE PRODUCT {Mage::log("checkout/onepage34",null,"onepageemail.log");
return parent::saveOrder();
}
$this->validate();
$isNewCustomer = false;
switch ($this->getCheckoutMethod()) {
case self::METHOD_GUEST:Mage::log("checkout/onepage40",null,"onepageemail.log");
$this->_prepareGuestQuote();
break;
case self::METHOD_REGISTER:Mage::log("checkout/onepage43",null,"onepageemail.log");
$this->_prepareNewCustomerQuote();
$isNewCustomer = true;
break;
default:Mage::log("checkout/onepage47",null,"onepageemail.log");
$this->_prepareCustomerQuote();
break;
}
if ($this->getQuote()->getCustomerId()) {Mage::log("checkout/onepage52",null,"onepageemail.log");
$this->getQuote()->getCustomer()->save();
}
#AW_SARP2 override start
$service = Mage::getModel('aw_sarp2/sales_service_profile', $this->getQuote());Mage::log("checkout/onepage56",null,"onepageemail.log");
$service->submitProfile();Mage::log("checkout/onepage57",null,"onepageemail.log");
#AW_SARP2 override end
$this->getQuote()->save();Mage::log("checkout/onepage60",null,"onepageemail.log");
if ($isNewCustomer) {Mage::log("checkout/onepage61",null,"onepageemail.log");
try {
$this->_involveNewCustomer();Mage::log("checkout/onepage63",null,"onepageemail.log");
} catch (Exception $e) {
Mage::logException($e);
}
}
$this->_checkoutSession->setLastQuoteId($this->getQuote()->getId())
->setLastSuccessQuoteId($this->getQuote()->getId())
->clearHelperData();Mage::log("checkout/onepage71",null,"onepageemail.log");
// add recurring profiles information to the session
$profiles = $service->getRecurringPaymentProfiles();Mage::log("checkout/onepage73",null,"onepageemail.log");
if ($profiles) {Mage::log("checkout/onepage74",null,"onepageemail.log");
$ids = array();
foreach ($profiles as $profile) {
$ids[] = $profile->getId();
}Mage::log("checkout/onepage78",null,"onepageemail.log");
$this->sendSubscribeEmail2();Mage::log("checkout/onepage79",null,"onepageemail.log");
$this->_checkoutSession->setLastRecurringProfileIds($ids);
Mage::log("checkout/onepage82",null,"onepageemail.log");
}
return $this;
}
public function sendSubscribeEmail2(){ //HERE I TRY TO SEND THE EMAIL
$templateId = 12;
// Set sender information
$senderName = Mage::getStoreConfig('trans_email/ident_support/name');
$senderEmail = Mage::getStoreConfig('trans_email/ident_support/email');
$sender = array('name' => $senderName,
'email' => $senderEmail);
// Set recepient information
$recepientEmail = 'minorandres#gmail.com';
$recepientName = 'Test Test';
// Get Store ID
$storeId = Mage::app()->getStore()->getId();
// Set variables that can be used in email template
$vars = array('customerName' => 'test',
'customerEmail' => 'minorandres#gmail.com');
$translate = Mage::getSingleton('core/translate');Mage::log("checkout/onepage103",null,"onepageemail.log");
// Send Transactional Email
Mage::getModel('core/email_template')
->sendTransactional($templateId, $sender, $recepientEmail, $recepientName, $vars, $storeId);Mage::log("checkout/onepage106",null,"onepageemail.log");
if (!Mage::getModel('core/email_template')->getSentSuccess()) {
Mage::log("EXCEPTION!!!! =( checkout/onepage107",null,"onepageemail.log");
}
is there something in xml files that i have to do or other place?, please help me
Since i am dealing with subscription products they are handle by a different SMTP provider, on the exception.log i got and error "Mandril cant send email" something like that then i went to Admin Panel and under system>transactional emails has a subtab called mandril i configured that tool and create an account on mandril, then i put the API key indicaded by mandril into system>configuration>mandril(on left side).

Magento User Sub-Accounts for Impersonation

I have a requirement for a Magento project that accounts are hierarchical. That is one account can "own" multiple other accounts. If one account owns another account it is allowed to impersonate that account: create orders, view account information, and view previous orders.
I'm not sure where to begin. If you have any thoughts, could you please point me in the right direction?
One solution would be to set up a Multiple Select attribute and populate it with the user ids of the users allowed to impersonate. You could then create either a separate php file that runs magento and logs in the user based on who they select, or integrate it into the cms.
Here is my custom 'login' code that lets my sso users from my Microsoft Database login to magento.
You call this function and pass it a 'user' you want to login as. Seems to work pretty well, however you will need to modify it to your needs. Don't expect it to work out of the box!
FYI: if you don't pass in all the junk that magento needs about the dispatchevents() then the user will not login properly. I had to reverse engineer this whole dern thing, so don't expect to see it anywhere else besides here and bits and pieces of magento core :)
$userId = 5;
$user = Mage::getModel('customer/customer')->load($userId)->setWebsiteId(1);
$this->LoginToMagento($user, null);
function LoginToMagento($user, $noAddress) {
// Must include this file in order to use the object
include ('/var/www/app/code/core/Mage/Customer/controllers/AccountController.php');
// Configure Magento to think its using the frontend
Mage::getSingleton("core/session", array("name" => "frontend"));
Mage::getConfig()->init();
Mage::getConfig()->loadEventObservers('frontend');
Mage::app()->addEventArea('frontend');
Mage::app()->loadArea(Mage_Core_Model_App_Area::AREA_FRONTEND);
// Grab the request and modify it with my emulated controller's information
$request = Mage::app()->getRequest();
$request->setRouteName('customer');
$request->setControllerModule('Mage_Customer');
$request->setRoutingInfo('');
$request->setModuleName('customer');
$request->setControllerName('account');
$request->setModuleKey('module');
$request->setControllerKey('account');
$request->setActionName('loginPost');
$request->setActionKey('action');
// Grab the response
$response = Mage::app()->getResponse();
// Feed the request and response into a new accountcontroller object
$accountControl = new Mage_Customer_AccountController($request, $response);
// Dispatch events related to the controller actions for predispatch
Mage::dispatchEvent('controller_action_predispatch', array('controller_action' => $accountControl));
Mage::dispatchEvent('controller_action_predispatch_customer', array('controller_action' => $accountControl));
Mage::dispatchEvent('controller_action_predispatch_customer_account_loginPost', array('controller_action' => $accountControl));
// Grab an instance of the customer session model
$session = Mage::getSingleton('customer/session');
try{
// Attempt to login the user
$session->setCustomerAsLoggedIn($user);
$session->renewSession();
} catch (Mage_Core_Exception $e) {
// Lets hope to never get here
$message = $e->getMessage();
error_log($message);
Mage::getSingleton('core/session')->addError($message);
}
// Perform the postdispatch events for 'after emulation of the controller'
Mage::dispatchEvent('controller_action_postdispatch_customer_account_loginPost', array('controller_action'=>$accountControl));
Mage::dispatchEvent('controller_action_postdispatch_customer', array('controller_action'=>$accountControl));
Mage::dispatchEvent('controller_action_postdispatch', array('controller_action'=>$accountControl));
$customer = Mage::getModel('customer/customer')
->getCollection()
->addAttributeToSelect('*')
->addAttributeToFilter('entity_id', array('eq' => $user->getId()))
->getFirstItem();
try
{
// Prepare a collection of required values that the customer *should* have been set from netforum
$collection = Mage::getModel('eav/entity_attribute')->getCollection();
$collection->addFieldToFilter('entity_type_id', Mage::getModel('eav/entity')->setType('customer')->getTypeId());
// The var representing if validation has failed
$failedReq = false;
// Loop through each user defined required attribute and if we find one
// on the customer that is not set, forward the user to their account config page
foreach ($collection as $attribute)
{
if ($attribute['is_required'] && $attribute['is_user_defined'])
{
$attrCode = $attribute['attribute_code'];
if (!isset($customer[$attrCode]))
{
$failedReq = true;
}
}
}
// Try to determine where we logged in from (URL)
Mage::getSingleton("core/session", array("name" => "frontend"));
$session = Mage::getSingleton("customer/session");
$outputMessage = $session->getData('before_auth_url');
// Proceeed differently based on the existence of addresses
if ($noAddress == true)
{
if ($failedReq)
{
// Customer failed login. To be expected if they are signing in with SSO and never have before
$redirect_to = 'https://' . $_SERVER['HTTP_HOST'] . '/customer/account/edit/';
Mage::getSingleton('core/session')->addError('<b>Please fill in the required fields marked with * and click "Save"</b>');
header("Location: $redirect_to");
}
else
{
// Customer checks out ok, but has no addresses. Send them to the address setup screen
Mage::getSingleton('core/session')->addError('<b>Please fill in your address and phone number, then click "Save"</b>');
$redirect_to = 'https://' . $_SERVER['HTTP_HOST'] . '/customer/address/edit/';
header("Location: $redirect_to");
}
}
else
{
// Customer has addresses being passed from SSO
$defaultBillingId = $customer->getDefaultBillingAddress()->getId();
$hasPhoneNumber = false;
foreach ($customer->getAddresses() as $address)
{
$addrs = Mage::getModel('customer/address')->load($address->getId());
$magePhone = $addrs->getTelephone();
if ($magePhone)
{
$hasPhoneNumber = true;
}
}
if ($failedReq)
{
// Customer failed login. To be expected if they are signing in with SSO and never have before
$redirect_to = 'https://' . $_SERVER['HTTP_HOST'] . '/customer/account/edit/';
Mage::getSingleton('core/session')->addError('<b>Please fill in the required fields marked with * and click "Save"</b>');
header("Location: $redirect_to");
}
else
{
// Customer is has default values filled out
if (!$hasPhoneNumber)
{
// Phone number is missing for an address so redirect there and force em to enter it.
Mage::getSingleton('core/session')->addError('<b>Please fill in the required fields marked with * and click "Save Address"</b>');
$redirect_to = 'https://' . $_SERVER['HTTP_HOST'] . '/customer/address/edit/id/' . $defaultBillingId;
header("Location: $redirect_to");
}
else
{
// Everything is ok, so just try to send them back to where they came from, or the account screen
if ($outputMessage)
{
$redirect_to = $outputMessage;
}
else
{
$redirect_to = 'https://' . $_SERVER['HTTP_HOST'] . '/customer/account/';
}
header("Location: $redirect_to");
}
}
}
}
catch (Exception $e)
{
if ($outputMessage)
{
$redirect_to = $outputMessage;
}
else
{
$redirect_to = 'https://' . $_SERVER['HTTP_HOST'] . '/customer/account/';
}
header("Location: $redirect_to");
}
}
I know I am late but
http://amasty.com/sales-reps-and-dealers.html
This extension can be helpful to achieve what you are looking for. It will allow to create hierarchical accounts and assign the sales rep/sub admins to the orders and provide the access levels.
Hope this helps.

Updating customer data from observer after customer_register_success event

Having issues setting the customers group id from an observer. The event is picking up on a new user creation via customer_register_success event. The event is passed to my observer, e.g.
public function registrationSuccess(Varien_Event_Observer $observer) {
// extract customer data from event
$customer = $observer->getCustomer()->getData();
Mage::log('COOKIES', json_encode($_COOKIE));
// a cookie should have been set with the membership id
if (isset($_COOKIE['membership_account_id'])) {
Mage::log('COOKIE SET, ASSOCIATING MEMBERSHIP');
// associate new account with membership, and upgrade user to membership status
$this->associateMembership($customer['entity_id'], $_COOKIE['membership_account_id']);
}
}
Which then calls the associateMembership method to update the group id, and set a custom customer attribute called rms_id:
public function associateMembership($customer_id, $account_id) {
// load customer model
$customer = Mage::getModel('customer/customer')->load($customer_id);
Mage::log('CUSTOMER DATA: ' . json_encode($customer->toArray()));
// upgrade customer to membership level, and set custom rms_id attribute
$customer
->setWebsiteId(Mage::app()->getWebsite()->getId())
->setGroupId(4)
->setRmsId($account_id);
// save
try {
$customer->save();
Mage::log('ACCOUNT ASSOCIATED: CUSTOMER ID = ' . $customer_id . ' ACCOUNT ID = ' . $account_id);
} catch (Exception $ex) {
Mage::log($ex);
}
}
For some reason, there's no error coming back. I'm getting the correct user id, and everything seems to be working. However, the group is not being set, nor is my custom id.
Should I be using another event that will allow the save to go through?
Try loading the website id before loading the customer
$customer = Mage::getModel('customer/customer')
$customer->setWebsiteId(Mage::app()->getWebsite()->getId());
$customer->load($customer_id);
customer_register_success will re-save the customer data after you save it in your custom observer
Also customer_register_success pass the customer data so you should not need to reload it.
see /app/code/core/Mage/Customer/controllers/AccountController.php
Mage::dispatchEvent('customer_register_success',
array('account_controller' => $this, 'customer' => $customer)
);
Try
public function registrationSuccess(Varien_Event_Observer $observer) {
// extract customer data from event
$customer = $observer->getCustomer();
Mage::log('COOKIES', json_encode($_COOKIE));
// a cookie should have been set with the membership id
if ($membership_account_id = Mage::getModel('core/cookie')->get('membership_account_id')) {
Mage::log('COOKIE SET, ASSOCIATING MEMBERSHIP');
$customer->setGroupId(4)
->setRmsId($membership_account_id);
}
return $this;
}
Try to set customer website id before load.
e.g.
$customer = Mage::getModel('customer/customer')
->setWebsiteId(Mage::app()->getWebsite()->getId())
->load($customer_id);
Also try to put die; after $customer->save(); while testing - in such case you will be sure that nothing else changes customers data after you (may be some other observer).

magento redirect checkout payment to a 3rd party gateway

I am trying to implement my new payment method its working fine. But My requirement is little bit different. I need to redirect user to the payment gateway page. This is how I am trying to implement.
When user clicks on Place Order my Namespace_Bank_Model_Payment >> authorize method gets called. My gateway Says send an initial request, Based on details given gateway send a URL & Payment id. On this Url user must be redirected Where customer actually makes the payment. I have two actions in Controller success & error to handle the final response.
As, this code is getting called in an ajax request, I can't redirect user to another website. Can anybody guide me how to accomplish it?
Here is my code. I Have implemented getOrderPlaceRedirectUrl() method.
Here is my class::
<?php
class Namespace_Hdfc_Model_Payment extends Mage_Payment_Model_Method_Abstract
{
protected $_isGateway = true;
protected $_canAuthorize = true;
protected $_canUseCheckout = true;
protected $_code = "hdfc";
/**
* Order instance
*/
protected $_order;
protected $_config;
protected $_payment;
protected $_redirectUrl;
/**
* #return Mage_Checkout_Model_Session
*/
protected function _getCheckout()
{
return Mage::getSingleton('checkout/session');
}
/**
* Return order instance loaded by increment id'
*
* #return Mage_Sales_Model_Order
*/
protected function _getOrder()
{
return $this->_order;
}
/**
* Return HDFC config instance
*
*/
public function getConfig()
{
if(empty($this->_config))
$this->_config = Mage::getModel('hdfc/config');
return $this->_config;
}
public function authorize(Varien_Object $payment, $amount)
{
if (empty($this->_order))
$this->_order = $payment->getOrder();
if (empty($this->_payment))
$this->_payment = $payment;
$orderId = $payment->getOrder()->getIncrementId();
$order = $this->_getOrder();
$billingAddress = $order->getBillingAddress();
$tm = Mage::getModel('hdfc/hdfc');
$qstr = $this->getQueryString();
// adding amount
$qstr .= '&amt='.$amount;
//echo 'obj details:';
//print_r(get_class_methods(get_class($billingAddress)));
// adding UDFs
$qstr .= '&udf1='.$order->getCustomerEmail();
$qstr .= '&udf2='.str_replace(".", '', $billingAddress->getName() );
$qstr .= '&udf3='.str_replace("\n", ' ', $billingAddress->getStreetFull());
$qstr .= '&udf4='.$billingAddress->getCity();
$qstr .= '&udf5='.$billingAddress->getCountry();
$qstr .= '&trackid='.$orderId;
// saving transaction into database;
$tm->setOrderId($orderId);
$tm->setAction(1);
$tm->setAmount($amount);
$tm->setTransactionAt( now() );
$tm->setCustomerEmail($order->getCustomerEmail());
$tm->setCustomerName($billingAddress->getName());
$tm->setCustomerAddress($billingAddress->getStreetFull());
$tm->setCustomerCity($billingAddress->getCity());
$tm->setCustomerCountry($billingAddress->getCountry());
$tm->setTempStatus('INITIAL REQUEST SENT');
$tm->save();
Mage::Log("\n\n queryString = $qstr");
// posting to server
try{
$response = $this->_initiateRequest($qstr);
// if response has error;
if($er = strpos($response,"!ERROR!") )
{
$tm->setErrorDesc( $response );
$tm->setTempStatus('TRANSACTION FAILED WHILE INITIAL REQUEST RESPONSE');
$tm->save();
$this->_getCheckout()->addError( $response );
return false;
}
$i = strpos($response,":");
$paymentId = substr($response, 0, $i);
$paymentPage = substr( $response, $i + 1);
$tm->setPaymentId($paymentId);
$tm->setPaymentPage($paymentPage);
$tm->setTempStatus('REDIRECTING TO PAYMENT GATEWAY');
$tm->save();
// prepare url for redirection & redirect it to gateway
$rurl = $paymentPage . '?PaymentID=' . $paymentId;
Mage::Log("url to redicts:: $rurl");
$this->_redirectUrl = $rurl; // saving redirect rl in object
// header("Location: $rurl"); // this is where I am trying to redirect as it is an ajax call so it won't work
//exit;
}
catch (Exception $e)
{
Mage::throwException($e->getMessage());
}
}
public function getOrderPlaceRedirectUrl()
{
Mage::Log('returning redirect url:: ' . $this->_redirectUrl ); // not in log
return $this->_redirectUrl;
}
}
Now getOrderPlaceRedirectUrl() its getting called. I can see the Mage::log message. but the url is not there. I mean the value of $this->_redirectUrl is not there at the time of function call.
And one more thing, I am not planning to show customer any page like "You are being redirected".
Magento supports this type of payment gateway as standard and directly supports redirecting the user to a third party site for payment.
In your payment model, the one that extends Mage_Payment_Model_Method_Abstract, you'll need to implement the method:
function getOrderPlaceRedirectUrl() {
return 'http://www.where.should.we.pay.com/pay';
Typically you redirect the user to a page on your site, /mymodule/payment/redirect for example, and then handle the redirection logic in the action of the controller. This keeps your payment model clean and stateless, while allowing you to some some kind of "You are now being transferred to the gateway for payment" message.
Save everything you need to decide where to redirect to in a session variable, again typically Mage::getSingleton('checkout/session').
Magento have a pretty solid, if messy, implementation of this for Paypal standard. You can checkout how they do it in app/code/core/Mage/Paypal/{Model/Standard.php,controllers/StandardController.php}.
Hello guys here is solution.
In authorize function (see my code in above answer) change
$this->_redirectUrl = $rurl;
by Mage::getSingleton('customer/session')->setRedirectUrl($rurl);
& in function getOrderPlaceRedirectUrl() change it to like
public function getOrderPlaceRedirectUrl()
{
Mage::Log('returning redirect url:: ' . Mage::getSingleton('customer/session')->getRedirectUrl() );
return Mage::getSingleton('customer/session')->getRedirectUrl(); ;
}
after that code must be running & u'll be getting redirected to the third party gateway

Resources