#_liamm3

1 messages · Page 1 of 1 (latest)

cunning lagoonBOT
weary thistle
#

Hmm is that Express Checkout Element? I think Express Checkout Element only has wallet buttons

analog birch
#

Yes, it's the Express Checkout Element. Here is the code for calling our backend

expressCheckoutElement.on('shippingaddresschange', async (event) => {
  const address = event.address;
  console.log("Address changed:", address);
  console.log('event', event);

  const res = await fetch('/actions/api-module/stripe-express/update-address', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Accept': 'application/json',
    },
    body: JSON.stringify({
      address,
      sku: {{ product.defaultVariant.sku }},
    }),
  });
  const payload = await res.json();
  const resolve = event.resolve;
  orderId = payload.orderNumber;

  resolve({
    lineItems: payload.displayItems
  });
});

And this is an example response, when a user selects an UK address:

{
    "id": 20702,
    "displayItems": [
        {
            "name": "Advanced Cream",
            "amount": 6600
        },
        {
            "name": "19 % MwSt. Entfernt",
            "amount": -1054
        },
        {
            "name": "0 %",
            "amount": 0
        }
    ],
    "total": {
        "label": "Insgesamt",
        "amount": 5546
    },
    "shippingOptions": [
        {
            "id": "standard",
            "label": "Standard",
            "amount": 0
        }
    ],
    "orderNumber": "e44c9e0d46903a44df49edc46f464f28",
    "status": "success"
}
cunning lagoonBOT
weary thistle
#

Can you still try the fetch_updates function above?