@dotbots-boutique/auth-sdk 1.0.10 → 1.0.12
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/dist/cjs/index.js +10 -4
- package/dist/esm/index.js +10 -4
- package/dist/types/DotBotsAuth.d.ts +1 -1
- package/dist/types/PostMessageHandler.d.ts +1 -1
- package/dist/types/index.js +10 -4
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -196,9 +196,10 @@ class PostMessageHandler {
|
|
|
196
196
|
/**
|
|
197
197
|
* Notify the parent of a successful charge (for real-time payment indicator).
|
|
198
198
|
*/
|
|
199
|
-
sendCharge(appId, featureCode,
|
|
199
|
+
sendCharge(appId, featureCode, quantity, transactionId) {
|
|
200
200
|
if (this.isInIframe()) {
|
|
201
|
-
|
|
201
|
+
console.warn(`[DotBotsAuth] Sending DOTBOTS_CHARGE postMessage — featureCode: ${featureCode}, quantity: ${quantity}, transactionId: ${transactionId}`);
|
|
202
|
+
window.parent.postMessage({ type: 'DOTBOTS_CHARGE', appId, featureCode, quantity, transactionId }, this.marketplaceOrigin);
|
|
202
203
|
}
|
|
203
204
|
}
|
|
204
205
|
}
|
|
@@ -336,6 +337,7 @@ class DotBotsAuth {
|
|
|
336
337
|
async charge(featureCode, paidBy, quantity) {
|
|
337
338
|
this.assertInitialized();
|
|
338
339
|
const baseUrl = this.proxyConfigManager.getBaseUrl();
|
|
340
|
+
console.warn(`[DotBotsAuth] charge() — featureCode: ${featureCode}, paidBy: ${paidBy}, quantity: ${quantity ?? 1}`);
|
|
339
341
|
const response = await this.buildRequest(`${baseUrl}/payments/charge`, {
|
|
340
342
|
method: 'POST',
|
|
341
343
|
headers: { 'Content-Type': 'application/json' },
|
|
@@ -343,13 +345,17 @@ class DotBotsAuth {
|
|
|
343
345
|
});
|
|
344
346
|
if (response.status === 402) {
|
|
345
347
|
const body = await response.json();
|
|
348
|
+
console.error(`[DotBotsAuth] charge() failed — 402: ${body.error}`, body.reason);
|
|
346
349
|
throw new DotBotsAuthError('PAYMENT_FAILED', body.error, body.reason);
|
|
347
350
|
}
|
|
348
351
|
if (!response.ok) {
|
|
352
|
+
console.error(`[DotBotsAuth] charge() failed — HTTP ${response.status}`);
|
|
349
353
|
throw new DotBotsAuthError('NETWORK_ERROR', 'Payment request failed');
|
|
350
354
|
}
|
|
351
355
|
const result = await response.json();
|
|
352
|
-
|
|
356
|
+
const qty = quantity ?? 1;
|
|
357
|
+
console.warn(`[DotBotsAuth] charge() success — transactionId: ${result.transactionId}, quantity: ${qty}`);
|
|
358
|
+
this.postMessageHandler.sendCharge(this.config.appId, featureCode, qty, result.transactionId);
|
|
353
359
|
this.emit('charged');
|
|
354
360
|
return result;
|
|
355
361
|
}
|
|
@@ -443,7 +449,7 @@ class DotBotsAuth {
|
|
|
443
449
|
}
|
|
444
450
|
}
|
|
445
451
|
}
|
|
446
|
-
DotBotsAuth.SDK_VERSION = '1.0.
|
|
452
|
+
DotBotsAuth.SDK_VERSION = '1.0.12';
|
|
447
453
|
|
|
448
454
|
exports.DotBotsAuth = DotBotsAuth;
|
|
449
455
|
exports.DotBotsAuthError = DotBotsAuthError;
|
package/dist/esm/index.js
CHANGED
|
@@ -194,9 +194,10 @@ class PostMessageHandler {
|
|
|
194
194
|
/**
|
|
195
195
|
* Notify the parent of a successful charge (for real-time payment indicator).
|
|
196
196
|
*/
|
|
197
|
-
sendCharge(appId, featureCode,
|
|
197
|
+
sendCharge(appId, featureCode, quantity, transactionId) {
|
|
198
198
|
if (this.isInIframe()) {
|
|
199
|
-
|
|
199
|
+
console.warn(`[DotBotsAuth] Sending DOTBOTS_CHARGE postMessage — featureCode: ${featureCode}, quantity: ${quantity}, transactionId: ${transactionId}`);
|
|
200
|
+
window.parent.postMessage({ type: 'DOTBOTS_CHARGE', appId, featureCode, quantity, transactionId }, this.marketplaceOrigin);
|
|
200
201
|
}
|
|
201
202
|
}
|
|
202
203
|
}
|
|
@@ -334,6 +335,7 @@ class DotBotsAuth {
|
|
|
334
335
|
async charge(featureCode, paidBy, quantity) {
|
|
335
336
|
this.assertInitialized();
|
|
336
337
|
const baseUrl = this.proxyConfigManager.getBaseUrl();
|
|
338
|
+
console.warn(`[DotBotsAuth] charge() — featureCode: ${featureCode}, paidBy: ${paidBy}, quantity: ${quantity ?? 1}`);
|
|
337
339
|
const response = await this.buildRequest(`${baseUrl}/payments/charge`, {
|
|
338
340
|
method: 'POST',
|
|
339
341
|
headers: { 'Content-Type': 'application/json' },
|
|
@@ -341,13 +343,17 @@ class DotBotsAuth {
|
|
|
341
343
|
});
|
|
342
344
|
if (response.status === 402) {
|
|
343
345
|
const body = await response.json();
|
|
346
|
+
console.error(`[DotBotsAuth] charge() failed — 402: ${body.error}`, body.reason);
|
|
344
347
|
throw new DotBotsAuthError('PAYMENT_FAILED', body.error, body.reason);
|
|
345
348
|
}
|
|
346
349
|
if (!response.ok) {
|
|
350
|
+
console.error(`[DotBotsAuth] charge() failed — HTTP ${response.status}`);
|
|
347
351
|
throw new DotBotsAuthError('NETWORK_ERROR', 'Payment request failed');
|
|
348
352
|
}
|
|
349
353
|
const result = await response.json();
|
|
350
|
-
|
|
354
|
+
const qty = quantity ?? 1;
|
|
355
|
+
console.warn(`[DotBotsAuth] charge() success — transactionId: ${result.transactionId}, quantity: ${qty}`);
|
|
356
|
+
this.postMessageHandler.sendCharge(this.config.appId, featureCode, qty, result.transactionId);
|
|
351
357
|
this.emit('charged');
|
|
352
358
|
return result;
|
|
353
359
|
}
|
|
@@ -441,6 +447,6 @@ class DotBotsAuth {
|
|
|
441
447
|
}
|
|
442
448
|
}
|
|
443
449
|
}
|
|
444
|
-
DotBotsAuth.SDK_VERSION = '1.0.
|
|
450
|
+
DotBotsAuth.SDK_VERSION = '1.0.12';
|
|
445
451
|
|
|
446
452
|
export { DotBotsAuth, DotBotsAuthError };
|
|
@@ -8,7 +8,7 @@ export declare class DotBotsAuth {
|
|
|
8
8
|
private readonly listeners;
|
|
9
9
|
private cachedUser;
|
|
10
10
|
private initialized;
|
|
11
|
-
static readonly SDK_VERSION = "1.0.
|
|
11
|
+
static readonly SDK_VERSION = "1.0.12";
|
|
12
12
|
constructor(config: DotBotsConfig);
|
|
13
13
|
initialize(): Promise<void>;
|
|
14
14
|
getUser(): Promise<DotBotsUser>;
|
|
@@ -18,5 +18,5 @@ export declare class PostMessageHandler {
|
|
|
18
18
|
/**
|
|
19
19
|
* Notify the parent of a successful charge (for real-time payment indicator).
|
|
20
20
|
*/
|
|
21
|
-
sendCharge(appId: string, featureCode: string,
|
|
21
|
+
sendCharge(appId: string, featureCode: string, quantity: number, transactionId: string): void;
|
|
22
22
|
}
|
package/dist/types/index.js
CHANGED
|
@@ -194,9 +194,10 @@ class PostMessageHandler {
|
|
|
194
194
|
/**
|
|
195
195
|
* Notify the parent of a successful charge (for real-time payment indicator).
|
|
196
196
|
*/
|
|
197
|
-
sendCharge(appId, featureCode,
|
|
197
|
+
sendCharge(appId, featureCode, quantity, transactionId) {
|
|
198
198
|
if (this.isInIframe()) {
|
|
199
|
-
|
|
199
|
+
console.warn(`[DotBotsAuth] Sending DOTBOTS_CHARGE postMessage — featureCode: ${featureCode}, quantity: ${quantity}, transactionId: ${transactionId}`);
|
|
200
|
+
window.parent.postMessage({ type: 'DOTBOTS_CHARGE', appId, featureCode, quantity, transactionId }, this.marketplaceOrigin);
|
|
200
201
|
}
|
|
201
202
|
}
|
|
202
203
|
}
|
|
@@ -334,6 +335,7 @@ class DotBotsAuth {
|
|
|
334
335
|
async charge(featureCode, paidBy, quantity) {
|
|
335
336
|
this.assertInitialized();
|
|
336
337
|
const baseUrl = this.proxyConfigManager.getBaseUrl();
|
|
338
|
+
console.warn(`[DotBotsAuth] charge() — featureCode: ${featureCode}, paidBy: ${paidBy}, quantity: ${quantity ?? 1}`);
|
|
337
339
|
const response = await this.buildRequest(`${baseUrl}/payments/charge`, {
|
|
338
340
|
method: 'POST',
|
|
339
341
|
headers: { 'Content-Type': 'application/json' },
|
|
@@ -341,13 +343,17 @@ class DotBotsAuth {
|
|
|
341
343
|
});
|
|
342
344
|
if (response.status === 402) {
|
|
343
345
|
const body = await response.json();
|
|
346
|
+
console.error(`[DotBotsAuth] charge() failed — 402: ${body.error}`, body.reason);
|
|
344
347
|
throw new DotBotsAuthError('PAYMENT_FAILED', body.error, body.reason);
|
|
345
348
|
}
|
|
346
349
|
if (!response.ok) {
|
|
350
|
+
console.error(`[DotBotsAuth] charge() failed — HTTP ${response.status}`);
|
|
347
351
|
throw new DotBotsAuthError('NETWORK_ERROR', 'Payment request failed');
|
|
348
352
|
}
|
|
349
353
|
const result = await response.json();
|
|
350
|
-
|
|
354
|
+
const qty = quantity ?? 1;
|
|
355
|
+
console.warn(`[DotBotsAuth] charge() success — transactionId: ${result.transactionId}, quantity: ${qty}`);
|
|
356
|
+
this.postMessageHandler.sendCharge(this.config.appId, featureCode, qty, result.transactionId);
|
|
351
357
|
this.emit('charged');
|
|
352
358
|
return result;
|
|
353
359
|
}
|
|
@@ -441,6 +447,6 @@ class DotBotsAuth {
|
|
|
441
447
|
}
|
|
442
448
|
}
|
|
443
449
|
}
|
|
444
|
-
DotBotsAuth.SDK_VERSION = '1.0.
|
|
450
|
+
DotBotsAuth.SDK_VERSION = '1.0.12';
|
|
445
451
|
|
|
446
452
|
export { DotBotsAuth, DotBotsAuthError };
|