Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


These support forums are now closed for new topics and comments.
Please head on over to http://eureka.ucommerce.net/ for support.

  • Lee 1130 posts 3088 karma points
    Apr 03, 2013 @ 08:18
    Lee
    0

    Create/Save Order Before PayPal Redirect?

    How do a save an order (i.e. Assign it an order number and have it show in the awaiting payments folder in the uCommerce admin) before I redirect the user to PayPal?

    I have tried both of the following before going off to PayPal?

    PipelineFactory.Create<PurchaseOrder>("SaveOrder").Execute(paymentRequest.PurchaseOrder);
    PipelineFactory.Create<PurchaseOrder>("Processing").Execute(paymentRequest.PurchaseOrder);

    BUT STILL this does not save it and assign it an order number OR make it show in the awaiting payments folder in the backend? How can I make it work how I need it to work?

  • Tim 174 posts 398 karma points
    Apr 03, 2013 @ 08:28
    Tim
    0

    Are you using the built in PayPal payment provider? If you are then this is done when you call TransactionLibrary.Checkout(); (remember to call ExecuteBasketPipeline first).

  • Tim 174 posts 398 karma points
    Apr 03, 2013 @ 08:32
    Tim
    0

    As a side note, it's the payment reference you should be sending to the payment gateway (PayPal) this way you can create a new payment reference if it fails (where as you'd be abusing the order number if you did that).

  • Morten Skjoldager 440 posts 1499 karma points
    Apr 03, 2013 @ 08:50
    Morten Skjoldager
    0

    The order number is typically only used for completed orders. That is assigned in the checkout PipeLine which should be called in some point of time after you get redirected back to your site from PayPal. 

    If your not familliar with the pipelines or pipeline pattern in general i'd suggest that you take a look at: 

    http://blog.lasseeskildsen.net/post/uCommerce-Pipelines-Explained.aspx

    Also you can see how each pipeline are configured in the Pipelines folder under ucommerce in the umbraco folder. 

    But as Tim says. You should call ExecuteBasketPipeline which will make the order ready for checkout and afterwards use the TransactionLibrary.Checkout() which will then find your configured paymentmethod and redirect to paypal. 

  • Søren Spelling Lund 1797 posts 2786 karma points
    Apr 03, 2013 @ 08:56
    Søren Spelling Lund
    1

    Hi Lee,

    You can just assign an order number to the order before redirecting. If an order number is already assigned when times comes to execute the checkout pipeline uCommerce will keep the existing order number.

    Here's how:

    purchaseOrder.OrderNumber = new CheckoutService.GetOrderNumber();
    purchaseOrder.Save();

    You can also resuse the AssignOrderNumber pipeline task, which by default is configured in the Checkout pipeline. You can move it to any other pipeline.

    The pipelines you've tried out are meant for a couple of different things:

    The SaveOrder pipeline is meant for saving existing orders, which require recalculating order total. Generally speaking the SaveOrder pipeline is executed in the backend whenever the a user clicks the save button on an order.

    The Processing pipeline is executed automatically when the order is moved to "Processing" order status. By default this happens when dealing with asynchronous payment gateways, which may take some time to report back whether a payment was processed successfully or not.

  • Lee 1130 posts 3088 karma points
    Apr 03, 2013 @ 09:31
    Lee
    0
    Soren Quoted
    The Processing pipeline is executed automatically when the order is moved to "Processing" order status. By default this happens when dealing with asynchronous payment gateways, which may take some time to report back whether a payment was processed successfully or not.

    This is exactly the problem AND we are currently using the Processing pipeline before we redirect the user to PayPal (We have a custom PayPal implementation for the new paypal pro hosted solution and using IPN which works fine).

    But I expected the order to then be saved and shown in the Processing or Awaiting Payment folder? But its not? Why is this? Reason why it needs to be saved and shown is for two main reasons:

    1. So the store admins can check any outstanding unpaid for orders and contact the customer if necessary
    2. PayPal beleive it or not goes down from time to time *sarcasm* and unless these orders are saved and we can check. Then we might never know there is an issue with PayPal or know who abandoned the cart/store

    I was under the impression if the processing pipeline was executed. It would all be saved, and put in the processing folder?

    Re Order Number:

    Thanks that'll work perfectly. Again reason for this is for tracking. You need an order number for the code on the order confirmation page.

  • Tim 174 posts 398 karma points
    Apr 03, 2013 @ 09:46
    Tim
    0

    >I was under the impression if the processing pipeline was executed. It would all be saved, and put in the processing folder?

    It depends what your pipeline is configured to do (check the config) but just triggering a pipeline will only do whats in the configuration and nothing else (calling the method e.g. Checkout may do other actions under the hood).

  • Søren Spelling Lund 1797 posts 2786 karma points
    Apr 03, 2013 @ 14:10
    Søren Spelling Lund
    0
    I see the issue. uCommerce is only converting a basket to order once payment is successfully authorized. The reason being we don't want to let orders in which haven't been covered in full with payment.
    I can certainly see the argument for another pre-order status like "PaymentPending" the main issue is that you'd potentially have a lot of orders in that state because people will abondon cart during the payment phase and there's no way to distinguish between the scenario of "a real abondonment" and "a technical issue abandonment".
    uCommerce leaves the order status at "basket" because the customermight decide to return to the store without actually paying, either by A) presssing the cancel link on the payment gateway pages, or B) simply typing in the store URL later on. In this case I believe it makes sense to have the cart stick around so the customer can amend it if they need to or resume purchase later on.
    Luckily you can get exactly the behavior you want.
    By default uCommerce will load up the basket linked via the cookie and also check whether the status of the basket is indeed "Basket". If not, a new basket will be created. You can override this behavior.
    You will be able to update the order status of the basket to "Processing" or indeed any other order status and have it show up in the backend by overriding "OrderContext.GetBasket(Guid)" and registering your new implementation in "ucommerce/configuration/Custom.config".
    Here's how:
    public class MyOrderContext : OrderContext
    {
      public override Basket GetBasket(Guid basketId)
      {
      return PurchaseOrder.SingleOrDefault(o => o.BasketId == basketId);
    }
    }

    Hope this helps.

  • Lee 1130 posts 3088 karma points
    Apr 03, 2013 @ 14:28
    Lee
    0

    Thanks for the reply.

    I 'think' we have now got around the issue by doing the below just before we go to PayPal. So the order now has an order number (And matches the order number stored against the payment in PayPal) and shows in the backend in uCommerce in the Awaiting Payment folder (It seems if you set the completed date then the order appears in the back end in uCommerce).

                var coService = new CheckoutService();
                paymentRequest.PurchaseOrder.OrderNumber = coService.GetOrderNumber();
                paymentRequest.PurchaseOrder.CompletedDate = DateTime.Now;
                paymentRequest.PurchaseOrder.Save();

    We are still doing some testing, but will come back if its not. Unless you can see any issues with us doing this that we might not have thought of?

    Just a note though....

    I can certainly see the argument for another pre-order status like "PaymentPending" the main issue is that you'd potentially have a lot of orders in that state because people will abondon cart during the payment phase and there's no way to distinguish between the scenario of "a real abondonment" and "a technical issue abandonment".

    Personally I think its a high priority for any real online business to know how many abandoned carts you have irrelavant whether is a technical issue or real abandonment. Without knowing this you may never know there is a problem and you are getting a lot of people putting in cart and not completing (Apart from them checking their Google Analytics sales funnel)

    Also its very interesting to see what people are putting in there cart and abandoning. Could be a lot of the same product. Which could mean there is a problem with it (Maybe technical), or they like it but something else along the checkout is putting them off (i.e. shipping or don't trust that payment gateway is secure etc..)

    Without this information the store owner is slightly blind unless they know there way around Google Analytics and eCommerce setup.

  • Søren Spelling Lund 1797 posts 2786 karma points
    Apr 03, 2013 @ 20:42
    Søren Spelling Lund
    0

    Setting the CompletedDate will not make orders show up in the backend. Only changing order status will do that, however, if you didn't implement the override to OrderContext I posted, the cart will be emptied when order status is changed from "basket", thus customers returning to the store "on purpose" will not see their existing cart, but a new one. This may or may not be what you're after. If you want the cart to still be available upon return to the store without payment completed you need the OrderContext override in place.

    I absolutely see the scenario for having an "Awaiting Payment" status. I worry that making it available in the backend will confuse store owners as we're not talking about orders per say, but it still shows up in the order processing work flow. I'd love some input on that.

  • Lee 1130 posts 3088 karma points
    Apr 03, 2013 @ 20:48
    Lee
    0

    Hate to disagree with the boss... But setting the CompletedDate 100% makes it appear in our 'awaiting payment' folder (Might be something to do with our pipeline but don't think so). Also the order stays in the cart until the payment is completed? If they redirect to PayPal but abandon there, and come back to the site their order is still in the cart?

  • Søren Spelling Lund 1797 posts 2786 karma points
    Apr 09, 2013 @ 12:03
    Søren Spelling Lund
    0

    Probably a customization. I believe I was in contact with Matt about something along those lines now that I stop and think about it.

Please Sign in or register to post replies

Write your reply to:

Draft