In the workflow of Merchello, when Basket is transformed to Invoice, and Basket does not exists anymore?
My issue is this:
I would to allow buyer to manage Basket to the confirm of Basket. After this time the basket can generate Invoice, and Basket can be deleted.
If buyer want to pay with credit card (example PayPal), the confirm proces does not delete the Basket: I would that the Basket is the current basket of current Customer.
Instead of this, what I look in my project is this: when the Buyer click to Confirm button of Basket workflow (with PayPal plugin), the Buyer is redirect to PayPal where he will do login to pay.
At the same time the Basket is deleted, and a new Invoice is creaded and editable by backoffice. The "payment status" is "unpaid", but in "Sale Information" I look this:
"Payment procedded by: PayPal"
"Authorized: $123.00"
But the buyer has not confirmed any payment in PayPal website.
Then I am to search the method that create/confirm the Invoice (and Basket deleted).
The basket is deleted in the Merchello.Core.Sales.SalesPrepartionEvents class by handling the SalesPrepartionBase.Finalizing event.
This event is raised when a payment is processed but you bring up a good use case for cancelling the event.
You could simply use the invoice service to save the prepared invoice and then use the extension method off of the invoice to capture the authorize payment which would circumvent the event altogether.
var invoice = salesPreparation.PrepareInvoice();
var invoiceService = MerchelloContext.Current.Services.InvoiceService;
// invoice must be saved before applying a payment albeit typically the provider checks this and should do it for you.
invoiceService.Save(invoice);
var paymentResult = invoice.AuthorizePayment([PayPalPaymentMethod]);
// then redirect
Haven't tested it but I think it would do exactly what you want.
basket.Empty() will clear all of the items in the basket.
There will be some orphaned information (sale prepartion data) in the merchItemCache and merchItemCacheItem table. If the checkout is anonymous, this could be cleaned automatically if you configure the RemoveAnonymousCustomers scheduled task
The code that you suggest fires an exception: NullReferenceException.
Stack:
in Merchello.Core.Persistence.Repositories.ItemCacheRepository.PersistDeletedItem(IItemCache entity) in c:\Working Repositories\GitHub\Merchello\src\Merchello.Core\Persistence\Repositories\ItemCacheRepository.cs:line 133
in Merchello.Core.Persistence.Repositories.MerchelloRepositoryBase`1.PersistDeletedItem(IEntity entity) in c:\Working Repositories\GitHub\Merchello\src\Merchello.Core\Persistence\Repositories\MerchelloRepositoryBase.cs:line 126
in Merchello.Core.Persistence.UnitOfWork.PetaPocoUnitOfWork.Commit(Action`1 transactionCompleting) in c:\Working Repositories\GitHub\Merchello\src\Merchello.Core\Persistence\UnitOfWork\PetaPocoUnitOfWork.cs:line 115
in Merchello.Core.Services.ItemCacheService.Delete(IItemCache itemCache, Boolean raiseEvents) in c:\Working Repositories\GitHub\Merchello\src\Merchello.Core\Services\ItemCacheService.cs:line 177
The behavior is this:
add article to basket
invoke method with your code: the exception is not fired; basket is empty sometimes.
invoke method with your code more times: the exception is fired; basket does not change.
Now, if user add another article to basket, the cycle restart.
I try to use basket.Empty(). It seems to do what I need: a basket ready to a new customer order.
When Basket is converted to Invoice?
In the workflow of Merchello, when Basket is transformed to Invoice, and Basket does not exists anymore?
My issue is this:
I would to allow buyer to manage Basket to the confirm of Basket. After this time the basket can generate Invoice, and Basket can be deleted.
If buyer want to pay with credit card (example PayPal), the confirm proces does not delete the Basket: I would that the Basket is the current basket of current Customer.
Instead of this, what I look in my project is this: when the Buyer click to Confirm button of Basket workflow (with PayPal plugin), the Buyer is redirect to PayPal where he will do login to pay. At the same time the Basket is deleted, and a new Invoice is creaded and editable by backoffice. The "payment status" is "unpaid", but in "Sale Information" I look this:
But the buyer has not confirmed any payment in PayPal website.
Then I am to search the method that create/confirm the Invoice (and Basket deleted).
Thanks
The basket is deleted in the Merchello.Core.Sales.SalesPrepartionEvents class by handling the SalesPrepartionBase.Finalizing event.
This event is raised when a payment is processed but you bring up a good use case for cancelling the event.
You could simply use the invoice service to save the prepared invoice and then use the extension method off of the invoice to capture the authorize payment which would circumvent the event altogether.
Haven't tested it but I think it would do exactly what you want.
Perfect!
It works fine! Thanks!
My previous line code was:
var paymentResult = salesPreparation.AuthorizePayment(paymentMethodKey.Value, processorArgs);
The issue is solved with this line code:
var paymentResult = invoice.AuthorizePayment(paymentMethodKey.Value, processorArgs);
Now, when buyer abort payment in PayPal website, he return to check-up step of basket. It is exactly what I want.
If buyer confirm payment in PayPal website, he go to confirmed step of basket. Ok.
But the basket is not empty.
What is the best practice now?
I need to invoke
basket.Empty()
?Or I forgot something?
basket.Empty() will clear all of the items in the basket.
There will be some orphaned information (sale prepartion data) in the merchItemCache and merchItemCacheItem table. If the checkout is anonymous, this could be cleaned automatically if you configure the RemoveAnonymousCustomers scheduled task
In /Config/umbracoSettings.config
Otherwise you can delete the information by doing something like:
or create another scheduled task to clear out this info after X days or something.
The code that you suggest fires an exception: NullReferenceException.
Stack:
The behavior is this:
Now, if user add another article to basket, the cycle restart.
I try to use
basket.Empty()
. It seems to do what I need: a basket ready to a new customer order.is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.