Skip to content

Commit

Permalink
Add example on how an order can be created asynchronously
Browse files Browse the repository at this point in the history
  • Loading branch information
butenkor authored Mar 10, 2023
1 parent f21f1e9 commit bc2c28f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion docs/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Both approaches have their good and bad sides, but we found out that creating an
#### What to consider when creating an order _AFTER_ a successful commercetools payment ?

- **Shop (success redirect URL) is not reachable due to the network issues**: Since shop creates an order and success shop redirect URL can not be reached we might end up with a successful payment but no order.
- **Possible solution**: Create an order asynchronously based on the payment transaction changes, which delivery is guaranteed due to the asynchronous notifications from Adyen. Depending on your preference you might either query for the latest messages of type [PaymentTransactionAdded](https://docs.commercetools.com/api/message-types#paymenttransactionadded-message), [PaymentTransactionStateChanged](https://docs.commercetools.com/api/message-types#paymenttransactionstatechanged-message) or [subscribe](https://docs.commercetools.com/api/projects/subscriptions#create-a-subscription) to the mentioned message types. Every [message](https://docs.commercetools.com/api/message-types#message) will link its payment through the `resource` field and since every payment is attached to a cart one has all the informations at hand to decide if the cart has to be converted to order or not. Since the job or worker processing the message is not a usual place where the order is created it might be reasonable to pass the cart ID to another service or web shop URL which will verify the cart and create an order out of it.
- **Possible solution**: Create an order asynchronously based on the payment transaction changes, which delivery is guaranteed due to the asynchronous notifications from Adyen. Depending on your preference you might either query for the latest messages of type [PaymentTransactionAdded](https://docs.commercetools.com/api/message-types#paymenttransactionadded-message), [PaymentTransactionStateChanged](https://docs.commercetools.com/api/message-types#paymenttransactionstatechanged-message) or [subscribe](https://docs.commercetools.com/api/projects/subscriptions#create-a-subscription) to the mentioned message types. Every [message](https://docs.commercetools.com/api/message-types#message) will link its payment through the `resource` field and since every payment is attached to a cart one has all the informations at hand to decide if the cart has to be converted to order or not. Since the job or worker processing the message is not a usual place where the order is created it might be reasonable to pass the cart ID to another service or web shop URL which will verify the cart and create an order out of it. An example implementation which follows the described approach is shown by [commercetools-payment-to-order-processor](https://github.com/commercetools/commercetools-payment-to-order-processor)
- **More than 1 successful payments on the cart/order**: It is possible to have more than 1 valid payments on the cart/order. It could happen for example when customer initiates a payment in two different tabs for the same cart and both payments are of type redirect (like credit card and paypal.
These two payments can be completed independently in both tabs. Since every payment should be always attached to the cart this would make a cart to link two successful payments.
- **Possible solution**: [Refund](https://github.com/commercetools/commercetools-adyen-integration/blob/master/extension/docs/Refund.md) one of the successful payments. Similar as in case of `Create an order based on transaction state changes` above one could process the same message types in order to figure out if the cart has to many successful payments and create a refund.
Expand Down

0 comments on commit bc2c28f

Please sign in to comment.