Webhooks : livraison

Vous pouvez utiliser le webhook des tarifs de livraison lorsque vous souhaitez gérer vous-même le calcul des tarifs de livraison. Snipcart appellera votre application à l'URL spécifiée dans votre tableau de bord.

Dans votre tableau de bord, allez dans Store configurations → Shipping → Webhooks et entrez les informations de point de terminaison requises.

Snipcart fera une requête HTTP POST à l'URL spécifiée. Le corps de la demande contiendra tous les détails de la commande en cours.

Requête

Méthode POST

Content-Type application/json

Corps

{
  "eventName": "shippingrates.fetch",
  "mode": "Live",
  "createdOn": "2015-02-21T14:58:02.6738454Z",
  "content": {
    "token": "22808196-0eff-4a6e-b136-3e4d628b3cf5",
    "creationDate": "2015-02-21T14:58:02.6738454Z",
    "modificationDate": "2015-02-21T14:58:02.6738454Z",
    "status": "Processed",
    "currency": "USD",
    "lang": "en",
    "paymentMethod": "CreditCard",
    "email": "customer@snipcart.com",
    "cardHolderName": "Nicolas Cage",
    "billingAddressName": "Nicolas Cage",
    "billingAddressCompanyName": "Company name",
    "billingAddressAddress1": "888 The street",
    "billingAddressAddress2": "",
    "billingAddressCity": "Québec",
    "billingAddressCountry": "CA",
    "billingAddressProvince": "QC",
    "billingAddressPostalCode": "G1G 1G1",
    "billingAddressPhone": "(888) 888-8888",
    "shippingAddressName": "Nicolas Cage",
    "shippingAddressCompanyName": "Company name",
    "shippingAddressAddress1": "888 The street",
    "shippingAddressAddress2": "",
    "shippingAddressCity": "Québec",
    "shippingAddressCountry": "CA",
    "shippingAddressProvince": "QC",
    "shippingAddressPostalCode": "G1G 1G1",
    "shippingAddressPhone": "(888) 888-8888",
    "shippingAddressSameAsBilling": true,
    "finalGrandTotal": 310.00,
    "shippingAddressComplete": true,
    "creditCardLast4Digits": "4242",
    "shippingFees": 10.00,
    "shippingMethod": "Livraison",
    "items": [{
      "uniqueId": "eb4c9dae-e725-4dad-b7ae-a5e48097c831",
      "token": "22808196-0eff-4a6e-b136-3e4d628b3cf5",
      "id": "1",
      "name": "Movie",
      "price": 300.00,
      "originalPrice": 300.00,
      "quantity": 1,
      "url": "https://snipcart.com",
      "weight": 10.00,
      "description": "Something",
      "image": "http://placecage.com/50/50",
      "customFieldsJson": "[]",
      "stackable": true,
      "maxQuantity": null,
      "totalPrice": 300.0000,
      "totalWeight": 10.00,
      "shippable": true,
    }],
    "subtotal": 610.0000,
    "totalWeight": 20.00,
    "discounts": [],
    "willBePaidLater": false
  }
}

Réponse

Snipcart s'attend à recevoir un objet JSON contenant un tableau de taux de livraison.

Succès

Le code d'état de la réponse doit être 2XX pour indiquer que la demande a été traitée avec succès.

En-têtes HTTP obligatoires

Clé Valeur
Content-Type application/json

Contenu

{
  "rates": [{
    "cost": 10,
    "description": "10$ shipping"
    }, {
    "cost": 20,
    "description": "20$ shipping",
    "guaranteedDaysToDelivery": 5
    },
    ...
  ]
}

Erreur

Si vous voulez que Snipcart affiche un message d'erreur à vos clients, vous pouvez le faire en nous retournant un code d'état 2XX avec l'objet JSON suivant.

{
  "errors": [{
    "key": "invalid_postal_code",
    "message": "The postal code is invalid."
    },
    ...
  ]
}
,"Événements d'abonnement","40a530dd-3f7b-4ee5-ae03-7a3086880611","8aa7b1f20ec8","6cf508a2d7df","4e4ff387741f","df4220ff1446","Exemples","94c7836ce5f3","/passerelle-de-paiement-personnalisee","77889630-cd22-4ad6-b352-54040033c724","6027ba2be58f","/passerelle-de-paiement-personnalisee/configuration-du-commercant","Merchant configuration","Configuration du commerçant","3ba3026b-2bfb-40b8-b0e3-b1a29eb5d8cd","9214ffdcbab4","/passerelle-de-paiement-personnalisee/api","e6809589-d283-4b10-9e5c-a8ec15303cfb","8046985b24d4","/passerelle-de-paiement-personnalisee/retourner-les-methodes-de-paiement","Return payment methods","Retourner les méthodes de paiement","b7d8c26b-e5f4-484b-a9ef-a5ca41f85393","136519945525","/passerelle-de-paiement-personnalisee/ecran-de-paiement","External checkout","Paiement externe","ec2a5724-5506-47b6-9c7a-d310bb4d0e09","aa53add73259","/passerelle-de-paiement-personnalisee/traitement-cote-serveur","Server-side processing","Traitement côté serveur","bd87ce7d-0239-420a-9a18-862a9b6deb66","4ed2a6ce8bd9","/passerelle-de-paiement-personnalisee/confirmation-de-redirection-de-commande","Redirect customers","Rediriger les clients vers Snipcart","e2d6d233-29ec-4b16-ab36-56f868588988","e1b66edceecc","/passerelle-de-paiement-personnalisee/paiements-des-remboursements","Refund payments","Paiements des remboursements","6a85e846-fa51-410b-9709-7ff8cdd89f41","569a37399012","/passerelle-de-paiement-personnalisee/tutoriel","Tutorial: Google Pay","Tutoriel : Google Pay","9af20347-1724-4fac-8db6-adc33da0c35e","98ab29c4ef61","/passerelle-de-paiement-personnalisee/reference-technique","Technical reference","Référence technique","1b6b88cc-39a0-486e-90d3-ede9e872b9f2","Custom payment gateway","db553a8396c1","b024edbeb039","a1d79bb2-ed0b-4d69-9307-4dc381de6e60","f0b1bed30c4e","f63e3ad3-382f-4ac2-9935-f1275b7ae6c3","48f4c95f530f","c41c5d4f-4381-4c68-9d0c-fb3a7d329f0d","e6ad3d4da679","db83302dc1f0","47fdea683c65","de84dce9-5f6a-4813-a2d7-37c28b99d69d","103ea81a8c8f","e4dfbc3a-02ae-4604-a259-5b5189d531e8","51b6515636bc","666201e04a04","c419b3e240bf","f6c8e023-437e-4223-a9a7-4b3747c53731","986ab3a92333","936f652a-6bcb-4efd-b400-2ae02fa7b8bb","ba3536c135b9","43ecdf47ca2c","cd7ba04f-a8fe-468d-9fca-1725eaf6a7fd","19b188bc1a55","f9086567414b","c8b716de8866","f850a03b5f01","39809dc73095","9b3097d5-6456-427f-abde-3f4a0ba89fa4","b5e0d2ec1f25","5d9b9c748755","c1c4e307dd2a","aa824bbbe90d","6e0066de927f","b09130bd2488","62ceaaea8d3a","551c7a0a47a1","e6157c641659","594a93ba7710","2c2884a584d0","fe313fdf8bd1","2f0bdbc6ef59","0dacdbeb4268","07ac02a70ccb","7e82126553e8","330206f64118","c6934077f49d","d9c0a229f193","bbf5d766d79a","6b7887281cf8","daec53f67df3","76f6cdbdc745","3909b2163ee3","dec5aedf-b3f4-4f94-9baa-ce3fc6bf0f88","589889f37a6b","8fbb322c-10b3-4952-a3a9-34b62cca514a","858b7845c741","0c133347-9483-4a0e-85bb-427c0526c23d","5ee89489ffee","2496927b-dbd3-47e5-9bd4-b3d9f160ac60","4890b4ff36c8","Custom validation","35e4f0d2-1047-4369-bfb0-4a1c8d5dbd47","Javascript API","4513cd33faee","14b10ee600d6","a7235b09213a","8215d5e00da1","9081f539df33","c51838d9467f","1923fd982292","9c2a598a3fbe","5e7e2599977f","35740d4f7ac7","8aa326c13f44","0f1f116d43ff","151c7d49f3a4","0db1a7e14b66","9050fb6daa4d","59ca8bcefd5a","f89bcde7d5e1","bd1a1711f21b","bd052759fc05","9c7942dcc6c7","1003dc63c5d9")