cordova-plugin-googlepay-button 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +1 -1
- package/plugin.xml +2 -2
- package/src/android/GooglePayButtonPlugin.java +24 -6
package/README.md
CHANGED
@@ -11,7 +11,7 @@ cordova plugin add cordova-plugin-googlepay-button
|
|
11
11
|
or for Cordova build service, e.g. [VoltBuilder](https://volt.build/), add the following to config.xml:
|
12
12
|
|
13
13
|
```
|
14
|
-
<plugin name="cordova-plugin-googlepay-button" source="npm" spec="0.0.
|
14
|
+
<plugin name="cordova-plugin-googlepay-button" source="npm" spec="0.0.4" />
|
15
15
|
```
|
16
16
|
|
17
17
|
## Usage
|
package/package.json
CHANGED
package/plugin.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
3
3
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
4
4
|
id="cordova-plugin-googlepay-button"
|
5
|
-
version="0.0.
|
5
|
+
version="0.0.4">
|
6
6
|
|
7
7
|
<name>Google Pay Button Plugin</name>
|
8
8
|
<description>Cordova plugin for Google Pay PayButton API integration</description>
|
@@ -10,7 +10,7 @@
|
|
10
10
|
<keywords>cordova,google,pay,button,paybutton</keywords>
|
11
11
|
|
12
12
|
<js-module src="www/GooglePayButton.js" name="GooglePayButton">
|
13
|
-
<clobbers target="
|
13
|
+
<clobbers target="cordova.plugins.GooglePayButton" />
|
14
14
|
</js-module>
|
15
15
|
|
16
16
|
<platform name="android">
|
@@ -14,6 +14,7 @@ import android.content.Context;
|
|
14
14
|
import android.view.View;
|
15
15
|
import android.view.ViewGroup;
|
16
16
|
import android.widget.FrameLayout;
|
17
|
+
import android.util.Log;
|
17
18
|
|
18
19
|
import com.google.android.gms.wallet.button.ButtonConstants;
|
19
20
|
import com.google.android.gms.wallet.button.ButtonOptions;
|
@@ -21,8 +22,16 @@ import com.google.android.gms.wallet.button.PayButton;
|
|
21
22
|
|
22
23
|
public class GooglePayButtonPlugin extends CordovaPlugin {
|
23
24
|
|
25
|
+
private static final String TAG = "GooglePayButtonPlugin";
|
24
26
|
private PayButton payButton;
|
25
27
|
private CallbackContext callbackContext;
|
28
|
+
private CordovaWebView webView;
|
29
|
+
|
30
|
+
@Override
|
31
|
+
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
|
32
|
+
super.initialize(cordova, webView);
|
33
|
+
this.webView = webView;
|
34
|
+
}
|
26
35
|
|
27
36
|
@Override
|
28
37
|
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
|
@@ -44,8 +53,8 @@ public class GooglePayButtonPlugin extends CordovaPlugin {
|
|
44
53
|
public void run() {
|
45
54
|
try {
|
46
55
|
// Get the WebView's parent container
|
47
|
-
View
|
48
|
-
ViewGroup parent = (ViewGroup)
|
56
|
+
View webViewView = webView.getView();
|
57
|
+
ViewGroup parent = (ViewGroup) webViewView.getParent();
|
49
58
|
|
50
59
|
// Create PayButton if not exists
|
51
60
|
if (payButton == null) {
|
@@ -65,6 +74,7 @@ public class GooglePayButtonPlugin extends CordovaPlugin {
|
|
65
74
|
payButton.setOnClickListener(new View.OnClickListener() {
|
66
75
|
@Override
|
67
76
|
public void onClick(View v) {
|
77
|
+
Log.d(TAG, "PayButton clicked");
|
68
78
|
if (callbackContext != null) {
|
69
79
|
callbackContext.success("clicked");
|
70
80
|
}
|
@@ -88,7 +98,10 @@ public class GooglePayButtonPlugin extends CordovaPlugin {
|
|
88
98
|
parent.addView(payButton, params);
|
89
99
|
payButton.setVisibility(View.VISIBLE);
|
90
100
|
|
101
|
+
Log.d(TAG, "PayButton shown successfully");
|
102
|
+
|
91
103
|
} catch (Exception e) {
|
104
|
+
Log.e(TAG, "Error showing PayButton: " + e.getMessage(), e);
|
92
105
|
if (callbackContext != null) {
|
93
106
|
callbackContext.error("Error showing PayButton: " + e.getMessage());
|
94
107
|
}
|
@@ -101,11 +114,16 @@ public class GooglePayButtonPlugin extends CordovaPlugin {
|
|
101
114
|
cordova.getActivity().runOnUiThread(new Runnable() {
|
102
115
|
@Override
|
103
116
|
public void run() {
|
104
|
-
|
105
|
-
payButton
|
106
|
-
|
107
|
-
(
|
117
|
+
try {
|
118
|
+
if (payButton != null) {
|
119
|
+
payButton.setVisibility(View.GONE);
|
120
|
+
if (payButton.getParent() != null) {
|
121
|
+
((ViewGroup) payButton.getParent()).removeView(payButton);
|
122
|
+
}
|
123
|
+
Log.d(TAG, "PayButton hidden successfully");
|
108
124
|
}
|
125
|
+
} catch (Exception e) {
|
126
|
+
Log.e(TAG, "Error hiding PayButton: " + e.getMessage(), e);
|
109
127
|
}
|
110
128
|
}
|
111
129
|
});
|