Fetch Guest customer Payment details by /V1/guest-carts/:cartId/shipping-information REST API Magento 2.

Guest Quote REST API /V1/guest-carts/:cartId/shipping-information to fetch available payment method and cart totals related information for Guest Cart.

When you work with the Guest Customer Order flow via API, you need given API details to fetch the payment method for the current quote.

Before Moving further you have an available Guest Cart token to fetch payment details.

Action: POST

URL: <WEBSITE_URL>/rest/<store_code>/V1/guest-carts/:cartId/shipping-information
(Example: https://magento.test/rest/default/V1/guest-carts/fQtl1bxLdxud1fFEP68znOAPnAFFpjVh/shipping-information)

Payload:

{
    "addressInformation": {
        "shipping_address": {
            "region": "California",
            "region_id": "12",
            "country_id": "US",
            "street": [
                "34 Royal Street"
            ],
            "postcode": "90011",
            "city": "California",
            "firstname": "Rakesh",
            "lastname": "Patel",
            "email": "rakesh@jesadiya.com",
            "telephone": "0144225311"
        },
        "billing_address": {
            "region": "California",
            "region_id": "12",
            "country_id": "US",
            "street": [
                "34 Royal Street"
            ],
            "postcode": "90011",
            "city": "California",
            "firstname": "Rakesh",
            "lastname": "Patel",
            "email": "rakesh@jesadiya.com",
            "telephone": "01422531"
        },
        "shipping_carrier_code": "flatrate",
        "shipping_method_code": "flatrate"
    }
}

For the current quote, you must pass shipping_address and billing_address data with shipping_carrier_code and shipping_method_code.

You can fetch the shipping carrier and method code from the Guest Estimate shipping method REST API.

Response:

{
    "payment_methods": [
        {
            "code": "checkmo",
            "title": "Check / Money order"
        },
        {
            "code": "paypal...",
            "title": "Credit / Debit card"
        }
    ],
    "totals": {
         .....
    }
}