Skip to content
This repository has been archived by the owner on Dec 14, 2023. It is now read-only.

Add support for Google merchant ID #57

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,13 @@ let opts: BrainTreeOptions = {
collectDeviceData: false,
requestThreeDSecureVerification: true,
enableGooglePay: true, // need to do additional setup for android. Please check demo project. Details: https://developers.braintreepayments.com/guides/google-pay/client-side/android/v3#add-google-play-services-wallet
googleMerchantId: "AAAAAAAAAA", //Google Merchant Id for production environment
currencyCode: "USD"
};
```

Google pay on production environment works only with a package signed with your release keys

## Setup iOS paypal & Venmo.

If you want to use Paypal & Venmo then you will need to edit your app `Info.plist` file which is located `app/App_Resources/iOS/Info.plist` to add `URL scheme` like this:
Expand Down
10 changes: 9 additions & 1 deletion src/braintree.android.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {AndroidApplication, Application, Observable} from "@nativescript/core";
import { AndroidApplication, Application, Observable } from "@nativescript/core";

declare const com;
const DropInRequest = com.braintreepayments.api.dropin.DropInRequest;
Expand Down Expand Up @@ -27,6 +27,9 @@ export class Braintree extends Observable {
let activity = Application.android.foregroundActivity || Application.android.startActivity;

let dropInRequest = new DropInRequest();
if (options.vaultManager) {
dropInRequest.vaultManager(options.vaultManager);
}

if (options.amount) {
dropInRequest.amount(options.amount);
Expand Down Expand Up @@ -152,6 +155,9 @@ export class Braintree extends Observable {
.setCurrencyCode(options.currencyCode)
.build())
.billingAddressRequired(true);
if (options.googleMerchantId) {
googlePaymentRequest.googleMerchantId(options.googleMerchantId);
}

dropInRequest.googlePaymentRequest(googlePaymentRequest);
}
Expand All @@ -164,6 +170,8 @@ export interface BrainTreeOptions {
requestThreeDSecureVerification?: boolean;
// Required for google pay
enableGooglePay?: boolean;
googleMerchantId?: string;
currencyCode?: string;
vaultManager?: boolean;
}

5 changes: 4 additions & 1 deletion src/braintree.ios.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Observable} from "@nativescript/core";
import { Observable } from "@nativescript/core";
import { BrainTreeOptions } from '.';

const setupAppDeligate = require('./getappdelegate').setupAppDeligate;
Expand Down Expand Up @@ -26,6 +26,9 @@ export class Braintree extends Observable {
public startPayment(token: any, options: BrainTreeOptions) {

let request = BTDropInRequest.alloc().init();
if (options.vaultManager) {
request.vaultManager = options.vaultManager;
}

if (options.amount) {
request.amount = options.amount;
Expand Down
4 changes: 3 additions & 1 deletion src/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Observable} from "@nativescript/core";
import { Observable } from "@nativescript/core";

export declare function setupBraintreeAppDeligate(urlScheme: any): void;

Expand Down Expand Up @@ -28,7 +28,9 @@ export interface BrainTreeOptions {
* currencyCode is required for Google Pay
*/
enableGooglePay?: boolean;
googleMerchantId?: string;
currencyCode?: string;
vaultManager?: boolean;
}

export interface ApplePayLineItem {
Expand Down