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

Reply via email to