Yup, I figured that out as well with some trial/error :) I just sent the revised class code which has similar code.

Many thanks,

Vikram

Arvydas wrote:
Ah.. my fault with given example. Your "ap_cancelurl" should redirect back
to order class, execute some function, e.g. cancelPayment, where:

1. delete order:

           $oOrder = oxNew( 'oxorder' );
           $oOrder->delete( $this->getOrderId() );

2. redirect to payment step by returning:

           return "payment?payerror=-1&payerrortext=someerrortext"

This should work now.. :)

--------------------------------------------------
From: "Vikram Vaswani" <[email protected]>
Sent: Tuesday, August 18, 2009 9:34 AM
To: <[email protected]>
Subject: [oxid-dev-general] More questions on alertpay integration module

Hi Arvydas and others,

I am facing a strange problem in my attempt to integrate OXID with alertpay. As per earlier emails, I have created a module that extends order and oxorder, as per code below.

Here is what happens:
1. I first submit the order using alertpay as my payment option.
2. Things work fine and OXID redirects to alertpay for payment information.
2. I choose to cancel the payment process on alertpay
4. Alertpay redirects me back to OXID using the Url
index.php?cl=payment&payerror=-1&payerrortext='.urlencode('AlertPay error').'&sid=. Thisrenders the payment selection page.
5. I again select alertpay as my payment option and submit my order.
6. OXID straightaway takes me to the order thank you page without redirecting me to alertpay???????

What am I doing wrong in this case?


<?php
class AlertPay_Order extends AlertPay_Order_parent {

  // set AlertPay merchant name
  protected $sMerchantId = '[email protected]';

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

  protected function _getNextStep($iSuccess)
  {
    $oOrder = oxNew('oxorder');
    $lang = oxLang::getInstance()->getLanguageAbbr();
if ($oOrder->load(oxSession::getVar('sess_challenge')) && $oOrder->oxorder__oxpaymenttype->value == 'alertpay') {

      if (is_numeric($iSuccess) && $iSuccess == 1) {
        $oBasket = $this->getBasket();
        $dAmount = $oBasket->getPrice()->getBruttoPrice();

        $oCur = $this->getConfig()->getActShopCurrencyObject();
        $sCur = $oCur->name;

        $oOrder->oxorder__oxtransstatus = new oxField('ERROR');
        $oOrder->save();

        $aFormData = array(
          'ap_purchasetype'   => 'item-goods',
          'ap_merchant'       => $this->sMerchantId,
          'ap_currency'       => $sCur,
          'ap_quantity'       => '1',
// 'ap_returnurl' => 'http://oxid.localhost/ap_result.php?x=return/' . $this->getSession()->getId(), 'ap_returnurl' => 'http://oxid.localhost/ap-return-'.$lang.'/?sid=' . $this->getSession()->getId(),
          'ap_itemname'       => 'Shopping Cart Items and Delivery Fees',
'ap_description' => $this->getConfig()->getActiveShop()->oxshops__oxname->value,
//          'ap_amount'         => $dAmount,
          'ap_amount'         => 0.01,
// 'ap_cancelurl' => 'http://oxid.localhost/ap_result.php?x=cancel/' . $this->getSession()->getId(), 'ap_cancelurl' => 'http://oxid.localhost/ap-cancel-'.$lang.'/?sid=' . $this->getSession()->getId(),
          'apc_1'             => $this->getSession()->getId(),
        );

oxUtils::getInstance()->redirect($this->sGatewayUrl . '?' . http_build_query($aFormData));
      }

if ($iSuccess === 'AlertPayOK' && $oOrder->load(oxSession::getVar('sess_challenge'))) {
        $oOrder->oxorder__oxtransstatus = new oxField('OK');
        $oOrder->save();
        $oBasket = $this->getBasket();
        $oUser = $this->getUser();
$iSuccess = $oOrder->sendAlertPayOrderByEmail($oUser, $oBasket, $oUserPayment);
        //$iSuccess = 1;
      }
    }

    return parent::_getNextStep($iSuccess);
  }

  public function processAlertPayResponse()
  {
    $iSuccess = 'AlertPayOK';
    return $this->_getNextStep($iSuccess);
  }

}


<?php
class AlertPay_oxOrder extends AlertPay_oxOrder_parent {

protected function _sendOrderByEmail($oUser = null, $oBasket = null, $oPayment = null)
   {
     if ($this->oxorder__oxpaymenttype->value == 'alertpay') {
       return 1;
     } else {
       return parent::_sendOrderByEmail($oUser, $oBasket, $oPayment);
     }
   }

public function sendAlertPayOrderByEmail($oUser = null, $oBasket = null, $oPayment = null) {
     return parent::_sendOrderByEmail($oUser, $oBasket, $oPayment);
   }
}
?>


_______________________________________________
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