@tagadapay/plugin-sdk 4.0.2 → 4.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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * TagadaPay React SDK v4.0.2
2
+ * TagadaPay React SDK v4.0.4
3
3
  * CDN Bundle - React hooks and TagadaProvider (Debug Build)
4
4
  * @license MIT
5
5
  */
@@ -14115,6 +14115,7 @@ var TagadaReactSDKBundle = (() => {
14115
14115
  "src/v2/core/resources/offers.ts"() {
14116
14116
  "use strict";
14117
14117
  init_previewMode();
14118
+ init_funnelClient();
14118
14119
  OffersResource = class {
14119
14120
  constructor(apiClient) {
14120
14121
  this.apiClient = apiClient;
@@ -14179,13 +14180,14 @@ var TagadaReactSDKBundle = (() => {
14179
14180
  * @param mainOrderId - Optional main order ID (for upsells)
14180
14181
  */
14181
14182
  async payPreviewedOffer(offerId, currency = "", lineItems, returnUrl, mainOrderId, initiatedBy) {
14183
+ const effectiveInitiatedBy = initiatedBy != null ? initiatedBy : getAssignedPaymentInitiator();
14182
14184
  console.log("\u{1F4B3} [OffersResource] Calling pay-preview API:", {
14183
14185
  offerId,
14184
14186
  currency,
14185
14187
  lineItems,
14186
14188
  returnUrl,
14187
14189
  mainOrderId,
14188
- initiatedBy,
14190
+ initiatedBy: effectiveInitiatedBy,
14189
14191
  endpoint: "/api/v1/offers/".concat(offerId, "/pay-preview")
14190
14192
  });
14191
14193
  const response = await this.apiClient.post("/api/v1/offers/".concat(offerId, "/pay-preview"), __spreadValues({
@@ -14194,7 +14196,7 @@ var TagadaReactSDKBundle = (() => {
14194
14196
  lineItems,
14195
14197
  returnUrl: returnUrl || (typeof window !== "undefined" ? window.location.href : ""),
14196
14198
  mainOrderId
14197
- }, initiatedBy ? { initiatedBy } : {}));
14199
+ }, effectiveInitiatedBy ? { initiatedBy: effectiveInitiatedBy } : {}));
14198
14200
  console.log("\u{1F4E5} [OffersResource] Pay-preview API response:", response);
14199
14201
  return response;
14200
14202
  }
@@ -14259,31 +14261,35 @@ var TagadaReactSDKBundle = (() => {
14259
14261
  /**
14260
14262
  * Pay with checkout session
14261
14263
  */
14262
- async payWithCheckoutSession(checkoutSessionId, orderId) {
14264
+ async payWithCheckoutSession(checkoutSessionId, orderId, initiatedBy) {
14263
14265
  const draft = isDraftMode();
14264
- await this.apiClient.post("/api/v1/checkout-sessions/".concat(checkoutSessionId, "/pay"), {
14266
+ const effectiveInitiatedBy = initiatedBy != null ? initiatedBy : getAssignedPaymentInitiator();
14267
+ await this.apiClient.post("/api/v1/checkout-sessions/".concat(checkoutSessionId, "/pay"), __spreadProps(__spreadValues({
14265
14268
  checkoutSessionId,
14266
14269
  draft,
14267
14270
  // 🎯 Use dynamic draft mode instead of hardcoded false
14268
- returnUrl: typeof window !== "undefined" ? window.location.href : "",
14271
+ returnUrl: typeof window !== "undefined" ? window.location.href : ""
14272
+ }, effectiveInitiatedBy ? { initiatedBy: effectiveInitiatedBy } : {}), {
14269
14273
  metadata: {
14270
14274
  comingFromPostPurchase: true,
14271
14275
  postOrder: orderId,
14272
14276
  upsell: true,
14273
14277
  source: "offer"
14274
14278
  }
14275
- });
14279
+ }));
14276
14280
  }
14277
14281
  /**
14278
14282
  * Pay for an offer directly
14279
14283
  */
14280
- async payOffer(offerId, orderId) {
14284
+ async payOffer(offerId, orderId, initiatedBy) {
14281
14285
  const draft = isDraftMode();
14282
- return this.apiClient.post("/api/v1/offers/".concat(offerId, "/pay"), {
14286
+ const effectiveInitiatedBy = initiatedBy != null ? initiatedBy : getAssignedPaymentInitiator();
14287
+ return this.apiClient.post("/api/v1/offers/".concat(offerId, "/pay"), __spreadProps(__spreadValues({
14283
14288
  offerId,
14284
14289
  draft,
14285
14290
  // 🎯 Use dynamic draft mode instead of hardcoded false
14286
- returnUrl: typeof window !== "undefined" ? window.location.href : "",
14291
+ returnUrl: typeof window !== "undefined" ? window.location.href : ""
14292
+ }, effectiveInitiatedBy ? { initiatedBy: effectiveInitiatedBy } : {}), {
14287
14293
  metadata: orderId ? {
14288
14294
  comingFromPostPurchase: true,
14289
14295
  postOrder: orderId,
@@ -14293,7 +14299,7 @@ var TagadaReactSDKBundle = (() => {
14293
14299
  upsell: true,
14294
14300
  source: "offer"
14295
14301
  }
14296
- });
14302
+ }));
14297
14303
  }
14298
14304
  /**
14299
14305
  * Transform offer to checkout session with dynamic variant selection
@@ -37391,7 +37397,6 @@ var TagadaReactSDKBundle = (() => {
37391
37397
  init_modern2();
37392
37398
  var import_react65 = __require("react");
37393
37399
  init_offers();
37394
- init_funnelClient();
37395
37400
  init_useApiQuery();
37396
37401
  function usePreviewOffer(options) {
37397
37402
  const { offerId, currency: requestedCurrency = "", initialSelections = {} } = options;
@@ -37597,20 +37602,18 @@ var TagadaReactSDKBundle = (() => {
37597
37602
  });
37598
37603
  }, [summary, effectiveCurrency]);
37599
37604
  const pay = (0, import_react65.useCallback)(async (mainOrderId, payOptions) => {
37600
- var _a11;
37601
37605
  if (isPaying) {
37602
37606
  throw new Error("Payment already in progress");
37603
37607
  }
37604
37608
  setIsPaying(true);
37605
37609
  try {
37606
- const initiatedBy = (_a11 = payOptions == null ? void 0 : payOptions.initiatedBy) != null ? _a11 : getAssignedPaymentInitiator();
37607
37610
  const result = await offersResource.payPreviewedOffer(
37608
37611
  offerId,
37609
37612
  effectiveCurrency,
37610
37613
  lineItemsForPreview,
37611
37614
  typeof window !== "undefined" ? window.location.href : void 0,
37612
37615
  mainOrderId,
37613
- initiatedBy
37616
+ payOptions == null ? void 0 : payOptions.initiatedBy
37614
37617
  );
37615
37618
  console.log("[usePreviewOffer] Payment initiated:", result);
37616
37619
  return {