The following presents instructions of using Tink library with .NET C#.
First, please ensure that
- Visual Studio 2010 or later is installed
- Java Runtime Environment 8 or later is installed
Next, download tink-jni-examples. Under folder TinkJNIDotNet, open solution TinkDotNetSample with Visual Studio.
In App.config, update all settings that will be loaded during runtime. If you are not sure about the settings to be used, please ask your Google Pay point of contact.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<!-- name of gateway -->
<add key="Gateway_Name" value="your gateway name"/>
<!-- base64-encoded PKCS8 private key generated by gateway -->
<add key="Base64_PKCS8_Private_key" value="your private key"/>
<!-- environment is either INSTANCE_TEST or INSTANCE_PRODUCTION -->
<add key="Trusted_Signing_Keys_Env" value="INSTANCE_TEST"/>
</appSettings>
</configuration>
IMPORTANT NOTES
For PRODUCTION environment, it is advisable to fetch the Private Key from Hardware Security Module (HSM) or Environment Variables instead of storing it as plain text in config files.
In Program.cs, update the variable _paymentSampleToken with the token of payment data generated using instructions from test app or test web.
/// <summary>
/// Sample token generated by Google Pay test web or app
/// </summary>
private const string _paymentSampleToken = "{...}";
Now, you can build and run the program. The output shall contain the decrypted data.