@rebilly/instruments 16.112.1 → 16.113.1
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 +1 -6
- package/dist/index.js +100 -38
- package/dist/index.min.js +6 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
## [16.
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
### Bug Fixes
|
|
5
|
-
|
|
6
|
-
* **storefront-payment-form:** Payout request did not require address in instruments config ([#21355](https://github.com/Rebilly/rebilly/issues/21355)) ([2194f00](https://github.com/Rebilly/rebilly/commit/2194f00512f4a7f398e1221fd44c2fb7ca277bd7))
|
|
1
|
+
## [16.113.1](https://github.com/Rebilly/rebilly/compare/instruments/core-v16.113.0...instruments/core-v16.113.1) (2026-05-13)
|
package/dist/index.js
CHANGED
|
@@ -2206,7 +2206,7 @@ let ModalIframe$1 = class ModalIframe extends BaseIframe {
|
|
|
2206
2206
|
window.addEventListener(
|
|
2207
2207
|
"message",
|
|
2208
2208
|
async (event) => {
|
|
2209
|
-
var _a, _b;
|
|
2209
|
+
var _a, _b, _c;
|
|
2210
2210
|
if (((_a = event.data) == null ? void 0 : _a.type) === "rebilly-spf:ready" && event.source === this.component.frame.contentWindow) {
|
|
2211
2211
|
this.component.frame.contentWindow.postMessage(
|
|
2212
2212
|
{
|
|
@@ -2223,7 +2223,19 @@ let ModalIframe$1 = class ModalIframe extends BaseIframe {
|
|
|
2223
2223
|
isRedirected = true;
|
|
2224
2224
|
}
|
|
2225
2225
|
if (event.data === "rebilly-instruments-approval-url-close") {
|
|
2226
|
-
if (
|
|
2226
|
+
if ((_b = this.model) == null ? void 0 : _b.setup) {
|
|
2227
|
+
const { instrument, transaction } = this.model.setup;
|
|
2228
|
+
state.storefront.setSessionToken(
|
|
2229
|
+
instrument.token || state.options.jwt
|
|
2230
|
+
);
|
|
2231
|
+
const { fields: updatedTransaction } = await state.storefront.transactions.get({
|
|
2232
|
+
id: transaction.id
|
|
2233
|
+
});
|
|
2234
|
+
close({
|
|
2235
|
+
transaction: updatedTransaction,
|
|
2236
|
+
instrument
|
|
2237
|
+
});
|
|
2238
|
+
} else if (state.options.transactionType === "purchase") {
|
|
2227
2239
|
state.storefront.setSessionToken(
|
|
2228
2240
|
state.data.token || state.options.jwt
|
|
2229
2241
|
);
|
|
@@ -2231,7 +2243,7 @@ let ModalIframe$1 = class ModalIframe extends BaseIframe {
|
|
|
2231
2243
|
state.storefront.transactions.get({
|
|
2232
2244
|
id: state.data.transaction.id
|
|
2233
2245
|
}),
|
|
2234
|
-
((
|
|
2246
|
+
((_c = state.data.invoice) == null ? void 0 : _c.id) ? state.storefront.invoices.get({
|
|
2235
2247
|
id: state.data.invoice.id
|
|
2236
2248
|
}) : { fields: null }
|
|
2237
2249
|
]);
|
|
@@ -2244,17 +2256,6 @@ let ModalIframe$1 = class ModalIframe extends BaseIframe {
|
|
|
2244
2256
|
updatedPurchase.invoice = invoice;
|
|
2245
2257
|
}
|
|
2246
2258
|
close(updatedPurchase);
|
|
2247
|
-
} else if (state.options.transactionType === "setup") {
|
|
2248
|
-
state.storefront.setSessionToken(
|
|
2249
|
-
state.data.instrument.token || state.options.jwt
|
|
2250
|
-
);
|
|
2251
|
-
const { fields: transaction } = await state.storefront.transactions.get({
|
|
2252
|
-
id: state.data.transaction.id
|
|
2253
|
-
});
|
|
2254
|
-
close({
|
|
2255
|
-
transaction,
|
|
2256
|
-
instrument: state.data.instrument
|
|
2257
|
-
});
|
|
2258
2259
|
} else {
|
|
2259
2260
|
close();
|
|
2260
2261
|
}
|
|
@@ -5298,7 +5299,7 @@ function C$1({ options: e2 }) {
|
|
|
5298
5299
|
}
|
|
5299
5300
|
function o2() {
|
|
5300
5301
|
const i = {
|
|
5301
|
-
"REB-API-CONSUMER": `${["Rebilly", e2.appName, "js-sdk"].filter((g) => g).join("/")}@
|
|
5302
|
+
"REB-API-CONSUMER": `${["Rebilly", e2.appName, "js-sdk"].filter((g) => g).join("/")}@42eda38`
|
|
5302
5303
|
};
|
|
5303
5304
|
return e2.apiKey && (i["REB-APIKEY"] = e2.apiKey), i;
|
|
5304
5305
|
}
|
|
@@ -18720,16 +18721,19 @@ async function fetchAccountAndWebsite() {
|
|
|
18720
18721
|
});
|
|
18721
18722
|
}
|
|
18722
18723
|
async function setupPaymentInstrument({
|
|
18723
|
-
data
|
|
18724
|
+
data,
|
|
18725
|
+
instrument
|
|
18724
18726
|
}) {
|
|
18725
18727
|
return Endpoint(async () => {
|
|
18726
18728
|
var _a, _b, _c;
|
|
18727
18729
|
validateStorefront(state.storefront);
|
|
18728
18730
|
validateOptions$1(state.options);
|
|
18729
|
-
const
|
|
18730
|
-
state.storefront.setSessionToken(
|
|
18731
|
+
const targetInstrument = instrument ?? (await state.storefront.paymentInstruments.create({ data })).fields;
|
|
18732
|
+
state.storefront.setSessionToken(
|
|
18733
|
+
targetInstrument.token || state.options.jwt
|
|
18734
|
+
);
|
|
18731
18735
|
const setupPayload = {
|
|
18732
|
-
id:
|
|
18736
|
+
id: targetInstrument.id,
|
|
18733
18737
|
data: {
|
|
18734
18738
|
websiteId: state.options.websiteId,
|
|
18735
18739
|
...data
|
|
@@ -18745,7 +18749,7 @@ async function setupPaymentInstrument({
|
|
|
18745
18749
|
setupPayload.data.redirectUrl = `${setupPayload.data.redirectUrl}&originalRedirectUrl=${state.data.transaction.redirectUrl}`;
|
|
18746
18750
|
}
|
|
18747
18751
|
const { fields: transaction } = await state.storefront.paymentInstruments.setup(setupPayload);
|
|
18748
|
-
return { instrument, transaction };
|
|
18752
|
+
return { instrument: targetInstrument, transaction };
|
|
18749
18753
|
});
|
|
18750
18754
|
}
|
|
18751
18755
|
async function fetchPaymentInstrument() {
|
|
@@ -18812,7 +18816,6 @@ const _PayoutRequestModel = class _PayoutRequestModel extends BaseModel {
|
|
|
18812
18816
|
};
|
|
18813
18817
|
_PayoutRequestModel.Status = {
|
|
18814
18818
|
pending: "pending",
|
|
18815
|
-
partiallyFulfilled: "partially-fulfilled",
|
|
18816
18819
|
fulfilled: "fulfilled",
|
|
18817
18820
|
canceled: "canceled"
|
|
18818
18821
|
};
|
|
@@ -18897,6 +18900,9 @@ class DataInstance {
|
|
|
18897
18900
|
} else if (this.transaction) {
|
|
18898
18901
|
currency = this.transaction.currency;
|
|
18899
18902
|
amount = this.transaction.amount;
|
|
18903
|
+
} else if (this.payout) {
|
|
18904
|
+
currency = this.payout.currency;
|
|
18905
|
+
amount = this.payout.amount;
|
|
18900
18906
|
} else if (this.money) {
|
|
18901
18907
|
currency = this.money.currency;
|
|
18902
18908
|
amount = this.money.amount;
|
|
@@ -23107,25 +23113,78 @@ async function makePayment({ payload }) {
|
|
|
23107
23113
|
}
|
|
23108
23114
|
return fields;
|
|
23109
23115
|
}
|
|
23110
|
-
|
|
23111
|
-
|
|
23112
|
-
|
|
23113
|
-
|
|
23114
|
-
}
|
|
23116
|
+
const PAYOUT_SETUP_REQUIRED_METHODS = ["VegaWallet"];
|
|
23117
|
+
async function awaitPayoutSetupApprovalUrl({
|
|
23118
|
+
instrument,
|
|
23119
|
+
transaction
|
|
23115
23120
|
}) {
|
|
23116
|
-
|
|
23117
|
-
|
|
23118
|
-
|
|
23121
|
+
var _a, _b;
|
|
23122
|
+
if (!(transaction == null ? void 0 : transaction.approvalUrl) || transaction.result !== "unknown") {
|
|
23123
|
+
return;
|
|
23124
|
+
}
|
|
23125
|
+
validateOptions$1(state.options);
|
|
23126
|
+
if ((_a = state.options.features) == null ? void 0 : _a.fullPageRedirect) {
|
|
23127
|
+
window.location.href = transaction.approvalUrl;
|
|
23128
|
+
return new Promise(() => {
|
|
23119
23129
|
});
|
|
23120
|
-
paymentInstrumentId = newPaymentInstrumentId;
|
|
23121
23130
|
}
|
|
23122
|
-
const
|
|
23131
|
+
const paymentMethodsUrl = (_b = state.options._computed) == null ? void 0 : _b.paymentMethodsUrl;
|
|
23132
|
+
const name = "rebilly-instruments-approval-url";
|
|
23133
|
+
return new Promise((resolve, reject) => {
|
|
23134
|
+
mountModal({
|
|
23135
|
+
name,
|
|
23136
|
+
// Load the iframe at the root URL so App.vue can complete its postmate
|
|
23137
|
+
// handshake before mountModal navigates the child router to the approval-url route
|
|
23138
|
+
url: `${paymentMethodsUrl}?name=${name}`,
|
|
23139
|
+
model: {
|
|
23140
|
+
setup: { instrument, transaction }
|
|
23141
|
+
},
|
|
23142
|
+
close: ({
|
|
23143
|
+
transaction: updatedTransaction
|
|
23144
|
+
} = {}) => {
|
|
23145
|
+
if ((updatedTransaction == null ? void 0 : updatedTransaction.result) === "declined") {
|
|
23146
|
+
reject(
|
|
23147
|
+
new Error("Payment instrument verification failed.")
|
|
23148
|
+
);
|
|
23149
|
+
return;
|
|
23150
|
+
}
|
|
23151
|
+
resolve();
|
|
23152
|
+
}
|
|
23153
|
+
});
|
|
23154
|
+
});
|
|
23155
|
+
}
|
|
23156
|
+
async function makePayout({ payload }) {
|
|
23157
|
+
const { isExistingInstrument, _raw, redirectUrl } = payload;
|
|
23158
|
+
const paymentInstrumentId = await resolvePaymentInstrumentId({
|
|
23159
|
+
token: _raw,
|
|
23160
|
+
isExistingInstrument,
|
|
23161
|
+
redirectUrl
|
|
23162
|
+
});
|
|
23163
|
+
return updatePayoutRequest({
|
|
23123
23164
|
id: state.data.payout.id,
|
|
23124
|
-
data: {
|
|
23125
|
-
|
|
23126
|
-
|
|
23165
|
+
data: { paymentInstrumentId }
|
|
23166
|
+
});
|
|
23167
|
+
}
|
|
23168
|
+
async function resolvePaymentInstrumentId({
|
|
23169
|
+
token,
|
|
23170
|
+
isExistingInstrument,
|
|
23171
|
+
redirectUrl
|
|
23172
|
+
}) {
|
|
23173
|
+
if (PAYOUT_SETUP_REQUIRED_METHODS.includes(token.method)) {
|
|
23174
|
+
const redirectField = redirectUrl ? { redirectUrl } : {};
|
|
23175
|
+
const { instrument, transaction } = await setupPaymentInstrument(
|
|
23176
|
+
isExistingInstrument ? { instrument: token, data: redirectField } : { data: { token: token.id, ...redirectField } }
|
|
23177
|
+
);
|
|
23178
|
+
await awaitPayoutSetupApprovalUrl({ instrument, transaction });
|
|
23179
|
+
return instrument.id;
|
|
23180
|
+
}
|
|
23181
|
+
if (isExistingInstrument) {
|
|
23182
|
+
return token.id;
|
|
23183
|
+
}
|
|
23184
|
+
const { id } = await createPaymentInstrument({
|
|
23185
|
+
data: { token: token.id }
|
|
23127
23186
|
});
|
|
23128
|
-
return
|
|
23187
|
+
return id;
|
|
23129
23188
|
}
|
|
23130
23189
|
async function purchase({ payload }) {
|
|
23131
23190
|
var _a, _b;
|
|
@@ -23196,11 +23255,14 @@ async function setup({ payload }) {
|
|
|
23196
23255
|
window.location = transaction.approvalUrl;
|
|
23197
23256
|
} else {
|
|
23198
23257
|
const { paymentMethodsUrl } = state.options._computed;
|
|
23258
|
+
const name = "rebilly-instruments-approval-url";
|
|
23199
23259
|
mountModal({
|
|
23200
|
-
name
|
|
23201
|
-
|
|
23260
|
+
name,
|
|
23261
|
+
// Load the iframe at the root URL so App.vue can complete its postmate
|
|
23262
|
+
// handshake before mountModal navigates the child router to the approval-url route
|
|
23263
|
+
url: `${paymentMethodsUrl}?name=${name}`,
|
|
23202
23264
|
model: {
|
|
23203
|
-
setup: { transaction }
|
|
23265
|
+
setup: { instrument, transaction }
|
|
23204
23266
|
},
|
|
23205
23267
|
close: ({
|
|
23206
23268
|
transaction: updatedTransaction = transaction
|