• Welcome to KonaKart Community Forum. Please login or sign up.
 

New payment module

Started by ReneA, August 24, 2008, 09:39:31 pm

Previous topic - Next topic

ReneA

Dear Konakarts,

I'm developing a new payment module for EnterPayment (www.enterpayment.de). I have read the instructions and managed to copy and setup the new modules.

However, EnterPayment requires distinct first name and last name to be passed on in the request. Now, I've seen that the modules Authorizenet does a split of the BillingName using the space as a terminator. This can be a solution but can also lead to wrong results when there are more spaces within the name.
The same is for State and Country.

My question is: is it possible to extend PaymentDetails to include FirstName and LastName as well as State and Country ?

Another possible approach could be to get the order.BillingAddrId, retrieve the Addr and composing the required string to pass on to EnterPayment. However, I could not find an api to retrieve an Addr and passing an id.

julie

The PaymentDetails object has 5 custom fields that you could use.

Would you consider contributing your gateway to the KonaKart community when you've completed it ?

Thanks,

Julie

ReneA

Quote from: julie on August 25, 2008, 06:26:29 am
The PaymentDetails object has 5 custom fields that you could use.

Would you consider contributing your gateway to the KonaKart community when you've completed it ?

Thanks,

Julie


Thanks Julie for your reply.
Yes, I would donate the module to the Konakart community, but then I would like to create a nice structured module. I try to avoid using the custom fields.

The gateway protocol is based on xml data passing. In the url parameter xml the request is passed on to the gateway. The result is also returned as xml. So, xml parsing is required.
I already developed the interface coding for another Java project. It is now a matter of integrating into Konakart.

It would be convenient if the PaymentDetails includes the same fields as Addr so that the payment modules can access all fields (in the case of EnterPayment, firstname and lastname) to compose their interface string. In that way it is convenient to let the jsp conditionally show/let edit all these fields (like setShowfirstname, setShowlastname). This jsp is included within the custom modifiable code but the control is via the PaymentDetails interface which is not within the custom code.

Another solution would be to directly access the chosen billing Addr. But I haven't found an Konakart API by which I can retrieve an Addr by Id.

This is what is required by EnterPayment gateway:
card holder
firstname    mandatory
lastname    mandatory
street    mandatory
zip/Postal    mandatory
city            mandatory
state    partly mandatory This field is mandatory, when the customer comes from the USA, Canada or Australia. For all other countries this field should be empty. See appendix for allowed values
country    mandatory    ISO-3166 country code. See appendix for allowed values
telephone    optional
email      mandatory
ip            optional

julie

QuoteYes, I would donate the module to the Konakart community, but then I would like to create a nice structured module. I try to avoid using the custom fields.


We added the custom fields for cases like yours where the gateway requires information that we haven't catered for directly, so I'd have no hesitation with using them. As long as your action class (i.e. AuthorizenetAction.java) and your module are in sync everything should be fine.

QuoteAnother solution would be to directly access the chosen billing Addr. But I haven't found an Konakart API by which I can retrieve an Addr by Id.


In the action class you normally have a copy of the order object which should have the billing address populated.

ReneA

Thanks Julie,

I've made the choice to retrieve the billing AddressIf by Id from the order:
            // Get the billing address
            int billingAddrId = order.getBillingAddrId();
            kkAppEng.getCustomerMgr().setSelectedAddrFromId(billingAddrId);
            AddressIf billingAddr = kkAppEng.getCustomerMgr().getSelectedAddr();

In that way I'm able to access the proper fields directly:
      xml.append("        <name>" + ba.getFirstName() + "</name>\n");
      xml.append("        <surname>" + ba.getLastName() + "</surname>\n");
      xml.append("        <street>" + ba.getStreetAddress() + "</street>\n");
      xml.append("        <zip>" + ba.getPostcode() + "</zip>\n");
      xml.append("        <city>" + ba.getCity() + "</city>\n");
      xml.append("        <state>" + ba.getState() + "</state>\n");
      xml.append("        <country>" + ba.getCountryName() + "</country>\n");

That works fine. But... the country must be passed as an ISO-3166 country code.
I know, from the administration, see "Locations/Taxes", "Countries" that the 2-letter ISO code is maintained within Konakart tables.

How can I retrieve the CountryIf for the given ba.getCountryId() ? Is or are there any API's in Konakart to be used ?


julie

There is a method often used by the payment and shipping modules:

CountryIf country = getEng().getCountryPerName(order.getBillingCountry());

Also you can probably get all of the billing address directly from the order object rather than having to look it up again.

ReneA

Thanks Julie,

That helped.

By the way, I discovered that Konakart is generating an exception on the following highlighted line of code:
            // Get the billing address
            int billingAddressId = order.getBillingAddrId();
            kkAppEng.getCustomerMgr().setSelectedAddrFromId(billingAddressId);
            AddressIf billingAddress = kkAppEng.getCustomerMgr().getSelectedAddr();

in the following circumstances:
- I'm using Konakart 2.2.4
- I'm NOT using the onepagecheckout (disabled via admin)
- just started Tomcat, so there are no sessions pending, no signed on users
- my test user has 1 item already added in the shopcart (from a previous session)
- the test user does a signon via "My Account"
- then goes to "Checkout"
- hits in screen "Delivery information" the "Continue" button
- hits in screen "Payment information" the "Continue" button
- hits in screen "Order confirmation" the "Confirm order" button
- fills in the credit card details and hits the "Continue" button

Exception Name = com.konakart.al.KKAppException
Exception Message = The current customer has no addresses.
Exception Stack Trace =
at com.konakart.al.CustomerMgr.setSelectedAddrFromId(Unknown Source)
at com.konakart.actions.gateways.EnterpaymentAction.execute(EnterpaymentAction.java:173)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)

Whenever the test user does a "Change billing address" (with or without changing the billing address, the exception does not occur. So it only occurs when accepting the default billing address.

Any ideas what is going on ?

Thanks, Rene

julie

setSelectedAddrFromId() on the client engine is normally called after populateCurrentCustomerAddresses() which saves the customer addresses on the customer object on the session. If the populate method isn't called, then setSelectedAddrFromId() finds an empty address array and throws the exception.

ReneA

Quote from: julie on August 26, 2008, 04:15:04 pm
setSelectedAddrFromId() on the client engine is normally called after populateCurrentCustomerAddresses() which saves the customer addresses on the customer object on the session. If the populate method isn't called, then setSelectedAddrFromId() finds an empty address array and throws the exception.


Thank you, Julie,

that was the solution.

The request string for the gateway is now being properly composed and sent out to the gateway. I also receive the result from the gateway. The next step is to parse the response and handle the result.

I will keep you informed.

Once again, thank you for your quick response.

Rene

julie

Great. You could be the first payment module contributor  8)

ReneA

Hello Julie,

I posted a private message to you with some questions about donating the software.
Please, check your inbox in this forum.

Kind regards,
Rene

Quote from: julie on August 27, 2008, 09:23:09 am
Great. You could be the first payment module contributor  8)

ReneA

Quote from: julie on August 27, 2008, 09:23:09 am
Great. You could be the first payment module contributor  8)


Julie...

I tried to post the contribution files for the new payment module (source code and documentation). But unfortunately, the file size for uploading attachments is limited to 128 Kb ! The size of the zip file is 130 Kb.

Is it possible to increase this limit or should I send you the files by email ?

Regards,
Rene

pete

Hi Rene,

Could you try again please ? I've increased the maximum size to 512 kb.

ReneA

Quote from: pete on September 30, 2008, 10:19:59 pm
Hi Rene,

Could you try again please ? I've increased the maximum size to 512 kb.


Thanks Pete, the upload is fine now. See the contributions section.