Amazon Pay - API

So far we discussed the client side implementation provided by Amazon Pay. On the Spryker OS side, the module provides tools for rendering Amazon Pay widgets.

Another part of the implementation is the Amazon Pay API function wrapper, implemented as a Facade.

Each API call involves similar classes from the module:

  • An adapter for adapting Amazon SDK that makes the rest of the module independent of the external library;
  • A converter from Amazon responses to Spryker OS transfer objects;
  • A logger for logging information about API calls;
  • A transaction for updating transfer objects.

Since it is a standard Spryker OS practice, an entry point is a public method of the Facade, so the flow for a typical transaction includes the following steps:

  1. Logically grouping the affected order items, based on the transaction type:
    • for authorize & capture - by AuthorizationReferenceId
    • for refund & capture status update - by AmazonCaptureId
    • no grouping is required for close and cancel since operations are performed for the whole order.
  2. The following steps are executed for each group separately
  3. Calling Facade method.
  4. Facade creates a related transaction handler or a collection of transaction handlers.
  5. The transaction handler has execute method expecting an AmazonCallTransfer object as a parameter.
  6. The transaction handler passes a transfer object to the adapter which is responsible for direct communication with the Amazon Pay API. Using the provided SDK it converts API responses into transfer objects using converters. Apart from adapters and converters, the rest of the code does not know anything about Amazon Pay API details and only works with Spryker OS transfer objects.
  7. If not all order items, belonging to a logical group, where requested for the update, a new group is created for affected order items.
  8. The transaction handler returns a modified transfer object. All information related to Amazon Pay is stored into AmazonpayPaymentTransfer transfer object and into the database.

Additional Information:

See also:


Last review date: Oct 17th, 2018