Hi Arvydas,

Yes, I had already met these two conditions before. Not sure why it was returning iSuccess=3. It seems to be happening on and off, I am not able to understand why.

I also have some questions about the approach you showed:

1. Once the transaction is complete on alertpay, it will redirect to a new URL that you specify. One issue is that this URL cannot have any parameters of its own. Therefore, sending it to a URL like http://oxid.localhost/index.php?cl=order&fnc=processalertPay&sid=xx does not work

I have worked around this right now by creating a static script in the OXID root directory and making that script internally do the redirect. However this is not a great solution. I was wondering if I could instead use the OXID SEO engine to create a 'virtual' URL for this ie. http://oxid.localhost/alertpay_success which redirects to above. If I do this, what values do I give for the oxobjectid and oxident fields?

2. Once the redirection to alertpay happens, there are 3 possible results:
User payment succeeds
User payment fails
User cancels operation

In these cases, I want to redirect back to either the 'thankyou' page or the 'choose payment method' page with an error message. For the payment method page, I guess I can redirect to http://oxid.localhost/index.php?cl=payment&payerror=4, but how do I display a custom error message? And in the case of success, what is the URL to display the thank you page?

Vikram


Arvydas wrote:
it is executed, at least on my pc I enabled its execution, but here is two conditions:

1. create some user with existing email, do not use admin
2. when you create payment, please change its oxid field value (use php my admin) to "alertpay" and check its setup (group, country assignment, delivery set config)




--------------------------------------------------
From: "Vikram Vaswani" <[email protected]>
Sent: Monday, August 17, 2009 10:51 AM
To: <[email protected]>
Subject: Re: [oxid-dev-general][Fwd: Re:Urgent questiononpaymentgatewayintegration]> Hi Arvydas,

We spoke about this some time ago. I tried using the code you sent below, but when I click the final 'submit order' button, the new module _getNextStep() method never gets executed.

I checked and the new class has been set up correctly in admin and it is being instantiated correctly by OXID. I then added a breakpoint and realized that it is because $iSuccess is always 3 and so the _getNextStep() method is never executed. Any idea why this could be happening?

Vikram

Arvydas wrote:
Here is what you need:

1. forget oxPaymentGateway::executePayment() - in your case you don't need it at all;
2. make a module for order with these:

<?php
   // set payment method as active
   protected $_blActive = true;

   // set Alertpay merchant name
   protected $loginId = 'XXX';

   // set Alertpay gateway URL
   protected $gatewayUrl = 'https://www.alertpay.com/PayProcess.aspx';

   protected function _getNextStep( $iSuccess )
   {
       // defining that everything was fine
       if ( is_numeric( $iSuccess ) && $iSuccess > 0 && $iSuccess < 2 )
           $oOrder = oxNew( 'oxorder' );
if ( $oOrder->load( $this->getOrderId() ) && $oOrder->oxorder__oxpaymenttype->value == 'alertpay' ) {
               // your code goes here
               $oCur = $this->getConfig()->getActShopCurrencyObject();

               $formData = array(
                   'ap_purchasetype'   => 'item-goods',
                   'ap_merchant'       => $this->loginId,
                   'ap_currency'       => $oCur->name,
                   'ap_quantity'       => '1',
'ap_returnurl' => 'http://oxid.localhost/index.php?cl=order&fnc=processalertPay&sid=' . $this->getSession()->getId(),
                   'ap_itemname'       => 'Shopping Cart',
'ap_description' => $this->getConfig()->getActiveShop()->oxshops__oxname->value,
                   'ap_amount'         => $dAmount,
'ap_cancelurl' => 'http://oxid.localhost/index.php?cl=payment&payerror=4&sid=' . $this->getSession()->getId(),
                   'apc_1'             => $this->getSession()->getId(),
                 );

oxUtils::getInstance()->redirect( $this->gatewayUrl . http_build_query( $formData ) );
           }
       }

if ( $iSuccess === 'AlertPayOK' && $oOrder->load( $this->getOrderId() ) ) {
           // you load order here and set its status to OK
$oOrder->oxorder__oxtransstatus = new oxField( "PAYMENT_OK" );

           //saving
           $oOrder->save();

           // check code below
           // means emailing succeded
           $iSuccess = $oOrder->sendAlertPayEmails();

       } elseif ( $iSuccess === 'AlertPayERROR' ) {
// you set this code to move user back to payment selection page // or you can simply return NULL and user will stay in order confirmation page
           $iSuccess = 2;

       }

       return parent::_getNextStep( $iSuccess );
   }

   public function processAlertPay()
   {
// this function will be called when ap_returnurl will be executed // so now you can check response parameters and do all other you need

       // on success you set
       $iSuccess = 'AlertPayOK';

       // on error you set
       $iSuccess = 'AlertPayERROR';

       // set

       // you will be redirected now where needed..
       return $this->_getNextStep( $iSuccess )
   }

   public function getOrderId()
   {
       return oxSession::getVar( 'sess_challenge' );
   }
?>

3. additionally you need to handle email sending - oxOrder::_sendOrderByEmail(), and send emails only when everything went file:
<?php
protected function _sendOrderByEmail( $oUser = null, $oBasket = null, $oPayment = null )
   {
       if ( $this->oxorder__oxpaymenttype->value != 'alertpay') {
return parent::_sendOrderByEmail( $oUser, $oBasket, $oPayment );
       }

       return 1;
   }

   public function sendAlertPayEmails()
   {
       ...
return $this->_sendOrderByEmail( $oUser = null, $oBasket = null, $oPayment = null )
   }

4. I did not check the code, probably errors contain.. but the idea should be clear! ;)

where should I send my paypal account data? :D
_______________________________________________
dev-general mailing list
[email protected]
http://dir.gmane.org/gmane.comp.php.oxid.general

_______________________________________________
dev-general mailing list
[email protected]
http://dir.gmane.org/gmane.comp.php.oxid.general

_______________________________________________
dev-general mailing list
[email protected]
http://dir.gmane.org/gmane.comp.php.oxid.general

_______________________________________________
dev-general mailing list
[email protected]
http://dir.gmane.org/gmane.comp.php.oxid.general

Reply via email to