Vonage / vonage-php-sdk-core

Vonage REST API client for PHP. API support for SMS, Voice, Text-to-Speech, Numbers, Verify (2FA) and more.
https://developer.vonage.com/
Apache License 2.0
916 stars 180 forks source link

Vonage server does not send `scts` property in `DeliveryReceipt` JSON Payload #416

Closed ankurk91 closed 1 year ago

ankurk91 commented 1 year ago

Expected Behavior

DeliveryReceipt class should be able to construct the object

Current Behavior

Vonage\SMS\Webhook\DeliveryReceipt class throws an exception that scts property is not there

InvalidArgumentException: Delivery Receipt missing required data `scts` in /home/user-name/laravel/vendor/vonage/client-core/src/SMS/Webhook/DeliveryReceipt.php:223

Possible Solution

Make scts optional

Steps to Reproduce (for bugs)

Send an SMS to a wrong number, and receive a DLR on app server and check JSON Payload, you will find scts missing

// Controller code
$dlr = new DeliveryReceipt($request->json()->all());

Context

Here is the JSON Payload that we received from vonage server

{
  "err-code": "12",
  "timestamp": "1687253022",
  "messageId": "2e1b8fa7-5fb5-4792-b24c-4caa2d06d73b",
  "msisdn": "<<WRONG-NUMBER>>",
  "api-key": "0506784e",
  "price": "0.00620000",
  "to": "<<PHONE-NUMBER>>",
  "network-code": "US-TOLL-FREE",
  "nonce": "3e6f06a8-cc54-4389-b259-eb9c05fa344c",
  "message-timestamp": "2023-06-20 09:23:42",
  "sig": "2774ed469193bb96e363f44739e4faba",
  "status": "failed"
}

Notice the failed status

Your Environment

SecondeJK commented 1 year ago

scts is a property that looks to have been changed in the API (we saw this recently that affected how the webhooks are constructed.) I'll take another look at this, it might be just be a case of making it optional (hopefully) but there may be some logic that relies on that property

SecondeJK commented 1 year ago

Fixed by #424, thank you for reporting