Please select a payment method, Please select a shipping method (eCom API)

Nikola PetrovNikola Petrov Member Posts: 1

Hi there!

I'm creating a new order via API and I keep running into the same issue - I can't validate it even after setting the payment and shipping methods. Here is what I am doing:

$checkout = $api->checkouts->create( ... );

Then I'm getting the methods with:

$shipping_methods = $api->checkoutsShipment_methods->get( $checkout_id );
$payment_methods  = $api->checkoutsPayment_methods->get( $checkout_id );

And then setting them with:

// Set the shipping method
$api->checkouts->update( $checkout_id, [
   "shipment_method" => [
      "id" => $shipping_methods[0]['id']
] );

// Set the payment method
$checkout = $api->checkouts->update( $checkout_id, [
   "payment_method" => [
      "id"     => $payment_methods[0]['id']
] );

At this point everything works as expected. If I var_dump the $updated_checkout array, I can see the payment and shipping methods being set. However, once I try

// Validate the new order
$validate = $api->checkoutsValidate->get( $checkout['id'] );

I am still getting:

  array(2) {
    string(30) "Please select a payment method"
    string(31) "Please select a shipping method"

Am I missing something or doing something wrong?

Thank you!


1 comment

  • HiddeHidde Member, Partner Posts: 44 partner

    I had the same issue today. I found out the shipping and payment methods are reset if you add products to the checkout. So you could try the following order:

    1. Create the checkout
    2. Add products to the checkout
    3. Set the payment and shipping methods

    In this order it works for me.

    Hidde Schuurman | Backend & App Developer bij InStijl Media | Gold Partner Lightspeed
Sign In or Register to comment.