@delopay/sdk 0.230.0 → 0.234.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/{chunk-HNQKUUSW.js → chunk-3NOAX6WN.js} +193 -4
- package/dist/chunk-3NOAX6WN.js.map +1 -0
- package/dist/index.cjs +199 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +133 -2
- package/dist/index.d.ts +133 -2
- package/dist/index.js +15 -1
- package/dist/internal.cjs +199 -3
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/internal.js +15 -1
- package/dist/internal.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-HNQKUUSW.js.map +0 -1
package/dist/internal.cjs
CHANGED
|
@@ -155,6 +155,11 @@ __export(internal_exports, {
|
|
|
155
155
|
WHOP_CARD_PRESETS: () => WHOP_CARD_PRESETS,
|
|
156
156
|
WHOP_EMAIL_LABELS: () => WHOP_EMAIL_LABELS,
|
|
157
157
|
WHOP_GRAY_COLORS: () => WHOP_GRAY_COLORS,
|
|
158
|
+
WHOP_LOOKS: () => WHOP_LOOKS,
|
|
159
|
+
WHOP_LOOK_SETTINGS: () => WHOP_LOOK_SETTINGS,
|
|
160
|
+
WHOP_RADII: () => WHOP_RADII,
|
|
161
|
+
WHOP_SELECTIONS: () => WHOP_SELECTIONS,
|
|
162
|
+
WHOP_SHADOWS: () => WHOP_SHADOWS,
|
|
158
163
|
Webhooks: () => Webhooks,
|
|
159
164
|
WhopResolutionCases: () => WhopResolutionCases,
|
|
160
165
|
airwallexCardLayout: () => airwallexCardLayout,
|
|
@@ -227,6 +232,7 @@ __export(internal_exports, {
|
|
|
227
232
|
knownSectionLabelKey: () => knownSectionLabelKey,
|
|
228
233
|
leaf: () => leaf,
|
|
229
234
|
logoDimensions: () => logoDimensions,
|
|
235
|
+
matchWhopLook: () => matchWhopLook,
|
|
230
236
|
nativePaneMethodInfo: () => nativePaneMethodInfo,
|
|
231
237
|
nearestWhopAccent: () => nearestWhopAccent,
|
|
232
238
|
noticeText: () => noticeText,
|
|
@@ -264,6 +270,7 @@ __export(internal_exports, {
|
|
|
264
270
|
surfacePadValue: () => surfacePadValue,
|
|
265
271
|
validSectionOrder: () => validSectionOrder,
|
|
266
272
|
validatePanes: () => validatePanes,
|
|
273
|
+
vaultFormAppearance: () => vaultFormAppearance,
|
|
267
274
|
verticalGapValue: () => verticalGapValue,
|
|
268
275
|
visibleCustomFields: () => visibleCustomFields,
|
|
269
276
|
whopAccentSwatch: () => whopAccentSwatch,
|
|
@@ -2116,6 +2123,20 @@ var PaymentLinks = class {
|
|
|
2116
2123
|
async retrieve(linkId) {
|
|
2117
2124
|
return this.request("GET", `/payment-link/${encodeURIComponent(linkId)}`);
|
|
2118
2125
|
}
|
|
2126
|
+
/**
|
|
2127
|
+
* The merchant and payment an opaque checkout link opens.
|
|
2128
|
+
*
|
|
2129
|
+
* A link the API issues today is `/pay/{payment_link_id}`, so it names
|
|
2130
|
+
* neither the merchant nor the payment. This answers which ones it means.
|
|
2131
|
+
* Unauthenticated, like the checkout render it precedes: no credential is
|
|
2132
|
+
* needed or sent beyond what the client already carries. An unknown id is a
|
|
2133
|
+
* 404.
|
|
2134
|
+
*
|
|
2135
|
+
* `GET /payment-link/resolve/{payment_link_id}`
|
|
2136
|
+
*/
|
|
2137
|
+
async resolve(paymentLinkId) {
|
|
2138
|
+
return this.request("GET", `/payment-link/resolve/${encodeURIComponent(paymentLinkId)}`);
|
|
2139
|
+
}
|
|
2119
2140
|
/**
|
|
2120
2141
|
* List payment links, optionally filtered by status or date range.
|
|
2121
2142
|
*
|
|
@@ -8926,6 +8947,114 @@ var WHOP_GRAY_COLORS = [
|
|
|
8926
8947
|
"sand"
|
|
8927
8948
|
];
|
|
8928
8949
|
var WHOP_BILLING_DETAILS = ["minimal", "full"];
|
|
8950
|
+
var WHOP_RADII = ["checkout", "square", "small", "medium", "large"];
|
|
8951
|
+
var WHOP_SHADOWS = ["none", "soft"];
|
|
8952
|
+
var WHOP_SELECTIONS = ["radio_tint", "radio", "tint"];
|
|
8953
|
+
var WHOP_LOOKS = [
|
|
8954
|
+
"standard",
|
|
8955
|
+
"clean",
|
|
8956
|
+
"whop",
|
|
8957
|
+
"cards",
|
|
8958
|
+
"tiles",
|
|
8959
|
+
"soft",
|
|
8960
|
+
"minimal"
|
|
8961
|
+
];
|
|
8962
|
+
var WHOP_LOOK_SETTINGS = {
|
|
8963
|
+
// The fewest fields Whop takes a card with, laid out as Stripe's card
|
|
8964
|
+
// form: the email, the number above expiry and code, then one group of
|
|
8965
|
+
// name, country (preselected) and postal code. Whop refuses a card without
|
|
8966
|
+
// any of them. The wallets are the shop's own express buttons.
|
|
8967
|
+
standard: {
|
|
8968
|
+
whopCardPreset: "card_stacked",
|
|
8969
|
+
whopBillingDetails: "minimal",
|
|
8970
|
+
whopSeparated: false,
|
|
8971
|
+
whopFieldChrome: "outlined",
|
|
8972
|
+
whopEmailLabel: "above",
|
|
8973
|
+
whopRadius: "checkout",
|
|
8974
|
+
whopShadow: "soft",
|
|
8975
|
+
whopMethodIcons: true,
|
|
8976
|
+
whopSelection: "radio_tint"
|
|
8977
|
+
},
|
|
8978
|
+
// Flat fields like the checkout's own, the method list with the chosen
|
|
8979
|
+
// method tinted beside its radio.
|
|
8980
|
+
clean: {
|
|
8981
|
+
whopCardPreset: "accordion",
|
|
8982
|
+
whopBillingDetails: "minimal",
|
|
8983
|
+
whopSeparated: false,
|
|
8984
|
+
whopFieldChrome: "outlined",
|
|
8985
|
+
whopEmailLabel: "above",
|
|
8986
|
+
whopRadius: "checkout",
|
|
8987
|
+
whopShadow: "none",
|
|
8988
|
+
whopMethodIcons: true,
|
|
8989
|
+
whopSelection: "radio_tint"
|
|
8990
|
+
},
|
|
8991
|
+
// Whop's own form: its corners, its soft shadow, its radio dots.
|
|
8992
|
+
whop: {
|
|
8993
|
+
whopCardPreset: "accordion",
|
|
8994
|
+
whopBillingDetails: "minimal",
|
|
8995
|
+
whopSeparated: false,
|
|
8996
|
+
whopFieldChrome: "outlined",
|
|
8997
|
+
whopEmailLabel: "above",
|
|
8998
|
+
whopRadius: "small",
|
|
8999
|
+
whopShadow: "soft",
|
|
9000
|
+
whopMethodIcons: true,
|
|
9001
|
+
whopSelection: "radio"
|
|
9002
|
+
},
|
|
9003
|
+
// Each method its own raised card, the chosen one tinted, no dots.
|
|
9004
|
+
cards: {
|
|
9005
|
+
whopCardPreset: "accordion",
|
|
9006
|
+
whopBillingDetails: "minimal",
|
|
9007
|
+
whopSeparated: true,
|
|
9008
|
+
whopFieldChrome: "outlined",
|
|
9009
|
+
whopEmailLabel: "above",
|
|
9010
|
+
whopRadius: "medium",
|
|
9011
|
+
whopShadow: "soft",
|
|
9012
|
+
whopMethodIcons: true,
|
|
9013
|
+
whopSelection: "tint"
|
|
9014
|
+
},
|
|
9015
|
+
// The methods as tiles above the card's fields.
|
|
9016
|
+
tiles: {
|
|
9017
|
+
whopCardPreset: "tiles",
|
|
9018
|
+
whopBillingDetails: "minimal",
|
|
9019
|
+
whopSeparated: false,
|
|
9020
|
+
whopFieldChrome: "outlined",
|
|
9021
|
+
whopEmailLabel: "above",
|
|
9022
|
+
whopRadius: "checkout",
|
|
9023
|
+
whopShadow: "none",
|
|
9024
|
+
whopMethodIcons: true,
|
|
9025
|
+
whopSelection: "radio_tint"
|
|
9026
|
+
},
|
|
9027
|
+
// Filled fields with the captions inside, round corners.
|
|
9028
|
+
soft: {
|
|
9029
|
+
whopCardPreset: "accordion",
|
|
9030
|
+
whopBillingDetails: "minimal",
|
|
9031
|
+
whopSeparated: false,
|
|
9032
|
+
whopFieldChrome: "filled",
|
|
9033
|
+
whopEmailLabel: "floating",
|
|
9034
|
+
whopRadius: "large",
|
|
9035
|
+
whopShadow: "none",
|
|
9036
|
+
whopMethodIcons: false,
|
|
9037
|
+
whopSelection: "radio_tint"
|
|
9038
|
+
},
|
|
9039
|
+
// The card alone on one line, underlined, captions inside.
|
|
9040
|
+
minimal: {
|
|
9041
|
+
whopCardPreset: "card_compact",
|
|
9042
|
+
whopBillingDetails: "minimal",
|
|
9043
|
+
whopSeparated: false,
|
|
9044
|
+
whopFieldChrome: "underline",
|
|
9045
|
+
whopEmailLabel: "floating",
|
|
9046
|
+
whopRadius: "square",
|
|
9047
|
+
whopShadow: "none",
|
|
9048
|
+
whopMethodIcons: true,
|
|
9049
|
+
whopSelection: "radio_tint"
|
|
9050
|
+
}
|
|
9051
|
+
};
|
|
9052
|
+
function matchWhopLook(settings) {
|
|
9053
|
+
const keys = Object.keys(WHOP_LOOK_SETTINGS.clean);
|
|
9054
|
+
return WHOP_LOOKS.find(
|
|
9055
|
+
(look) => keys.every((key) => WHOP_LOOK_SETTINGS[look][key] === settings[key])
|
|
9056
|
+
) ?? null;
|
|
9057
|
+
}
|
|
8929
9058
|
|
|
8930
9059
|
// src/branding.ts
|
|
8931
9060
|
function surchargeShowsLabel(labelMode, style, position) {
|
|
@@ -9200,6 +9329,19 @@ function inputPadValue(size) {
|
|
|
9200
9329
|
function buttonPadValue(size) {
|
|
9201
9330
|
return BUTTON_PAD[size] ?? BUTTON_PAD.md;
|
|
9202
9331
|
}
|
|
9332
|
+
function vaultFormAppearance(b, danger) {
|
|
9333
|
+
return {
|
|
9334
|
+
surface: b.surface,
|
|
9335
|
+
text: b.text,
|
|
9336
|
+
border: b.border,
|
|
9337
|
+
accent: b.primary,
|
|
9338
|
+
...danger ? { danger } : {},
|
|
9339
|
+
font: b.fontFamily,
|
|
9340
|
+
radius: b.radiusInput,
|
|
9341
|
+
size: b.inputSize,
|
|
9342
|
+
labels: b.labelStyle
|
|
9343
|
+
};
|
|
9344
|
+
}
|
|
9203
9345
|
function logoDimensions(size) {
|
|
9204
9346
|
switch (size) {
|
|
9205
9347
|
case "sm":
|
|
@@ -9679,7 +9821,7 @@ var DEFAULT_BRANDING_BASE = {
|
|
|
9679
9821
|
micropaymentFieldFontSize: "md",
|
|
9680
9822
|
micropaymentFieldWeight: "regular",
|
|
9681
9823
|
micropaymentFocusRing: "strong",
|
|
9682
|
-
whopCardPreset: "
|
|
9824
|
+
whopCardPreset: "card_stacked",
|
|
9683
9825
|
whopAccentColor: "auto",
|
|
9684
9826
|
whopGrayColor: "auto",
|
|
9685
9827
|
whopBillingDetails: "minimal",
|
|
@@ -9689,6 +9831,10 @@ var DEFAULT_BRANDING_BASE = {
|
|
|
9689
9831
|
whopFieldFontSize: "md",
|
|
9690
9832
|
whopFieldWeight: "regular",
|
|
9691
9833
|
whopFocusRing: "strong",
|
|
9834
|
+
whopRadius: "checkout",
|
|
9835
|
+
whopShadow: "soft",
|
|
9836
|
+
whopMethodIcons: true,
|
|
9837
|
+
whopSelection: "radio_tint",
|
|
9692
9838
|
customCss: ""
|
|
9693
9839
|
};
|
|
9694
9840
|
var DEFAULT_BRANDING = {
|
|
@@ -10677,6 +10823,18 @@ function decodeBranding(source) {
|
|
|
10677
10823
|
CARD_FOCUS_RINGS,
|
|
10678
10824
|
DEFAULT_BRANDING.whopFocusRing
|
|
10679
10825
|
),
|
|
10826
|
+
whopRadius: pickEnum(extras["whopRadius"], WHOP_RADII, DEFAULT_BRANDING.whopRadius),
|
|
10827
|
+
whopShadow: pickEnum(
|
|
10828
|
+
extras["whopShadow"],
|
|
10829
|
+
WHOP_SHADOWS,
|
|
10830
|
+
DEFAULT_BRANDING.whopShadow
|
|
10831
|
+
),
|
|
10832
|
+
whopMethodIcons: parseBool(extras["whopMethodIcons"], DEFAULT_BRANDING.whopMethodIcons),
|
|
10833
|
+
whopSelection: pickEnum(
|
|
10834
|
+
extras["whopSelection"],
|
|
10835
|
+
WHOP_SELECTIONS,
|
|
10836
|
+
DEFAULT_BRANDING.whopSelection
|
|
10837
|
+
),
|
|
10680
10838
|
paypalValidTint: parseBool(extras["paypalValidTint"], DEFAULT_BRANDING.paypalValidTint),
|
|
10681
10839
|
nomupayFormStyle: pickEnum(
|
|
10682
10840
|
extras["nomupayFormStyle"],
|
|
@@ -10834,6 +10992,10 @@ function encodeBranding(branding, base) {
|
|
|
10834
10992
|
whopFieldFontSize: branding.whopFieldFontSize,
|
|
10835
10993
|
whopFieldWeight: branding.whopFieldWeight,
|
|
10836
10994
|
whopFocusRing: branding.whopFocusRing,
|
|
10995
|
+
whopRadius: branding.whopRadius,
|
|
10996
|
+
whopShadow: branding.whopShadow,
|
|
10997
|
+
whopMethodIcons: String(branding.whopMethodIcons),
|
|
10998
|
+
whopSelection: branding.whopSelection,
|
|
10837
10999
|
paypalValidTint: String(branding.paypalValidTint),
|
|
10838
11000
|
nomupayFormStyle: branding.nomupayFormStyle,
|
|
10839
11001
|
nomupayShowLabels: String(branding.nomupayShowLabels),
|
|
@@ -11287,6 +11449,14 @@ function parseImportedBranding(raw) {
|
|
|
11287
11449
|
CARD_FOCUS_RINGS,
|
|
11288
11450
|
dflt.whopFocusRing
|
|
11289
11451
|
),
|
|
11452
|
+
whopRadius: pickEnum(root["whopRadius"], WHOP_RADII, dflt.whopRadius),
|
|
11453
|
+
whopShadow: pickEnum(root["whopShadow"], WHOP_SHADOWS, dflt.whopShadow),
|
|
11454
|
+
whopMethodIcons: parseBool(root["whopMethodIcons"], dflt.whopMethodIcons),
|
|
11455
|
+
whopSelection: pickEnum(
|
|
11456
|
+
root["whopSelection"],
|
|
11457
|
+
WHOP_SELECTIONS,
|
|
11458
|
+
dflt.whopSelection
|
|
11459
|
+
),
|
|
11290
11460
|
paypalValidTint: parseBool(root["paypalValidTint"], dflt.paypalValidTint),
|
|
11291
11461
|
nomupayFormStyle: pickEnum(
|
|
11292
11462
|
root["nomupayFormStyle"],
|
|
@@ -11826,11 +11996,29 @@ var CheckoutSession = class {
|
|
|
11826
11996
|
* reports the vault as enabled and still expects its cards cloaked. The same
|
|
11827
11997
|
* status also covers a payment that does not exist.
|
|
11828
11998
|
*
|
|
11999
|
+
* `params.appearance` asks for a form styled to match the page (Enigma
|
|
12000
|
+
* Vault). The answer then carries `height`, the frame height to use. If the
|
|
12001
|
+
* vault refuses the styled form the answer is the plain one, without
|
|
12002
|
+
* `height`. `params.locale` is the buyer's locale.
|
|
12003
|
+
*
|
|
11829
12004
|
* `GET /payment-link/{merchantId}/{paymentId}/vault/collect-session`
|
|
11830
12005
|
*/
|
|
11831
|
-
async vaultCollectSession(options) {
|
|
12006
|
+
async vaultCollectSession(options, params) {
|
|
12007
|
+
const look = params?.appearance;
|
|
11832
12008
|
return this.client.request("GET", `${this.linkBase}/vault/collect-session`, {
|
|
11833
12009
|
...options,
|
|
12010
|
+
query: {
|
|
12011
|
+
locale: params?.locale,
|
|
12012
|
+
form_surface: look?.surface,
|
|
12013
|
+
form_text: look?.text,
|
|
12014
|
+
form_border: look?.border,
|
|
12015
|
+
form_accent: look?.accent,
|
|
12016
|
+
form_danger: look?.danger,
|
|
12017
|
+
form_font: look?.font,
|
|
12018
|
+
form_radius: look?.radius,
|
|
12019
|
+
form_size: look?.size,
|
|
12020
|
+
form_labels: look?.labels
|
|
12021
|
+
},
|
|
11834
12022
|
headers: this.bearerHeaders(options?.headers)
|
|
11835
12023
|
});
|
|
11836
12024
|
}
|
|
@@ -12419,9 +12607,10 @@ function encodePanes(panes) {
|
|
|
12419
12607
|
};
|
|
12420
12608
|
});
|
|
12421
12609
|
}
|
|
12610
|
+
var OPAQUE_PAYMENT_LINK_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
12422
12611
|
function focusedCheckoutUrl(params) {
|
|
12423
12612
|
const base = params.checkoutBaseUrl.replace(/\/+$/, "");
|
|
12424
|
-
const path = `${base}/pay/${encodeURIComponent(params.merchantId)}/${encodeURIComponent(
|
|
12613
|
+
const path = params.paymentLinkId && OPAQUE_PAYMENT_LINK_ID.test(params.paymentLinkId) ? `${base}/pay/${params.paymentLinkId}` : `${base}/pay/${encodeURIComponent(params.merchantId)}/${encodeURIComponent(
|
|
12425
12614
|
params.paymentId
|
|
12426
12615
|
)}`;
|
|
12427
12616
|
const query = new URLSearchParams({ pane: params.method });
|
|
@@ -14155,6 +14344,11 @@ var DelopayInternal = class extends Delopay {
|
|
|
14155
14344
|
WHOP_CARD_PRESETS,
|
|
14156
14345
|
WHOP_EMAIL_LABELS,
|
|
14157
14346
|
WHOP_GRAY_COLORS,
|
|
14347
|
+
WHOP_LOOKS,
|
|
14348
|
+
WHOP_LOOK_SETTINGS,
|
|
14349
|
+
WHOP_RADII,
|
|
14350
|
+
WHOP_SELECTIONS,
|
|
14351
|
+
WHOP_SHADOWS,
|
|
14158
14352
|
Webhooks,
|
|
14159
14353
|
WhopResolutionCases,
|
|
14160
14354
|
airwallexCardLayout,
|
|
@@ -14227,6 +14421,7 @@ var DelopayInternal = class extends Delopay {
|
|
|
14227
14421
|
knownSectionLabelKey,
|
|
14228
14422
|
leaf,
|
|
14229
14423
|
logoDimensions,
|
|
14424
|
+
matchWhopLook,
|
|
14230
14425
|
nativePaneMethodInfo,
|
|
14231
14426
|
nearestWhopAccent,
|
|
14232
14427
|
noticeText,
|
|
@@ -14264,6 +14459,7 @@ var DelopayInternal = class extends Delopay {
|
|
|
14264
14459
|
surfacePadValue,
|
|
14265
14460
|
validSectionOrder,
|
|
14266
14461
|
validatePanes,
|
|
14462
|
+
vaultFormAppearance,
|
|
14267
14463
|
verticalGapValue,
|
|
14268
14464
|
visibleCustomFields,
|
|
14269
14465
|
whopAccentSwatch,
|