PaystackHQ / plugin-magento-2

Paystack Plugin for Magento 2
MIT License
6 stars 14 forks source link

Receiving payment for unordered item(s) #11

Closed AwoyoToyin closed 7 years ago

AwoyoToyin commented 7 years ago

The issue

  1. The customer is prompted to make payment on clicking the "place order" button
  2. The payment is processed successfully
  3. The system tries to create the actual order from the quote object but fails for some reason. Let's call this reason... "network"
  4. The customer's account has been debited without an assurance of getting his/her order. The merchant most likely would never know he received payments for a good never gonna be delivered; not unless the customer complains anyway.

Solution

  1. Create the order with a "Pending Payment" status
  2. On successful order creation, prompt customer to make payments If payment is successful:
  3. Update the order status to "Processing"

@ibrahimlawal please let me know what's your take on this

ibrahimlawal commented 7 years ago

@AwoyoToyin Very well thought.

AwoyoToyin commented 7 years ago

@ibrahimlawal Happy you think so too.

Milestones

  1. I would like to eliminate the subscription to the sales_order_place_after event and remove the Profibro\Paystack\Observer\AfterOrderObserver altogether.
  2. Add a new order_status field in the system.xml for setting a default new order status; in this case "Pending Payment". DONE
  3. Add a new custom event say payment_verify_after that gets dispatched after the payment is verified successfully. DONE
  4. Add a Profibro\Paystack\Observer\AfterPaymentVerifyObserver that subscribes to the custom event. This observer simply gets the last real order and sets the status to "Processing". DONE

I have begun work on this and the only issue I have is: It seems the new order_status field in the system.xml for setting a default new order status is essentially useless has magento ignores it and defaults to "Pending" anyways.

Solution:

  1. Skip step 1 & 2 defined in the milestone and instead do a check to make sure the order was place using profibro_paystack payment code before setting the status to "Pending Payment".

What do you think?

ibrahimlawal commented 7 years ago

@AwoyoToyin Awesome, looking forward to testing this.

AwoyoToyin commented 7 years ago

@ibrahimlawal Great! The proposed solution is ready and you can go ahead with the testing whenever you can. What do you want me to do? Create a pull request?

ibrahimlawal commented 7 years ago

If it's on a staging server, that'd be great

AwoyoToyin commented 7 years ago

I'll see what I can do about that.

ibrahimlawal commented 7 years ago

But yea, a PR is great if that's a long thing 😃

AwoyoToyin commented 7 years ago

I do have it running on a client's server (which hasn't gone live yet) right now just, not exactly my staging environment. Think a PR would have to do for now. Probably have my own staging environment ready next time.

AwoyoToyin commented 7 years ago

@ibrahimlawal I believe we can mark this as closed now, right?