@alma/widgets 3.0.5 → 3.1.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/raw/widgets.js +34 -4
- package/dist/raw/widgets.js.map +1 -1
- package/dist/raw/widgets.m.js +34 -4
- package/dist/raw/widgets.m.js.map +1 -1
- package/dist/raw/widgets.modern.js +34 -4
- package/dist/raw/widgets.modern.js.map +1 -1
- package/dist/raw/widgets.umd.js +34 -4
- package/dist/raw/widgets.umd.js.map +1 -1
- package/dist/types/Widgets/EligibilityModal/ModalContainer.d.ts +2 -0
- package/dist/types/Widgets/PaymentPlans/index.d.ts +2 -0
- package/dist/types/hooks/useFetchEligibility.d.ts +1 -1
- package/dist/types/types.d.ts +4 -0
- package/dist/widgets.js +1 -1
- package/dist/widgets.js.map +1 -1
- package/dist/widgets.m.js +1 -1
- package/dist/widgets.m.js.map +1 -1
- package/dist/widgets.modern.js +1 -1
- package/dist/widgets.modern.js.map +1 -1
- package/dist/widgets.umd.js +1 -1
- package/dist/widgets.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -2149,7 +2149,7 @@ const filterELigibility = (eligibilities, configPlans) => {
|
|
|
2149
2149
|
const useFetchEligibility = (purchaseAmount, {
|
|
2150
2150
|
domain,
|
|
2151
2151
|
merchantId
|
|
2152
|
-
}, plans) => {
|
|
2152
|
+
}, plans, customerBillingCountry, customerShippingCountry) => {
|
|
2153
2153
|
const [eligibility, setEligibility] = useState([]);
|
|
2154
2154
|
const [status, setStatus] = useState(apiStatus.PENDING);
|
|
2155
2155
|
const configInstallments = plans == null ? void 0 : plans.map(plan => ({
|
|
@@ -2159,9 +2159,27 @@ const useFetchEligibility = (purchaseAmount, {
|
|
|
2159
2159
|
}));
|
|
2160
2160
|
useEffect(() => {
|
|
2161
2161
|
if (status === apiStatus.PENDING) {
|
|
2162
|
+
let billing_address = null;
|
|
2163
|
+
|
|
2164
|
+
if (customerBillingCountry) {
|
|
2165
|
+
billing_address = {
|
|
2166
|
+
country: customerBillingCountry
|
|
2167
|
+
};
|
|
2168
|
+
}
|
|
2169
|
+
|
|
2170
|
+
let shipping_address = null;
|
|
2171
|
+
|
|
2172
|
+
if (customerShippingCountry) {
|
|
2173
|
+
shipping_address = {
|
|
2174
|
+
country: customerShippingCountry
|
|
2175
|
+
};
|
|
2176
|
+
}
|
|
2177
|
+
|
|
2162
2178
|
fetchFromApi(domain + '/v2/payments/eligibility', {
|
|
2163
2179
|
purchase_amount: purchaseAmount,
|
|
2164
|
-
queries: configInstallments
|
|
2180
|
+
queries: configInstallments,
|
|
2181
|
+
billing_address,
|
|
2182
|
+
shipping_address
|
|
2165
2183
|
}, {
|
|
2166
2184
|
Authorization: `Alma-Merchant-Auth ${merchantId}`
|
|
2167
2185
|
}).then(res => {
|
|
@@ -2875,10 +2893,12 @@ const ModalContainer = ({
|
|
|
2875
2893
|
purchaseAmount,
|
|
2876
2894
|
apiData,
|
|
2877
2895
|
configPlans,
|
|
2896
|
+
customerBillingCountry,
|
|
2897
|
+
customerShippingCountry,
|
|
2878
2898
|
onClose,
|
|
2879
2899
|
cards
|
|
2880
2900
|
}) => {
|
|
2881
|
-
const [eligibilityPlans, status] = useFetchEligibility(purchaseAmount, apiData, configPlans);
|
|
2901
|
+
const [eligibilityPlans, status] = useFetchEligibility(purchaseAmount, apiData, configPlans, customerBillingCountry, customerShippingCountry);
|
|
2882
2902
|
return /*#__PURE__*/React.createElement(EligibilityModal, {
|
|
2883
2903
|
initialPlanIndex: 0,
|
|
2884
2904
|
onClose: onClose,
|
|
@@ -2994,10 +3014,12 @@ const PaymentPlanWidget = ({
|
|
|
2994
3014
|
purchaseAmount,
|
|
2995
3015
|
suggestedPaymentPlan,
|
|
2996
3016
|
cards,
|
|
3017
|
+
customerBillingCountry,
|
|
3018
|
+
customerShippingCountry,
|
|
2997
3019
|
transitionDelay,
|
|
2998
3020
|
hideBorder: _hideBorder = false
|
|
2999
3021
|
}) => {
|
|
3000
|
-
const [eligibilityPlans, status] = useFetchEligibility(purchaseAmount, apiData, configPlans);
|
|
3022
|
+
const [eligibilityPlans, status] = useFetchEligibility(purchaseAmount, apiData, configPlans, customerBillingCountry, customerShippingCountry);
|
|
3001
3023
|
const eligiblePlans = eligibilityPlans.filter(plan => plan.eligible);
|
|
3002
3024
|
const activePlanIndex = getIndexOfActivePlan({
|
|
3003
3025
|
eligibilityPlans,
|
|
@@ -3140,6 +3162,8 @@ class WidgetsController {
|
|
|
3140
3162
|
hideBorder = false,
|
|
3141
3163
|
monochrome = true,
|
|
3142
3164
|
suggestedPaymentPlan,
|
|
3165
|
+
customerBillingCountry,
|
|
3166
|
+
customerShippingCountry,
|
|
3143
3167
|
locale = Locale.en,
|
|
3144
3168
|
cards
|
|
3145
3169
|
} = options;
|
|
@@ -3155,6 +3179,8 @@ class WidgetsController {
|
|
|
3155
3179
|
purchaseAmount: purchaseAmount,
|
|
3156
3180
|
suggestedPaymentPlan: suggestedPaymentPlan,
|
|
3157
3181
|
cards: cards,
|
|
3182
|
+
customerBillingCountry: customerBillingCountry,
|
|
3183
|
+
customerShippingCountry: customerShippingCountry,
|
|
3158
3184
|
transitionDelay: transitionDelay,
|
|
3159
3185
|
hideBorder: hideBorder
|
|
3160
3186
|
})), document.querySelector(container));
|
|
@@ -3168,6 +3194,8 @@ class WidgetsController {
|
|
|
3168
3194
|
purchaseAmount,
|
|
3169
3195
|
plans,
|
|
3170
3196
|
locale = Locale.en,
|
|
3197
|
+
customerBillingCountry,
|
|
3198
|
+
customerShippingCountry,
|
|
3171
3199
|
cards
|
|
3172
3200
|
} = options;
|
|
3173
3201
|
|
|
@@ -3180,6 +3208,8 @@ class WidgetsController {
|
|
|
3180
3208
|
purchaseAmount: purchaseAmount,
|
|
3181
3209
|
apiData: this.apiData,
|
|
3182
3210
|
configPlans: plans,
|
|
3211
|
+
customerBillingCountry: customerBillingCountry,
|
|
3212
|
+
customerShippingCountry: customerShippingCountry,
|
|
3183
3213
|
onClose: close,
|
|
3184
3214
|
cards: cards
|
|
3185
3215
|
})), document.querySelector(container));
|