ti.googlepay
Axway Titanium Hyperloop module for GooglePay
Installation
- Enable
hyperloop
module intiapp.xml
- Copy
ti.googlepay.js
intoapp/lib
folder. - Add dependency in
app/platform/android/gradle.build
dependencies { implementation 'com.google.android.gms:play-services-wallet:18.0.0' }
- Enable wallet in
tiapp.xml
<meta-data android:name="com.google.android.gms.wallet.api.enabled" android:value="true" />
- (optional) If you want to use
Pay with GPay
button, copy assets from brand guideline page intoapp/platform/android/res
Methods
-
createGooglePayButton(options) - returns
Ti.UI.View
with GPay button inside.-
options - any
Ti.UI.View
propertiesoptions.layout:
googlepay_button
,pay_with_googlepay_button
-
-
createPaymentsClient(options, callback) - returns
paymentClient
-
options
options.enviorment:
ENVIRONMENT_TEST
,ENVIRONMENT_PROD
options.theme:
THEME_LIGHT
,THEME_DARK
const googlepay = require('ti.googlepay'); const gpay = googlepay.getPaymentsClient({ environment: "ENVIRONMENT_TEST", theme: "THEME_LIGHT" });
-
paymentClient
methods:
-
isReadyToPay(options, callback)
- options - isReadyToPayRequest
gpay.isReadyToPay({ allowedPaymentMethods: ['PAYMENT_METHOD_CARD', 'PAYMENT_METHOD_TOKENIZED_CARD'] }, function(e) { if (e.success) { //Show GPay button } });
-
makePayment(options, callback)
- options - paymentDataRequest
gpay.makePayment({ apiVersion: 2, apiVersionMinor: 0, merchantInfo: { merchantName: "Example Merchant" }, allowedPaymentMethods: [ { type: "CARD", parameters: { allowedAuthMethods: ["PAN_ONLY", "CRYPTOGRAM_3DS"], allowedCardNetworks: ["MASTERCARD", "VISA"] }, tokenizationSpecification: { type: "PAYMENT_GATEWAY", parameters: { gateway: "exmpleGateway", gatewayMerchantId: "exampleGatewayMerchantId" } } } ], transactionInfo: { totalPriceStatus: "FINAL", totalPrice: "12.34", currencyCode: "USD" } }, function(e) { if (e.success) { console.log(e.result); } else { alert(e.error); } });