@rebilly/instruments 8.40.0 → 8.41.0

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 CHANGED
@@ -1,3 +1,17 @@
1
+ ## [8.41.0](https://github.com/Rebilly/rebilly/compare/instruments/core-v8.40.1...instruments/core-v8.41.0) (2024-02-02)
2
+
3
+
4
+ ### Features
5
+
6
+ * **Instruments:** Payouts to show results and redirect later ([#3280](https://github.com/Rebilly/rebilly/issues/3280)) ([229b1af](https://github.com/Rebilly/rebilly/commit/229b1af4d08b07cad2342d6aa2b929a95e677efc))
7
+
8
+ ## [8.40.1](https://github.com/Rebilly/rebilly/compare/instruments/core-v8.40.0...instruments/core-v8.40.1) (2024-02-02)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **instruments:** account data race condition in fetch data ([#3265](https://github.com/Rebilly/rebilly/issues/3265)) ([3ddc8c2](https://github.com/Rebilly/rebilly/commit/3ddc8c22ff451e664dd3de72c707efed6b81c422))
14
+
1
15
  ## [8.40.0](https://github.com/Rebilly/rebilly/compare/instruments/core-v8.39.0...instruments/core-v8.40.0) (2024-02-01)
2
16
 
3
17
 
package/dist/index.js CHANGED
@@ -14605,19 +14605,26 @@ async function fetchData({
14605
14605
  }
14606
14606
  let readyToPayPromise = Promise.resolve(null);
14607
14607
  let readyToPayoutPromise = Promise.resolve(null);
14608
+ let fetchAccountAndWebsitePromise = Promise.resolve();
14608
14609
  let availableInstrumentsPromise = null;
14609
14610
  if ((_d = state.options) == null ? void 0 : _d.jwt) {
14610
- fetchAccountAndWebsite$1().then(({ account, website }) => {
14611
- if (state.data == null) {
14612
- throw new Error("Invalid data instance");
14611
+ fetchAccountAndWebsitePromise = fetchAccountAndWebsite$1().then(
14612
+ ({ account, website }) => {
14613
+ if (state.data == null) {
14614
+ throw new Error("Invalid data instance");
14615
+ }
14616
+ state.data.account = account;
14617
+ state.data.website = website;
14613
14618
  }
14614
- state.data.account = account;
14615
- state.data.website = website;
14616
- });
14619
+ );
14617
14620
  if ((_e = state.options) == null ? void 0 : _e.payout) {
14618
- readyToPayoutPromise = fetchReadyToPayout();
14621
+ readyToPayoutPromise = fetchAccountAndWebsitePromise.then(
14622
+ () => fetchReadyToPayout()
14623
+ );
14619
14624
  } else {
14620
- readyToPayPromise = fetchReadyToPay();
14625
+ readyToPayPromise = fetchAccountAndWebsitePromise.then(
14626
+ () => fetchReadyToPay()
14627
+ );
14621
14628
  }
14622
14629
  availableInstrumentsPromise = fetchInstruments();
14623
14630
  } else {
@@ -23393,7 +23400,7 @@ function handleComputedProperty(options) {
23393
23400
  var _a;
23394
23401
  return Object.assign({}, options, {
23395
23402
  _computed: {
23396
- version: "8.39.0",
23403
+ version: "8.40.1",
23397
23404
  paymentMethodsUrl: ((_a = options._dev) == null ? void 0 : _a.paymentMethodsUrl) ?? "https://forms.secure-payments.app"
23398
23405
  }
23399
23406
  });
@@ -26371,15 +26378,19 @@ async function purchase({ payload }) {
26371
26378
  try {
26372
26379
  let fields;
26373
26380
  let completedEvent;
26381
+ let flow;
26374
26382
  if (state.options.payout) {
26375
26383
  fields = await makePayout({ payload });
26376
26384
  completedEvent = events.payoutCompleted;
26385
+ flow = "payout";
26377
26386
  } else if (state.data.isPayment) {
26378
26387
  fields = await makePayment({ payload });
26379
26388
  completedEvent = events.purchaseCompleted;
26389
+ flow = "payment";
26380
26390
  } else {
26381
26391
  fields = await makePurchase({ payload });
26382
26392
  completedEvent = events.purchaseCompleted;
26393
+ flow = "purchase";
26383
26394
  }
26384
26395
  if (((_a = fields.transaction) == null ? void 0 : _a.approvalUrl) && ((_b = fields.transaction) == null ? void 0 : _b.result) === "unknown") {
26385
26396
  if (state.options.features.fullPageRedirect) {
@@ -26387,7 +26398,7 @@ async function purchase({ payload }) {
26387
26398
  } else {
26388
26399
  handleApprovalUrl({ fields, payload });
26389
26400
  }
26390
- } else if (fields.selectedPaymentInstrumentRedirectUrl) {
26401
+ } else if (flow !== "payout" && fields.selectedPaymentInstrumentRedirectUrl) {
26391
26402
  window.location = fields.selectedPaymentInstrumentRedirectUrl;
26392
26403
  } else {
26393
26404
  completedEvent.dispatch(fields);
@@ -26725,7 +26736,7 @@ class RebillyInstrumentsInstance {
26725
26736
  await show({ componentName, payload });
26726
26737
  }
26727
26738
  get version() {
26728
- return `RebillyInstruments Ver.${"8.39.0"}`;
26739
+ return `RebillyInstruments Ver.${"8.40.1"}`;
26729
26740
  }
26730
26741
  on(eventName, callback) {
26731
26742
  on({ eventName, callback });