We have a number of free products (and generally people will be ordering single items from our new site), and I was wondering if there was abuilt in mechanism so that when a zero value basket is processed we bypass the payment step(in our case a call to the payment provider)
What you can do is change the selected payment method in the javascript before the goToPayment funktion is called.
Be aware taht this would be a potential "security" risk as anyone could change the payment provider to the free one, thus passing the payment step. All they have to do is know Tea Commerce and guess the id of the free payment method.
To make it more secure you could hook into Tea Commerce's .NET API and throw an error if anyone tries to goToPayment with the free payment method. That would be done in the BeforePaymentFormGenerated event.
My scenario is that my online shop needs to sell two products - one is priced and the other is free (a trial copy). They both need to go through the checkout process since licence codes are generated at the back-end and emailed to the customer. However, the payment gateway is only necessary if the total basket value is not zero. If someone just wans the trial copy (and no other products) then they should be able to complete the order without hitting the payment gateway.
Are you using the latest version of Tea commerce, because I think the bypass may be included or eaier to do in the newer version.. but I'd suggest checking with the TeaCommerce guys.. they are always mst helpful
Basicly what you are going to do is the same as the other forum post. You will need to change the payment method depending on the contents of the cart.
You need to have two payment methods. One with credit card, and the other with the default Tea Commerce provider, which skips right to the confirmation page.
In your event handler you set the payment method on your order to the one or the other, and saves the order. That's all you need to do.
Which is the "default Tea Commerce provider"? My setup has two "Payment methods": "Credit Card" and "PayPal" - and if I create a new payment method I get a choice of payment providers (in the 3rd tab) none of which seems to jump out at me as the default TeaCommerce provider. I can see the following:
2CheckOut
AuthorizeNet
Axcess
DIBS
ePay
Invoicing
Netaxept
Ogone
Payer
PayEx
PayPal
QuickPay
SagePay
Wannafind
WorldPay
Apologies for requiring more assistance - you may need to spell it out!
Also, once I get this new payment provider created - do I need to inspect the database to determine the ID of the payment method and use that ID when changing the method?
OK - I have added the event and that's being hit - but here's what I have now:
I have added a payment method (called "No payment") based on the Invoicing payment provider (with default settings)
If I set "No payment" to be available to all countries then it shows up as an option alongside PayPal on the payment page and I can choose that and we go straight to confirmation. But I don't want Invoicing to show up as an option when there's a non-zero value cart.
If I set "No payment" to NOT be available to all countries then my ChangePaymentMethod is ignored and it just goes to PayPal (which is the default setting on the Shipping/Payment page).
I suppose that what I need is for the shipping/payment page to be skipped (since it captures nothing of interest other than a default payment option and a default shipping option) - and for the PayPal method to be set for non-zero value carts and the "No payment" method to be set for zero value carts. If that's the correct way then how do I skip from the Information to the Accept page?
An update on the above. I have modified the step-accept and step-information cshtml files to do a "double step" to miss out the payment/shipping page - so that avoids the customer dealing with a page that only has defaults and also avoids them being able to choose an Invoicing method when the cart is non-zero.
However, I now notice the following. The BeforePaymentFormGenerated event is being trapped correctly on the transition from the information page to the accept page - and in that event I am changing the order payment method (using order.ChangePaymentMethod(int id) followed by order.Save()) depending on the total value of the cart. I can step through in debug and the correct payment method is chosen for each case. BUT... the change in payment method is sometimes not detected and so the transition from accept page to payment page results in the PayPal page being shown when the payment method should be Invoicing and the sequence should just jump to the confirmation page (I have set the confirmation page correctly as the setting for the invoicing payment method).
In the above case, if I go back to the information page and back again to the accept page and then to payment the sequence then works correctly. It is as though the timing is off somehow - and I suspect I am not calling the correct method for changing the payment method.
When the PaymentFormGenerating event is hit - Tea Commerce has already found out which payment method to use and extracted the settings etc. So at this step it is to late to change the payment method. You will have to do that before the payment form is generated. So that is why this wont work at the moment :)
The code is very simple along the following lines (I am not near my workstation at the moment):
if (order.TotalPrice.Value > 0){order.ChangePaymentMethod(2); // PayPal}else{order.ChangePaymentMethod(4); // "No payment" (Invoicing)}order.Save();
If I need to determine the payment method based on the order value without doing that on the payment form generated event, then can I do this on a simple order updated event instead?
I cant figure out the right place to do this. It might be at the page where you change the order information or another step you want to change this. But I just know that you shouldn't do it in the PaymentFormGeneration event :)
I am just reporting back. I was able to resolve this using the order update events - to modify the payment method depending on the total cart value at each event.
I had to handle the issue that a change in payment method would cause another order update event to be triggered and I am not certain that I've handled that correctly but so far the site is now working.
My odyssey so far has involved a few challenges but I now seem to have a fully functioning software licencing web shop (catering for different product and licence types, EU VAT rules and auto generating licence codes and download links) up and running (subject to final testing). I've also created support for single, multiple and domain licences - by using Umbraco item types for multiple/domain (so they are managed via Umbraco back-end) whilst using a separate entity for single licences.
No doubt this is just in time for new releases of TeaCommerce and/or Umbraco which will break it! ;)
Thanks for your help this far - I'll post a list to the site when I've completed full testing.
Items with zero value
We have a number of free products (and generally people will be ordering single items from our new site), and I was wondering if there was abuilt in mechanism so that when a zero value basket is processed we bypass the payment step(in our case a call to the payment provider)
ravi
Hi Ravi,
There is no built in function doing that.
What you can do is change the selected payment method in the javascript before the goToPayment funktion is called.
Be aware taht this would be a potential "security" risk as anyone could change the payment provider to the free one, thus passing the payment step. All they have to do is know Tea Commerce and guess the id of the free payment method.
To make it more secure you could hook into Tea Commerce's .NET API and throw an error if anyone tries to goToPayment with the free payment method. That would be done in the BeforePaymentFormGenerated event.
/Rune
I thought that might be the case, and I figured that we might have to do a bypass
Just to let you all know. We are also discussing this in a slightly different scenario here:
http://our.umbraco.org/projects/website-utilities/tea-commerce/tea-commerce-support/33373-by-pass-payment-for-certain-users
/Rune
Hi,
My scenario is that my online shop needs to sell two products - one is priced and the other is free (a trial copy). They both need to go through the checkout process since licence codes are generated at the back-end and emailed to the customer. However, the payment gateway is only necessary if the total basket value is not zero. If someone just wans the trial copy (and no other products) then they should be able to complete the order without hitting the payment gateway.
I have read this thread and also the one relating to bypassing users (http://our.umbraco.org/projects/website-utilities/tea-commerce/tea-commerce-support/33373-by-pass-payment-for-certain-users?p=0) but since the last info on this was in July 2012 then I am hoping that there is now a simple set of instructions/options to allow me to fulfil my requirements and which relates to more recent versions of TC and Umbraco.
What is the latest please?
Cheers,
Martin
Are you using the latest version of Tea commerce, because I think the bypass may be included or eaier to do in the newer version.. but I'd suggest checking with the TeaCommerce guys.. they are always mst helpful
Hi Ravi,
Thanks for the reply. I am using TeaCommerce 2.1.2 with Umbraco 6.0.5.
I am hoping one of the TeaCommerce guys will respond or point me to some documentation.
Cheers,
Martin
Hi Martin,
Basicly what you are going to do is the same as the other forum post. You will need to change the payment method depending on the contents of the cart.
I expect that you are using Tea Commerce 2.0 in which case you will need to use the notification center to hook into the appropriate event:
http://documentation.teacommerce.net/net-api/notification-center/
In your hook you will need to use the .NET API to change the current payment method.
/Rune
Hi Rune,
I can easily add the WebshopEvents_BeforePaymntFormGenerated event handler into my existing code (alongside where I have other event handlers).
I believe I can also determine whether the total order price is zero (order.TotalPrice.Value == 0 ??).
But I cannot work out what to do on that condition!
Should I skip across the payment and go to confirmation - if so how?
Or should I set some sort of weird payment method that skips the payment step?
I have tried researching - but I'm not getting very far.
Cheers,
Martin
Hi Martin,
You need to have two payment methods. One with credit card, and the other with the default Tea Commerce provider, which skips right to the confirmation page.
In your event handler you set the payment method on your order to the one or the other, and saves the order. That's all you need to do.
/Rune
We did something similar with the old version of TeaCommerce, and its pretty robust once it's i place..
Hi Rune (and thanks Ravi),
Which is the "default Tea Commerce provider"?
My setup has two "Payment methods": "Credit Card" and "PayPal" - and if I create a new payment method I get a choice of payment providers (in the 3rd tab) none of which seems to jump out at me as the default TeaCommerce provider. I can see the following:
Apologies for requiring more assistance - you may need to spell it out!
Also, once I get this new payment provider created - do I need to inspect the database to determine the ID of the payment method and use that ID when changing the method?
Cheers,
Martin
Nudge... Anyone?
That would be Invoicing. The only one not connected to at specific payment gateway
/Rune
Hi Rune,
OK - I have added the event and that's being hit - but here's what I have now:
I suppose that what I need is for the shipping/payment page to be skipped (since it captures nothing of interest other than a default payment option and a default shipping option) - and for the PayPal method to be set for non-zero value carts and the "No payment" method to be set for zero value carts. If that's the correct way then how do I skip from the Information to the Accept page?
Any other options?
Cheers,
Martin
Hi Rune,
An update on the above. I have modified the step-accept and step-information cshtml files to do a "double step" to miss out the payment/shipping page - so that avoids the customer dealing with a page that only has defaults and also avoids them being able to choose an Invoicing method when the cart is non-zero.
However, I now notice the following. The BeforePaymentFormGenerated event is being trapped correctly on the transition from the information page to the accept page - and in that event I am changing the order payment method (using order.ChangePaymentMethod(int id) followed by order.Save()) depending on the total value of the cart. I can step through in debug and the correct payment method is chosen for each case. BUT... the change in payment method is sometimes not detected and so the transition from accept page to payment page results in the PayPal page being shown when the payment method should be Invoicing and the sequence should just jump to the confirmation page (I have set the confirmation page correctly as the setting for the invoicing payment method).
In the above case, if I go back to the information page and back again to the accept page and then to payment the sequence then works correctly. It is as though the timing is off somehow - and I suspect I am not calling the correct method for changing the payment method.
Any ideas?
Cheers,
Martin
Could you post your BeforePaymentFormGenerated code?
I will have Anders take a look at your situation, he might have a simple answer.
/Rune
Hi Martin
When the PaymentFormGenerating event is hit - Tea Commerce has already found out which payment method to use and extracted the settings etc. So at this step it is to late to change the payment method. You will have to do that before the payment form is generated. So that is why this wont work at the moment :)
Kind regards
Anders
Hi Rune and Anders,
The code is very simple along the following lines (I am not near my workstation at the moment):
if (order.TotalPrice.Value > 0){order.ChangePaymentMethod(2); // PayPal}else{order.ChangePaymentMethod(4); // "No payment" (Invoicing)}order.Save();If I need to determine the payment method based on the order value without doing that on the payment form generated event, then can I do this on a simple order updated event instead?
Cheers,
Martin
I cant figure out the right place to do this. It might be at the page where you change the order information or another step you want to change this. But I just know that you shouldn't do it in the PaymentFormGeneration event :)
Hi Anders,
I will assess the remaining options and try some things out this weekend and I'll report back. Fingers crossed.
Cheers,
Martin
Hi Rune and Anders,
I am just reporting back. I was able to resolve this using the order update events - to modify the payment method depending on the total cart value at each event.
I had to handle the issue that a change in payment method would cause another order update event to be triggered and I am not certain that I've handled that correctly but so far the site is now working.
My odyssey so far has involved a few challenges but I now seem to have a fully functioning software licencing web shop (catering for different product and licence types, EU VAT rules and auto generating licence codes and download links) up and running (subject to final testing). I've also created support for single, multiple and domain licences - by using Umbraco item types for multiple/domain (so they are managed via Umbraco back-end) whilst using a separate entity for single licences.
No doubt this is just in time for new releases of TeaCommerce and/or Umbraco which will break it! ;)
Thanks for your help this far - I'll post a list to the site when I've completed full testing.
Cheers,
Martin
is working on a reply...