Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CheckoutPaymentMethod .FromJson method doesn't preserve GooglePayToken integrity #1039

Closed
PG-RichT opened this issue Jul 10, 2024 · 1 comment

Comments

@PG-RichT
Copy link
Contributor

Describe the bug

CheckoutPaymentMethod .FromJson method doesn't preserve GooglePayToken integrity causing failure to complete payment.

On submission of PaymentRequest, the following error is returned from the Adyen API:

{
  "status": 422,
  "errorCode": "5_202",
  "message": "Invalid PayWithGoogle Token",
  "errorType": "validation",
  "pspReference": "VMN8WMH3WFRLLR65"
}

In the Adyen documentation for handling errors with Google Pay (https://docs.adyen.com/development-resources/error-codes/#5202-invalid-paywithgoogle-token), you state:

Make sure that you are sending in the correct token. Do not escape the stringified JSON; send it as it is.

To Reproduce
Steps to reproduce the behavior:

Using the C# Adyen client library, receive a MakePayment payload from Adyen Dropin client and create a CheckoutPaymentMethod object using the static FromJson method and the received paymentMethod object contents.

On receipt the paymentMethod contents looks like something this. Note the encoding at the end of each property value inside the signedMessage object:

{
  "type": "paywithgoogle",
  "googlePayToken": "{\"signature\":\"MEYCIQDBZEzdH0afYNxdkFD8L9KduGfFO6ZwLma9KxkDzUOqBwIhAJRUpkA7Dhvxub2RZc5fk67xKmjz4JxYYmp0w20j06nB\",\"protocolVersion\":\"ECv1\",\"signedMessage\":\"{\\\"encryptedMessage\\\":\\\"Tggo9YYct1D09NwPy5QXH0RYDqRW9FfwSqwlNWGtnJGmF9/LH263lJg6Wob7JlEjePIxh4Vp2ILx1wbx5U9tIecDB9/gHO0cYMRpJi5mUPlWSz0/3MJU6Vf49+XWmCuvTscAKRE90UzafDajKBtpjWM8KDpgt3vHUQDJaNr3k+cBTFOWydYJXOUfyCmT7u+5LV11Kho7E8YC15EbFBVeZ00CCi7qF5k8PavtTEeUuks+0zV7izCjHASljiHCFOdN4c7o09VRrFakVidhH8QgltS9+eW4O09O6+9c0CMZaqLoRjVygAIbH7VPH26qI20SsUg5NNYhfVjjaBapJljWvW1XxHsJ8VmWnKNdDW4JoFgNIpeECi/BGVwgyyI3LmhtSD1qwCOb9r3l6iH7/1usvFMusVmvFfRElhbgILRZrNi4zJ2RZfseJFe8vO8JctX8RfJgPJlEFqe/qTGLXEsjNyB1ePz9g9mvkOccWz0Cge20I8gZBdSpQKZkPiu9yTwOPw\\\\u003d\\\\u003d\\\",\\\"ephemeralPublicKey\\\":\\\"BMzHuZyjSIngfmV6FVt5PRu5km/ESAqPfe4xXjmUIYyol9THh16Y1r4ZzHyfo3NFtcksteOOKlpW7qMln791KUE\\\\u003d\\\",\\\"tag\\\":\\\"O2FfG8JBYMGLI/6U0dm0Qm57APD7ivme8xxPZBSfKBM\\\\u003d\\\"}\"}",
  "googlePayCardNetwork": "MASTERCARD",
  "checkoutAttemptId": "bd2828fb-2243-467d-9f64-68cab32ea99717206059619985659D9DFED0E623007C65F15855C2CA4F4874C10AEB4F7A0462D72DC2C82C648"
}

After creating an object using the FromJson method, note the change to the end of the property values inside the nested signedMessage object that causes the issue:

{
  "signature": "MEYCIQDBZEzdH0afYNxdkFD8L9KduGfFO6ZwLma9KxkDzUOqBwIhAJRUpkA7Dhvxub2RZc5fk67xKmjz4JxYYmp0w20j06nB",
  "protocolVersion": "ECv1",
  "signedMessage": "{\"encryptedMessage\":\"Tggo9YYct1D09NwPy5QXH0RYDqRW9FfwSqwlNWGtnJGmF9/LH263lJg6Wob7JlEjePIxh4Vp2ILx1wbx5U9tIecDB9/gHO0cYMRpJi5mUPlWSz0/3MJU6Vf49+XWmCuvTscAKRE90UzafDajKBtpjWM8KDpgt3vHUQDJaNr3k+cBTFOWydYJXOUfyCmT7u+5LV11Kho7E8YC15EbFBVeZ00CCi7qF5k8PavtTEeUuks+0zV7izCjHASljiHCFOdN4c7o09VRrFakVidhH8QgltS9+eW4O09O6+9c0CMZaqLoRjVygAIbH7VPH26qI20SsUg5NNYhfVjjaBapJljWvW1XxHsJ8VmWnKNdDW4JoFgNIpeECi/BGVwgyyI3LmhtSD1qwCOb9r3l6iH7/1usvFMusVmvFfRElhbgILRZrNi4zJ2RZfseJFe8vO8JctX8RfJgPJlEFqe/qTGLXEsjNyB1ePz9g9mvkOccWz0Cge20I8gZBdSpQKZkPiu9yTwOPw\\u003d\\u003d\",\"ephemeralPublicKey\":\"BMzHuZyjSIngfmV6FVt5PRu5km/ESAqPfe4xXjmUIYyol9THh16Y1r4ZzHyfo3NFtcksteOOKlpW7qMln791KUE\\u003d\",\"tag\":\"O2FfG8JBYMGLI/6U0dm0Qm57APD7ivme8xxPZBSfKBM\\u003d\"}"
}

Expected behavior
The contents of the googlePayToken should be preserved and not altered in any way.

Desktop (please complete the following information):

  • Dropin, v5.66.1
  • dotNet library v17.0.0
  • OS: Windows
  • Browser: Chrome
  • Version: 126.0.6478.127 (Official Build) (64-bit)
@PG-RichT
Copy link
Contributor Author

For anyone else that finds themselves here, I resolved the issue. It helps if your incoming payload is mapped to the 'Adyen.Model.Checkout.PaymentRequest' model, then all is well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant