.NET idiomatic library that performs the steps outlined in Payment data cryptography.
It allows you to decrypt and verify a PaymentMethodToken
object generated by
the Google Pay API. It supports versions ECv1
and ECv2
.
Internally, it relies on Bouncy Castle C# and has no other external dependencies.
// To use INSTANCE_TEST, set the parameter to true
var keyProvider = new GooglePay.PaymentDataCryptography.GoogleKeyProvider(false);
var parser = new GooglePay.PaymentDataCryptography.PaymentMethodTokenRecipient("merchant:YOUR_MERCHANT_ID", keyProvider);
parser.AddPrivateKey(PrivateKey1);
parser.AddPrivateKey(PrivateKey2);
string decryptedMessage = parser.Unseal(encryptedMessage);
var passCallbackValidator = new PassCallbackValidator();
var innerMessage = passCallbackValidator.Verify("YOUR_ISSUER_ID", receivedCallbackMessage);
This is not an official Google product.
Tink is the library actively maintained and supported by the Google Pay team. Using Tink to perform payment data cryptography for Google Pay is highly recommended.