An open API service indexing awesome lists of open source software.

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#

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.