@agnostack/next-shopify 1.1.1-alpha.19 → 1.1.1-alpha.20
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/CHANGELOG.md +7 -0
- package/dist/utils/billing.js +16 -7
- package/dist/utils/billing.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [1.1.1-alpha.20](https://github.com/agnostack/next-shopify/compare/v1.1.1-alpha.19...v1.1.1-alpha.20) (2022-11-10)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* modify rest payload ([8ce8810](https://github.com/agnostack/next-shopify/commit/8ce8810fc2f04834237cc874ad92c9fecbf13e93))
|
|
7
|
+
|
|
1
8
|
## [1.1.1-alpha.19](https://github.com/agnostack/next-shopify/compare/v1.1.1-alpha.18...v1.1.1-alpha.19) (2022-11-10)
|
|
2
9
|
|
|
3
10
|
|
package/dist/utils/billing.js
CHANGED
|
@@ -88,6 +88,7 @@ class BillingManager {
|
|
|
88
88
|
else {
|
|
89
89
|
hasPayment = false;
|
|
90
90
|
confirmationUrl = await this.requestPayment();
|
|
91
|
+
console.log(`>>> ~ confirmationUrl`, confirmationUrl);
|
|
91
92
|
}
|
|
92
93
|
return { hasPayment, confirmationUrl };
|
|
93
94
|
}
|
|
@@ -119,9 +120,12 @@ class BillingManager {
|
|
|
119
120
|
`shop=${this.shop}`,
|
|
120
121
|
`host=${Buffer.from(`${this.shop}/admin`).toString('base64')}`
|
|
121
122
|
];
|
|
123
|
+
console.log(`>>> ~ queryParams`, queryParams);
|
|
122
124
|
// NOTE do we need to use shopify.Context values anywhere else
|
|
123
125
|
const returnUrl = `https://${this.shopify.Context.HOST_NAME}?${queryParams.join('&')}`;
|
|
126
|
+
console.log(`>>> ~ returnUrl`, returnUrl);
|
|
124
127
|
let data;
|
|
128
|
+
console.log(`>>> ~ this.isRecurring`, this.isRecurring);
|
|
125
129
|
if (this.isRecurring) {
|
|
126
130
|
const mutationResponse = await this.requestRecurringPayment(client, returnUrl);
|
|
127
131
|
data = (_b = (_a = mutationResponse === null || mutationResponse === void 0 ? void 0 : mutationResponse.body) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.appSubscriptionCreate;
|
|
@@ -130,14 +134,15 @@ class BillingManager {
|
|
|
130
134
|
const mutationResponse = await this.requestSinglePayment(client, returnUrl);
|
|
131
135
|
data = (_d = (_c = mutationResponse === null || mutationResponse === void 0 ? void 0 : mutationResponse.body) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.appPurchaseOneTimeCreate;
|
|
132
136
|
}
|
|
137
|
+
console.log(`>>> ~ data`, data);
|
|
133
138
|
if (display_1.arrayNotEmpty(data === null || data === void 0 ? void 0 : data.userErrors)) {
|
|
134
|
-
throw new ShopifyBillingError('Error while billing the store');
|
|
139
|
+
throw new ShopifyBillingError('Error while billing the store: requestPayment');
|
|
135
140
|
}
|
|
136
141
|
return data === null || data === void 0 ? void 0 : data.confirmationUrl;
|
|
137
142
|
}
|
|
138
143
|
async requestSinglePayment(client, returnUrl) {
|
|
139
144
|
var _a, _b;
|
|
140
|
-
const
|
|
145
|
+
const payload = {
|
|
141
146
|
data: {
|
|
142
147
|
query: ONE_TIME_PURCHASE_MUTATION,
|
|
143
148
|
variables: {
|
|
@@ -147,15 +152,17 @@ class BillingManager {
|
|
|
147
152
|
test: this.testMode,
|
|
148
153
|
},
|
|
149
154
|
},
|
|
150
|
-
}
|
|
155
|
+
};
|
|
156
|
+
console.log(`>>> ~ requestSinglePayment payload`, payload);
|
|
157
|
+
const mutationResponse = await client.query(payload);
|
|
151
158
|
if (((_a = mutationResponse === null || mutationResponse === void 0 ? void 0 : mutationResponse.body) === null || _a === void 0 ? void 0 : _a.errors) && display_1.arrayNotEmpty((_b = mutationResponse === null || mutationResponse === void 0 ? void 0 : mutationResponse.body) === null || _b === void 0 ? void 0 : _b.errors)) {
|
|
152
|
-
throw new ShopifyBillingError('Error while billing the store', mutationResponse.body.errors);
|
|
159
|
+
throw new ShopifyBillingError('Error while billing the store: requestSinglePayment', mutationResponse.body.errors);
|
|
153
160
|
}
|
|
154
161
|
return mutationResponse;
|
|
155
162
|
}
|
|
156
163
|
async requestRecurringPayment(client, returnUrl) {
|
|
157
164
|
var _a, _b;
|
|
158
|
-
const
|
|
165
|
+
const payload = {
|
|
159
166
|
data: {
|
|
160
167
|
query: RECURRING_PURCHASE_MUTATION,
|
|
161
168
|
variables: {
|
|
@@ -174,9 +181,11 @@ class BillingManager {
|
|
|
174
181
|
test: this.testMode,
|
|
175
182
|
},
|
|
176
183
|
},
|
|
177
|
-
}
|
|
184
|
+
};
|
|
185
|
+
console.log(`>>> ~ requestRecurringPayment payload`, payload);
|
|
186
|
+
const mutationResponse = await client.query(payload);
|
|
178
187
|
if (((_a = mutationResponse === null || mutationResponse === void 0 ? void 0 : mutationResponse.body) === null || _a === void 0 ? void 0 : _a.errors) && display_1.arrayNotEmpty((_b = mutationResponse === null || mutationResponse === void 0 ? void 0 : mutationResponse.body) === null || _b === void 0 ? void 0 : _b.errors)) {
|
|
179
|
-
throw new ShopifyBillingError('Error while billing the store', mutationResponse.body.errors);
|
|
188
|
+
throw new ShopifyBillingError('Error while billing the store: requestRecurringPayment', mutationResponse.body.errors);
|
|
180
189
|
}
|
|
181
190
|
return mutationResponse;
|
|
182
191
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"billing.js","sourceRoot":"","sources":["../../src/utils/billing.js"],"names":[],"mappings":";;;AAAA,sDAA+C;AAE/C,uCAQkB;AAEL,QAAA,iBAAiB,GAAG;IAC/B,QAAQ,EAAE,UAAU;IACpB,aAAa,EAAE,eAAe;IAC9B,MAAM,EAAE,QAAQ;CACjB,CAAA;AAED,MAAM,mBAAmB,GAAG;IAC1B,yBAAiB,CAAC,aAAa;IAC/B,yBAAiB,CA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;oBACT,IAAI,EAAE,IAAI,CAAC,QAAQ;iBACpB;aACF;SACF,CAAA;QACD,OAAO,CAAC,GAAG,CAAC,uCAAuC,EAAE,OAAO,CAAC,CAAA;QAC7D,MAAM,gBAAgB,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;QAEpD,IAAI,CAAA,MAAA,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,IAAI,0CAAE,MAAM,KAAI,uBAAa,CAAC,MAAA,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,IAAI,0CAAE,MAAM,CAAC,EAAE;YACnF,MAAM,IAAI,mBAAmB,CAC3B,wDAAwD,EACxD,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAC7B,CAAA;SACF;QAED,OAAO,gBAAgB,CAAA;IACzB,CAAC;CACF;AAxJD,wCAwJC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agnostack/next-shopify",
|
|
3
|
-
"version": "1.1.1-alpha.
|
|
3
|
+
"version": "1.1.1-alpha.20",
|
|
4
4
|
"author": "agnoStack Dev <developers@agnostack.com> (https://agnostack.com)",
|
|
5
5
|
"owner": "agnoStack",
|
|
6
6
|
"description": "Please contact agnoStack via info@agnostack.com for any questions",
|