@flopay/shared 1.2.7 → 1.3.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.cjs CHANGED
@@ -44,6 +44,7 @@ __export(index_exports, {
44
44
  DEFAULT_CURRENCY: () => DEFAULT_CURRENCY,
45
45
  ELEMENT_TYPES: () => ELEMENT_TYPES,
46
46
  FLAT_APPEARANCE: () => FLAT_APPEARANCE,
47
+ FLO_SDK_VERSION_HEADER: () => FLO_SDK_VERSION_HEADER,
47
48
  FloPayError: () => FloPayError,
48
49
  GLASS_DARK_APPEARANCE: () => GLASS_DARK_APPEARANCE,
49
50
  GLASS_LIGHT_APPEARANCE: () => GLASS_LIGHT_APPEARANCE,
@@ -82,6 +83,7 @@ __export(index_exports, {
82
83
  hasVendoredStripeMethodLogo: () => hasVendoredStripeMethodLogo,
83
84
  isAVSEnabled: () => isAVSEnabled,
84
85
  isAVSFieldVisible: () => isAVSFieldVisible,
86
+ isSetupIntentClientSecret: () => isSetupIntentClientSecret,
85
87
  isValidPublishableKey: () => isValidPublishableKey,
86
88
  isValidSecretKey: () => isValidSecretKey,
87
89
  needsStripeMethodExplicitConfirm: () => needsStripeMethodExplicitConfirm,
@@ -181,7 +183,8 @@ var PAYMENT_METHOD_LOGOS = {
181
183
  };
182
184
 
183
185
  // src/constants.ts
184
- var SDK_VERSION = "1.2.7";
186
+ var SDK_VERSION = "1.3.0";
187
+ var FLO_SDK_VERSION_HEADER = "x-flo-sdk-version";
185
188
  var BILLING_API_URL_STAGING = "https://api.stage.flopay.com";
186
189
  var BILLING_API_URL_PRODUCTION = "https://api.flopay.com";
187
190
  var DEFAULT_API_BASE_URL = BILLING_API_URL_STAGING;
@@ -863,6 +866,9 @@ function stripeExpressMethodToOptionKey(method) {
863
866
  function buildPlaceholderMark(glyph, discColor, glyphColor) {
864
867
  return `<svg viewBox="0 0 22 22" xmlns="http://www.w3.org/2000/svg" role="img" aria-hidden="true"><circle cx="11" cy="11" r="11" fill="${discColor}"/><text x="11" y="15.5" text-anchor="middle" font-size="13" font-weight="700" font-family="-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif" fill="${glyphColor}">${glyph}</text></svg>`;
865
868
  }
869
+ function buildBankMark(discColor, glyphColor) {
870
+ return `<svg viewBox="0 0 22 22" xmlns="http://www.w3.org/2000/svg" role="img" aria-hidden="true"><circle cx="11" cy="11" r="11" fill="${discColor}"/><g fill="${glyphColor}"><path d="M11 4 L17.5 8 L4.5 8 Z"/><rect x="5" y="8.4" width="12" height="1.2" rx="0.3"/><rect x="5.9" y="10" width="1.5" height="5"/><rect x="8.55" y="10" width="1.5" height="5"/><rect x="11.95" y="10" width="1.5" height="5"/><rect x="14.6" y="10" width="1.5" height="5"/><rect x="4.6" y="15.4" width="12.8" height="1.5" rx="0.3"/></g></svg>`;
871
+ }
866
872
  var SEPA_COUNTRIES = [
867
873
  "AT",
868
874
  "BE",
@@ -903,6 +909,7 @@ var SEPA_COUNTRIES = [
903
909
  "VA"
904
910
  // non-EEA SEPA participants
905
911
  ];
912
+ var BANK_TRANSFER_COUNTRIES = [...SEPA_COUNTRIES, "JP", "MX", "US"];
906
913
  var STRIPE_METHOD_MATRIX = {
907
914
  // ─── Express wallets ────────────────────────────────────────────────────
908
915
  apple_pay: {
@@ -935,14 +942,42 @@ var STRIPE_METHOD_MATRIX = {
935
942
  express: true,
936
943
  needsExplicitConfirm: false
937
944
  },
945
+ // ─── Klarna: PaymentElement tile, explicit confirm ─────────────────────
946
+ // Klarna renders as a PaymentElement tile (NOT express) so it always appears
947
+ // when the backend includes it in `enabledPaymentMethods`. Stripe's
948
+ // ExpressCheckoutElement only paints a Klarna button in eligible *real*
949
+ // browsers (never headless), which made it effectively invisible and looked
950
+ // like an SDK-level disable — as a tile it's purely backend-driven. Klarna
951
+ // may redirect during confirm, but it still surfaces a deliberate "Pay with
952
+ // Klarna" step: it omits `needsExplicitConfirm: false`, so the default
953
+ // `needsStripeMethodExplicitConfirm(...) === true` applies — unlike the
954
+ // auto-confirm APMs below.
938
955
  klarna: {
939
956
  displayName: "Klarna",
940
957
  currencies: ["usd", "eur", "gbp", "aud", "nzd", "cad", "chf", "sek", "nok", "dkk", "pln", "czk", "ron"],
941
958
  amounts: { usd: { min: 100 }, eur: { min: 100 }, gbp: { min: 100 } },
942
- express: true,
943
- needsExplicitConfirm: false
959
+ // Default (explicit "Pay with Klarna" button) — Klarna's PaymentElement can
960
+ // collect inline data and isn't a pure redirect-only method, so surface a
961
+ // deliberate confirm rather than auto-submitting on tile click.
962
+ theme: {
963
+ light: {
964
+ backgroundColor: "#FFB3C7",
965
+ textColor: "#0A0B09",
966
+ borderColor: "#FFB3C7",
967
+ logoSvg: buildPlaceholderMark("K", "#0A0B09", "#FFB3C7")
968
+ },
969
+ dark: {
970
+ backgroundColor: "#FFB3C7",
971
+ textColor: "#0A0B09",
972
+ borderColor: "#FFB3C7",
973
+ logoSvg: buildPlaceholderMark("K", "#0A0B09", "#FFB3C7")
974
+ }
975
+ }
944
976
  },
945
977
  // ─── PaymentElement APMs: auto-confirm (redirect-only, no Pay button) ───
978
+ // Affirm and Cash App Pay are pure redirect/handoff methods with no inline
979
+ // inputs, so they auto-submit on tile click (`needsExplicitConfirm: false`).
980
+ //
946
981
  // Affirm currently rejects on non-USD currencies via
947
982
  // /v1/elements/sessions, hence the narrow currency list. Below $35.00 USD
948
983
  // it returns `amount_too_small` and blanks out the whole accordion, hence
@@ -972,6 +1007,10 @@ var STRIPE_METHOD_MATRIX = {
972
1007
  displayName: "Cash App Pay",
973
1008
  currencies: ["usd"],
974
1009
  countries: ["US"],
1010
+ // Cash App Pay cannot process a $0 (or sub-$0.50) charge — Stripe rejects
1011
+ // `amount_too_small`. Range per Stripe: USD 0.50 – 999,999.99. Keeps a
1012
+ // free-trial ($0 today) cart from surfacing a Cash App button.
1013
+ amounts: { usd: { min: 50, max: 99999999 } },
975
1014
  needsExplicitConfirm: false,
976
1015
  theme: {
977
1016
  light: {
@@ -1003,11 +1042,28 @@ var STRIPE_METHOD_MATRIX = {
1003
1042
  gbp: { min: 100, max: 12e4 },
1004
1043
  aud: { min: 100, max: 2e5 },
1005
1044
  nzd: { min: 100, max: 2e5 }
1045
+ },
1046
+ // Afterpay's brand mint (#B2FCE4) with black wordmark/icon — the signature
1047
+ // palette from afterpay.com's brand system.
1048
+ theme: {
1049
+ light: {
1050
+ backgroundColor: "#B2FCE4",
1051
+ textColor: "#0A0B09",
1052
+ borderColor: "#B2FCE4",
1053
+ logoSvg: buildPlaceholderMark("A", "#0A0B09", "#B2FCE4")
1054
+ },
1055
+ dark: {
1056
+ backgroundColor: "#B2FCE4",
1057
+ textColor: "#0A0B09",
1058
+ borderColor: "#B2FCE4",
1059
+ logoSvg: buildPlaceholderMark("A", "#0A0B09", "#B2FCE4")
1060
+ }
1006
1061
  }
1007
1062
  },
1008
1063
  alipay: {
1009
1064
  displayName: "Alipay",
1010
- currencies: ["cny", "aud", "cad", "eur", "gbp", "hkd", "jpy", "myr", "nzd", "sgd", "usd"],
1065
+ // Presentment currencies only Alipay is offered to USD / CNY carts.
1066
+ currencies: ["usd", "cny"],
1011
1067
  theme: {
1012
1068
  light: {
1013
1069
  backgroundColor: "#1677FF",
@@ -1044,6 +1100,25 @@ var STRIPE_METHOD_MATRIX = {
1044
1100
  }
1045
1101
  }
1046
1102
  },
1103
+ bizum: {
1104
+ displayName: "Bizum",
1105
+ currencies: ["eur"],
1106
+ countries: ["ES"],
1107
+ theme: {
1108
+ light: {
1109
+ backgroundColor: "#00BFB3",
1110
+ textColor: "#FFFFFF",
1111
+ borderColor: "#00BFB3",
1112
+ logoSvg: buildPlaceholderMark("B", "#FFFFFF", "#00BFB3")
1113
+ },
1114
+ dark: {
1115
+ backgroundColor: "#00BFB3",
1116
+ textColor: "#FFFFFF",
1117
+ borderColor: "#00BFB3",
1118
+ logoSvg: buildPlaceholderMark("B", "#FFFFFF", "#00BFB3")
1119
+ }
1120
+ }
1121
+ },
1047
1122
  blik: {
1048
1123
  displayName: "BLIK",
1049
1124
  currencies: ["pln"],
@@ -1064,7 +1139,25 @@ var STRIPE_METHOD_MATRIX = {
1064
1139
  }
1065
1140
  },
1066
1141
  boleto: { displayName: "Boleto", currencies: ["brl"], countries: ["BR"] },
1067
- customer_balance: { displayName: "Customer Balance", currencies: ["*"] },
1142
+ customer_balance: {
1143
+ displayName: "Bank Transfer",
1144
+ currencies: ["eur", "usd"],
1145
+ countries: BANK_TRANSFER_COUNTRIES,
1146
+ theme: {
1147
+ light: {
1148
+ backgroundColor: "#1F2937",
1149
+ textColor: "#FFFFFF",
1150
+ borderColor: "#1F2937",
1151
+ logoSvg: buildBankMark("#1F2937", "#FFFFFF")
1152
+ },
1153
+ dark: {
1154
+ backgroundColor: "#374151",
1155
+ textColor: "#FFFFFF",
1156
+ borderColor: "#374151",
1157
+ logoSvg: buildBankMark("#374151", "#FFFFFF")
1158
+ }
1159
+ }
1160
+ },
1068
1161
  eps: {
1069
1162
  displayName: "EPS",
1070
1163
  currencies: ["eur"],
@@ -1123,6 +1216,25 @@ var STRIPE_METHOD_MATRIX = {
1123
1216
  }
1124
1217
  },
1125
1218
  konbini: { displayName: "Konbini", currencies: ["jpy"], countries: ["JP"] },
1219
+ kr_card: {
1220
+ displayName: "Korean Card",
1221
+ currencies: ["krw"],
1222
+ countries: ["KR"],
1223
+ theme: {
1224
+ light: {
1225
+ backgroundColor: "#0B3D91",
1226
+ textColor: "#FFFFFF",
1227
+ borderColor: "#0B3D91",
1228
+ logoSvg: buildPlaceholderMark("K", "#FFFFFF", "#0B3D91")
1229
+ },
1230
+ dark: {
1231
+ backgroundColor: "#0B3D91",
1232
+ textColor: "#FFFFFF",
1233
+ borderColor: "#0B3D91",
1234
+ logoSvg: buildPlaceholderMark("K", "#FFFFFF", "#0B3D91")
1235
+ }
1236
+ }
1237
+ },
1126
1238
  multibanco: { displayName: "Multibanco", currencies: ["eur"], countries: ["PT"] },
1127
1239
  oxxo: { displayName: "OXXO", currencies: ["mxn"], countries: ["MX"] },
1128
1240
  p24: {
@@ -1188,10 +1300,30 @@ var STRIPE_METHOD_MATRIX = {
1188
1300
  }
1189
1301
  }
1190
1302
  },
1303
+ upi: {
1304
+ displayName: "UPI",
1305
+ currencies: ["inr"],
1306
+ countries: ["IN"],
1307
+ theme: {
1308
+ light: {
1309
+ backgroundColor: "#FF7909",
1310
+ textColor: "#FFFFFF",
1311
+ borderColor: "#FF7909",
1312
+ logoSvg: buildPlaceholderMark("U", "#FFFFFF", "#FF7909")
1313
+ },
1314
+ dark: {
1315
+ backgroundColor: "#FF7909",
1316
+ textColor: "#FFFFFF",
1317
+ borderColor: "#FF7909",
1318
+ logoSvg: buildPlaceholderMark("U", "#FFFFFF", "#FF7909")
1319
+ }
1320
+ }
1321
+ },
1191
1322
  us_bank_account: { displayName: "US Bank Account", currencies: ["usd"], countries: ["US"] },
1192
1323
  wechat_pay: {
1193
1324
  displayName: "WeChat Pay",
1194
- currencies: ["cny", "usd", "eur", "gbp", "aud", "cad", "jpy", "chf", "hkd", "sgd", "nzd", "nok", "sek", "dkk"],
1325
+ // Presentment currencies only WeChat Pay is offered to USD / CNY carts.
1326
+ currencies: ["usd", "cny"],
1195
1327
  theme: {
1196
1328
  light: {
1197
1329
  backgroundColor: "#07C160",
@@ -2025,6 +2157,9 @@ function isValidPublishableKey(key) {
2025
2157
  function isValidSecretKey(key) {
2026
2158
  return /^sk_(test|live)_[A-Za-z0-9]+$/.test(key);
2027
2159
  }
2160
+ function isSetupIntentClientSecret(clientSecret) {
2161
+ return typeof clientSecret === "string" && clientSecret.startsWith("seti_");
2162
+ }
2028
2163
  // Annotate the CommonJS export names for ESM import in node:
2029
2164
  0 && (module.exports = {
2030
2165
  BILLING_API_URL,
@@ -2051,6 +2186,7 @@ function isValidSecretKey(key) {
2051
2186
  DEFAULT_CURRENCY,
2052
2187
  ELEMENT_TYPES,
2053
2188
  FLAT_APPEARANCE,
2189
+ FLO_SDK_VERSION_HEADER,
2054
2190
  FloPayError,
2055
2191
  GLASS_DARK_APPEARANCE,
2056
2192
  GLASS_LIGHT_APPEARANCE,
@@ -2089,6 +2225,7 @@ function isValidSecretKey(key) {
2089
2225
  hasVendoredStripeMethodLogo,
2090
2226
  isAVSEnabled,
2091
2227
  isAVSFieldVisible,
2228
+ isSetupIntentClientSecret,
2092
2229
  isValidPublishableKey,
2093
2230
  isValidSecretKey,
2094
2231
  needsStripeMethodExplicitConfirm,