Checkout

The checkout process is done via shop_submitOrder mutation. This page describes the minimum requirements to place an order successfully.

Minimum Requirements For shop_submitOrder Mutation

Orders can be submitted for both types of customers if the following minimum requirements are met.

For registered users the guestId may not be set, as it would turn it into a guest order.

Mutation query:

mutation Mutation($data: UpdateCartInput!) {
    cart_update(data: $data) {
        ... on UpdateCartSuccess {
            cart {
                id
            }
        }
    }
}

Variables for the mutation (just for showcasing):

{
  "data": {
    "ops": [
      {
        "setBillingAddress": {
          "value": {
            "salutation": "MR",
            "firstname": "John",
            "lastname": "Doe",
            "street": "Any Street",
            "number": "1",
            "city": "Any City",
            "postcode": "12345",
            "country": "Any Country"
          }
        },
        "setGuestId": {
          "value": ""
        },
        "setPaymentMethod": {
          "value": {
            "interfaceId": "",
            "methodCode": ""
          }
        },
        "setShippingMethod": {
          "value": {
            "shipperId": ""
          }
        },
        "positionOp": {
          "addPosition": {
            "setItemId": {
              "value": ""
            },
            "updateQuantity": {
              "quantity": 1
            }
          }
        }
      }
    ]
  }
}

Afterwards the mutation shop_submitOrder can be used to submit the order with the given cartId.

Supporting Operations

To get a list of the available shipping methods the following query can be used:

query Query {
  shop_findCarts {
    availableShippingMethods {
      amount {
        amount
        currencyCode
        currencySymbol
        intAmount
        precision
        stringValue
      }
      description
      freeShipping
      name
      shipperId
    }
  }
}

To get a list of the available payment methods the following query can be used:

query Cart_availablePayments($cartId: ID!) {
  cart_availablePayments(cartId: $cartId) {
    interfaceId
    methodCodes
  }
}
# with variable:
{
  "cartId": ""
}

Mutation paypal_createOrder

If an order with payment method PayPal gets submitted the mutation paypal_createOrder with the orderId that is returned by shop_submitOrder is needed to start the PayPal payment process. Afterwards an approval link is returned where the payment gets handled. The customer logs into PayPal, selects the payment options and then returns to the app context, by the browser following the redirect from PayPal, to the PayPal approve URL. It will automatically try to capture the payment and then change the order to completed. (ERP system is responsible for this task to handle in the background) The server redirects to the frontend PayPal success url.