Skip to content

Latest commit

 

History

History
52 lines (41 loc) · 3.07 KB

PHP-HOWTO.md

File metadata and controls

52 lines (41 loc) · 3.07 KB

PHP HOW-TO

The following presents instructions of coding with PHP of Tink library for Google Pay gateway/processor partners. The sample PHP code uses PHP/JavaBridge to host a library on JVM servlet allowing Java code to be called by native PHP applications.

1. Installation

First, please ensure that

Next, download tink-jni-examples and move folder "TinkPHPSample" into the Apache HTTP Web Root folder accordingly. Don't forget to also move the tink-java.ini file inside into the directory containing additional *.ini files.

2. Configuration

In tink-java.ini, update all settings accordingly. The settings will be loaded automatically to be used in TinkDecryptor.php. If you are not sure about the settings to be used, please ask your Google Pay point of contact.

; environment is either INSTANCE_TEST or INSTANCE_PRODUCTION
trusted_signing_keys_env = "INSTANCE_TEST"

; name of gateway
gateway_name = "gateway:<place_your_gateway_name_here>"

; 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>"

; protocol version
protocol_version = "ECv2"

; Required for java-bridge
; Refer to http://php-java-bridge.sourceforge.net/pjb/docs/php-api-old/ for more options
; The request log level between 0 (log off) and 4 (log debug)
java.hosts = "localhost:8081"
java.log_level = 2

; Hosted java-bridge library (servlet and local path)
; Please ensure that PHP have the Read and Write access to the local path
java_bridge_servlet_path = "http://localhost:8081/JavaBridge/java/Java.inc"
java_bridge_local_path = "java.inc"

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

Execute the TinkDecryptor.jar by using the command below. Note that you will need to specify the Port Number in the argument to host the PHP/JavaBridge. Make sure that you specify the same Port Number as per configured in the tink-java.ini.

java -jar TinkDecryptor.jar 8081

IMPORTANT NOTES
For PRODUCTION environment, for easier administration and higher availability, please run TinkDecryptor as a background service.

Update the content of tokendata.json with the token of paymentData generated in test app or test web.

Run and navigate to the TinkDecryptor.php. The output shall contain the decrypted data.