https://github.com/google-pay/payment-data-cryptography-dotnet
Sample implementation of Google Pay Payment Data Cryptography in C#
https://github.com/google-pay/payment-data-cryptography-dotnet
Last synced: about 1 year ago
JSON representation
Sample implementation of Google Pay Payment Data Cryptography in C#
- Host: GitHub
- URL: https://github.com/google-pay/payment-data-cryptography-dotnet
- Owner: google-pay
- License: apache-2.0
- Created: 2019-03-05T12:14:06.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-07-13T03:34:51.000Z (almost 4 years ago)
- Last Synced: 2024-03-27T10:06:29.820Z (about 2 years ago)
- Language: C#
- Size: 52.7 KB
- Stars: 29
- Watchers: 17
- Forks: 19
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# Google Pay - payment data cryptography in C#
## Overview
.NET idiomatic library that performs the steps outlined in [Payment data cryptography](https://developers.google.com/pay/api/web/guides/resources/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#](https://www.bouncycastle.org/csharp/index.html)
and has no other external dependencies.
## Sample use
### Decrypt payment messages
```csharp
// 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);
```
### Validate Pass callbacks:
```csharp
var passCallbackValidator = new PassCallbackValidator();
var innerMessage = passCallbackValidator.Verify("YOUR_ISSUER_ID", receivedCallbackMessage);
```
## Disclaimer
This is not an official Google product.
[Tink](https://github.com/google/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.