@economist/web-apple-pay 0.1.3-beta.35 → 0.1.3-beta.36
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 +10 -192
- package/dist/src/apple-pay-button.js +10 -192
- package/dist/src/apple-pay-button.stories.js +10 -192
- package/dist/src/apple-pay-modal.stories.js +10 -192
- package/dist/src/clients/payment-checkout/detects.js +5 -2
- package/dist/src/index.js +10 -192
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1122,10 +1122,13 @@ var isAppleDeviceOrSafari = () => {
|
|
|
1122
1122
|
};
|
|
1123
1123
|
var bypassApplePayChecks = () => new URLSearchParams(window.location.search).get("BYPASS_APPLE_PAY_CHECKS") !== null;
|
|
1124
1124
|
var isApplePayAvailable = async () => {
|
|
1125
|
-
if (
|
|
1126
|
-
return
|
|
1125
|
+
if (bypassApplePayChecks()) {
|
|
1126
|
+
return true;
|
|
1127
1127
|
}
|
|
1128
1128
|
const applePaySession = window.ApplePaySession;
|
|
1129
|
+
if (!applePaySession && !isAppleDeviceOrSafari()) {
|
|
1130
|
+
return false;
|
|
1131
|
+
}
|
|
1129
1132
|
if (!applePaySession) {
|
|
1130
1133
|
return false;
|
|
1131
1134
|
}
|
|
@@ -2037,203 +2040,18 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2037
2040
|
// ─── Render pipeline ────────────────────────────────────────────────────────
|
|
2038
2041
|
async #run() {
|
|
2039
2042
|
try {
|
|
2040
|
-
console.log(
|
|
2041
|
-
"[ApplePayButton] #run start",
|
|
2042
|
-
JSON.stringify(
|
|
2043
|
-
{
|
|
2044
|
-
country: this.#country,
|
|
2045
|
-
offer_sku: this.#offer?.sku_id,
|
|
2046
|
-
entry_point: this.#entryPoint
|
|
2047
|
-
},
|
|
2048
|
-
null,
|
|
2049
|
-
2
|
|
2050
|
-
)
|
|
2051
|
-
);
|
|
2052
2043
|
this.#renderTemplate();
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
{
|
|
2057
|
-
country: this.#country,
|
|
2058
|
-
offer_sku: this.#offer?.sku_id
|
|
2059
|
-
},
|
|
2060
|
-
null,
|
|
2061
|
-
2
|
|
2062
|
-
)
|
|
2063
|
-
);
|
|
2064
|
-
const availabilityBlocked = await this.#checkAvailability();
|
|
2065
|
-
console.log(
|
|
2066
|
-
"[ApplePayButton] #checkAvailability result",
|
|
2067
|
-
JSON.stringify(
|
|
2068
|
-
{
|
|
2069
|
-
blocked: availabilityBlocked,
|
|
2070
|
-
country: this.#country,
|
|
2071
|
-
offer_sku: this.#offer?.sku_id
|
|
2072
|
-
},
|
|
2073
|
-
null,
|
|
2074
|
-
2
|
|
2075
|
-
)
|
|
2076
|
-
);
|
|
2077
|
-
if (availabilityBlocked) {
|
|
2078
|
-
console.log(
|
|
2079
|
-
"[ApplePayButton] #run early return after #checkAvailability",
|
|
2080
|
-
JSON.stringify(
|
|
2081
|
-
{
|
|
2082
|
-
country: this.#country,
|
|
2083
|
-
offer_sku: this.#offer?.sku_id
|
|
2084
|
-
},
|
|
2085
|
-
null,
|
|
2086
|
-
2
|
|
2087
|
-
)
|
|
2088
|
-
);
|
|
2089
|
-
return;
|
|
2090
|
-
}
|
|
2091
|
-
const offerMissing = this.#checkOffer();
|
|
2092
|
-
console.log(
|
|
2093
|
-
"[ApplePayButton] #checkOffer result",
|
|
2094
|
-
JSON.stringify(
|
|
2095
|
-
{
|
|
2096
|
-
blocked: offerMissing,
|
|
2097
|
-
country: this.#country,
|
|
2098
|
-
offer_sku: this.#offer?.sku_id
|
|
2099
|
-
},
|
|
2100
|
-
null,
|
|
2101
|
-
2
|
|
2102
|
-
)
|
|
2103
|
-
);
|
|
2104
|
-
if (offerMissing) {
|
|
2105
|
-
console.log(
|
|
2106
|
-
"[ApplePayButton] #run early return after #checkOffer",
|
|
2107
|
-
JSON.stringify(
|
|
2108
|
-
{
|
|
2109
|
-
country: this.#country,
|
|
2110
|
-
offer_sku: this.#offer?.sku_id
|
|
2111
|
-
},
|
|
2112
|
-
null,
|
|
2113
|
-
2
|
|
2114
|
-
)
|
|
2115
|
-
);
|
|
2116
|
-
return;
|
|
2117
|
-
}
|
|
2118
|
-
const sessionBlocked = await this.#checkSession();
|
|
2119
|
-
console.log(
|
|
2120
|
-
"[ApplePayButton] #checkSession result",
|
|
2121
|
-
JSON.stringify(
|
|
2122
|
-
{
|
|
2123
|
-
blocked: sessionBlocked,
|
|
2124
|
-
country: this.#country,
|
|
2125
|
-
offer_sku: this.#offer?.sku_id,
|
|
2126
|
-
session_user_type: this.#sessionData?.userType,
|
|
2127
|
-
session_logged_in: this.#sessionData?.loggedIn
|
|
2128
|
-
},
|
|
2129
|
-
null,
|
|
2130
|
-
2
|
|
2131
|
-
)
|
|
2132
|
-
);
|
|
2133
|
-
if (sessionBlocked) {
|
|
2134
|
-
console.log(
|
|
2135
|
-
"[ApplePayButton] #run early return after #checkSession",
|
|
2136
|
-
JSON.stringify(
|
|
2137
|
-
{
|
|
2138
|
-
country: this.#country,
|
|
2139
|
-
offer_sku: this.#offer?.sku_id
|
|
2140
|
-
},
|
|
2141
|
-
null,
|
|
2142
|
-
2
|
|
2143
|
-
)
|
|
2144
|
-
);
|
|
2145
|
-
return;
|
|
2146
|
-
}
|
|
2044
|
+
if (await this.#checkAvailability()) return;
|
|
2045
|
+
if (this.#checkOffer()) return;
|
|
2046
|
+
if (await this.#checkSession()) return;
|
|
2147
2047
|
this.#captureReturnUrl();
|
|
2148
|
-
console.log(
|
|
2149
|
-
"[ApplePayButton] #captureReturnUrl done",
|
|
2150
|
-
JSON.stringify(
|
|
2151
|
-
{
|
|
2152
|
-
return_url: this.#returnUrl
|
|
2153
|
-
},
|
|
2154
|
-
null,
|
|
2155
|
-
2
|
|
2156
|
-
)
|
|
2157
|
-
);
|
|
2158
2048
|
this.#computeBillingCountries();
|
|
2159
|
-
|
|
2160
|
-
"[ApplePayButton] #computeBillingCountries done",
|
|
2161
|
-
JSON.stringify(
|
|
2162
|
-
{
|
|
2163
|
-
supported_billing_countries: this.#supportedBillingCountries
|
|
2164
|
-
},
|
|
2165
|
-
null,
|
|
2166
|
-
2
|
|
2167
|
-
)
|
|
2168
|
-
);
|
|
2169
|
-
const optionsBlocked = await this.#fetchAndCacheOptions();
|
|
2170
|
-
console.log(
|
|
2171
|
-
"[ApplePayButton] #fetchAndCacheOptions result",
|
|
2172
|
-
JSON.stringify(
|
|
2173
|
-
{
|
|
2174
|
-
blocked: optionsBlocked,
|
|
2175
|
-
has_apple_pay_option: Boolean(this.#paymentOptions?.options?.apple_pay)
|
|
2176
|
-
},
|
|
2177
|
-
null,
|
|
2178
|
-
2
|
|
2179
|
-
)
|
|
2180
|
-
);
|
|
2181
|
-
if (optionsBlocked) {
|
|
2182
|
-
console.log(
|
|
2183
|
-
"[ApplePayButton] #run early return after #fetchAndCacheOptions",
|
|
2184
|
-
JSON.stringify(
|
|
2185
|
-
{
|
|
2186
|
-
country: this.#country,
|
|
2187
|
-
offer_sku: this.#offer?.sku_id
|
|
2188
|
-
},
|
|
2189
|
-
null,
|
|
2190
|
-
2
|
|
2191
|
-
)
|
|
2192
|
-
);
|
|
2193
|
-
return;
|
|
2194
|
-
}
|
|
2049
|
+
if (await this.#fetchAndCacheOptions()) return;
|
|
2195
2050
|
this.#finishLoading();
|
|
2196
|
-
|
|
2197
|
-
"[ApplePayButton] #finishLoading done",
|
|
2198
|
-
JSON.stringify(
|
|
2199
|
-
{
|
|
2200
|
-
country: this.#country,
|
|
2201
|
-
offer_sku: this.#offer?.sku_id
|
|
2202
|
-
},
|
|
2203
|
-
null,
|
|
2204
|
-
2
|
|
2205
|
-
)
|
|
2206
|
-
);
|
|
2207
|
-
} catch (error) {
|
|
2208
|
-
console.log(
|
|
2209
|
-
"[ApplePayButton] #run failed",
|
|
2210
|
-
JSON.stringify(
|
|
2211
|
-
{
|
|
2212
|
-
country: this.#country,
|
|
2213
|
-
offer_sku: this.#offer?.sku_id,
|
|
2214
|
-
error: error instanceof Error ? {
|
|
2215
|
-
name: error.name,
|
|
2216
|
-
message: error.message,
|
|
2217
|
-
stack: error.stack
|
|
2218
|
-
} : error
|
|
2219
|
-
},
|
|
2220
|
-
null,
|
|
2221
|
-
2
|
|
2222
|
-
)
|
|
2223
|
-
);
|
|
2051
|
+
} catch {
|
|
2224
2052
|
this.style.display = "none";
|
|
2225
2053
|
this.querySelector(SEL_CONTAINER)?.remove();
|
|
2226
2054
|
} finally {
|
|
2227
|
-
console.log(
|
|
2228
|
-
"[ApplePayButton] #run finally",
|
|
2229
|
-
JSON.stringify(
|
|
2230
|
-
{
|
|
2231
|
-
rendering: this.#rendering
|
|
2232
|
-
},
|
|
2233
|
-
null,
|
|
2234
|
-
2
|
|
2235
|
-
)
|
|
2236
|
-
);
|
|
2237
2055
|
this.#rendering = false;
|
|
2238
2056
|
}
|
|
2239
2057
|
}
|
|
@@ -1117,10 +1117,13 @@ var isAppleDeviceOrSafari = () => {
|
|
|
1117
1117
|
};
|
|
1118
1118
|
var bypassApplePayChecks = () => new URLSearchParams(window.location.search).get("BYPASS_APPLE_PAY_CHECKS") !== null;
|
|
1119
1119
|
var isApplePayAvailable = async () => {
|
|
1120
|
-
if (
|
|
1121
|
-
return
|
|
1120
|
+
if (bypassApplePayChecks()) {
|
|
1121
|
+
return true;
|
|
1122
1122
|
}
|
|
1123
1123
|
const applePaySession = window.ApplePaySession;
|
|
1124
|
+
if (!applePaySession && !isAppleDeviceOrSafari()) {
|
|
1125
|
+
return false;
|
|
1126
|
+
}
|
|
1124
1127
|
if (!applePaySession) {
|
|
1125
1128
|
return false;
|
|
1126
1129
|
}
|
|
@@ -2032,203 +2035,18 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2032
2035
|
// ─── Render pipeline ────────────────────────────────────────────────────────
|
|
2033
2036
|
async #run() {
|
|
2034
2037
|
try {
|
|
2035
|
-
console.log(
|
|
2036
|
-
"[ApplePayButton] #run start",
|
|
2037
|
-
JSON.stringify(
|
|
2038
|
-
{
|
|
2039
|
-
country: this.#country,
|
|
2040
|
-
offer_sku: this.#offer?.sku_id,
|
|
2041
|
-
entry_point: this.#entryPoint
|
|
2042
|
-
},
|
|
2043
|
-
null,
|
|
2044
|
-
2
|
|
2045
|
-
)
|
|
2046
|
-
);
|
|
2047
2038
|
this.#renderTemplate();
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
{
|
|
2052
|
-
country: this.#country,
|
|
2053
|
-
offer_sku: this.#offer?.sku_id
|
|
2054
|
-
},
|
|
2055
|
-
null,
|
|
2056
|
-
2
|
|
2057
|
-
)
|
|
2058
|
-
);
|
|
2059
|
-
const availabilityBlocked = await this.#checkAvailability();
|
|
2060
|
-
console.log(
|
|
2061
|
-
"[ApplePayButton] #checkAvailability result",
|
|
2062
|
-
JSON.stringify(
|
|
2063
|
-
{
|
|
2064
|
-
blocked: availabilityBlocked,
|
|
2065
|
-
country: this.#country,
|
|
2066
|
-
offer_sku: this.#offer?.sku_id
|
|
2067
|
-
},
|
|
2068
|
-
null,
|
|
2069
|
-
2
|
|
2070
|
-
)
|
|
2071
|
-
);
|
|
2072
|
-
if (availabilityBlocked) {
|
|
2073
|
-
console.log(
|
|
2074
|
-
"[ApplePayButton] #run early return after #checkAvailability",
|
|
2075
|
-
JSON.stringify(
|
|
2076
|
-
{
|
|
2077
|
-
country: this.#country,
|
|
2078
|
-
offer_sku: this.#offer?.sku_id
|
|
2079
|
-
},
|
|
2080
|
-
null,
|
|
2081
|
-
2
|
|
2082
|
-
)
|
|
2083
|
-
);
|
|
2084
|
-
return;
|
|
2085
|
-
}
|
|
2086
|
-
const offerMissing = this.#checkOffer();
|
|
2087
|
-
console.log(
|
|
2088
|
-
"[ApplePayButton] #checkOffer result",
|
|
2089
|
-
JSON.stringify(
|
|
2090
|
-
{
|
|
2091
|
-
blocked: offerMissing,
|
|
2092
|
-
country: this.#country,
|
|
2093
|
-
offer_sku: this.#offer?.sku_id
|
|
2094
|
-
},
|
|
2095
|
-
null,
|
|
2096
|
-
2
|
|
2097
|
-
)
|
|
2098
|
-
);
|
|
2099
|
-
if (offerMissing) {
|
|
2100
|
-
console.log(
|
|
2101
|
-
"[ApplePayButton] #run early return after #checkOffer",
|
|
2102
|
-
JSON.stringify(
|
|
2103
|
-
{
|
|
2104
|
-
country: this.#country,
|
|
2105
|
-
offer_sku: this.#offer?.sku_id
|
|
2106
|
-
},
|
|
2107
|
-
null,
|
|
2108
|
-
2
|
|
2109
|
-
)
|
|
2110
|
-
);
|
|
2111
|
-
return;
|
|
2112
|
-
}
|
|
2113
|
-
const sessionBlocked = await this.#checkSession();
|
|
2114
|
-
console.log(
|
|
2115
|
-
"[ApplePayButton] #checkSession result",
|
|
2116
|
-
JSON.stringify(
|
|
2117
|
-
{
|
|
2118
|
-
blocked: sessionBlocked,
|
|
2119
|
-
country: this.#country,
|
|
2120
|
-
offer_sku: this.#offer?.sku_id,
|
|
2121
|
-
session_user_type: this.#sessionData?.userType,
|
|
2122
|
-
session_logged_in: this.#sessionData?.loggedIn
|
|
2123
|
-
},
|
|
2124
|
-
null,
|
|
2125
|
-
2
|
|
2126
|
-
)
|
|
2127
|
-
);
|
|
2128
|
-
if (sessionBlocked) {
|
|
2129
|
-
console.log(
|
|
2130
|
-
"[ApplePayButton] #run early return after #checkSession",
|
|
2131
|
-
JSON.stringify(
|
|
2132
|
-
{
|
|
2133
|
-
country: this.#country,
|
|
2134
|
-
offer_sku: this.#offer?.sku_id
|
|
2135
|
-
},
|
|
2136
|
-
null,
|
|
2137
|
-
2
|
|
2138
|
-
)
|
|
2139
|
-
);
|
|
2140
|
-
return;
|
|
2141
|
-
}
|
|
2039
|
+
if (await this.#checkAvailability()) return;
|
|
2040
|
+
if (this.#checkOffer()) return;
|
|
2041
|
+
if (await this.#checkSession()) return;
|
|
2142
2042
|
this.#captureReturnUrl();
|
|
2143
|
-
console.log(
|
|
2144
|
-
"[ApplePayButton] #captureReturnUrl done",
|
|
2145
|
-
JSON.stringify(
|
|
2146
|
-
{
|
|
2147
|
-
return_url: this.#returnUrl
|
|
2148
|
-
},
|
|
2149
|
-
null,
|
|
2150
|
-
2
|
|
2151
|
-
)
|
|
2152
|
-
);
|
|
2153
2043
|
this.#computeBillingCountries();
|
|
2154
|
-
|
|
2155
|
-
"[ApplePayButton] #computeBillingCountries done",
|
|
2156
|
-
JSON.stringify(
|
|
2157
|
-
{
|
|
2158
|
-
supported_billing_countries: this.#supportedBillingCountries
|
|
2159
|
-
},
|
|
2160
|
-
null,
|
|
2161
|
-
2
|
|
2162
|
-
)
|
|
2163
|
-
);
|
|
2164
|
-
const optionsBlocked = await this.#fetchAndCacheOptions();
|
|
2165
|
-
console.log(
|
|
2166
|
-
"[ApplePayButton] #fetchAndCacheOptions result",
|
|
2167
|
-
JSON.stringify(
|
|
2168
|
-
{
|
|
2169
|
-
blocked: optionsBlocked,
|
|
2170
|
-
has_apple_pay_option: Boolean(this.#paymentOptions?.options?.apple_pay)
|
|
2171
|
-
},
|
|
2172
|
-
null,
|
|
2173
|
-
2
|
|
2174
|
-
)
|
|
2175
|
-
);
|
|
2176
|
-
if (optionsBlocked) {
|
|
2177
|
-
console.log(
|
|
2178
|
-
"[ApplePayButton] #run early return after #fetchAndCacheOptions",
|
|
2179
|
-
JSON.stringify(
|
|
2180
|
-
{
|
|
2181
|
-
country: this.#country,
|
|
2182
|
-
offer_sku: this.#offer?.sku_id
|
|
2183
|
-
},
|
|
2184
|
-
null,
|
|
2185
|
-
2
|
|
2186
|
-
)
|
|
2187
|
-
);
|
|
2188
|
-
return;
|
|
2189
|
-
}
|
|
2044
|
+
if (await this.#fetchAndCacheOptions()) return;
|
|
2190
2045
|
this.#finishLoading();
|
|
2191
|
-
|
|
2192
|
-
"[ApplePayButton] #finishLoading done",
|
|
2193
|
-
JSON.stringify(
|
|
2194
|
-
{
|
|
2195
|
-
country: this.#country,
|
|
2196
|
-
offer_sku: this.#offer?.sku_id
|
|
2197
|
-
},
|
|
2198
|
-
null,
|
|
2199
|
-
2
|
|
2200
|
-
)
|
|
2201
|
-
);
|
|
2202
|
-
} catch (error) {
|
|
2203
|
-
console.log(
|
|
2204
|
-
"[ApplePayButton] #run failed",
|
|
2205
|
-
JSON.stringify(
|
|
2206
|
-
{
|
|
2207
|
-
country: this.#country,
|
|
2208
|
-
offer_sku: this.#offer?.sku_id,
|
|
2209
|
-
error: error instanceof Error ? {
|
|
2210
|
-
name: error.name,
|
|
2211
|
-
message: error.message,
|
|
2212
|
-
stack: error.stack
|
|
2213
|
-
} : error
|
|
2214
|
-
},
|
|
2215
|
-
null,
|
|
2216
|
-
2
|
|
2217
|
-
)
|
|
2218
|
-
);
|
|
2046
|
+
} catch {
|
|
2219
2047
|
this.style.display = "none";
|
|
2220
2048
|
this.querySelector(SEL_CONTAINER)?.remove();
|
|
2221
2049
|
} finally {
|
|
2222
|
-
console.log(
|
|
2223
|
-
"[ApplePayButton] #run finally",
|
|
2224
|
-
JSON.stringify(
|
|
2225
|
-
{
|
|
2226
|
-
rendering: this.#rendering
|
|
2227
|
-
},
|
|
2228
|
-
null,
|
|
2229
|
-
2
|
|
2230
|
-
)
|
|
2231
|
-
);
|
|
2232
2050
|
this.#rendering = false;
|
|
2233
2051
|
}
|
|
2234
2052
|
}
|
|
@@ -1125,10 +1125,13 @@ var isAppleDeviceOrSafari = () => {
|
|
|
1125
1125
|
};
|
|
1126
1126
|
var bypassApplePayChecks = () => new URLSearchParams(window.location.search).get("BYPASS_APPLE_PAY_CHECKS") !== null;
|
|
1127
1127
|
var isApplePayAvailable = async () => {
|
|
1128
|
-
if (
|
|
1129
|
-
return
|
|
1128
|
+
if (bypassApplePayChecks()) {
|
|
1129
|
+
return true;
|
|
1130
1130
|
}
|
|
1131
1131
|
const applePaySession = window.ApplePaySession;
|
|
1132
|
+
if (!applePaySession && !isAppleDeviceOrSafari()) {
|
|
1133
|
+
return false;
|
|
1134
|
+
}
|
|
1132
1135
|
if (!applePaySession) {
|
|
1133
1136
|
return false;
|
|
1134
1137
|
}
|
|
@@ -2040,203 +2043,18 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2040
2043
|
// ─── Render pipeline ────────────────────────────────────────────────────────
|
|
2041
2044
|
async #run() {
|
|
2042
2045
|
try {
|
|
2043
|
-
console.log(
|
|
2044
|
-
"[ApplePayButton] #run start",
|
|
2045
|
-
JSON.stringify(
|
|
2046
|
-
{
|
|
2047
|
-
country: this.#country,
|
|
2048
|
-
offer_sku: this.#offer?.sku_id,
|
|
2049
|
-
entry_point: this.#entryPoint
|
|
2050
|
-
},
|
|
2051
|
-
null,
|
|
2052
|
-
2
|
|
2053
|
-
)
|
|
2054
|
-
);
|
|
2055
2046
|
this.#renderTemplate();
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
{
|
|
2060
|
-
country: this.#country,
|
|
2061
|
-
offer_sku: this.#offer?.sku_id
|
|
2062
|
-
},
|
|
2063
|
-
null,
|
|
2064
|
-
2
|
|
2065
|
-
)
|
|
2066
|
-
);
|
|
2067
|
-
const availabilityBlocked = await this.#checkAvailability();
|
|
2068
|
-
console.log(
|
|
2069
|
-
"[ApplePayButton] #checkAvailability result",
|
|
2070
|
-
JSON.stringify(
|
|
2071
|
-
{
|
|
2072
|
-
blocked: availabilityBlocked,
|
|
2073
|
-
country: this.#country,
|
|
2074
|
-
offer_sku: this.#offer?.sku_id
|
|
2075
|
-
},
|
|
2076
|
-
null,
|
|
2077
|
-
2
|
|
2078
|
-
)
|
|
2079
|
-
);
|
|
2080
|
-
if (availabilityBlocked) {
|
|
2081
|
-
console.log(
|
|
2082
|
-
"[ApplePayButton] #run early return after #checkAvailability",
|
|
2083
|
-
JSON.stringify(
|
|
2084
|
-
{
|
|
2085
|
-
country: this.#country,
|
|
2086
|
-
offer_sku: this.#offer?.sku_id
|
|
2087
|
-
},
|
|
2088
|
-
null,
|
|
2089
|
-
2
|
|
2090
|
-
)
|
|
2091
|
-
);
|
|
2092
|
-
return;
|
|
2093
|
-
}
|
|
2094
|
-
const offerMissing = this.#checkOffer();
|
|
2095
|
-
console.log(
|
|
2096
|
-
"[ApplePayButton] #checkOffer result",
|
|
2097
|
-
JSON.stringify(
|
|
2098
|
-
{
|
|
2099
|
-
blocked: offerMissing,
|
|
2100
|
-
country: this.#country,
|
|
2101
|
-
offer_sku: this.#offer?.sku_id
|
|
2102
|
-
},
|
|
2103
|
-
null,
|
|
2104
|
-
2
|
|
2105
|
-
)
|
|
2106
|
-
);
|
|
2107
|
-
if (offerMissing) {
|
|
2108
|
-
console.log(
|
|
2109
|
-
"[ApplePayButton] #run early return after #checkOffer",
|
|
2110
|
-
JSON.stringify(
|
|
2111
|
-
{
|
|
2112
|
-
country: this.#country,
|
|
2113
|
-
offer_sku: this.#offer?.sku_id
|
|
2114
|
-
},
|
|
2115
|
-
null,
|
|
2116
|
-
2
|
|
2117
|
-
)
|
|
2118
|
-
);
|
|
2119
|
-
return;
|
|
2120
|
-
}
|
|
2121
|
-
const sessionBlocked = await this.#checkSession();
|
|
2122
|
-
console.log(
|
|
2123
|
-
"[ApplePayButton] #checkSession result",
|
|
2124
|
-
JSON.stringify(
|
|
2125
|
-
{
|
|
2126
|
-
blocked: sessionBlocked,
|
|
2127
|
-
country: this.#country,
|
|
2128
|
-
offer_sku: this.#offer?.sku_id,
|
|
2129
|
-
session_user_type: this.#sessionData?.userType,
|
|
2130
|
-
session_logged_in: this.#sessionData?.loggedIn
|
|
2131
|
-
},
|
|
2132
|
-
null,
|
|
2133
|
-
2
|
|
2134
|
-
)
|
|
2135
|
-
);
|
|
2136
|
-
if (sessionBlocked) {
|
|
2137
|
-
console.log(
|
|
2138
|
-
"[ApplePayButton] #run early return after #checkSession",
|
|
2139
|
-
JSON.stringify(
|
|
2140
|
-
{
|
|
2141
|
-
country: this.#country,
|
|
2142
|
-
offer_sku: this.#offer?.sku_id
|
|
2143
|
-
},
|
|
2144
|
-
null,
|
|
2145
|
-
2
|
|
2146
|
-
)
|
|
2147
|
-
);
|
|
2148
|
-
return;
|
|
2149
|
-
}
|
|
2047
|
+
if (await this.#checkAvailability()) return;
|
|
2048
|
+
if (this.#checkOffer()) return;
|
|
2049
|
+
if (await this.#checkSession()) return;
|
|
2150
2050
|
this.#captureReturnUrl();
|
|
2151
|
-
console.log(
|
|
2152
|
-
"[ApplePayButton] #captureReturnUrl done",
|
|
2153
|
-
JSON.stringify(
|
|
2154
|
-
{
|
|
2155
|
-
return_url: this.#returnUrl
|
|
2156
|
-
},
|
|
2157
|
-
null,
|
|
2158
|
-
2
|
|
2159
|
-
)
|
|
2160
|
-
);
|
|
2161
2051
|
this.#computeBillingCountries();
|
|
2162
|
-
|
|
2163
|
-
"[ApplePayButton] #computeBillingCountries done",
|
|
2164
|
-
JSON.stringify(
|
|
2165
|
-
{
|
|
2166
|
-
supported_billing_countries: this.#supportedBillingCountries
|
|
2167
|
-
},
|
|
2168
|
-
null,
|
|
2169
|
-
2
|
|
2170
|
-
)
|
|
2171
|
-
);
|
|
2172
|
-
const optionsBlocked = await this.#fetchAndCacheOptions();
|
|
2173
|
-
console.log(
|
|
2174
|
-
"[ApplePayButton] #fetchAndCacheOptions result",
|
|
2175
|
-
JSON.stringify(
|
|
2176
|
-
{
|
|
2177
|
-
blocked: optionsBlocked,
|
|
2178
|
-
has_apple_pay_option: Boolean(this.#paymentOptions?.options?.apple_pay)
|
|
2179
|
-
},
|
|
2180
|
-
null,
|
|
2181
|
-
2
|
|
2182
|
-
)
|
|
2183
|
-
);
|
|
2184
|
-
if (optionsBlocked) {
|
|
2185
|
-
console.log(
|
|
2186
|
-
"[ApplePayButton] #run early return after #fetchAndCacheOptions",
|
|
2187
|
-
JSON.stringify(
|
|
2188
|
-
{
|
|
2189
|
-
country: this.#country,
|
|
2190
|
-
offer_sku: this.#offer?.sku_id
|
|
2191
|
-
},
|
|
2192
|
-
null,
|
|
2193
|
-
2
|
|
2194
|
-
)
|
|
2195
|
-
);
|
|
2196
|
-
return;
|
|
2197
|
-
}
|
|
2052
|
+
if (await this.#fetchAndCacheOptions()) return;
|
|
2198
2053
|
this.#finishLoading();
|
|
2199
|
-
|
|
2200
|
-
"[ApplePayButton] #finishLoading done",
|
|
2201
|
-
JSON.stringify(
|
|
2202
|
-
{
|
|
2203
|
-
country: this.#country,
|
|
2204
|
-
offer_sku: this.#offer?.sku_id
|
|
2205
|
-
},
|
|
2206
|
-
null,
|
|
2207
|
-
2
|
|
2208
|
-
)
|
|
2209
|
-
);
|
|
2210
|
-
} catch (error) {
|
|
2211
|
-
console.log(
|
|
2212
|
-
"[ApplePayButton] #run failed",
|
|
2213
|
-
JSON.stringify(
|
|
2214
|
-
{
|
|
2215
|
-
country: this.#country,
|
|
2216
|
-
offer_sku: this.#offer?.sku_id,
|
|
2217
|
-
error: error instanceof Error ? {
|
|
2218
|
-
name: error.name,
|
|
2219
|
-
message: error.message,
|
|
2220
|
-
stack: error.stack
|
|
2221
|
-
} : error
|
|
2222
|
-
},
|
|
2223
|
-
null,
|
|
2224
|
-
2
|
|
2225
|
-
)
|
|
2226
|
-
);
|
|
2054
|
+
} catch {
|
|
2227
2055
|
this.style.display = "none";
|
|
2228
2056
|
this.querySelector(SEL_CONTAINER)?.remove();
|
|
2229
2057
|
} finally {
|
|
2230
|
-
console.log(
|
|
2231
|
-
"[ApplePayButton] #run finally",
|
|
2232
|
-
JSON.stringify(
|
|
2233
|
-
{
|
|
2234
|
-
rendering: this.#rendering
|
|
2235
|
-
},
|
|
2236
|
-
null,
|
|
2237
|
-
2
|
|
2238
|
-
)
|
|
2239
|
-
);
|
|
2240
2058
|
this.#rendering = false;
|
|
2241
2059
|
}
|
|
2242
2060
|
}
|
|
@@ -1117,10 +1117,13 @@ var isAppleDeviceOrSafari = () => {
|
|
|
1117
1117
|
};
|
|
1118
1118
|
var bypassApplePayChecks = () => new URLSearchParams(window.location.search).get("BYPASS_APPLE_PAY_CHECKS") !== null;
|
|
1119
1119
|
var isApplePayAvailable = async () => {
|
|
1120
|
-
if (
|
|
1121
|
-
return
|
|
1120
|
+
if (bypassApplePayChecks()) {
|
|
1121
|
+
return true;
|
|
1122
1122
|
}
|
|
1123
1123
|
const applePaySession = window.ApplePaySession;
|
|
1124
|
+
if (!applePaySession && !isAppleDeviceOrSafari()) {
|
|
1125
|
+
return false;
|
|
1126
|
+
}
|
|
1124
1127
|
if (!applePaySession) {
|
|
1125
1128
|
return false;
|
|
1126
1129
|
}
|
|
@@ -2032,203 +2035,18 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2032
2035
|
// ─── Render pipeline ────────────────────────────────────────────────────────
|
|
2033
2036
|
async #run() {
|
|
2034
2037
|
try {
|
|
2035
|
-
console.log(
|
|
2036
|
-
"[ApplePayButton] #run start",
|
|
2037
|
-
JSON.stringify(
|
|
2038
|
-
{
|
|
2039
|
-
country: this.#country,
|
|
2040
|
-
offer_sku: this.#offer?.sku_id,
|
|
2041
|
-
entry_point: this.#entryPoint
|
|
2042
|
-
},
|
|
2043
|
-
null,
|
|
2044
|
-
2
|
|
2045
|
-
)
|
|
2046
|
-
);
|
|
2047
2038
|
this.#renderTemplate();
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
{
|
|
2052
|
-
country: this.#country,
|
|
2053
|
-
offer_sku: this.#offer?.sku_id
|
|
2054
|
-
},
|
|
2055
|
-
null,
|
|
2056
|
-
2
|
|
2057
|
-
)
|
|
2058
|
-
);
|
|
2059
|
-
const availabilityBlocked = await this.#checkAvailability();
|
|
2060
|
-
console.log(
|
|
2061
|
-
"[ApplePayButton] #checkAvailability result",
|
|
2062
|
-
JSON.stringify(
|
|
2063
|
-
{
|
|
2064
|
-
blocked: availabilityBlocked,
|
|
2065
|
-
country: this.#country,
|
|
2066
|
-
offer_sku: this.#offer?.sku_id
|
|
2067
|
-
},
|
|
2068
|
-
null,
|
|
2069
|
-
2
|
|
2070
|
-
)
|
|
2071
|
-
);
|
|
2072
|
-
if (availabilityBlocked) {
|
|
2073
|
-
console.log(
|
|
2074
|
-
"[ApplePayButton] #run early return after #checkAvailability",
|
|
2075
|
-
JSON.stringify(
|
|
2076
|
-
{
|
|
2077
|
-
country: this.#country,
|
|
2078
|
-
offer_sku: this.#offer?.sku_id
|
|
2079
|
-
},
|
|
2080
|
-
null,
|
|
2081
|
-
2
|
|
2082
|
-
)
|
|
2083
|
-
);
|
|
2084
|
-
return;
|
|
2085
|
-
}
|
|
2086
|
-
const offerMissing = this.#checkOffer();
|
|
2087
|
-
console.log(
|
|
2088
|
-
"[ApplePayButton] #checkOffer result",
|
|
2089
|
-
JSON.stringify(
|
|
2090
|
-
{
|
|
2091
|
-
blocked: offerMissing,
|
|
2092
|
-
country: this.#country,
|
|
2093
|
-
offer_sku: this.#offer?.sku_id
|
|
2094
|
-
},
|
|
2095
|
-
null,
|
|
2096
|
-
2
|
|
2097
|
-
)
|
|
2098
|
-
);
|
|
2099
|
-
if (offerMissing) {
|
|
2100
|
-
console.log(
|
|
2101
|
-
"[ApplePayButton] #run early return after #checkOffer",
|
|
2102
|
-
JSON.stringify(
|
|
2103
|
-
{
|
|
2104
|
-
country: this.#country,
|
|
2105
|
-
offer_sku: this.#offer?.sku_id
|
|
2106
|
-
},
|
|
2107
|
-
null,
|
|
2108
|
-
2
|
|
2109
|
-
)
|
|
2110
|
-
);
|
|
2111
|
-
return;
|
|
2112
|
-
}
|
|
2113
|
-
const sessionBlocked = await this.#checkSession();
|
|
2114
|
-
console.log(
|
|
2115
|
-
"[ApplePayButton] #checkSession result",
|
|
2116
|
-
JSON.stringify(
|
|
2117
|
-
{
|
|
2118
|
-
blocked: sessionBlocked,
|
|
2119
|
-
country: this.#country,
|
|
2120
|
-
offer_sku: this.#offer?.sku_id,
|
|
2121
|
-
session_user_type: this.#sessionData?.userType,
|
|
2122
|
-
session_logged_in: this.#sessionData?.loggedIn
|
|
2123
|
-
},
|
|
2124
|
-
null,
|
|
2125
|
-
2
|
|
2126
|
-
)
|
|
2127
|
-
);
|
|
2128
|
-
if (sessionBlocked) {
|
|
2129
|
-
console.log(
|
|
2130
|
-
"[ApplePayButton] #run early return after #checkSession",
|
|
2131
|
-
JSON.stringify(
|
|
2132
|
-
{
|
|
2133
|
-
country: this.#country,
|
|
2134
|
-
offer_sku: this.#offer?.sku_id
|
|
2135
|
-
},
|
|
2136
|
-
null,
|
|
2137
|
-
2
|
|
2138
|
-
)
|
|
2139
|
-
);
|
|
2140
|
-
return;
|
|
2141
|
-
}
|
|
2039
|
+
if (await this.#checkAvailability()) return;
|
|
2040
|
+
if (this.#checkOffer()) return;
|
|
2041
|
+
if (await this.#checkSession()) return;
|
|
2142
2042
|
this.#captureReturnUrl();
|
|
2143
|
-
console.log(
|
|
2144
|
-
"[ApplePayButton] #captureReturnUrl done",
|
|
2145
|
-
JSON.stringify(
|
|
2146
|
-
{
|
|
2147
|
-
return_url: this.#returnUrl
|
|
2148
|
-
},
|
|
2149
|
-
null,
|
|
2150
|
-
2
|
|
2151
|
-
)
|
|
2152
|
-
);
|
|
2153
2043
|
this.#computeBillingCountries();
|
|
2154
|
-
|
|
2155
|
-
"[ApplePayButton] #computeBillingCountries done",
|
|
2156
|
-
JSON.stringify(
|
|
2157
|
-
{
|
|
2158
|
-
supported_billing_countries: this.#supportedBillingCountries
|
|
2159
|
-
},
|
|
2160
|
-
null,
|
|
2161
|
-
2
|
|
2162
|
-
)
|
|
2163
|
-
);
|
|
2164
|
-
const optionsBlocked = await this.#fetchAndCacheOptions();
|
|
2165
|
-
console.log(
|
|
2166
|
-
"[ApplePayButton] #fetchAndCacheOptions result",
|
|
2167
|
-
JSON.stringify(
|
|
2168
|
-
{
|
|
2169
|
-
blocked: optionsBlocked,
|
|
2170
|
-
has_apple_pay_option: Boolean(this.#paymentOptions?.options?.apple_pay)
|
|
2171
|
-
},
|
|
2172
|
-
null,
|
|
2173
|
-
2
|
|
2174
|
-
)
|
|
2175
|
-
);
|
|
2176
|
-
if (optionsBlocked) {
|
|
2177
|
-
console.log(
|
|
2178
|
-
"[ApplePayButton] #run early return after #fetchAndCacheOptions",
|
|
2179
|
-
JSON.stringify(
|
|
2180
|
-
{
|
|
2181
|
-
country: this.#country,
|
|
2182
|
-
offer_sku: this.#offer?.sku_id
|
|
2183
|
-
},
|
|
2184
|
-
null,
|
|
2185
|
-
2
|
|
2186
|
-
)
|
|
2187
|
-
);
|
|
2188
|
-
return;
|
|
2189
|
-
}
|
|
2044
|
+
if (await this.#fetchAndCacheOptions()) return;
|
|
2190
2045
|
this.#finishLoading();
|
|
2191
|
-
|
|
2192
|
-
"[ApplePayButton] #finishLoading done",
|
|
2193
|
-
JSON.stringify(
|
|
2194
|
-
{
|
|
2195
|
-
country: this.#country,
|
|
2196
|
-
offer_sku: this.#offer?.sku_id
|
|
2197
|
-
},
|
|
2198
|
-
null,
|
|
2199
|
-
2
|
|
2200
|
-
)
|
|
2201
|
-
);
|
|
2202
|
-
} catch (error) {
|
|
2203
|
-
console.log(
|
|
2204
|
-
"[ApplePayButton] #run failed",
|
|
2205
|
-
JSON.stringify(
|
|
2206
|
-
{
|
|
2207
|
-
country: this.#country,
|
|
2208
|
-
offer_sku: this.#offer?.sku_id,
|
|
2209
|
-
error: error instanceof Error ? {
|
|
2210
|
-
name: error.name,
|
|
2211
|
-
message: error.message,
|
|
2212
|
-
stack: error.stack
|
|
2213
|
-
} : error
|
|
2214
|
-
},
|
|
2215
|
-
null,
|
|
2216
|
-
2
|
|
2217
|
-
)
|
|
2218
|
-
);
|
|
2046
|
+
} catch {
|
|
2219
2047
|
this.style.display = "none";
|
|
2220
2048
|
this.querySelector(SEL_CONTAINER)?.remove();
|
|
2221
2049
|
} finally {
|
|
2222
|
-
console.log(
|
|
2223
|
-
"[ApplePayButton] #run finally",
|
|
2224
|
-
JSON.stringify(
|
|
2225
|
-
{
|
|
2226
|
-
rendering: this.#rendering
|
|
2227
|
-
},
|
|
2228
|
-
null,
|
|
2229
|
-
2
|
|
2230
|
-
)
|
|
2231
|
-
);
|
|
2232
2050
|
this.#rendering = false;
|
|
2233
2051
|
}
|
|
2234
2052
|
}
|
|
@@ -10,10 +10,13 @@ var isAppleDeviceOrSafari = () => {
|
|
|
10
10
|
};
|
|
11
11
|
var bypassApplePayChecks = () => new URLSearchParams(window.location.search).get("BYPASS_APPLE_PAY_CHECKS") !== null;
|
|
12
12
|
var isApplePayAvailable = async () => {
|
|
13
|
-
if (
|
|
14
|
-
return
|
|
13
|
+
if (bypassApplePayChecks()) {
|
|
14
|
+
return true;
|
|
15
15
|
}
|
|
16
16
|
const applePaySession = window.ApplePaySession;
|
|
17
|
+
if (!applePaySession && !isAppleDeviceOrSafari()) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
17
20
|
if (!applePaySession) {
|
|
18
21
|
return false;
|
|
19
22
|
}
|
package/dist/src/index.js
CHANGED
|
@@ -1122,10 +1122,13 @@ var isAppleDeviceOrSafari = () => {
|
|
|
1122
1122
|
};
|
|
1123
1123
|
var bypassApplePayChecks = () => new URLSearchParams(window.location.search).get("BYPASS_APPLE_PAY_CHECKS") !== null;
|
|
1124
1124
|
var isApplePayAvailable = async () => {
|
|
1125
|
-
if (
|
|
1126
|
-
return
|
|
1125
|
+
if (bypassApplePayChecks()) {
|
|
1126
|
+
return true;
|
|
1127
1127
|
}
|
|
1128
1128
|
const applePaySession = window.ApplePaySession;
|
|
1129
|
+
if (!applePaySession && !isAppleDeviceOrSafari()) {
|
|
1130
|
+
return false;
|
|
1131
|
+
}
|
|
1129
1132
|
if (!applePaySession) {
|
|
1130
1133
|
return false;
|
|
1131
1134
|
}
|
|
@@ -2037,203 +2040,18 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2037
2040
|
// ─── Render pipeline ────────────────────────────────────────────────────────
|
|
2038
2041
|
async #run() {
|
|
2039
2042
|
try {
|
|
2040
|
-
console.log(
|
|
2041
|
-
"[ApplePayButton] #run start",
|
|
2042
|
-
JSON.stringify(
|
|
2043
|
-
{
|
|
2044
|
-
country: this.#country,
|
|
2045
|
-
offer_sku: this.#offer?.sku_id,
|
|
2046
|
-
entry_point: this.#entryPoint
|
|
2047
|
-
},
|
|
2048
|
-
null,
|
|
2049
|
-
2
|
|
2050
|
-
)
|
|
2051
|
-
);
|
|
2052
2043
|
this.#renderTemplate();
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
{
|
|
2057
|
-
country: this.#country,
|
|
2058
|
-
offer_sku: this.#offer?.sku_id
|
|
2059
|
-
},
|
|
2060
|
-
null,
|
|
2061
|
-
2
|
|
2062
|
-
)
|
|
2063
|
-
);
|
|
2064
|
-
const availabilityBlocked = await this.#checkAvailability();
|
|
2065
|
-
console.log(
|
|
2066
|
-
"[ApplePayButton] #checkAvailability result",
|
|
2067
|
-
JSON.stringify(
|
|
2068
|
-
{
|
|
2069
|
-
blocked: availabilityBlocked,
|
|
2070
|
-
country: this.#country,
|
|
2071
|
-
offer_sku: this.#offer?.sku_id
|
|
2072
|
-
},
|
|
2073
|
-
null,
|
|
2074
|
-
2
|
|
2075
|
-
)
|
|
2076
|
-
);
|
|
2077
|
-
if (availabilityBlocked) {
|
|
2078
|
-
console.log(
|
|
2079
|
-
"[ApplePayButton] #run early return after #checkAvailability",
|
|
2080
|
-
JSON.stringify(
|
|
2081
|
-
{
|
|
2082
|
-
country: this.#country,
|
|
2083
|
-
offer_sku: this.#offer?.sku_id
|
|
2084
|
-
},
|
|
2085
|
-
null,
|
|
2086
|
-
2
|
|
2087
|
-
)
|
|
2088
|
-
);
|
|
2089
|
-
return;
|
|
2090
|
-
}
|
|
2091
|
-
const offerMissing = this.#checkOffer();
|
|
2092
|
-
console.log(
|
|
2093
|
-
"[ApplePayButton] #checkOffer result",
|
|
2094
|
-
JSON.stringify(
|
|
2095
|
-
{
|
|
2096
|
-
blocked: offerMissing,
|
|
2097
|
-
country: this.#country,
|
|
2098
|
-
offer_sku: this.#offer?.sku_id
|
|
2099
|
-
},
|
|
2100
|
-
null,
|
|
2101
|
-
2
|
|
2102
|
-
)
|
|
2103
|
-
);
|
|
2104
|
-
if (offerMissing) {
|
|
2105
|
-
console.log(
|
|
2106
|
-
"[ApplePayButton] #run early return after #checkOffer",
|
|
2107
|
-
JSON.stringify(
|
|
2108
|
-
{
|
|
2109
|
-
country: this.#country,
|
|
2110
|
-
offer_sku: this.#offer?.sku_id
|
|
2111
|
-
},
|
|
2112
|
-
null,
|
|
2113
|
-
2
|
|
2114
|
-
)
|
|
2115
|
-
);
|
|
2116
|
-
return;
|
|
2117
|
-
}
|
|
2118
|
-
const sessionBlocked = await this.#checkSession();
|
|
2119
|
-
console.log(
|
|
2120
|
-
"[ApplePayButton] #checkSession result",
|
|
2121
|
-
JSON.stringify(
|
|
2122
|
-
{
|
|
2123
|
-
blocked: sessionBlocked,
|
|
2124
|
-
country: this.#country,
|
|
2125
|
-
offer_sku: this.#offer?.sku_id,
|
|
2126
|
-
session_user_type: this.#sessionData?.userType,
|
|
2127
|
-
session_logged_in: this.#sessionData?.loggedIn
|
|
2128
|
-
},
|
|
2129
|
-
null,
|
|
2130
|
-
2
|
|
2131
|
-
)
|
|
2132
|
-
);
|
|
2133
|
-
if (sessionBlocked) {
|
|
2134
|
-
console.log(
|
|
2135
|
-
"[ApplePayButton] #run early return after #checkSession",
|
|
2136
|
-
JSON.stringify(
|
|
2137
|
-
{
|
|
2138
|
-
country: this.#country,
|
|
2139
|
-
offer_sku: this.#offer?.sku_id
|
|
2140
|
-
},
|
|
2141
|
-
null,
|
|
2142
|
-
2
|
|
2143
|
-
)
|
|
2144
|
-
);
|
|
2145
|
-
return;
|
|
2146
|
-
}
|
|
2044
|
+
if (await this.#checkAvailability()) return;
|
|
2045
|
+
if (this.#checkOffer()) return;
|
|
2046
|
+
if (await this.#checkSession()) return;
|
|
2147
2047
|
this.#captureReturnUrl();
|
|
2148
|
-
console.log(
|
|
2149
|
-
"[ApplePayButton] #captureReturnUrl done",
|
|
2150
|
-
JSON.stringify(
|
|
2151
|
-
{
|
|
2152
|
-
return_url: this.#returnUrl
|
|
2153
|
-
},
|
|
2154
|
-
null,
|
|
2155
|
-
2
|
|
2156
|
-
)
|
|
2157
|
-
);
|
|
2158
2048
|
this.#computeBillingCountries();
|
|
2159
|
-
|
|
2160
|
-
"[ApplePayButton] #computeBillingCountries done",
|
|
2161
|
-
JSON.stringify(
|
|
2162
|
-
{
|
|
2163
|
-
supported_billing_countries: this.#supportedBillingCountries
|
|
2164
|
-
},
|
|
2165
|
-
null,
|
|
2166
|
-
2
|
|
2167
|
-
)
|
|
2168
|
-
);
|
|
2169
|
-
const optionsBlocked = await this.#fetchAndCacheOptions();
|
|
2170
|
-
console.log(
|
|
2171
|
-
"[ApplePayButton] #fetchAndCacheOptions result",
|
|
2172
|
-
JSON.stringify(
|
|
2173
|
-
{
|
|
2174
|
-
blocked: optionsBlocked,
|
|
2175
|
-
has_apple_pay_option: Boolean(this.#paymentOptions?.options?.apple_pay)
|
|
2176
|
-
},
|
|
2177
|
-
null,
|
|
2178
|
-
2
|
|
2179
|
-
)
|
|
2180
|
-
);
|
|
2181
|
-
if (optionsBlocked) {
|
|
2182
|
-
console.log(
|
|
2183
|
-
"[ApplePayButton] #run early return after #fetchAndCacheOptions",
|
|
2184
|
-
JSON.stringify(
|
|
2185
|
-
{
|
|
2186
|
-
country: this.#country,
|
|
2187
|
-
offer_sku: this.#offer?.sku_id
|
|
2188
|
-
},
|
|
2189
|
-
null,
|
|
2190
|
-
2
|
|
2191
|
-
)
|
|
2192
|
-
);
|
|
2193
|
-
return;
|
|
2194
|
-
}
|
|
2049
|
+
if (await this.#fetchAndCacheOptions()) return;
|
|
2195
2050
|
this.#finishLoading();
|
|
2196
|
-
|
|
2197
|
-
"[ApplePayButton] #finishLoading done",
|
|
2198
|
-
JSON.stringify(
|
|
2199
|
-
{
|
|
2200
|
-
country: this.#country,
|
|
2201
|
-
offer_sku: this.#offer?.sku_id
|
|
2202
|
-
},
|
|
2203
|
-
null,
|
|
2204
|
-
2
|
|
2205
|
-
)
|
|
2206
|
-
);
|
|
2207
|
-
} catch (error) {
|
|
2208
|
-
console.log(
|
|
2209
|
-
"[ApplePayButton] #run failed",
|
|
2210
|
-
JSON.stringify(
|
|
2211
|
-
{
|
|
2212
|
-
country: this.#country,
|
|
2213
|
-
offer_sku: this.#offer?.sku_id,
|
|
2214
|
-
error: error instanceof Error ? {
|
|
2215
|
-
name: error.name,
|
|
2216
|
-
message: error.message,
|
|
2217
|
-
stack: error.stack
|
|
2218
|
-
} : error
|
|
2219
|
-
},
|
|
2220
|
-
null,
|
|
2221
|
-
2
|
|
2222
|
-
)
|
|
2223
|
-
);
|
|
2051
|
+
} catch {
|
|
2224
2052
|
this.style.display = "none";
|
|
2225
2053
|
this.querySelector(SEL_CONTAINER)?.remove();
|
|
2226
2054
|
} finally {
|
|
2227
|
-
console.log(
|
|
2228
|
-
"[ApplePayButton] #run finally",
|
|
2229
|
-
JSON.stringify(
|
|
2230
|
-
{
|
|
2231
|
-
rendering: this.#rendering
|
|
2232
|
-
},
|
|
2233
|
-
null,
|
|
2234
|
-
2
|
|
2235
|
-
)
|
|
2236
|
-
);
|
|
2237
2055
|
this.#rendering = false;
|
|
2238
2056
|
}
|
|
2239
2057
|
}
|
package/package.json
CHANGED