@rebilly/instruments 3.26.2-beta.0 → 3.26.4-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 +2 -2
- package/dist/index.min.js +2 -2
- package/package.json +1 -1
- package/src/storefront/models/ready-to-pay-model.js +19 -0
- package/src/style/base/index.js +1 -1
- package/src/views/method-selector/express-methods.js +2 -1
- package/src/views/method-selector/mount-express-methods.js +25 -2
package/package.json
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import PaymentMetadataModel from './payment-metadata';
|
|
2
2
|
|
|
3
3
|
export class ReadyToPayFeatureModel {
|
|
4
|
+
static FeatureName = {
|
|
5
|
+
paypalBillingAgreement: 'PayPal billing agreement',
|
|
6
|
+
googlePay: 'Google Pay',
|
|
7
|
+
applePay: 'Apple Pay',
|
|
8
|
+
};
|
|
9
|
+
|
|
4
10
|
constructor({
|
|
5
11
|
name = '',
|
|
6
12
|
expirationTime = '',
|
|
@@ -54,4 +60,17 @@ export default class ReadyToPayModel {
|
|
|
54
60
|
this.filters = filters;
|
|
55
61
|
this.metadata = metadata ? new PaymentMetadataModel(metadata) : null;
|
|
56
62
|
}
|
|
63
|
+
|
|
64
|
+
get optionsPaymentInstrumentsKey() {
|
|
65
|
+
switch (this.feature?.name) {
|
|
66
|
+
case ReadyToPayFeatureModel.FeatureName.paypalBillingAgreement:
|
|
67
|
+
return 'paypal';
|
|
68
|
+
case ReadyToPayFeatureModel.FeatureName.googlePay:
|
|
69
|
+
return 'googlePay';
|
|
70
|
+
case ReadyToPayFeatureModel.FeatureName.applePay:
|
|
71
|
+
return 'applePay';
|
|
72
|
+
default:
|
|
73
|
+
return undefined
|
|
74
|
+
}
|
|
75
|
+
}
|
|
57
76
|
}
|
package/src/style/base/index.js
CHANGED
|
@@ -92,7 +92,7 @@ export const vars = (theme) => `
|
|
|
92
92
|
background-size: 200% 100%;
|
|
93
93
|
-webkit-animation: 1.5s rebillyExpressShine linear infinite;
|
|
94
94
|
animation: 1.5s rebillyExpressShine linear infinite;
|
|
95
|
-
height: 48px;
|
|
95
|
+
min-height: 48px;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
.rebilly-instruments-express-methods .rebilly-instruments-express-methods-container > *:last-child {
|
|
@@ -4,7 +4,7 @@ export default function mountExpressMethod({
|
|
|
4
4
|
}) {
|
|
5
5
|
const {Rebilly} = window;
|
|
6
6
|
const container = document.querySelector(`.rebilly-instruments-${id}-method`);
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
// Hack: The correct way to do this is to accept the options via the framepay package
|
|
9
9
|
// Will remove once these options are added to framepay
|
|
10
10
|
function updateApplePayStyling() {
|
|
@@ -35,6 +35,7 @@ export default function mountExpressMethod({
|
|
|
35
35
|
if (id === 'apple-pay') {
|
|
36
36
|
updateApplePayStyling();
|
|
37
37
|
}
|
|
38
|
+
|
|
38
39
|
} else {
|
|
39
40
|
console.warn(`method '${id}' is not supported`);
|
|
40
41
|
}
|
|
@@ -24,12 +24,35 @@ export async function mountExpressMethods({
|
|
|
24
24
|
);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
function generateExpressMethodHeight(method) {
|
|
28
|
+
let height;
|
|
29
|
+
const optionId = method.optionsPaymentInstrumentsKey;
|
|
30
|
+
|
|
31
|
+
// Return the default size of express methods if no id is found
|
|
32
|
+
if (!optionId) return '48px';
|
|
33
|
+
|
|
34
|
+
const {buttonHeight, displayOptions} = state.options.paymentInstruments?.[optionId];
|
|
35
|
+
|
|
36
|
+
if (displayOptions) {
|
|
37
|
+
height = displayOptions.buttonHeight;
|
|
38
|
+
} else {
|
|
39
|
+
height = buttonHeight;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (typeof height === 'number') {
|
|
43
|
+
height = `${buttonHeight}px`;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return height;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
methods.forEach(method => {
|
|
50
|
+
const {METHOD_ID: id} = getMethodData(method);
|
|
28
51
|
// filter out apple pay unless in safari
|
|
29
52
|
if (id === 'apple-pay' && !browserIsSafari()) return
|
|
30
53
|
|
|
31
54
|
container.innerHTML += `
|
|
32
|
-
<div class="rebilly-instruments-${id}-method"></div>
|
|
55
|
+
<div class="rebilly-instruments-${id}-method" style="height: ${generateExpressMethodHeight(method)}"></div>
|
|
33
56
|
`;
|
|
34
57
|
mountExpressMethod({
|
|
35
58
|
state,
|