@rebilly/instruments 3.25.0-beta.0 → 3.25.1-beta.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/dist/index.js +4 -4
- package/dist/index.min.js +5 -5
- package/package.json +1 -1
- package/src/functions/mount/fetch-data.js +2 -2
- package/src/functions/mount/setup-options.js +10 -6
- package/src/functions/mount/setup-user-flow.js +9 -2
- package/src/functions/purchase.js +4 -3
- package/src/storefront/models/ready-to-pay-model.js +2 -0
- package/src/style/base/index.js +2 -2
package/package.json
CHANGED
|
@@ -106,7 +106,7 @@ export class DataInstance {
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
toPostmatesModel() {
|
|
109
|
-
return {
|
|
109
|
+
return JSON.parse(JSON.stringify({
|
|
110
110
|
...this,
|
|
111
111
|
amountAndCurrency: this.amountAndCurrency,
|
|
112
112
|
isPayment: this.isPayment,
|
|
@@ -115,7 +115,7 @@ export class DataInstance {
|
|
|
115
115
|
summaryItems: this.summaryItems,
|
|
116
116
|
summaryLineItems: this.summaryLineItems,
|
|
117
117
|
isShippingRequired: this.isShippingRequired
|
|
118
|
-
}
|
|
118
|
+
}))
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
|
|
@@ -60,24 +60,23 @@ export function sanitizeOptions(options) {
|
|
|
60
60
|
export function validateOptions(options) {
|
|
61
61
|
// TODO: validate more options
|
|
62
62
|
const purchaseData = [
|
|
63
|
-
options.jwt,
|
|
64
63
|
options.items,
|
|
65
64
|
options.invoiceId,
|
|
66
65
|
options.money,
|
|
67
66
|
options.transactionId,
|
|
68
67
|
].filter(v => v);
|
|
69
68
|
|
|
70
|
-
if (purchaseData.length === 0) {
|
|
69
|
+
if (!options.jwt && purchaseData.length === 0) {
|
|
71
70
|
throw new Error('Must provide purchase data');
|
|
72
71
|
}
|
|
73
72
|
|
|
74
73
|
if (purchaseData.length > 1) {
|
|
75
|
-
// JWT can be alone or with specific invoiceId or transactionId
|
|
76
|
-
if (options.jwt && (options.invoiceId || options.transactionId)) {
|
|
77
|
-
return
|
|
78
|
-
}
|
|
79
74
|
throw new Error('Must provide only one purchase data type');
|
|
80
75
|
}
|
|
76
|
+
|
|
77
|
+
if (!options.jwt && (options.invoiceId || options.transactionId)) {
|
|
78
|
+
throw new Error('Must provide a jwt');
|
|
79
|
+
}
|
|
81
80
|
}
|
|
82
81
|
|
|
83
82
|
export default ({
|
|
@@ -121,6 +120,7 @@ export default ({
|
|
|
121
120
|
claims: {
|
|
122
121
|
transactionId,
|
|
123
122
|
invoiceId,
|
|
123
|
+
websiteId,
|
|
124
124
|
}
|
|
125
125
|
} = decodeJwt(combinedOptions.jwt);
|
|
126
126
|
|
|
@@ -133,6 +133,10 @@ export default ({
|
|
|
133
133
|
if (invoiceId) {
|
|
134
134
|
combinedOptions.invoiceId = invoiceId;
|
|
135
135
|
}
|
|
136
|
+
|
|
137
|
+
if (websiteId) {
|
|
138
|
+
combinedOptions.websiteId = websiteId;
|
|
139
|
+
}
|
|
136
140
|
}
|
|
137
141
|
|
|
138
142
|
if (options.items) {
|
|
@@ -39,9 +39,16 @@ export default ({state = {}}) => {
|
|
|
39
39
|
|
|
40
40
|
if (state.options.features.autoResult) {
|
|
41
41
|
on({
|
|
42
|
-
eventName:
|
|
43
|
-
'setup-completed' : 'purchase-completed',
|
|
42
|
+
eventName: 'purchase-completed',
|
|
44
43
|
callback: (payload) => {
|
|
44
|
+
payload = JSON.parse(JSON.stringify(payload));
|
|
45
|
+
showResult({state, payload});
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
on({
|
|
49
|
+
eventName: 'setup-completed',
|
|
50
|
+
callback: (payload) => {
|
|
51
|
+
payload = JSON.parse(JSON.stringify(payload));
|
|
45
52
|
showResult({state, payload});
|
|
46
53
|
}
|
|
47
54
|
});
|
|
@@ -99,12 +99,13 @@ export async function makePurchase({ payload }) {
|
|
|
99
99
|
export function handleApprovalUrl({fields, payload}) {
|
|
100
100
|
if (payload.redirectUrl || !fields.transaction?.approvalUrl) {
|
|
101
101
|
const { paymentMethodsUrl } = state.options._computed;
|
|
102
|
-
|
|
102
|
+
|
|
103
|
+
const modelSafeFields = JSON.parse(JSON.stringify(fields));
|
|
103
104
|
const model = {};
|
|
104
105
|
if (state.data.isPayment) {
|
|
105
|
-
model.payment =
|
|
106
|
+
model.payment = modelSafeFields;
|
|
106
107
|
} else {
|
|
107
|
-
model.purchase =
|
|
108
|
+
model.purchase = modelSafeFields;
|
|
108
109
|
}
|
|
109
110
|
|
|
110
111
|
state.data = new DataInstance({...fields});
|
|
@@ -16,6 +16,7 @@ export class ReadyToPayFeatureModel {
|
|
|
16
16
|
// Paypal fields
|
|
17
17
|
paypalMerchantId = '',
|
|
18
18
|
billingAgreementToken = '',
|
|
19
|
+
paypalClientId = '',
|
|
19
20
|
|
|
20
21
|
// Plaid fields
|
|
21
22
|
linkToken = '',
|
|
@@ -31,6 +32,7 @@ export class ReadyToPayFeatureModel {
|
|
|
31
32
|
|
|
32
33
|
this.paypalMerchantId = paypalMerchantId;
|
|
33
34
|
this.billingAgreementToken = billingAgreementToken;
|
|
35
|
+
this.paypalClientId = paypalClientId;
|
|
34
36
|
|
|
35
37
|
this.linkToken = linkToken;
|
|
36
38
|
}
|
package/src/style/base/index.js
CHANGED
|
@@ -437,8 +437,8 @@ export const vars = (theme) => `
|
|
|
437
437
|
|
|
438
438
|
/* Methods */
|
|
439
439
|
.rebilly-instruments-methods-loader-card-icon {
|
|
440
|
-
width:
|
|
441
|
-
height:
|
|
440
|
+
width: calc(var(--rebilly-fontLineHeightBase) + 10px);
|
|
441
|
+
height: var(--rebilly-fontLineHeightBase);
|
|
442
442
|
margin-left: var(--rebilly-spacing2xs);
|
|
443
443
|
margin-bottom: var(--rebilly-spacing2xs);
|
|
444
444
|
}
|