Adyen / adyen-dotnet-api-library

Adyen API Library for .NET

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PaymentRequest deserialization error for Drop-in Gift Card payment

akidd40 opened this issue · comments

After upgrading the NuGet paclage tp v13.0.0 (from v9.2.1) the code that deserializes the PaymentRequest JSON throws a System.IO.InvalidDataException exception when the payment is by Gift Card (payment by Credit/Debit card still works fine). Unfortunately, this upgrade is to use a bug fix in the Checkout API so reverting back isn't an option.

The line of code that throws the exception is:

var paymentRequest = Adyen.Util.JsonOperation.Deserialize<PaymentRequest>(json);

or calling Newtonsoft directy:

var paymentRequest = JsonConvert.DeserializeObject<PaymentRequest>(json);

(using System.Text.Json also failed - so i gave up on that route)

The System.IO.InvalidDataException message is:

The JSON string `{"type":"giftcard","brand":"genericgiftcard","encryptedCardNumber":"eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkEyNTZDQkMtSFM1MTIiLCJ2ZXJzaW9uIjoiMSJ9.suLzGB4UlVG4GJFj5vfKWuT8NDeoKIb-vxZIYo3RsQpd6Prz3zD4TwHYXRVxr8ljISI1UBSX10vdzSDhMppP5WDiFBGhlgHqmZ9h80DZ-9RSBHTyZpd-Q4VOiQ9WjLvpCqQcbGrh7sX6jtzjD42SHVHS0Zusgc9wP5TAuSV5F-0mMSpyIDJe3W7L4_w3hIApfhAJu4BTEoCsK0DaJt0OXv8pIkkdEMkjBRj4WEWPGnmOxH3t5mqksUvSea3klWGgPfcKXH3sX88zJ6afzzFywbECVyowfot-b6P5xUSi26gxg0vzq4FzK25VHkgP5kLG857X7zQtLdOVNcf8D1t9Wg.98qBiw7dzofT0PTtte9mYw.PpvWr14bZMrqqYBo0TpOhz8daf4CADY85YC8OWYElRgiFrjjBBREiJBHdXA0i6Szt2ZqhJdYo7LIztKfbQ_cbSvqTUdKOE125RHJ5f7gfAzcTm9VYdqmqdNZcHIim9NP.K5RMvorfaBBDIBkZ7bWIGeErYBRrVXeSy3hntrI1KFo","encryptedSecurityCode":"eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkEyNTZDQkMtSFM1MTIiLCJ2ZXJzaW9uIjoiMSJ9.9Qw1vTO3s74eB8Bz8UjKBtgk9thsisXCoUjX3BV9C7zCa98GdEpVWtv0hqnKifU1rHOdACMF7oIOMapYpMCBZkv3IFPJ-NYaO8MK9FdP_LsmutUuEUuSUTDf980QDq4dtCyzobMTNwXMJHaGmMrBdxLLFweFvm7Y2kac3orVy0M10B2mIuGhRfnQJGwcPl3dT5q2-zc6XlHZef6D9ZvxEQ9R8EDeLaplzua0jbtTBEqZtDfb55FKlD2NAf804ivVfSTBqkTFDrkGDaf8OworOpW97_34yye3dPqflXrNIZHwm5xIn4cSIf4oSFWD9xeZR3oPzs8S3pivrzUq_NVyFw.bAqhedpqyXCKq7DTGF15nw.vaDMFpslrJM1BrPEeEVkAXMD7J5j_G5ElyAZBVkXjPl_o5qhhWF_wp4pyLnt-cUL11KD8d51jmhcRrl2GOt_yw.Ha1wqT7QDGLUvI8xUQ1B5dnV1jF-5n8PJm_zpoOGRyk","checkoutAttemptId":"6455a1e1-b05a-4006-b054-f9e873444e6b170169474298074544813E3B76C55C98649D0864DD6827225E080D8290B320300EEB30466BBA2"}` cannot be deserialized into any schema defined. MatchedTypes are: System.Collections.Generic.List`1[System.String]'

The problem is in specifically deserializing the PaymentMethod JSON, but i'm finding the decompiled code hard to follow. Any help or thoughts would be greatly appreciated.

Hi @akidd40,

Thanks for reaching out here and apologies for the delayed response.

Can you please replace the "type":"giftcard" with "type":"scheme"? I just tested this locally and it worked for me. I'm creating an internal ticket to see why we are not yet supporting this "giftcard" type yet (as we should), however hopefully this will enable you to fix this issue for now and continue with your integration.

I'll let you know once we have resolved this issue and can properly use this type definition.

Best, Jilling
Adyen

Thanks Jilling. this works for me too :)

Can i just check that gift card payment data with a type of "scheme" won't have any unintended effects downstream? (for example reporting).

Best,

Alistair

Hi Jilling,

I've just found what i presume is an unintended effect of switching type from "giftcard" to "scheme". A gift card payment against an Order for a higher amount now doesn't work. The initial Payments call returns a ResultCode of "Refused" with a RefusalReason of "Not enough balance".

Best,

Alistair

Hi @akidd40,

We've been working on getting giftcard supported as as a type.
You should be able to use it in our upcoming major release.

Kind Regards,
Wouter
Adyen