Glue: How to provide a state machine process for a method?

I am currently writing a GLUE API Module for an IoT Project. The idea is to order an Item, when a button is pressed. Similiar to the Amazon Dash Button.

My module accepts a POST requests with an authentication header and a SKU in its body. Upon receiving the request, it uses various clients to get the customer details, their cart id, Addresses, Payment Methods and Shipment Methods. To place the order I prepare a quoteTransfer object and provide it with the mentioned Information. So the whole process is basically the same as if you would call the “/access-tokens”, “/carts”, “/carts/{cartId}/items” and finally “/checkout”, but in just one request.

Now the problem is the actual order placement. I tried two methods:

  1. Using the ZedRequestClient to call ‘/checkout-rest-api/gateway/place-order’ with a RestCheckoutRequestAttributesTransfer object
  2. Using the CheckoutClient

The first approach results in the ZED error “BadMethodCallException - You need to provide at least one state machine process for given method!”. Unfortunately I couldn’t find anything about this error and I don’t know what method is meant and how I am able to provide it with a state machine. The given /checkout endpoint places an order successfully when used as intended, so I guess it’s an issue with my RestCheckoutRequestAttributesTransfer object, but I don’t see how to provide it with a state machine.

The second approach using the CheckoutClient gives me an “Order can not be processed” error, when calling getErrors() on the CheckoutResponseTransfer, which doesn’t help me much. The Method “isQuoteApplicableForCheckout” returns true though.

I would be very thankful if someone could explain the cause of the BadMethodCallException or how to debug the CheckoutClient further. Maybe both of my approaches are fundamentally wrong, so I am open for suggestions :grin:

Best Regards

This error means that for the payment method selected for this order, system cannot find configured state machine.
State machine is configured in the config file
PaymentMethodsConstants::PAYMENT_METHOD_INVOICE => ‘PaymentInvoice03’,

1 Like

Your tip made me realize that something about the payment is wrong. Turned out that I didn’t set the paymentSelection Field in my RestPaymentTransfer Object for the RestCheckoutRequestAttributesTransfer.

For others with the same problem:
I have set it using
$paymentProviderMethodToStateMachineMappig = $config->getPaymentProviderMethodToStateMachineMapping();


$config being my CheckoutRestApiConfig Object that I pass to my Processor in the constructor.

It works now, thanks again!