cordova-plugin-googlepay-button 0.0.7 → 0.0.9

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 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.7" />
14
+ <plugin name="cordova-plugin-googlepay-button" source="npm" spec="0.0.9" />
15
15
  ```
16
16
 
17
17
  ## Usage
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cordova-plugin-googlepay-button",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "description": "Cordova plugin for implementing the Google PayButton API",
5
5
  "cordova": {
6
6
  "id": "cordova-plugin-googlepay-button",
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.7">
5
+ version="0.0.9">
6
6
 
7
7
  <name>Google Pay Button Plugin</name>
8
8
  <description>Cordova plugin for Google Pay PayButton API integration</description>
@@ -16,7 +16,7 @@
16
16
  <platform name="android">
17
17
  <config-file target="res/xml/config.xml" parent="/*">
18
18
  <feature name="GooglePayButton">
19
- <param name="android-package" value="com.plugin.googlepay.GooglePayButton" />
19
+ <param name="android-package" value="com.plugin.googlepaybutton.GooglePayButton" />
20
20
  <param name="onload" value="false" />
21
21
  </feature>
22
22
  </config-file>
@@ -1,4 +1,4 @@
1
- package com.plugin.googlepay;
1
+ package com.plugin.googlepaybutton;
2
2
 
3
3
  import org.apache.cordova.CordovaPlugin;
4
4
  import org.apache.cordova.CallbackContext;
@@ -1,119 +1,27 @@
1
1
  // GooglePayButton.js - JavaScript interface for the Cordova plugin
2
2
 
3
- class GooglePayButton {
4
- constructor() {
5
- this.isReady = false;
6
- this.callbacks = {};
7
-
8
- // Wait for Cordova to be ready
9
- document.addEventListener('deviceready', () => {
10
- this.isReady = true;
11
- }, false);
12
- }
3
+ var exec = require('cordova/exec');
4
+
5
+ var GooglePayButton = {
13
6
 
14
7
  /**
15
- * Create the Google Pay button with specified options
16
- * @param {Object} options - Button configuration options
17
- * @param {string} options.theme - 'light' or 'dark'
18
- * @param {string} options.type - 'buy', 'checkout', 'pay', etc.
19
- * @param {number} options.cornerRadius - Corner radius in dp
20
- * @param {string} options.allowedPaymentMethods - JSON string of allowed payment methods
21
- * @param {Function} callback - Callback function for button clicks
8
+ * Show the Google Pay button
9
+ * When clicked, the successCallback will be called with "clicked"
10
+ * @param {Function} successCallback - Success callback function, receives "clicked" when button is tapped
11
+ * @param {Function} errorCallback - Error callback function
22
12
  */
23
- createButton(options, callback) {
24
- return new Promise((resolve, reject) => {
25
- if (!this.isReady) {
26
- reject(new Error('Cordova not ready'));
27
- return;
28
- }
29
-
30
- // Store the click callback
31
- if (callback) {
32
- this.callbacks.onClick = callback;
33
- }
34
-
35
- cordova.exec(
36
- (result) => {
37
- if (result === 'payButtonClicked' && this.callbacks.onClick) {
38
- this.callbacks.onClick();
39
- } else {
40
- resolve(result);
41
- }
42
- },
43
- (error) => reject(error),
44
- 'GooglePayButton',
45
- 'createPayButton',
46
- [options]
47
- );
48
- });
49
- }
50
-
51
- /**
52
- * Show the Google Pay button at specified position
53
- * @param {Object} position - Button position and size
54
- * @param {number} position.x - X coordinate in dp
55
- * @param {number} position.y - Y coordinate in dp
56
- * @param {number} position.width - Width in dp
57
- * @param {number} position.height - Height in dp
58
- */
59
- showButton(position) {
60
- return new Promise((resolve, reject) => {
61
- if (!this.isReady) {
62
- reject(new Error('Cordova not ready'));
63
- return;
64
- }
65
-
66
- cordova.exec(
67
- resolve,
68
- reject,
69
- 'GooglePayButton',
70
- 'showPayButton',
71
- [position]
72
- );
73
- });
74
- }
13
+ showPayButton: function(successCallback, errorCallback) {
14
+ exec(successCallback, errorCallback, 'GooglePayButton', 'showPayButton', []);
15
+ },
75
16
 
76
17
  /**
77
18
  * Hide the Google Pay button
19
+ * @param {Function} successCallback - Success callback function
20
+ * @param {Function} errorCallback - Error callback function
78
21
  */
79
- hideButton() {
80
- return new Promise((resolve, reject) => {
81
- if (!this.isReady) {
82
- reject(new Error('Cordova not ready'));
83
- return;
84
- }
85
-
86
- cordova.exec(
87
- resolve,
88
- reject,
89
- 'GooglePayButton',
90
- 'hidePayButton',
91
- []
92
- );
93
- });
94
- }
95
-
96
- /**
97
- * Update button options
98
- * @param {Object} options - New button options
99
- */
100
- updateButton(options) {
101
- return new Promise((resolve, reject) => {
102
- if (!this.isReady) {
103
- reject(new Error('Cordova not ready'));
104
- return;
105
- }
106
-
107
- cordova.exec(
108
- resolve,
109
- reject,
110
- 'GooglePayButton',
111
- 'updatePayButton',
112
- [options]
113
- );
114
- });
22
+ hidePayButton: function(successCallback, errorCallback) {
23
+ exec(successCallback, errorCallback, 'GooglePayButton', 'hidePayButton', []);
115
24
  }
116
- }
25
+ };
117
26
 
118
- // Export for use in React/ES6 modules
119
- export default new GooglePayButton();
27
+ module.exports = GooglePayButton;