# Ruby HOW-TO The following presents instructions of using [Tink](https://github.com/google/tink) library with Ruby.
# Ruby HOW-TO
The following presents instructions of using [Tink](https://github.com/google/tink) library with Ruby.

## 1. Installation
Download, unzip and open "TinkRubySample" project with Ruby IDE. Please ensure:
- [Ruby](https://www.ruby-lang.org/en/documentation/installation/) is installed
- [Ruby Gems](https://rubygems.org/), the Ruby Package Management framework is installed
- [RJB](https://rubygems.org/gems/rjb/versions/1.5.9) (Ruby Java Bridge) package is installed
- [Java Runtime Environment 8](https://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html) or later is installed

## 2. Configuration
In config.yml, update all settings accordingly. The settings will be loaded automatically to be used in tink_ruby_decryptor.rb.
```ruby
---
\# name of gateway
Gateway_Name: <place_your_gateway_name_here>

\# protocol version
Protocol_Version: ECv2

\# base64-encoded PKCS8 private key generated by gateway
\# For PROD env, it is advisable to fetch this key from Hardware Security Module (HSM)
\# or use Environment Variables instead of storing as plain text in config files
Base64_PKCS8_Private_key: <place_your_private_key_here>

\# environment is either INSTANCE_TEST or INSTANCE_PRODUCTION
Trusted_Signing_Keys_Env: INSTANCE_TEST
```
**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.

## 3. Testing with Payment Data
In tink_ruby_sample.rb, update the value of the PAYMENT_TOKEN constant with the token of paymentData generated in [test app](https://developers.google.com/pay/api/android/guides/tutorial#example) or [test web](https://developers.google.com/pay/api/web/guides/tutorial#full-example).
```ruby
class TinkRubySample
  PAYMENT_TOKEN = 'place_your_token_here'
  ...
end
```

Build and run the program. The output shall contain the decrypted data.

google-pay/tink-jni-examples,google-pay/tink-jni-examples,google-pay/tink-jni-examples,google-pay/tink-jni-examples,google-pay/tink-jni-examples,google-pay/tink-jni-examples