tutorial on lalamove webhook

24
CONFIDENTIAL Tutorial on Lalamove Webhook Lalamove Developers Sep 2021

Upload: others

Post on 02-Dec-2021

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Tutorial on Lalamove Webhook

CONFIDENTIAL

Tutorial on Lalamove WebhookLalamove DevelopersSep 2021

Page 2: Tutorial on Lalamove Webhook

CONFIDENTIAL Tutorial on Lalamove Webhook (Sep 2021)

● This deck explains the details of Lalamove’s webhook in Sandbox and Production

● We use webhook.site to demonstrate the idea

Objectives

Page 3: Tutorial on Lalamove Webhook

CONFIDENTIAL Tutorial on Lalamove Webhook (Sep 2021)

1. API credentials, commonly known as key AND secret

2. Go to Lalamove’ Partner Portal (partnerportal.lalamove.com)

○ Choose either environment (Sandbox or Production)

3. For demonstration, we will use the Sandbox environment

Pre-requisites

Page 4: Tutorial on Lalamove Webhook

CONFIDENTIAL Tutorial on Lalamove Webhook (Sep 2021)

1. Navigate to partnerportal.lalamove.com

2. Select the country that you are granted access

3. Login with the provided credentials

Partner Portal

Page 5: Tutorial on Lalamove Webhook

CONFIDENTIAL Tutorial on Lalamove Webhook (Sep 2021)

4. Click “Developers” at the header bar

5. Enter the webhook URL, click “Save”

(We use webhook.site for the demonstration)

Partner Portal

Page 6: Tutorial on Lalamove Webhook

CONFIDENTIAL Tutorial on Lalamove Webhook (Sep 2021)

6. For initial connection, make sure to send status 200 even when Lalamove doesn’t send anything in the body. It is recommended that you send 200 before any complex logic.

7. Once the connection is successful, make sure to validate the receive Webhook update’s signature. (Our Webhook fields are subject to change, so please don’t hard code any fields)

8. Whenever there is a status update, our Webhook will try to send the update 10 times within 24 hour day window. We will try again with exponential delay in between.. By the 10th status update, if we still don’t receive any, we will disable the URL. At this point, the client is responsible for going back to Partner Portal to update their Webhook URL.

9. Our Webhooks may not be sent in the right chronological order, so please make sure to sort them in the right order based on the timestamp after you’ve received them

Receiving the webhooks

Page 7: Tutorial on Lalamove Webhook

CONFIDENTIAL Tutorial on Lalamove Webhook (Sep 2021)

Validating the webhooks1. Check whether this apiKey is

the same

2. Insert your API Secret

3. Insert your URL path after the root domain (ex:https://abc.com/lalamove/webhook => /lalamove/webhook )

4. If two signatures are identical, then it’s a valid Lalamove Webhook update

Link to the code

Page 8: Tutorial on Lalamove Webhook

CONFIDENTIAL Tutorial on Lalamove Webhook (Sep 2021)

8. You will receive a webhook push if any of the followings happen to your orders:

a. Status Change (ORDER_STATUS_CHANGED )

b. Order Amount Changed (ORDER_AMOUNT_CHANGED )

■ Priority fee added

■ Add-on fee adjustment

c. Order Replaced (ORDER_REPLACED )

d. Wallet Balance Changed (WALLET_BALANCE_CHANGED)

When will Lalamove push message to your webhook?

Page 9: Tutorial on Lalamove Webhook

CONFIDENTIAL Tutorial on Lalamove Webhook (Sep 2021)

Status Change (ORDER_STATUS_CHANGED)

ORDER_STATUS_CHANGED has 7 different statuses

a. ASSIGNING_DRIVER

b. ON_GOING

c. PICKED_UP

d. COMPLETED

e. EXPIRED

f. CANCELED

g. REJECTED

Page 10: Tutorial on Lalamove Webhook

CONFIDENTIAL Tutorial on Lalamove Webhook (Sep 2021)

1. ASSIGNING_DRIVER

Note that this the orderRef id in developers.lalamove.com

Page 11: Tutorial on Lalamove Webhook

CONFIDENTIAL Tutorial on Lalamove Webhook (Sep 2021)

2. ON_GOING

Page 12: Tutorial on Lalamove Webhook

CONFIDENTIAL Tutorial on Lalamove Webhook (Sep 2021)

3. PICKED_UP

Page 13: Tutorial on Lalamove Webhook

CONFIDENTIAL Tutorial on Lalamove Webhook (Sep 2021)

4. COMPLETED

Page 14: Tutorial on Lalamove Webhook

CONFIDENTIAL Tutorial on Lalamove Webhook (Sep 2021)

5. EXPIRED

Page 15: Tutorial on Lalamove Webhook

CONFIDENTIAL Tutorial on Lalamove Webhook (Sep 2021)

6. CANCELED

Page 16: Tutorial on Lalamove Webhook

CONFIDENTIAL Tutorial on Lalamove Webhook (Sep 2021)

7. REJECTED

Page 17: Tutorial on Lalamove Webhook

CONFIDENTIAL Tutorial on Lalamove Webhook (Sep 2021)

Order Amount Changed (ORDER_AMOUNT_CHANGED)

Page 18: Tutorial on Lalamove Webhook

CONFIDENTIAL Tutorial on Lalamove Webhook (Sep 2021)

Wallet Balance Changed (WALLET_BALANCE_CHANGED)

Page 19: Tutorial on Lalamove Webhook

CONFIDENTIAL Tutorial on Lalamove Webhook (Sep 2021)

Cancel-and-Clone

● Currently, Lalamove cancels an old order and creates a new order by cloning when post-match adjustments (ex: driver waiting fees) need to be made for API orders.

● Previously clients didn’t have an effective way of tracking which new orders were cloned from what.

● To solve this, we have also created Webhook updates for Cancel-and-Clone orders. We will sequentially send updates of two order statuses (Canceled & Assigning) and ORDER_REPLACED event to indicate the replacement

Page 20: Tutorial on Lalamove Webhook

CONFIDENTIAL Tutorial on Lalamove Webhook (Sep 2021)

Normal CancellationThis is what clients would see when they cancel the order themselves

Note that the “cancelledReason” is “other” and doesn’t have “remark” field

Page 21: Tutorial on Lalamove Webhook

CONFIDENTIAL Tutorial on Lalamove Webhook (Sep 2021)

Step 1: Cancel existing order

Note that it will include the “cancelledReason” and the” remark”: “Canceled by Customer Service”

Page 22: Tutorial on Lalamove Webhook

CONFIDENTIAL Tutorial on Lalamove Webhook (Sep 2021)

Step 2: Create (Clone) new order

Note that there may be several status updates of new order to match the previous order status (ASSINGING, ON_GOING, and etc.)

Page 23: Tutorial on Lalamove Webhook

CONFIDENTIAL Tutorial on Lalamove Webhook (Sep 2021)

Step 3: Replacement

Page 24: Tutorial on Lalamove Webhook

CONFIDENTIAL

Thank you!Documentation: developers.lalamove.com

Questions? Contact [email protected]