Navigation

Amazon Pay - State Machine

The state machine is different for synchronous and asynchronous flow. Although from status "capture completed" it is the same and in the state machine, it's presented as a sub-process.

State machine for the synchronous flow:

Synchronous Flow

State machine for the asynchronous flow:

Asynchronous Flow

OMS Commands

In order to support processing of OMS, there's list of commands and conditions.

Below is the example of injection.

<script>
            /**
            * @param \Spryker\Zed\Kernel\Container $container
            *
            * @return void
            */
            protected function injectAmazonPayCommands(Container $container)
            {
                $container->extend(
                    OmsDependencyProvider::COMMAND_PLUGINS,
                    function (CommandCollectionInterface $commandCollection) {
                        $commandCollection
                            ->add(new CancelOrderCommandPlugin(), 'AmazonPay/CancelOrder')
                            ->add(new CloseOrderCommandPlugin(), 'AmazonPay/CloseOrder')
                            ->add(new RefundOrderCommandPlugin(), 'AmazonPay/RefundOrder')
                            ->add(new ReauthorizeExpiredOrderCommandPlugin(), 'AmazonPay/ReauthorizeExpiredOrder')
                            ->add(new CaptureCommandPlugin(), 'AmazonPay/Capture')
                            ->add(new UpdateSuspendedOrderCommandPlugin(), 'AmazonPay/UpdateSuspendedOrder')
                            ->add(new UpdateAuthorizationStatusCommandPlugin(), 'AmazonPay/UpdateAuthorizationStatus')
                            ->add(new UpdateCaptureStatusCommandPlugin(), 'AmazonPay/UpdateCaptureStatus')
                            ->add(new UpdateRefundStatusCommandPlugin(), 'AmazonPay/UpdateRefundStatus');

                        return $commandCollection;
                    }
                );
            }

            /**
            * @param \Spryker\Zed\Kernel\Container $container
            *
            * @return void
            */
            protected function injectAmazonPayConditions(Container $container)
            {
                $container->extend(OmsDependencyProvider::CONDITION_PLUGINS, function (ConditionCollectionInterface $conditionCollection) {
                $conditionCollection
                    ->add(new IsClosedConditionPlugin(), 'AmazonPay/IsClosed')
                    ->add(new IsCloseAllowedConditionPlugin(), 'AmazonPay/IsCloseAllowed')

                    ->add(new IsCancelledConditionPlugin(), 'AmazonPay/IsCancelled')
                    ->add(new IsCancelNotAllowedConditionPlugin(), 'AmazonPay/IsCancelNotAllowed')
                    ->add(new IsCancelledOrderConditionPlugin(), 'AmazonPay/IsOrderCancelled')

                    ->add(new IsAuthOpenConditionPlugin(), 'AmazonPay/IsAuthOpen')
                    ->add(new IsAuthDeclinedConditionPlugin(), 'AmazonPay/IsAuthDeclined')
                    ->add(new IsAuthPendingConditionPlugin(), 'AmazonPay/IsAuthPending')
                    ->add(new IsAuthSuspendedConditionPlugin(), 'AmazonPay/IsAuthSuspended')
                    ->add(new IsAuthExpiredConditionPlugin(), 'AmazonPay/IsAuthExpired')
                    ->add(new IsAuthClosedConditionPlugin(), 'AmazonPay/IsAuthClosed')
                    ->add(new IsAuthTransactionTimedOutConditionPlugin(), 'AmazonPay/IsAuthTransactionTimedOut')
                    ->add(new IsAuthSuspendedConditionPlugin(), 'AmazonPay/IsPaymentMethodChanged')

                    ->add(new IsCaptureCompletedConditionPlugin(), 'AmazonPay/IsCaptureCompleted')
                    ->add(new IsCaptureDeclinedConditionPlugin(), 'AmazonPay/IsCaptureDeclined')
                    ->add(new IsCapturePendingConditionPlugin(), 'AmazonPay/IsCapturePending')

                    ->add(new IsRefundCompletedConditionPlugin(), 'AmazonPay/IsRefundCompleted')
                    ->add(new IsRefundDeclinedConditionPlugin(), 'AmazonPay/IsRefundDeclined')
                    ->add(new IsRefundPendingConditionPlugin(), 'AmazonPay/IsRefundPending');

                    return $conditionCollection;
                });
            }
        </script>

 

See also:

 

Last review date: Nov. 13th, 2017