Skip to content

Commit 74a222d

Browse files
committed
feat: add google pay button
1 parent aae090f commit 74a222d

File tree

4 files changed

+54
-7
lines changed

4 files changed

+54
-7
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.reactnativepayments;
2+
3+
import android.content.Context;
4+
import android.view.LayoutInflater;
5+
import android.view.View;
6+
import android.widget.RelativeLayout;
7+
8+
/**
9+
* Image of Google Pay Button (buy_with_googlepay_button)
10+
* see https://developers.google.com/pay/api/android/guides/brand-guidelines
11+
*/
12+
public class GooglePayImage extends RelativeLayout {
13+
14+
public GooglePayImage(Context context) {
15+
super(context);
16+
17+
View view = LayoutInflater.from(getContext()).inflate(
18+
R.layout.buy_with_googlepay_button, null);
19+
20+
this.addView(view);
21+
}
22+
23+
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.reactnativepayments;
2+
3+
import android.view.LayoutInflater;
4+
import android.view.View;
5+
6+
import com.facebook.react.uimanager.SimpleViewManager;
7+
import com.facebook.react.uimanager.ThemedReactContext;
8+
9+
public class GooglePayImageManager extends SimpleViewManager<View> {
10+
11+
public static final String REACT_CLASS = "GooglePayImageView";
12+
13+
@Override
14+
public String getName() {
15+
return REACT_CLASS;
16+
}
17+
18+
@Override
19+
protected View createViewInstance(ThemedReactContext reactContext) {
20+
return LayoutInflater.from(reactContext).inflate(
21+
R.layout.buy_with_googlepay_button, null);
22+
}
23+
}

android/src/main/java/com/reactnativepayments/ReactNativePaymentsPackage.java

+4-6
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,17 @@
1010
import com.facebook.react.bridge.ReactApplicationContext;
1111
import com.facebook.react.uimanager.ViewManager;
1212
import com.facebook.react.bridge.JavaScriptModule;
13+
1314
public class ReactNativePaymentsPackage implements ReactPackage {
1415
@Override
1516
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
1617
return Arrays.<NativeModule>asList(new ReactNativePaymentsModule(reactContext));
1718
}
1819

19-
// Deprecated RN 0.47
20-
public List<Class<? extends JavaScriptModule>> createJSModules() {
21-
return Collections.emptyList();
22-
}
23-
2420
@Override
2521
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
26-
return Collections.emptyList();
22+
return Collections.<ViewManager>singletonList(
23+
new GooglePayImageManager()
24+
);
2725
}
2826
}

lib/js/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
// @flow
2+
import {requireNativeComponent} from 'react-native';
23

34
import _PaymentRequest from './PaymentRequest';
45
import _NativePayments from './NativePayments';
56
import { PKPaymentButton } from './PKPaymentButton';
67

78
export const ApplePayButton = PKPaymentButton;
89
export const PaymentRequest = _PaymentRequest;
9-
export const canMakePayments = _NativePayments.canMakePayments;
10+
export const canMakePayments = _NativePayments.canMakePayments;
11+
export const GooglePayButton = requireNativeComponent('GooglePayImageView')

0 commit comments

Comments
 (0)