2

I have a big problem dealing with new payment gateway creation. I followed a tutorial but I think I did something wrong because it doesn't work well.

I would like to create a "devis" (sorry I don't know the word in english... It looks like that.

When the customer buys something, he could choose this kind of payment which does nothing but provide the "devis". It would be perfect if the status of the order could be "on hold" directly in order to unhold it when the "real payment" is done.

I hope you have understand what I try to do but if you have not be free to ask me questions.

Here is what I've done:

  • I created a new class in the VirtoCommerce.PaymentGateways namespace called DevisPaymentGateway which inherits from the PaymentGatewayBase class. In this class there is just one method: ProcessPayment where I do:

    payment.status = PaymentStatus.Completed.ToString();

  • in the SqlOrderDatabaseInitializer.cs

    I created a private SetupDevisGateway method:

    private void SetupPaypalGateway(List<PaymentGateway> gateways)

    which is called in the CreatePaymentGateways method just after the paypal gateway.

  • I deployed the database thanks to your powershell script, the gateway is created as expected.

  • I enabled the gateway payment via VirtoCommerce Manager Then I bought something on the website and I chose the new Payment which is available so it seems to work.
  • When I click on proceed to checkout I have a new order line which is created with the "Pending" status so it's perfect...

When I bought something with paypal for example, there was the same reaction BUUUT when the new order line was created there was the onBeforeUpdate method which detected that new line and some work was done asynchronously. With the new gateway it seems that the onBeforeUpdate method doesn't work anymore... I think that I've forgot something which is done with Paypal and not with my gateway but what and where?

I already know that it's not a good idea to write something in the SqlOrderDatabaseInitializer.cs but I don't think that it's the problem... Does anybody have a solution?

Thanks

Edit: Explanation on what I try to achieve: Products which are sold are in fact a couple: "images treatments" + "images" Each customer can manage album and put photos into it, and when he clicks on a product (which is a treatment) he can choose an album. So it's why I need this event, when the payment is done and the status change from pending to in progress, I send relevant information (about the treatment, the album...) to a queue and I have worker roles (one for each treatment) which read these messages and do some work.

I hope you understand the idea but if you don't, do not hesitate to ask me questions

BigE
  • 31
  • 4
romainf
  • 31
  • 2

1 Answers1

0

can you explain why do you need that event? What will you do when that event is raised?

Some explanation below on how status is changed for the order below:

The order status is actually changed by the job "ProcessOrderStatusWork class" that simply runs in the background and changes the status order status from "Pending" to "InProgress" after order has been in pending state for a certain period of time. I would suggesting for you to create a copy of "ProcessOrderStatusWork" class and create a new job (name it MyProcessOrderStatusWork class), that in addition to changing status also adds custom work for your payment. You can then register that Job and disable the one included with VC, so it is not duplicated (by adding it in the database,similar to how you did payment gateway).

It might work for PayPal, because it uses slightly different logic, as order created on call back from PayPal, thus executing in the same web process and event is raised.

Woland
  • 2,881
  • 2
  • 20
  • 33
  • Ok I will try to do that. But where are you create the new job? – romainf Jul 24 '14 at 07:22
  • Because if I delete the Job in order to create an other one I don't understand how it could be work... – romainf Jul 24 '14 at 07:45
  • Here is an article describing in more details how jobs can be created, registered as well as how they work: http://docs.virtocommerce.com/display/vc1devguide/Long+running+tasks – Woland Jul 24 '14 at 17:05