Hi Vikram, Developers here were pretty busy with the final touches to eShop 4.1.3 release. First of all I see some problems with your order workflow. As far as I can see, on successful payment you totally miss cl=order step. I am not sure how about alter pay works, but isn't it something like other payment methods which works in 2 steps. 1st step - user authorization. 2nd - final processing. This way you can first identify user and to actually charge him on the last step. And in any case finalizeOrder() should be executed only once.
Regards Tomas Liubinas -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Vikram Vaswani Sent: Thursday, June 18, 2009 9:37 AM To: [email protected] Subject: [oxid-dev-general] [Fwd: Re: Urgent question onpaymentgateway integration] Hi all I haven't heard back from anyone on my message re: payment gateway redirection posted some days ago? Could someone with experience in this area help? TIA. Description as below: 1 When the user selects alertpay as the payment method and submits the order, I am redirecting the user to the alertpay site. 2 When the payment is successful, the user is redirected back to http://oxiddomain/index.php?cl=thankyou. 3 When there is a payment failure on alertpay.com, the user is redirected back to http://oxiddomain/index.php?cl=payment&payerror=4. This produces the payment method page, with an error saying that 'your payment was unsuccessful'. So far this is fine and the behaviour one would expect. 4 However, if the user again selects Alertpay as the payment method and submits the order again, the user is NOT redirected to alertpay. Instead the thankyou page appears immediately. This is clearly a problem. On debugging, it appears that in this second case, finalizeOrder() is not calling executePayment() because of the $blRecalculate flag. So the order controller is somewhere along the line setting this flag. I'm not sure where or why this is happening, can anyone suggest a solution? My payment gateway code is as below: <?php class alertpay_PaymentGateway extends alertpay_PaymentGateway_parent { // 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'; public function executePayment($dAmount, &$oOrder) { if ($oOrder->oxorder__oxpaymenttype->value != 'alertpay') { return parent::executePayment($dAmount, $oOrder); } $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=thankyou&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(), ); header('Location:' . $this->gatewayUrl . '?' . http_build_query($formData)); exit(); } } ?> -------------------- Let me know if you can help. Thanks. Vikram Tomas Liubinas wrote: > Hi Vikram, > > I had a quick look and it looks like getTransactionID() is not a standard > eShop method. I assume the error should be somewhere on module side. > Additionally you can check EXCEPTION_LOG.txt file for possible more > information. Changing iDebug constant in confi.inc.php to -1 also could help > in this case. > > Regards > Tomas Liubinas > > -----Original Message----- > From: [email protected] > [mailto:[email protected]] On Behalf Of Vikram Vaswani > Sent: Monday, June 15, 2009 8:45 PM > To: [email protected] > Subject: Re: [oxid-dev-general] Urgent question on paymentgateway integration > > Hi Tomas and others, > > Despite many efforts, I'm still not able to get this to work. Here's > what I'm doing: > > 1. In my oxPaymentGateway::executePayment(), I am generating a URL > string to alertpay.com and redirecting the user to that site. The URL > string is of the form: > > https://www.alertpay.com/PayProcess.aspx?ap_purchasetype=item-goods& > ap_merchant=XXX&ap_currency=GBP&ap_quantity=1 > &ap_returnurl=http%3A%2F%2Fmydomain.com%2Findex.php%3Fcl%3Dthankyou%26sid%3Ded2aa7c3716e0943139d2aafee783ad6& > ap_itemname=Shopping+Cart&ap_amount=10.19&ap_cancelurl= > &apc_1=ed2aa7c3716e0943139d2aafee783ad6 > > Notice that I am passing the SID as part of the return URL. > > 2. Now, once the user completes the payment process on alertpay.com, he > is redirected back to: > > http://mydomain.com/index.php?cl=thankyou&sid=ed2aa7c3716e0943139d2aafee783ad6 > > However, this presents the index page with the message 'Function > getTransactionID not defined (thankyou)'. > > Any idea what I'm doing wrong? > > 3. Can you suggest what should be the URL I should direct to for these > two cases: > > - the user cancels the payment on alertpay.com > - the user's payment fails due to incorrect card details > > Thanks for your help - I'm a bit confused by the above situation so > would appreciate your advice. > > Vikram > > Tomas Liubinas wrote: >> Hi Vicram, >> >> http://domain/index.php?&cl=thankyou looks ok (index.php?cl=thankyou to be >> precise). One of the reasons it redirects to start page could be empty >> session basket object. Try not to empty basket in your module. I aslo would >> suggest adding sid= param to your url in this case. >> >> >> Regards >> Tomas Liubinas >> >> -----Original Message----- >> From: [email protected] >> [mailto:[email protected]] On Behalf Of Vikram Vaswani >> Sent: Monday, June 15, 2009 5:45 PM >> To: [email protected] >> Cc: Dainius Bigelis >> Subject: Re: [oxid-dev-general] Urgent question on paymentgateway integration >> >> Hi all >> >> Another question which I am struggling with. One payment gateway >> requires me to forward the user to a separate site where the user can >> enter the card information. I have managed to get this to work by >> setting up a redirection in the executePayment() method. >> >> However, the gateway has asked for a "return URL" to which it will >> redirect the user once the payment process is complete (whether >> successful or not). I guess this return URL should be the 'thank you' >> page. I'm not able to figure out how to do this ie. what is the URL I >> should specify on the payment site? >> >> Note: I tried using http://domain/index.php?&cl=thankyou, but that >> doesn't work, it simply sends me back to the index page. Any ideas would >> be welcome. >> >> Vikram >> >> Arvydas wrote: >>> Explanation how everything works when user clicks button on last order >>> step: >>> >>> 1. Order::execute(): >>> - checks if all checkboxes (agb, customer info) were marked; >>> - checks if session user is available; >>> - creates OxOrder instance; >>> >>> 2. OxOrder::validateStock(): >>> - checks if its allowed to order items stored in basket; >>> - if some problems with stock - oxOutOfStockException >>> exception is thrown; >>> >>> 3. OxOrder::finalizeOrder(): >>> - copies user data to order (OxOrder::_setUser()); >>> - copies basket data to order (OxOrder::_loadFromBasket()); >>> - copies payment info to order (OxOrder::__setPayment()); >>> - stores order to db (OxOrder::save()); >>> - executes payment gateway (OxOrder::_executePayment()): >>> * creates payment gateway instance; >>> * executes payment gateway >>> (OxPaymentGateway::executePayment()); >>> * if gateway execution fails >>> (OxPaymentGateway::executePayment() returns FALSE): >>> - deletes order (OxOrder::delete()); >>> - checks if OxPaymentGateway::getLastError() returns >>> error - if found - returns it; >>> - checks if OxPaymentGateway::getLastErrorNo() >>> returns error number - if found - returns it; >>> - if no error info was found - returns "2"; >>> * if gateway execution succeded - returns TRUE; >>> - if payment gateway returns something else than TRUE - stops >>> order execution and returns its value; >>> - if payment gateway returns TRUE: >>> * sets order status to OK (OxOrder::_setOrderStatus()); >>> * updates shop stocks (OxOrder::_updateStock()); >>> * substracts wishlists/noticelists >>> (OxOrder::_updateWishlist()/OxOrder::_updateNoticeList()); >>> * sends order email to user and shop owner >>> (OxOrder::_sendOrderByEmail()) and returns email sending state. >>> 4. Order::_getNextStep(): >>> - takes value returned by OxOrder::finalizeOrder(), so here >>> you can manipulate with value returned by payment >>> gateway or email sender. >>> Standard values returned by OxOrder::finalizeOrder() are: >>> * 0 - order email sending problems - redirects to >>> "thankyou?mailerror=1"; >>> * 1 - order email was successfully sent - redirects to >>> "thankyou"; >>> * 2 - problems with payment gateway - error happened or >>> something, but no error info provided >>> >>> (OxPaymentGateway::getLastError()/OxPaymentGateway::getLastErrorNo() >>> gave no response) - >>> redirects to "payment?payerror=2" >>> * 3 - means must be kept on save order step; >>> * custom codes provided by user modules: >>> - numeric value and > 3 - redirects to >>> "payment?payerror="._ERROR_CODE_ >>> - is NOT numeric - redirects to >>> "payment?payerror=-1&payerrortext="._ERROR_TEXT_RETURNED_BY_PAYMENT_GATEWAY_; >>> >>> >>> >>> >>>> One question: if a transaction is approved by the payment gateway, it >>>> normally returns an approval code. How do I transfer this approval >>>> code from the oxPaymentGateway class to the 'order successful' screen? >>> Fastest solution: >>> >>> - write a module for OxPaymentGateway::executePayment()) which writes >>> order approval code to session (e.g. >>> OxSession::setVar('viOrderApprovalCode')); >>> - write a getter for Thankyou e.g. getOrderApprovalCode, which returns >>> approval code (and maybe unsets it >>> from session); in template you can call $oView->getOrderApprovalCode(); >>> >>> if you need to write this code to DB, you should create new field in >>> OxOrder table (please use your own prefix for field, >>> do not make regular ox, make e.g. vi_approvalcode) and set this field >>> value in OxPaymentGateway::executePayment() - >>> second parameter is OxOrder instance; >>> >>> >>> >>> -------------------------------------------------- >>> From: "Dainius Bigelis" <[email protected]> >>> Sent: Monday, June 15, 2009 1:13 PM >>> To: "Arvydas Vapsva" <[email protected]> >>> Subject: Fw: Re: [oxid-dev-general] Urgent question on >>> paymentgatewayintegration> >>>> -----Ursprüngliche Nachricht----- >>>> Von: [email protected] >>>> [mailto:[email protected]] Im Auftrag von Vikram >>>> Vaswani >>>> Gesendet: Montag, 15. Juni 2009 09:30 >>>> An: [email protected] >>>> Betreff: [!! SPAM] Re: [oxid-dev-general] Urgent question on >>>> paymentgateway integration >>>> >>>> Hi Marco, >>>> >>>> Thanks for this code, it's quite helpful. I'm making progress with this. >>>> >>>> One question: if a transaction is approved by the payment gateway, it >>>> normally returns an approval code. How do I transfer this approval >>>> code from the oxPaymentGateway class to the 'order successful' screen? >>>> >>>> Vikram >>>> >>>> Marco Steinhaeuser wrote: >>>>> Hey Vikram, >>>>> >>>>>> 3. Are there any "demo" implementation of a payment gateway module >>>>>> which I could use as a starting point? >>>>> Check out these extensions for CE: >>>>> >>>>> http://www.oxid-esales.com/en/exchange/extensions/oxid2ipayment-ce?ter >>>>> m=2223 >>>>> http://www.oxid-esales.com/en/exchange/extensions/gate2shop-payment-mo >>>>> dul-fuer-oxid-ce?term=2223 >>>>> >>>>> Hope that helps ;) >>>>> >>>>> Marco >>>>> >>>>> >>>>> >>>>> -----Ursprüngliche Nachricht----- >>>>> Von: [email protected] >>>>> [mailto:[email protected]] Im Auftrag von Vikram >>>>> Vaswani >>>>> Gesendet: Samstag, 13. Juni 2009 05:30 >>>>> An: [email protected] >>>>> Betreff: [oxid-dev-general] Urgent question on payment gateway >>>>> integration >>>>> >>>>> Hi >>>>> >>>>> I am trying to integrate the authorize.net payment gateway into OXID >>>>> as a module. Please could someone help with the following questions: >>>>> >>>>> 1. From the API docs, it seems that the "core" OXID module to extend >>>>> for this is oxPaymentGateway. Is this correct? Is it necessary to >>>>> also extend oxOrder? >>>>> >>>>> 2. Currently I am overriding the oxPaymentGateway::executePayment() >>>>> method. However, I am not able to understand how to handle payment >>>>> errors that occur when performing the transaction. Can someone >>>>> suggest the "best practice" way of raising these errors so that they >>>>> are visible to the customer on the final checkout page? >>>>> >>>>> 3. Are there any "demo" implementation of a payment gateway module >>>>> which I could use as a starting point? >>>>> >>>>> Thanks, >>>>> >>>>> Vikram >>>>> _______________________________________________ >>>>> 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 >>> >> _______________________________________________ >> 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 _______________________________________________ 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
