brainerce 2.7.0 → 2.9.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/README.md +202 -2
- package/dist/index.d.mts +222 -3
- package/dist/index.d.ts +222 -3
- package/dist/index.js +90 -1
- package/dist/index.mjs +89 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -201,7 +201,7 @@ These sequences are non-negotiable. The order of SDK calls matters.
|
|
|
201
201
|
```ts
|
|
202
202
|
const providers = await client.getPaymentProviders();
|
|
203
203
|
```
|
|
204
|
-
Each provider has a `renderType`: `'sdk-widget'` (Stripe, PayPal, Grow), `'iframe'` (Cardcom), `'redirect'
|
|
204
|
+
Each provider has a `renderType`: `'sdk-widget'` (Stripe, PayPal, Grow), `'iframe'` (Cardcom), `'redirect'` (Morning, Takbull, iCredit), `'sandbox'`. Branch on `renderType`, never on provider name. A provider's `clientSdk.displayModes` lists every mode it can serve; you may ask for one with `createPaymentIntent(checkoutId, { preferredRenderType: 'iframe' | 'redirect' })`, and the platform honours it only from that list, so still branch on what comes back.
|
|
205
205
|
5. Confirm payment using the provider's flow (Stripe Elements `stripe.confirmCardPayment`, PayPal button, redirect, etc.).
|
|
206
206
|
6. On the confirmation page, **always call both**:
|
|
207
207
|
```ts
|
|
@@ -433,6 +433,7 @@ The SDK exports these utility functions for common UI tasks:
|
|
|
433
433
|
| `isCouponApplicableToProduct(coupon, product)` | Check if coupon applies | `isCouponApplicableToProduct(coupon, product)` |
|
|
434
434
|
| `isAllowedPaymentUrl(url, options?)` | Validate a payment URL host | `isAllowedPaymentUrl(intent.clientSecret)` → `true` |
|
|
435
435
|
| `safePaymentRedirect(url, options?)` | Validate then `window.location.href` | `safePaymentRedirect(intent.clientSecret)` |
|
|
436
|
+
| `resolveRenderType(clientSdk, preferred?)` | Predict the `renderType` an intent will come back with (the platform's own rule), so you can pick `successUrl` before creating it | `resolveRenderType(provider.clientSdk, 'iframe')` → `'iframe'` |
|
|
436
437
|
| `buildProductJsonLd(product, opts)` | schema.org Product JSON-LD (PDPs only) | See SEO section |
|
|
437
438
|
| `buildArticleJsonLd(post, opts)` | schema.org Article JSON-LD for blog posts | See SEO section |
|
|
438
439
|
| `buildOrganizationJsonLd(store, opts)` | schema.org Organization for the homepage | See SEO section |
|
|
@@ -1322,6 +1323,38 @@ The SDK uses **server-side carts for all users**. Guests get automatic session c
|
|
|
1322
1323
|
> `publishProductToSalesChannel()`. Note `publishProduct()` is a DIFFERENT
|
|
1323
1324
|
> operation — that one pushes to external platforms, not to your storefront.
|
|
1324
1325
|
|
|
1326
|
+
> **A shopper cart holds at most 50 distinct lines.** Adding a 51st _different_
|
|
1327
|
+
> product throws a `400` carrying the error code `CART_LINE_LIMIT_REACHED`, with
|
|
1328
|
+
> the limit itself on `details.maxLines`. It is a fixed platform limit with no
|
|
1329
|
+
> per-store setting. **It applies in channel (`salesChannelId: 'vc_*'`) and store
|
|
1330
|
+
> (`storeId`) mode only — an admin (`apiKey: 'brainerce_*'`) cart is not
|
|
1331
|
+
> capped**, because a B2B or bulk-import cart legitimately runs long, so the same
|
|
1332
|
+
> call can succeed for one client and fail for another. The cap counts distinct
|
|
1333
|
+
> lines, not quantity, and is only checked when a **new** line would be created,
|
|
1334
|
+
> so a full cart can still have quantities changed and items removed rather than
|
|
1335
|
+
> becoming unusable. Show it as a "your cart is full" state and keep the item the
|
|
1336
|
+
> shopper tried to add on screen. ⛔ Bundle and order-bump adds are **not
|
|
1337
|
+
> transactional**: a bundle whose lines would cross 50 throws part-way and leaves
|
|
1338
|
+
> the earlier products of that bundle in the cart, so re-read the cart after a
|
|
1339
|
+
> failed bundle add.
|
|
1340
|
+
|
|
1341
|
+
**Detect a full cart by the code, not by the sentence.** The SDK hands the whole parsed
|
|
1342
|
+
error body back on `BrainerceError.details`, so the code is one level in and the limit sits
|
|
1343
|
+
beside it — `err.code` is NOT where it lives:
|
|
1344
|
+
|
|
1345
|
+
```typescript
|
|
1346
|
+
catch (err) {
|
|
1347
|
+
const body = (err as BrainerceError).details as
|
|
1348
|
+
{ code?: string; details?: { maxLines?: number } } | undefined;
|
|
1349
|
+
if (body?.code === 'CART_LINE_LIMIT_REACHED') showCartFull(body.details?.maxLines ?? 50);
|
|
1350
|
+
}
|
|
1351
|
+
```
|
|
1352
|
+
|
|
1353
|
+
⛔ **Keep any existing match on the message as a fallback.** The wording is byte-for-byte
|
|
1354
|
+
unchanged on purpose — storefronts written before the code existed still depend on it, and a
|
|
1355
|
+
storefront can be talking to a backend that has not been redeployed yet. Branch on the code
|
|
1356
|
+
first, then fall through to the prose match.
|
|
1357
|
+
|
|
1325
1358
|
```typescript
|
|
1326
1359
|
// Add to cart (guest or logged-in — same code!)
|
|
1327
1360
|
await client.smartAddToCart({ productId: 'prod_123', quantity: 2 });
|
|
@@ -2610,6 +2643,13 @@ await client.smartAddToCart({
|
|
|
2610
2643
|
> guest or a logged-in shopper, so you never need a `cartId` of your own.
|
|
2611
2644
|
> Validation stays server-side, so a bad modifier set still comes back as a
|
|
2612
2645
|
> `MODIFIER_VALIDATION_FAILED` envelope on `BrainerceError.details`.
|
|
2646
|
+
>
|
|
2647
|
+
> **The 50-distinct-line cap applies here too** (channel and store mode; not
|
|
2648
|
+
> admin). A 51st different product throws a `400` carrying the error code
|
|
2649
|
+
> `CART_LINE_LIMIT_REACHED` on `BrainerceError.details.code`, with the limit on
|
|
2650
|
+
> `BrainerceError.details.details.maxLines`. Branch on the code and keep any existing match on
|
|
2651
|
+
> the (unchanged) message text as a fallback — see
|
|
2652
|
+
> [Cart (Unified for All Users)](#cart-unified-for-all-users) above.
|
|
2613
2653
|
|
|
2614
2654
|
#### Get Cart
|
|
2615
2655
|
|
|
@@ -2874,6 +2914,14 @@ const cart = await client.addToCart(cartId, {
|
|
|
2874
2914
|
});
|
|
2875
2915
|
```
|
|
2876
2916
|
|
|
2917
|
+
> **Capped at 50 distinct lines** in channel and store mode (not admin): a 51st
|
|
2918
|
+
> different product throws a `400` carrying the error code
|
|
2919
|
+
> `CART_LINE_LIMIT_REACHED` on `BrainerceError.details.code`, with the limit on
|
|
2920
|
+
> `BrainerceError.details.details.maxLines`. Branch on the code and keep any existing match on
|
|
2921
|
+
> the (unchanged) message text as a fallback. Quantity changes on an already-full
|
|
2922
|
+
> cart still work — only a new line is refused. See
|
|
2923
|
+
> [Cart (Unified for All Users)](#cart-unified-for-all-users).
|
|
2924
|
+
|
|
2877
2925
|
#### Update Cart Item
|
|
2878
2926
|
|
|
2879
2927
|
```typescript
|
|
@@ -3615,7 +3663,7 @@ const config = await client.getPaymentConfig();
|
|
|
3615
3663
|
|
|
3616
3664
|
// Returns:
|
|
3617
3665
|
// {
|
|
3618
|
-
// provider: string, // 'stripe' | 'paypal' | 'grow' | 'cardcom' | any
|
|
3666
|
+
// provider: string, // 'stripe' | 'paypal' | 'grow' | 'cardcom' | 'icredit' | any
|
|
3619
3667
|
// // installed marketplace payment app — NOT a
|
|
3620
3668
|
// // closed union. Never switch on it exhaustively.
|
|
3621
3669
|
// publicKey: 'pk_live_xxx...', // Stripe publishable key or PayPal client ID
|
|
@@ -3640,6 +3688,7 @@ const intent = await client.createPaymentIntent(checkout.id);
|
|
|
3640
3688
|
// status: 'requires_payment_method',
|
|
3641
3689
|
// provider: 'stripe', // which processor took the intent
|
|
3642
3690
|
// clientSdk: { renderType: 'sdk-widget', /* … */ }, // HOW to render — see below
|
|
3691
|
+
// renderModeResolution: 'provider-default', // why renderType is what it is — see "Asking for a mode"
|
|
3643
3692
|
// }
|
|
3644
3693
|
```
|
|
3645
3694
|
|
|
@@ -3661,6 +3710,48 @@ Branch on `clientSdk?.renderType`. **Never** branch on "does `clientSdk` exist":
|
|
|
3661
3710
|
every provider returns one, sandbox included. And never hard-code by provider name.
|
|
3662
3711
|
Only `provider === 'stripe'` has a `clientSdk.initConfig.publishableKey`.
|
|
3663
3712
|
|
|
3713
|
+
#### Asking for a mode (`preferredRenderType`)
|
|
3714
|
+
|
|
3715
|
+
Some providers can present their payment surface more than one way. Each
|
|
3716
|
+
`getPaymentProviders()` entry carries `clientSdk.displayModes`, every mode the
|
|
3717
|
+
provider can serve, beside `clientSdk.renderType`, its default. Pass
|
|
3718
|
+
`preferredRenderType: 'iframe' | 'redirect'` and the platform returns that mode
|
|
3719
|
+
when `displayModes` lists it, and the provider's default otherwise. Asking is
|
|
3720
|
+
never an error. The intent's `renderModeResolution` tells you which happened:
|
|
3721
|
+
`'preferred'`, `'fallback'` (you asked for a mode the provider does not declare),
|
|
3722
|
+
or `'provider-default'` (you did not ask, or the intent is a sandbox one).
|
|
3723
|
+
|
|
3724
|
+
An iframe intent returns the shopper **inside the frame**, to a same-origin page
|
|
3725
|
+
that posts `brainerce:payment-complete` to the parent; a redirect intent returns
|
|
3726
|
+
them straight to your confirmation page. So predict the mode **before** the call
|
|
3727
|
+
and pass the matching `successUrl`. `resolveRenderType()` is the platform's own
|
|
3728
|
+
rule, exported so the two never disagree:
|
|
3729
|
+
|
|
3730
|
+
```typescript
|
|
3731
|
+
import { resolveRenderType } from 'brainerce';
|
|
3732
|
+
|
|
3733
|
+
const { defaultProvider } = await client.getPaymentProviders();
|
|
3734
|
+
const expected = resolveRenderType(defaultProvider?.clientSdk, 'iframe');
|
|
3735
|
+
const successUrl =
|
|
3736
|
+
expected === 'iframe'
|
|
3737
|
+
? `${origin}/payment-complete?checkout_id=${checkout.id}`
|
|
3738
|
+
: `${origin}/order-confirmation?checkout_id=${checkout.id}`;
|
|
3739
|
+
|
|
3740
|
+
const intent = await client.createPaymentIntent(checkout.id, {
|
|
3741
|
+
preferredRenderType: 'iframe',
|
|
3742
|
+
successUrl,
|
|
3743
|
+
});
|
|
3744
|
+
// Still branch on intent.clientSdk?.renderType — never on 'iframe'.
|
|
3745
|
+
```
|
|
3746
|
+
|
|
3747
|
+
Omit the option to take the provider's default, which is exactly what every
|
|
3748
|
+
storefront did before it existed. There is no merchant-dashboard setting for
|
|
3749
|
+
this: the storefront knows whether it has a frame to render into, the merchant
|
|
3750
|
+
does not. Only ask for `'iframe'` when you do, and when the provider's iframe has
|
|
3751
|
+
been verified on a real checkout. Any other value is rejected with `400`;
|
|
3752
|
+
`'sdk-widget'`, `'embedded-fields'` and `'sandbox'` are integration mechanisms,
|
|
3753
|
+
not presentation preferences.
|
|
3754
|
+
|
|
3664
3755
|
#### Confirm an SDK / redirect payment
|
|
3665
3756
|
|
|
3666
3757
|
```typescript
|
|
@@ -3702,6 +3793,13 @@ Do **not** call it on your `cancelUrl`. The buyer abandoned; just let them retry
|
|
|
3702
3793
|
> `getPaymentProviders()` and `waitForOrder()` are **sales-channel mode only**;
|
|
3703
3794
|
> they throw `BrainerceError` 400 on a `storeId` or `apiKey` client.
|
|
3704
3795
|
|
|
3796
|
+
> **`createPaymentIntent()` can throw `BrainerceError` 503 with
|
|
3797
|
+
> `err.details.code === 'PAYMENTS_PAUSED'`.** The platform pauses a store's payments
|
|
3798
|
+
> while its ownership is being transferred, until the new owner connects a payment
|
|
3799
|
+
> provider, which can take days. Show `err.message` ("Payments are temporarily
|
|
3800
|
+
> unavailable for this store") at the payment step, keep the cart and checkout, and
|
|
3801
|
+
> do not retry in a loop: nothing the storefront does lifts it.
|
|
3802
|
+
|
|
3705
3803
|
**Routing to a specific provider (`providerId`).** With `getPaymentProviders()` you
|
|
3706
3804
|
render additive **express buttons** (e.g. PayPal as a `WALLET`) alongside the primary
|
|
3707
3805
|
card form. When the buyer taps one, pass that provider's `id` so the charge routes to
|
|
@@ -3721,6 +3819,9 @@ Omit `providerId` to settle through the primary card processor (`defaultProvider
|
|
|
3721
3819
|
The platform scopes it to the store, so only that store's own installed providers are
|
|
3722
3820
|
selectable.
|
|
3723
3821
|
|
|
3822
|
+
The full options object is `{ providerId?, successUrl?, cancelUrl?, saveCard?,
|
|
3823
|
+
preferredRenderType? }`.
|
|
3824
|
+
|
|
3724
3825
|
#### Confirm Payment with Stripe.js
|
|
3725
3826
|
|
|
3726
3827
|
Use the client secret with Stripe.js to collect payment:
|
|
@@ -5994,6 +6095,55 @@ await client.setMetafieldPlatforms('def_id', {
|
|
|
5994
6095
|
});
|
|
5995
6096
|
```
|
|
5996
6097
|
|
|
6098
|
+
### Order custom fields
|
|
6099
|
+
|
|
6100
|
+
Merchant-defined fields that hold a value **on an order**. Not the ones a
|
|
6101
|
+
shopper fills in at checkout — these are the store's own, and they are how you
|
|
6102
|
+
attach something that only exists after the purchase: a licence key, a booking
|
|
6103
|
+
reference, a warranty number issued by a third party.
|
|
6104
|
+
|
|
6105
|
+
The point of writing here rather than emailing the customer yourself: the value
|
|
6106
|
+
travels to the merchant's own order email templates as `orderCustomFields`, and
|
|
6107
|
+
shows on the customer's own order page when the definition is `isPublic`. You do
|
|
6108
|
+
not build an email, and the merchant keeps their branding and their language.
|
|
6109
|
+
|
|
6110
|
+
⛔ **The stock templates do not print it.** The variable reaches every order
|
|
6111
|
+
email, but no default template renders it, so a value you write is invisible to
|
|
6112
|
+
the customer until the merchant adds the block to the template once (the email
|
|
6113
|
+
editor's variable helper offers `orderCustomFields`). Writing the field is not
|
|
6114
|
+
the same as the customer being told. Say so when you hand this to a merchant.
|
|
6115
|
+
|
|
6116
|
+
The merchant creates the definitions in the dashboard (Orders → settings). The
|
|
6117
|
+
SDK reads them and writes values.
|
|
6118
|
+
|
|
6119
|
+
```typescript
|
|
6120
|
+
// 1. Discover the keys. `key` is what you write; `type` is what a value must fit.
|
|
6121
|
+
const definitions = await client.getOrderCustomFieldDefinitions();
|
|
6122
|
+
|
|
6123
|
+
// 2. Write. A MERGE — omitted keys keep their value, null clears a non-required one.
|
|
6124
|
+
const stored = await client.setOrderCustomFieldValues(
|
|
6125
|
+
'order_123',
|
|
6126
|
+
{ licence_key: 'ABCD-EFGH-IJKL' },
|
|
6127
|
+
{ idempotencyKey: 'licence-order_123' }
|
|
6128
|
+
);
|
|
6129
|
+
console.log(stored.fields); // what was ACTUALLY persisted, after coercion
|
|
6130
|
+
|
|
6131
|
+
// 3. Read back later
|
|
6132
|
+
const { fields } = await client.getOrderCustomFieldValues('order_123');
|
|
6133
|
+
```
|
|
6134
|
+
|
|
6135
|
+
Three behaviours worth knowing before you rely on them:
|
|
6136
|
+
|
|
6137
|
+
- **A key with no active definition is ignored, not rejected.** The call still
|
|
6138
|
+
succeeds. Check the returned `fields` to confirm your value landed, rather
|
|
6139
|
+
than assuming a 200 means it did.
|
|
6140
|
+
- **Values are coerced to the definition type.** A `NUMBER` field written as
|
|
6141
|
+
`'5'` reads back as `5`. A value that cannot be coerced is a 400.
|
|
6142
|
+
- **`required` fields cannot be cleared.** Sending `null` for one is a 400.
|
|
6143
|
+
|
|
6144
|
+
Requires an API key with `orders:read` (the two reads) and `orders:write` (the
|
|
6145
|
+
write).
|
|
6146
|
+
|
|
5997
6147
|
### Per-Channel Publishing (Categories / Tags / Brands / Custom Fields)
|
|
5998
6148
|
|
|
5999
6149
|
Each of these entities can be **gated per vibe-coded site**: merchants
|
|
@@ -8099,6 +8249,53 @@ was missing 14 real events and still listed 8 fake ones — `coupon.*`,
|
|
|
8099
8249
|
subscribable events. If you're on an older SDK version, upgrade rather than
|
|
8100
8250
|
casting around the type.)
|
|
8101
8251
|
|
|
8252
|
+
### Finishing a purchase that depends on something outside Brainerce
|
|
8253
|
+
|
|
8254
|
+
The common shape: the customer pays, then a third party has to issue the thing
|
|
8255
|
+
they bought — a licence key, a booking reference, a ticket number — and only
|
|
8256
|
+
then can the customer be told what it is. That answer usually arrives seconds
|
|
8257
|
+
after payment, sometimes minutes, and occasionally never.
|
|
8258
|
+
|
|
8259
|
+
Do not hold the order confirmation waiting for it. The confirmation is the
|
|
8260
|
+
receipt for the payment; send it immediately, and deliver the answer in a
|
|
8261
|
+
second email once you have it.
|
|
8262
|
+
|
|
8263
|
+
```typescript
|
|
8264
|
+
// order.paid handler, on YOUR server
|
|
8265
|
+
const key = await someProvider.issue({
|
|
8266
|
+
// Use the order id as the provider's idempotency reference, never a random
|
|
8267
|
+
// one. A retried handler then collides with the original instead of buying
|
|
8268
|
+
// a second key.
|
|
8269
|
+
reference: order.id,
|
|
8270
|
+
});
|
|
8271
|
+
|
|
8272
|
+
await client.setOrderCustomFieldValues(
|
|
8273
|
+
order.id,
|
|
8274
|
+
{ licence_key: key },
|
|
8275
|
+
{ idempotencyKey: `licence-${order.id}` }
|
|
8276
|
+
);
|
|
8277
|
+
|
|
8278
|
+
// Fires ORDER_COMPLETED, which renders the field the line above just wrote.
|
|
8279
|
+
await client.updateOrder(order.id, { status: 'COMPLETED' });
|
|
8280
|
+
```
|
|
8281
|
+
|
|
8282
|
+
Two things this gets you for free:
|
|
8283
|
+
|
|
8284
|
+
- **The failure case has a queue.** If the provider errors, you never mark the
|
|
8285
|
+
order complete, so no email goes out claiming something was delivered. The
|
|
8286
|
+
merchant's list of paid-but-not-completed orders is the list of purchases
|
|
8287
|
+
needing attention, with no extra screen to build.
|
|
8288
|
+
- **The merchant owns the email.** The value renders through their existing
|
|
8289
|
+
`ORDER_COMPLETED` template, in their branding and their language. Add the
|
|
8290
|
+
field to that template once (as `orderCustomFields`) and every future
|
|
8291
|
+
integration reuses it.
|
|
8292
|
+
|
|
8293
|
+
⛔ **Marking an order `COMPLETED` also commits its inventory reservation, and
|
|
8294
|
+
tells the customer the whole order is done.** That is correct for a purely
|
|
8295
|
+
digital order. If the same order also ships a physical item, use a different
|
|
8296
|
+
signal — do not tell someone their parcel is finished because a licence
|
|
8297
|
+
arrived.
|
|
8298
|
+
|
|
8102
8299
|
---
|
|
8103
8300
|
|
|
8104
8301
|
## TypeScript Support
|
|
@@ -8138,6 +8335,8 @@ import type {
|
|
|
8138
8335
|
Order,
|
|
8139
8336
|
OrderStatus,
|
|
8140
8337
|
OrderItem,
|
|
8338
|
+
OrderCustomFieldDefinition,
|
|
8339
|
+
OrderCustomFieldValues,
|
|
8141
8340
|
|
|
8142
8341
|
// Webhooks
|
|
8143
8342
|
WebhookEvent,
|
|
@@ -8273,6 +8472,7 @@ const handleCheckout = async () => {
|
|
|
8273
8472
|
| `Product not found` | Unknown product ID, or a valid one that is `draft`/`archived`, or not published to this sales channel. The 404 is identical for all three, so it cannot be used to probe another channel's catalogue. |
|
|
8274
8473
|
| `Insufficient inventory` | Not enough stock |
|
|
8275
8474
|
| `Invalid quantity` | Quantity < 1 or > available |
|
|
8475
|
+
| `Payments are temporarily unavailable for this store` | `createPaymentIntent()` returned 503 `PAYMENTS_PAUSED`: the store is mid ownership transfer and stays paused until the new owner connects a payment provider. Show the message, keep the cart, do not retry in a loop. |
|
|
8276
8476
|
|
|
8277
8477
|
### Custom Hook for SDK Operations (Optional)
|
|
8278
8478
|
|
package/dist/index.d.mts
CHANGED
|
@@ -2381,6 +2381,66 @@ interface CreateOrderDto {
|
|
|
2381
2381
|
interface UpdateOrderDto {
|
|
2382
2382
|
status?: OrderStatus;
|
|
2383
2383
|
}
|
|
2384
|
+
/**
|
|
2385
|
+
* A merchant-defined field that can hold a value on an order.
|
|
2386
|
+
*
|
|
2387
|
+
* These are the fields the STORE manages on an order (`adminFieldValues`), not
|
|
2388
|
+
* the ones a shopper fills in during checkout. They are how an integration
|
|
2389
|
+
* attaches data that only exists after the purchase — a licence key, a booking
|
|
2390
|
+
* reference, a warranty number issued by a third party — to the order it
|
|
2391
|
+
* belongs to. What is written travels to the merchant's own order email
|
|
2392
|
+
* templates as `orderCustomFields`, so the customer can be told without a
|
|
2393
|
+
* bespoke email being built for each integration.
|
|
2394
|
+
*
|
|
2395
|
+
* ⛔ No default template PRINTS it. The merchant adds the block to their
|
|
2396
|
+
* template once; until then a written value is invisible to the customer.
|
|
2397
|
+
*/
|
|
2398
|
+
interface OrderCustomFieldDefinition {
|
|
2399
|
+
id: string;
|
|
2400
|
+
storeId: string;
|
|
2401
|
+
/** Display label. Renders beside the value in order emails. */
|
|
2402
|
+
name: string;
|
|
2403
|
+
/** The property name to use in `setOrderCustomFieldValues`. */
|
|
2404
|
+
key: string;
|
|
2405
|
+
description: string | null;
|
|
2406
|
+
type: 'TEXT' | 'TEXTAREA' | 'NUMBER' | 'BOOLEAN' | 'SELECT' | 'DATE' | 'DATETIME' | 'IMAGE';
|
|
2407
|
+
/** A required field cannot be cleared once it holds a value. */
|
|
2408
|
+
required: boolean;
|
|
2409
|
+
/**
|
|
2410
|
+
* When true the value is exposed to the storefront through the SDK, so the
|
|
2411
|
+
* customer can see it on their own order page and not only in the email.
|
|
2412
|
+
*/
|
|
2413
|
+
isPublic: boolean;
|
|
2414
|
+
position: number;
|
|
2415
|
+
/**
|
|
2416
|
+
* An inactive definition refuses new values but still resolves its label on
|
|
2417
|
+
* orders that already carry one.
|
|
2418
|
+
*/
|
|
2419
|
+
isActive: boolean;
|
|
2420
|
+
/** SELECT only. */
|
|
2421
|
+
options?: Array<{
|
|
2422
|
+
value: string;
|
|
2423
|
+
label: string;
|
|
2424
|
+
}> | null;
|
|
2425
|
+
minLength?: number | null;
|
|
2426
|
+
maxLength?: number | null;
|
|
2427
|
+
minValue?: string | null;
|
|
2428
|
+
maxValue?: string | null;
|
|
2429
|
+
dateAvailability?: unknown;
|
|
2430
|
+
translations?: Record<string, unknown> | null;
|
|
2431
|
+
createdAt: string;
|
|
2432
|
+
updatedAt: string;
|
|
2433
|
+
}
|
|
2434
|
+
/** The custom field values stored on one order, keyed by definition `key`. */
|
|
2435
|
+
interface OrderCustomFieldValues {
|
|
2436
|
+
orderId: string;
|
|
2437
|
+
/**
|
|
2438
|
+
* Values AFTER coercion to each field's type — a NUMBER field written as
|
|
2439
|
+
* `'5'` reads back as `5`. Keys with no matching definition were never
|
|
2440
|
+
* stored and so never appear here.
|
|
2441
|
+
*/
|
|
2442
|
+
fields: Record<string, unknown>;
|
|
2443
|
+
}
|
|
2384
2444
|
interface UpdateInventoryDto {
|
|
2385
2445
|
quantity: number;
|
|
2386
2446
|
variantId?: string;
|
|
@@ -4970,9 +5030,38 @@ interface PublishProductResponse {
|
|
|
4970
5030
|
* Returned by the backend in provider config and payment intents.
|
|
4971
5031
|
* The frontend dynamically loads the SDK script and calls init/render methods.
|
|
4972
5032
|
*/
|
|
5033
|
+
/**
|
|
5034
|
+
* Every way a provider can present its payment surface. `PaymentClientSdk.renderType`
|
|
5035
|
+
* is one of these; `PaymentClientSdk.displayModes` lists the ones the provider
|
|
5036
|
+
* can serve.
|
|
5037
|
+
*/
|
|
5038
|
+
type PaymentRenderType = 'sdk-widget' | 'iframe' | 'redirect' | 'sandbox' | 'embedded-fields';
|
|
5039
|
+
/**
|
|
5040
|
+
* The render modes a storefront may ASK for via
|
|
5041
|
+
* `createPaymentIntent(id, { preferredRenderType })`. Deliberately only the
|
|
5042
|
+
* two presentation choices: `sdk-widget`, `embedded-fields` and `sandbox` are
|
|
5043
|
+
* integration mechanisms a storefront cannot substitute at will.
|
|
5044
|
+
*/
|
|
5045
|
+
type PreferredRenderType = 'redirect' | 'iframe';
|
|
5046
|
+
/**
|
|
5047
|
+
* Why the `clientSdk.renderType` on a `PaymentIntent` is what it is.
|
|
5048
|
+
*
|
|
5049
|
+
* - `'preferred'` — you asked for a mode and the provider supports it.
|
|
5050
|
+
* - `'fallback'` — you asked for a mode the provider does not declare;
|
|
5051
|
+
* you got the provider's default instead.
|
|
5052
|
+
* - `'provider-default'` — you did not ask (or the intent is a sandbox one).
|
|
5053
|
+
*/
|
|
5054
|
+
type RenderModeResolution = 'preferred' | 'fallback' | 'provider-default';
|
|
4973
5055
|
interface PaymentClientSdk {
|
|
4974
5056
|
/** How the payment UI is rendered: 'sdk-widget' (JS SDK), 'iframe', 'redirect', 'sandbox' (test orders), or 'embedded-fields' (PCI-compliant provider-hosted fields embedded in merchant DOM, e.g. Cardcom OpenFields, Stripe Elements) */
|
|
4975
|
-
renderType:
|
|
5057
|
+
renderType: PaymentRenderType;
|
|
5058
|
+
/**
|
|
5059
|
+
* Every render mode this provider can serve. `renderType` is the default;
|
|
5060
|
+
* `preferredRenderType` on `createPaymentIntent` is honoured only if it is in
|
|
5061
|
+
* this list. Absent on legacy manifests — treat as `[renderType]`, which is
|
|
5062
|
+
* exactly what `resolveRenderType()` does.
|
|
5063
|
+
*/
|
|
5064
|
+
displayModes?: PaymentRenderType[];
|
|
4976
5065
|
/** URL of the main SDK script to load */
|
|
4977
5066
|
scriptUrl?: string;
|
|
4978
5067
|
/** Name of the global variable set by the SDK script (e.g., 'growPayment') */
|
|
@@ -5142,6 +5231,14 @@ interface PaymentIntent {
|
|
|
5142
5231
|
provider?: string;
|
|
5143
5232
|
/** Runtime client SDK overrides (merged with provider manifest config) */
|
|
5144
5233
|
clientSdk?: PaymentClientSdk;
|
|
5234
|
+
/**
|
|
5235
|
+
* Why the returned `clientSdk.renderType` is what it is — see
|
|
5236
|
+
* `RenderModeResolution`. Lets a storefront that asked for `iframe` and got
|
|
5237
|
+
* `redirect` tell "the provider does not support iframe" (`'fallback'`) from
|
|
5238
|
+
* "I never asked" (`'provider-default'`). Absent from older backends; always
|
|
5239
|
+
* branch on the `renderType` you got back, never on what you asked for.
|
|
5240
|
+
*/
|
|
5241
|
+
renderModeResolution?: RenderModeResolution;
|
|
5145
5242
|
}
|
|
5146
5243
|
/**
|
|
5147
5244
|
* The stored payment-record vocabulary. **UPPERCASE.**
|
|
@@ -8122,8 +8219,20 @@ interface TrackEventPayload {
|
|
|
8122
8219
|
/** Active dwell time in ms. Only meaningful for `eventType: 'engagement'`. Max 1 800 000 (30 min). */
|
|
8123
8220
|
engagedMs?: number;
|
|
8124
8221
|
}
|
|
8222
|
+
/**
|
|
8223
|
+
* The JSON body of any non-2xx response. `BrainerceError.details` holds a value
|
|
8224
|
+
* of this shape (the raw parsed body), so from a caught SDK error the code is
|
|
8225
|
+
* at `err.details.code`, one level deeper than it sits on the wire.
|
|
8226
|
+
*/
|
|
8125
8227
|
interface BrainerceApiError {
|
|
8126
8228
|
statusCode: number;
|
|
8229
|
+
/**
|
|
8230
|
+
* The stable, machine-readable error code — switch on THIS, never on
|
|
8231
|
+
* `message`, whose wording can change at any time. Always present: the API
|
|
8232
|
+
* derives a generic code from the status when a route supplies none.
|
|
8233
|
+
* The full list is at https://brainerce.com/docs/api/errors.
|
|
8234
|
+
*/
|
|
8235
|
+
code?: string;
|
|
8127
8236
|
message: string;
|
|
8128
8237
|
error?: string;
|
|
8129
8238
|
details?: unknown;
|
|
@@ -9121,6 +9230,63 @@ declare class BrainerceClient {
|
|
|
9121
9230
|
* Update an order (e.g., change status)
|
|
9122
9231
|
*/
|
|
9123
9232
|
updateOrder(orderId: string, data: UpdateOrderDto): Promise<Order>;
|
|
9233
|
+
/**
|
|
9234
|
+
* List the store's order custom field definitions.
|
|
9235
|
+
*
|
|
9236
|
+
* Call this before writing values: the `key` of each definition is what
|
|
9237
|
+
* {@link setOrderCustomFieldValues} accepts, and `type` is what a value has
|
|
9238
|
+
* to fit. Inactive definitions are included, so you can tell "the merchant
|
|
9239
|
+
* turned this field off" apart from "the merchant never created it".
|
|
9240
|
+
*
|
|
9241
|
+
* Requires an API key with the `orders:read` scope.
|
|
9242
|
+
*/
|
|
9243
|
+
getOrderCustomFieldDefinitions(): Promise<OrderCustomFieldDefinition[]>;
|
|
9244
|
+
/**
|
|
9245
|
+
* Read the custom field values stored on one order.
|
|
9246
|
+
*
|
|
9247
|
+
* Requires an API key with the `orders:read` scope.
|
|
9248
|
+
*/
|
|
9249
|
+
getOrderCustomFieldValues(orderId: string): Promise<OrderCustomFieldValues>;
|
|
9250
|
+
/**
|
|
9251
|
+
* Write custom field values onto an order.
|
|
9252
|
+
*
|
|
9253
|
+
* This is how work that finishes OUTSIDE Brainerce gets back onto the order
|
|
9254
|
+
* it belongs to. Subscribe to the `order.paid` webhook, call whatever third
|
|
9255
|
+
* party issues the thing you sell — a licence key, a booking reference, a
|
|
9256
|
+
* warranty number — then write the answer here. The value travels to the
|
|
9257
|
+
* merchant's own order email templates as `orderCustomFields` and, when the
|
|
9258
|
+
* definition is `isPublic`, to the customer's own order page. No email
|
|
9259
|
+
* template or endpoint has to be built per integration.
|
|
9260
|
+
*
|
|
9261
|
+
* ⛔ No default template PRINTS `orderCustomFields`. The variable reaches
|
|
9262
|
+
* every order email, but until the merchant adds the block to their template
|
|
9263
|
+
* once, a value written here is invisible to the customer. Writing the field
|
|
9264
|
+
* is not the same as the customer being told.
|
|
9265
|
+
*
|
|
9266
|
+
* The write is a MERGE: keys you leave out keep their current value, and
|
|
9267
|
+
* `null` clears a field that is not required. Values are coerced to the
|
|
9268
|
+
* definition's type and rejected with a 400 when they cannot be — but a key
|
|
9269
|
+
* with no active definition on the store is IGNORED rather than failing the
|
|
9270
|
+
* whole call, so read the returned `fields` to confirm what was stored.
|
|
9271
|
+
*
|
|
9272
|
+
* Pass an `idempotencyKey` when the caller may retry: an identical re-send
|
|
9273
|
+
* then replays the original response instead of writing again.
|
|
9274
|
+
*
|
|
9275
|
+
* Requires an API key with the `orders:write` scope.
|
|
9276
|
+
*
|
|
9277
|
+
* @example
|
|
9278
|
+
* ```typescript
|
|
9279
|
+
* // after the third party answered
|
|
9280
|
+
* await client.setOrderCustomFieldValues(
|
|
9281
|
+
* order.id,
|
|
9282
|
+
* { licence_key: 'ABCD-EFGH-IJKL' },
|
|
9283
|
+
* { idempotencyKey: `licence-${order.id}` }
|
|
9284
|
+
* );
|
|
9285
|
+
* // fires the "order completed" email, which carries the field
|
|
9286
|
+
* await client.updateOrder(order.id, { status: 'COMPLETED' });
|
|
9287
|
+
* ```
|
|
9288
|
+
*/
|
|
9289
|
+
setOrderCustomFieldValues(orderId: string, fields: Record<string, unknown>, options?: IdempotentRequestOptions): Promise<OrderCustomFieldValues>;
|
|
9124
9290
|
/**
|
|
9125
9291
|
* Update order status.
|
|
9126
9292
|
*
|
|
@@ -12028,6 +12194,25 @@ declare class BrainerceClient {
|
|
|
12028
12194
|
* subscription features.
|
|
12029
12195
|
*/
|
|
12030
12196
|
saveCard?: boolean;
|
|
12197
|
+
/**
|
|
12198
|
+
* How you would like the provider's payment surface presented. The
|
|
12199
|
+
* platform honours it when the provider supports that mode (it is
|
|
12200
|
+
* listed in the provider's `clientSdk.displayModes`), and otherwise
|
|
12201
|
+
* falls back to the provider's default — so always branch on the
|
|
12202
|
+
* `clientSdk.renderType` you get BACK, never on what you asked for.
|
|
12203
|
+
* The response's `renderModeResolution` says which happened. Omit to
|
|
12204
|
+
* take the provider's default.
|
|
12205
|
+
*
|
|
12206
|
+
* To pick the matching `successUrl` up front, call
|
|
12207
|
+
* `resolveRenderType(provider.clientSdk, preferred)` on the entry from
|
|
12208
|
+
* `getPaymentProviders()` — it applies the same rule the platform does.
|
|
12209
|
+
* An iframe intent returns the shopper INSIDE the frame, so its
|
|
12210
|
+
* `successUrl` must be a same-origin page that posts to the parent; a
|
|
12211
|
+
* redirect intent can return straight to the confirmation page.
|
|
12212
|
+
*
|
|
12213
|
+
* A value outside `'redirect' | 'iframe'` is rejected with 400.
|
|
12214
|
+
*/
|
|
12215
|
+
preferredRenderType?: PreferredRenderType;
|
|
12031
12216
|
}): Promise<PaymentIntent>;
|
|
12032
12217
|
/**
|
|
12033
12218
|
* Get payment status for a checkout.
|
|
@@ -14186,7 +14371,7 @@ declare class BrainerceError extends Error {
|
|
|
14186
14371
|
constructor(message: string, statusCode: number, details?: unknown);
|
|
14187
14372
|
}
|
|
14188
14373
|
|
|
14189
|
-
declare const SDK_VERSION = "2.
|
|
14374
|
+
declare const SDK_VERSION = "2.9.0";
|
|
14190
14375
|
|
|
14191
14376
|
/**
|
|
14192
14377
|
* Verify a webhook signature from Brainerce
|
|
@@ -14289,6 +14474,40 @@ declare function isAllowedPaymentUrl(url: string, options?: PaymentUrlOptions):
|
|
|
14289
14474
|
*/
|
|
14290
14475
|
declare function safePaymentRedirect(url: string, options?: PaymentUrlOptions): void;
|
|
14291
14476
|
|
|
14477
|
+
/**
|
|
14478
|
+
* Predict the `clientSdk.renderType` the platform will return for a given
|
|
14479
|
+
* provider and preference.
|
|
14480
|
+
*
|
|
14481
|
+
* Rules (identical to the platform's):
|
|
14482
|
+
* 1. No preference → the provider default.
|
|
14483
|
+
* 2. Preference declared in `displayModes` → the preference.
|
|
14484
|
+
* 3. Preference NOT declared → the provider default (the platform reports
|
|
14485
|
+
* `renderModeResolution: 'fallback'` on the intent).
|
|
14486
|
+
* 4. `displayModes` absent (legacy manifest) → treated as `[renderType]`.
|
|
14487
|
+
*
|
|
14488
|
+
* @param sdk - The `clientSdk` of an entry from `getPaymentProviders()`
|
|
14489
|
+
* (`defaultProvider.clientSdk` or `providers[i].clientSdk`).
|
|
14490
|
+
* @param preferred - The mode you intend to pass as `preferredRenderType`.
|
|
14491
|
+
* @returns The mode the intent will come back with. `'redirect'` when there is
|
|
14492
|
+
* no provider at all, so a storefront can always pick a return URL.
|
|
14493
|
+
*
|
|
14494
|
+
* @example
|
|
14495
|
+
* ```typescript
|
|
14496
|
+
* const { defaultProvider } = await client.getPaymentProviders();
|
|
14497
|
+
* const expected = resolveRenderType(defaultProvider?.clientSdk, 'iframe');
|
|
14498
|
+
* const successUrl = expected === 'iframe'
|
|
14499
|
+
* ? `${origin}/payment-complete?checkout_id=${checkoutId}`
|
|
14500
|
+
* : `${origin}/order-confirmation?checkout_id=${checkoutId}`;
|
|
14501
|
+
* const intent = await client.createPaymentIntent(checkoutId, {
|
|
14502
|
+
* preferredRenderType: 'iframe',
|
|
14503
|
+
* successUrl,
|
|
14504
|
+
* });
|
|
14505
|
+
* // Still branch on what came BACK — never on what you asked for.
|
|
14506
|
+
* if (intent.clientSdk?.renderType === 'iframe') { ... }
|
|
14507
|
+
* ```
|
|
14508
|
+
*/
|
|
14509
|
+
declare function resolveRenderType(sdk: Pick<PaymentClientSdk, 'renderType' | 'displayModes'> | null | undefined, preferred?: PreferredRenderType): PaymentRenderType;
|
|
14510
|
+
|
|
14292
14511
|
interface FormatProductPriceOptions {
|
|
14293
14512
|
/**
|
|
14294
14513
|
* BCP-47 locale for `Intl.NumberFormat`. Controls number grouping and
|
|
@@ -14687,4 +14906,4 @@ interface CategorySitemapOptions {
|
|
|
14687
14906
|
*/
|
|
14688
14907
|
declare function getCategorySitemapEntries(client: BrainerceClient, opts: CategorySitemapOptions): Promise<SitemapEntry[]>;
|
|
14689
14908
|
|
|
14690
|
-
export { type AddToCartDto, type AddressDetailsResult, type AddressSuggestion, type AiTranslateBulkInput, type AiTranslateBulkResult, type AiTranslateSingleInput, type AnnouncementContent, type AnnouncementSeverity, type AppliedDiscount, type ApplyCouponDto, type AssignTaxClassDto, type AttachModifierGroupInput, type Attribute, type AttributeDisplayType, type AttributeOption, type AttributeSource, type AutoRegionResponse, type AvailabilityClock, type BlogPost, type BlogPostListParams, type BlogPostListResponse, type BlogSitemapOptions, type BrainerceApiError, BrainerceClient, type BrainerceClientOptions, BrainerceError, type Brand, type BulkCreateProductsDto, type BulkCreateProductsError, type BulkCreateProductsJob, type BulkCreateProductsStatus, type BulkInventoryResponse, type BulkSaveVariantsDto, type BulkSaveVariantsResponse, type BulkVariantInput, type BusinessHoursWindow, type Cart, type CartAppliedDiscount, type CartBundleOffer, type CartBundleOfferOfferedProduct, type CartBundlesResponse, type CartIncludeOption, type CartIncludeOptions, type CartItem, type CartItemModifierLine, type CartItemUnavailableReason, type CartNudge, type CartRecommendationsResponse, type CartStatus, type CartUpgradeSuggestion, type CartUpgradesResponse, type CartWithIncludes, type Category, type CategoryDetail, type CategoryNode, type CategorySitemapOptions, type CategorySuggestion, type Checkout, type CheckoutAddress, type CheckoutBumpsResponse, type CheckoutCustomFieldDefinition, type CheckoutFieldPricing, type CheckoutFieldVisibility, type CheckoutLineItem, type CheckoutPrefillData, type CheckoutStatus, type CheckoutTender, type CompleteCheckoutResponse, type CompleteDraftDto, type ConfigureOAuthProviderDto as ConfigureOAuthProviderInput, type ConflictStatus, type ConnectorPlatform, type ContactFormFieldType, type ContactFormFieldValidation, type ContactFormPublic, type ContactFormPublicField, type ContactFormSummary, type Content, type ContentDataMap, type ContentStatus, type ContentSummary, type ContentType, type Coupon, type CouponCreateResponse, type CouponQueryParams, type CouponStatus, type CouponType, type CouponValidationWarning, type CreateAddressDto, type CreateAttributeDto as CreateAttributeInput, type CreateAttributeOptionDto as CreateAttributeOptionInput, type CreateBrandDto as CreateBrandInput, type CreateCategoryDto as CreateCategoryInput, type CreateCheckoutDto, type CreateContentInput, type CreateCouponDto, type CreateCustomerDto, type CreateEmailTemplateDto as CreateEmailTemplateInput, type CreateGuestOrderDto, type CreateInquiryInput, type CreateInquiryResponse, type CreateMetafieldDefinitionDto as CreateMetafieldDefinitionInput, type CreateModifierGroupInput, type CreateModifierInput, type CreateOrderDto, type CreateProductDto, type CreateRefundDto, type CreateRegionDto, type CreateReturnLabelDto as CreateReturnLabelInput, type CreateReturnLabelResponse, type CreateShippingRateDto as CreateShippingRateInput, type CreateShippingZoneDto as CreateShippingZoneInput, type CreateStockAlertInput, type CreateTagDto as CreateTagInput, type CreateTaxClassDto, type CreateTaxRateDto as CreateTaxRateInput, type CreateVariantDto, type Customer, type CustomerAddress, type CustomerAuthResponse, type CustomerOAuthProvider, type CustomerProfile, type CustomerQueryParams, type CustomizationFieldOption, type DateAvailabilityConstraints, type DateAvailabilitySurface, type DateFieldParseResult, type DeleteProductResponse, type DeliveryType, type DiscountBanner, type DiscountRuleType, type DownloadFile, type DraftLineItem, type EditInventoryDto, type EmailDomain, type EmailEventSettings, type EmailEventType, type EmailSettings, type EmailTemplate, type EmailTemplatePreview, type EmailTemplatesResponse, type EmailVerificationResponse, type ExtendReservationResponse, type FaqContent, type FaqItem, type FooterColumn, type FooterContent, type FooterLink, type FooterSocialLink, type FormatPriceOptions, type FormatProductPriceOptions, type FreeAllocationPolicy, type FulfillOrderDto, type GiftCardAdmin, type GiftCardAdminDetail, type GiftCardBalance, type GiftCardLiability, type GiftCardTransaction, type GuestCheckoutStartResponse, type GuestOrderResponse, type HeaderContent, type HeaderCta, type HeaderLogo, type HeaderNavItem, type I18nSettings, type IdempotentRequestOptions, type InsufficientStockError, type InventoryInfo, type InventoryReservationStrategy, type InventorySyncStatus, type InventoryTrackingMode, type InvitationStatus, type InviteMemberDto as InviteMemberInput, type InviteStoreMemberDto as InviteStoreMemberInput, type IssueGiftCardAdminDto, type IssuedGiftCardAdmin, type JsonLdOptions, type ListModifierGroupsParams, type ListNewsletterBenefitGrantsParams, type LocalCart, type LocalCartItem, type LocaleTranslation, type LockedVariant, type LoyaltyBadge, type LoyaltyMembershipPlan, type LoyaltyNextTierSummary, type LoyaltyReward, type LoyaltyRewardRecommendation, type LoyaltyStatus, type LoyaltyTierSummary, type MergeCartsDto, type MetafieldConflict, type MetafieldConflictResolution, type MetafieldDefinition, type MetafieldFilter, type MetafieldFilterValue, type MetafieldFiltersResponse, type MetafieldType, type Modifier, type ModifierGroup, type ModifierSelection, type ModifierSelectionType, type ModifierValidationCode, type ModifierValidationError, type ModifierValidationFailedError, type MyProductReview, type NestedModifierSelection, type NewsletterBenefitDiscountKind, type NewsletterBenefitGrant, type NewsletterBenefitGrantState, type NewsletterBenefitSettings, type OAuthAuthorizeResponse, type OAuthCallbackResponse, type OAuthConnection, type OAuthConnectionsResponse, type OAuthErrorCode, type OAuthProviderConfig, type OAuthProviderType, type OAuthProvidersResponse, type Order, type OrderAddress, type OrderBump, type OrderCustomer, type OrderDownloadLink, type OrderItem, type OrderQueryParams, type OrderStatus, type OrderStatusChange, type PageContent, type PageSeo, type PaginatedResponse, type PaidMembershipInfo, type ParsedDateFieldValue, type PaymentClientSdk, type PaymentConfig, type PaymentIntent, type PaymentProvider, type PaymentProviderConfig, type PaymentProvidersConfig, type PaymentRecordStatus, type PaymentStatus, type PaymentUrlOptions, type PickupLocation, type PlatformCouponCapabilities, type PlatformMetafieldMetadata, type PreviewEmailTemplateDto as PreviewEmailTemplateInput, type PriceDriftError, type Product, type ProductAttributeInput, type ProductAvailability, type ProductCustomizationField, type ProductDiscount, type ProductDiscountBadge, type ProductImage, type ProductInventoryResponse, type ProductMetafield, type ProductMetafieldValue, type ProductModifierGroupAttachment, type ProductQueryParams, type ProductRecommendation, type ProductRecommendationsResponse, type ProductRelationType, type ProductReview, type ProductReviewAdmin, type ProductReviewImage, type ProductReviewImageAdmin, type ProductSitemapOptions, type ProductStatus, type ProductSuggestion, type ProductUnavailableError, type ProductVariant, type PublicMetafieldDefinition, type PublicNewsletterBenefitOffer, type PublicRegion, type PublicRegionDetail, type PublicRegionPaymentProvider, type PublicTaxClass, type PublishProductResponse, RTL_LOCALES, type RecommendationVariant, type ReconcileInventoryResponse, type RedeemRewardResult, type ReferralInfo, type Refund, type RefundLineItem, type RefundLineItemResponse, type RefundType, type Region, type RegionPaymentProvider, type RegisterCustomerDto, type ReissuedGiftCardAdmin, type RelativeDateBounds, type ResendNewsletterBenefitResult, type ReservationInfo, type ResolveMetafieldConflictDto as ResolveMetafieldConflictInput, type ResolveSyncConflictDto as ResolveSyncConflictInput, type ReturnLabelParcel, type ReviewPhotoUpload, type ReviewStatus, type RichTextContent, SDK_VERSION, type SavedPaymentMethodSummary, type SearchSuggestions, type SelectPickupLocationDto, type SelectShippingMethodDto, type SendInvoiceDto, type SessionCartRef, type SetBillingAddressDto, type SetCheckoutCustomFieldsDto, type SetCheckoutCustomerDto, type SetDefinitionProductsDto as SetDefinitionProductsInput, type SetMetafieldPlatformsDto as SetMetafieldPlatformsInput, type SetShippingAddressDto, type SetShippingAddressResponse, type SetTranslationFields, type ShippingDestinations, type ShippingLine, type ShippingRate, type ShippingRateConfig, type ShippingRateType, type ShippingSummaryEntry, type ShippingZone, type ShippingZoneQueryParams, type SitemapEntry, type StockAlertResponse, type StockAvailabilityRequest, type StockAvailabilityResponse, type StockAvailabilityResult, type StoreCapabilities, type StoreInfo, type StoreInvitation, type StoreInvitationDetails, type StoreMember, type StorePermission, type StoreRole, type StoreTeamResponse, type StoreTracking, type StorefrontSavedPaymentMethod, type SubmitProductReviewInput, type SubscribeMarketingInput, type SubscribeMarketingResponse, type SupportedLocaleObject, type SyncConflict, type SyncConflictResolution, type SyncJob, type Tag, type TaxBreakdown, type TaxBreakdownItem, type TaxClass, type TaxEstimateResponse, type TaxRate, type TaxonomyQueryParams, type TeamInvitation, type TeamInvitationsResponse, type TeamMember, type TeamMembersResponse, type TeamRole, type TrackingEventItem, type TrackingEventName, type TrackingEventPayload, type TranslatableEntityType, type TranslationStatusEntry, type TranslationsMap, type UpdateAddressDto, type UpdateAttachmentInput, type UpdateAttributeDto as UpdateAttributeInput, type UpdateAttributeOptionDto as UpdateAttributeOptionInput, type UpdateBrandDto as UpdateBrandInput, type UpdateCartItemDto, type UpdateCategoryDto as UpdateCategoryInput, type UpdateContentInput, type UpdateCouponDto, type UpdateCustomerDto, type UpdateDraftDto, type UpdateEmailSettingsDto as UpdateEmailSettingsInput, type UpdateEmailTemplateDto as UpdateEmailTemplateInput, type UpdateInventoryDto, type UpdateMemberRoleDto as UpdateMemberRoleInput, type UpdateMetafieldDefinitionDto as UpdateMetafieldDefinitionInput, type UpdateModifierGroupInput, type UpdateModifierInput, type UpdateNewsletterBenefitSettingsInput, type UpdateOAuthProviderDto as UpdateOAuthProviderInput, type UpdateOrderDto, type UpdateOrderShippingDto, type UpdateProductDto, type UpdateRegionDto, type UpdateShippingRateDto as UpdateShippingRateInput, type UpdateShippingZoneDto as UpdateShippingZoneInput, type UpdateStoreMemberDto as UpdateStoreMemberInput, type UpdateTagDto as UpdateTagInput, type UpdateTaxClassDto, type UpdateTaxRateDto as UpdateTaxRateInput, type UpdateVariantDto, type UpdateVariantInventoryDto, type UpsellSettings, type UpsertProductMetafieldDto as UpsertProductMetafieldInput, type UserStore, type UserStorePermissions, type VariantInventoryResponse, type VariantPlatformOverlay, type VariantStatus, type WaitForOrderOptions, type WaitForOrderResult, type WebhookEvent, type WebhookEventType, type WriteProductReviewInput, buildArticleJsonLd, buildBreadcrumbJsonLd, buildCollectionPageJsonLd, buildOrganizationJsonLd, buildProductFaqJsonLd, buildProductJsonLd, buildWebsiteJsonLd, computeAvailableSlots, createWebhookHandler, deriveSeoDescription, enableDevGuards, formatMoney, formatPrice, formatProductPrice, formatVariantPrice, getBlogSitemapEntries, getBusinessHoursForDate, getCartItemImage, getCartItemName, getCartTotals, getCategorySitemapEntries, getDescriptionContent, getDirectionForLocale, formatPrice as getPriceDisplay, getProductCustomizationFields, getProductMetafield, getProductMetafieldValue, getProductMetafieldsByType, getProductPrice, getProductPriceInfo, getProductSitemapEntries, getProductSwatches, getStockStatus, getVariantOptions, getVariantPrice, isAllowedPaymentUrl, isCalendarDateAllowed, isCouponApplicableToProduct, isDateValueAllowed, isHtmlDescription, isWebhookEventType, jsonLdScriptProps, parseDateFieldValue, parseWebhookEvent, resolveRelativeBounds, resolveStoreLocalParts, safePaymentRedirect, stripHtml, validateDateAvailabilityConfig, verifyWebhook };
|
|
14909
|
+
export { type AddToCartDto, type AddressDetailsResult, type AddressSuggestion, type AiTranslateBulkInput, type AiTranslateBulkResult, type AiTranslateSingleInput, type AnnouncementContent, type AnnouncementSeverity, type AppliedDiscount, type ApplyCouponDto, type AssignTaxClassDto, type AttachModifierGroupInput, type Attribute, type AttributeDisplayType, type AttributeOption, type AttributeSource, type AutoRegionResponse, type AvailabilityClock, type BlogPost, type BlogPostListParams, type BlogPostListResponse, type BlogSitemapOptions, type BrainerceApiError, BrainerceClient, type BrainerceClientOptions, BrainerceError, type Brand, type BulkCreateProductsDto, type BulkCreateProductsError, type BulkCreateProductsJob, type BulkCreateProductsStatus, type BulkInventoryResponse, type BulkSaveVariantsDto, type BulkSaveVariantsResponse, type BulkVariantInput, type BusinessHoursWindow, type Cart, type CartAppliedDiscount, type CartBundleOffer, type CartBundleOfferOfferedProduct, type CartBundlesResponse, type CartIncludeOption, type CartIncludeOptions, type CartItem, type CartItemModifierLine, type CartItemUnavailableReason, type CartNudge, type CartRecommendationsResponse, type CartStatus, type CartUpgradeSuggestion, type CartUpgradesResponse, type CartWithIncludes, type Category, type CategoryDetail, type CategoryNode, type CategorySitemapOptions, type CategorySuggestion, type Checkout, type CheckoutAddress, type CheckoutBumpsResponse, type CheckoutCustomFieldDefinition, type CheckoutFieldPricing, type CheckoutFieldVisibility, type CheckoutLineItem, type CheckoutPrefillData, type CheckoutStatus, type CheckoutTender, type CompleteCheckoutResponse, type CompleteDraftDto, type ConfigureOAuthProviderDto as ConfigureOAuthProviderInput, type ConflictStatus, type ConnectorPlatform, type ContactFormFieldType, type ContactFormFieldValidation, type ContactFormPublic, type ContactFormPublicField, type ContactFormSummary, type Content, type ContentDataMap, type ContentStatus, type ContentSummary, type ContentType, type Coupon, type CouponCreateResponse, type CouponQueryParams, type CouponStatus, type CouponType, type CouponValidationWarning, type CreateAddressDto, type CreateAttributeDto as CreateAttributeInput, type CreateAttributeOptionDto as CreateAttributeOptionInput, type CreateBrandDto as CreateBrandInput, type CreateCategoryDto as CreateCategoryInput, type CreateCheckoutDto, type CreateContentInput, type CreateCouponDto, type CreateCustomerDto, type CreateEmailTemplateDto as CreateEmailTemplateInput, type CreateGuestOrderDto, type CreateInquiryInput, type CreateInquiryResponse, type CreateMetafieldDefinitionDto as CreateMetafieldDefinitionInput, type CreateModifierGroupInput, type CreateModifierInput, type CreateOrderDto, type CreateProductDto, type CreateRefundDto, type CreateRegionDto, type CreateReturnLabelDto as CreateReturnLabelInput, type CreateReturnLabelResponse, type CreateShippingRateDto as CreateShippingRateInput, type CreateShippingZoneDto as CreateShippingZoneInput, type CreateStockAlertInput, type CreateTagDto as CreateTagInput, type CreateTaxClassDto, type CreateTaxRateDto as CreateTaxRateInput, type CreateVariantDto, type Customer, type CustomerAddress, type CustomerAuthResponse, type CustomerOAuthProvider, type CustomerProfile, type CustomerQueryParams, type CustomizationFieldOption, type DateAvailabilityConstraints, type DateAvailabilitySurface, type DateFieldParseResult, type DeleteProductResponse, type DeliveryType, type DiscountBanner, type DiscountRuleType, type DownloadFile, type DraftLineItem, type EditInventoryDto, type EmailDomain, type EmailEventSettings, type EmailEventType, type EmailSettings, type EmailTemplate, type EmailTemplatePreview, type EmailTemplatesResponse, type EmailVerificationResponse, type ExtendReservationResponse, type FaqContent, type FaqItem, type FooterColumn, type FooterContent, type FooterLink, type FooterSocialLink, type FormatPriceOptions, type FormatProductPriceOptions, type FreeAllocationPolicy, type FulfillOrderDto, type GiftCardAdmin, type GiftCardAdminDetail, type GiftCardBalance, type GiftCardLiability, type GiftCardTransaction, type GuestCheckoutStartResponse, type GuestOrderResponse, type HeaderContent, type HeaderCta, type HeaderLogo, type HeaderNavItem, type I18nSettings, type IdempotentRequestOptions, type InsufficientStockError, type InventoryInfo, type InventoryReservationStrategy, type InventorySyncStatus, type InventoryTrackingMode, type InvitationStatus, type InviteMemberDto as InviteMemberInput, type InviteStoreMemberDto as InviteStoreMemberInput, type IssueGiftCardAdminDto, type IssuedGiftCardAdmin, type JsonLdOptions, type ListModifierGroupsParams, type ListNewsletterBenefitGrantsParams, type LocalCart, type LocalCartItem, type LocaleTranslation, type LockedVariant, type LoyaltyBadge, type LoyaltyMembershipPlan, type LoyaltyNextTierSummary, type LoyaltyReward, type LoyaltyRewardRecommendation, type LoyaltyStatus, type LoyaltyTierSummary, type MergeCartsDto, type MetafieldConflict, type MetafieldConflictResolution, type MetafieldDefinition, type MetafieldFilter, type MetafieldFilterValue, type MetafieldFiltersResponse, type MetafieldType, type Modifier, type ModifierGroup, type ModifierSelection, type ModifierSelectionType, type ModifierValidationCode, type ModifierValidationError, type ModifierValidationFailedError, type MyProductReview, type NestedModifierSelection, type NewsletterBenefitDiscountKind, type NewsletterBenefitGrant, type NewsletterBenefitGrantState, type NewsletterBenefitSettings, type OAuthAuthorizeResponse, type OAuthCallbackResponse, type OAuthConnection, type OAuthConnectionsResponse, type OAuthErrorCode, type OAuthProviderConfig, type OAuthProviderType, type OAuthProvidersResponse, type Order, type OrderAddress, type OrderBump, type OrderCustomFieldDefinition, type OrderCustomFieldValues, type OrderCustomer, type OrderDownloadLink, type OrderItem, type OrderQueryParams, type OrderStatus, type OrderStatusChange, type PageContent, type PageSeo, type PaginatedResponse, type PaidMembershipInfo, type ParsedDateFieldValue, type PaymentClientSdk, type PaymentConfig, type PaymentIntent, type PaymentProvider, type PaymentProviderConfig, type PaymentProvidersConfig, type PaymentRecordStatus, type PaymentRenderType, type PaymentStatus, type PaymentUrlOptions, type PickupLocation, type PlatformCouponCapabilities, type PlatformMetafieldMetadata, type PreferredRenderType, type PreviewEmailTemplateDto as PreviewEmailTemplateInput, type PriceDriftError, type Product, type ProductAttributeInput, type ProductAvailability, type ProductCustomizationField, type ProductDiscount, type ProductDiscountBadge, type ProductImage, type ProductInventoryResponse, type ProductMetafield, type ProductMetafieldValue, type ProductModifierGroupAttachment, type ProductQueryParams, type ProductRecommendation, type ProductRecommendationsResponse, type ProductRelationType, type ProductReview, type ProductReviewAdmin, type ProductReviewImage, type ProductReviewImageAdmin, type ProductSitemapOptions, type ProductStatus, type ProductSuggestion, type ProductUnavailableError, type ProductVariant, type PublicMetafieldDefinition, type PublicNewsletterBenefitOffer, type PublicRegion, type PublicRegionDetail, type PublicRegionPaymentProvider, type PublicTaxClass, type PublishProductResponse, RTL_LOCALES, type RecommendationVariant, type ReconcileInventoryResponse, type RedeemRewardResult, type ReferralInfo, type Refund, type RefundLineItem, type RefundLineItemResponse, type RefundType, type Region, type RegionPaymentProvider, type RegisterCustomerDto, type ReissuedGiftCardAdmin, type RelativeDateBounds, type RenderModeResolution, type ResendNewsletterBenefitResult, type ReservationInfo, type ResolveMetafieldConflictDto as ResolveMetafieldConflictInput, type ResolveSyncConflictDto as ResolveSyncConflictInput, type ReturnLabelParcel, type ReviewPhotoUpload, type ReviewStatus, type RichTextContent, SDK_VERSION, type SavedPaymentMethodSummary, type SearchSuggestions, type SelectPickupLocationDto, type SelectShippingMethodDto, type SendInvoiceDto, type SessionCartRef, type SetBillingAddressDto, type SetCheckoutCustomFieldsDto, type SetCheckoutCustomerDto, type SetDefinitionProductsDto as SetDefinitionProductsInput, type SetMetafieldPlatformsDto as SetMetafieldPlatformsInput, type SetShippingAddressDto, type SetShippingAddressResponse, type SetTranslationFields, type ShippingDestinations, type ShippingLine, type ShippingRate, type ShippingRateConfig, type ShippingRateType, type ShippingSummaryEntry, type ShippingZone, type ShippingZoneQueryParams, type SitemapEntry, type StockAlertResponse, type StockAvailabilityRequest, type StockAvailabilityResponse, type StockAvailabilityResult, type StoreCapabilities, type StoreInfo, type StoreInvitation, type StoreInvitationDetails, type StoreMember, type StorePermission, type StoreRole, type StoreTeamResponse, type StoreTracking, type StorefrontSavedPaymentMethod, type SubmitProductReviewInput, type SubscribeMarketingInput, type SubscribeMarketingResponse, type SupportedLocaleObject, type SyncConflict, type SyncConflictResolution, type SyncJob, type Tag, type TaxBreakdown, type TaxBreakdownItem, type TaxClass, type TaxEstimateResponse, type TaxRate, type TaxonomyQueryParams, type TeamInvitation, type TeamInvitationsResponse, type TeamMember, type TeamMembersResponse, type TeamRole, type TrackingEventItem, type TrackingEventName, type TrackingEventPayload, type TranslatableEntityType, type TranslationStatusEntry, type TranslationsMap, type UpdateAddressDto, type UpdateAttachmentInput, type UpdateAttributeDto as UpdateAttributeInput, type UpdateAttributeOptionDto as UpdateAttributeOptionInput, type UpdateBrandDto as UpdateBrandInput, type UpdateCartItemDto, type UpdateCategoryDto as UpdateCategoryInput, type UpdateContentInput, type UpdateCouponDto, type UpdateCustomerDto, type UpdateDraftDto, type UpdateEmailSettingsDto as UpdateEmailSettingsInput, type UpdateEmailTemplateDto as UpdateEmailTemplateInput, type UpdateInventoryDto, type UpdateMemberRoleDto as UpdateMemberRoleInput, type UpdateMetafieldDefinitionDto as UpdateMetafieldDefinitionInput, type UpdateModifierGroupInput, type UpdateModifierInput, type UpdateNewsletterBenefitSettingsInput, type UpdateOAuthProviderDto as UpdateOAuthProviderInput, type UpdateOrderDto, type UpdateOrderShippingDto, type UpdateProductDto, type UpdateRegionDto, type UpdateShippingRateDto as UpdateShippingRateInput, type UpdateShippingZoneDto as UpdateShippingZoneInput, type UpdateStoreMemberDto as UpdateStoreMemberInput, type UpdateTagDto as UpdateTagInput, type UpdateTaxClassDto, type UpdateTaxRateDto as UpdateTaxRateInput, type UpdateVariantDto, type UpdateVariantInventoryDto, type UpsellSettings, type UpsertProductMetafieldDto as UpsertProductMetafieldInput, type UserStore, type UserStorePermissions, type VariantInventoryResponse, type VariantPlatformOverlay, type VariantStatus, type WaitForOrderOptions, type WaitForOrderResult, type WebhookEvent, type WebhookEventType, type WriteProductReviewInput, buildArticleJsonLd, buildBreadcrumbJsonLd, buildCollectionPageJsonLd, buildOrganizationJsonLd, buildProductFaqJsonLd, buildProductJsonLd, buildWebsiteJsonLd, computeAvailableSlots, createWebhookHandler, deriveSeoDescription, enableDevGuards, formatMoney, formatPrice, formatProductPrice, formatVariantPrice, getBlogSitemapEntries, getBusinessHoursForDate, getCartItemImage, getCartItemName, getCartTotals, getCategorySitemapEntries, getDescriptionContent, getDirectionForLocale, formatPrice as getPriceDisplay, getProductCustomizationFields, getProductMetafield, getProductMetafieldValue, getProductMetafieldsByType, getProductPrice, getProductPriceInfo, getProductSitemapEntries, getProductSwatches, getStockStatus, getVariantOptions, getVariantPrice, isAllowedPaymentUrl, isCalendarDateAllowed, isCouponApplicableToProduct, isDateValueAllowed, isHtmlDescription, isWebhookEventType, jsonLdScriptProps, parseDateFieldValue, parseWebhookEvent, resolveRelativeBounds, resolveRenderType, resolveStoreLocalParts, safePaymentRedirect, stripHtml, validateDateAvailabilityConfig, verifyWebhook };
|
package/dist/index.d.ts
CHANGED
|
@@ -2381,6 +2381,66 @@ interface CreateOrderDto {
|
|
|
2381
2381
|
interface UpdateOrderDto {
|
|
2382
2382
|
status?: OrderStatus;
|
|
2383
2383
|
}
|
|
2384
|
+
/**
|
|
2385
|
+
* A merchant-defined field that can hold a value on an order.
|
|
2386
|
+
*
|
|
2387
|
+
* These are the fields the STORE manages on an order (`adminFieldValues`), not
|
|
2388
|
+
* the ones a shopper fills in during checkout. They are how an integration
|
|
2389
|
+
* attaches data that only exists after the purchase — a licence key, a booking
|
|
2390
|
+
* reference, a warranty number issued by a third party — to the order it
|
|
2391
|
+
* belongs to. What is written travels to the merchant's own order email
|
|
2392
|
+
* templates as `orderCustomFields`, so the customer can be told without a
|
|
2393
|
+
* bespoke email being built for each integration.
|
|
2394
|
+
*
|
|
2395
|
+
* ⛔ No default template PRINTS it. The merchant adds the block to their
|
|
2396
|
+
* template once; until then a written value is invisible to the customer.
|
|
2397
|
+
*/
|
|
2398
|
+
interface OrderCustomFieldDefinition {
|
|
2399
|
+
id: string;
|
|
2400
|
+
storeId: string;
|
|
2401
|
+
/** Display label. Renders beside the value in order emails. */
|
|
2402
|
+
name: string;
|
|
2403
|
+
/** The property name to use in `setOrderCustomFieldValues`. */
|
|
2404
|
+
key: string;
|
|
2405
|
+
description: string | null;
|
|
2406
|
+
type: 'TEXT' | 'TEXTAREA' | 'NUMBER' | 'BOOLEAN' | 'SELECT' | 'DATE' | 'DATETIME' | 'IMAGE';
|
|
2407
|
+
/** A required field cannot be cleared once it holds a value. */
|
|
2408
|
+
required: boolean;
|
|
2409
|
+
/**
|
|
2410
|
+
* When true the value is exposed to the storefront through the SDK, so the
|
|
2411
|
+
* customer can see it on their own order page and not only in the email.
|
|
2412
|
+
*/
|
|
2413
|
+
isPublic: boolean;
|
|
2414
|
+
position: number;
|
|
2415
|
+
/**
|
|
2416
|
+
* An inactive definition refuses new values but still resolves its label on
|
|
2417
|
+
* orders that already carry one.
|
|
2418
|
+
*/
|
|
2419
|
+
isActive: boolean;
|
|
2420
|
+
/** SELECT only. */
|
|
2421
|
+
options?: Array<{
|
|
2422
|
+
value: string;
|
|
2423
|
+
label: string;
|
|
2424
|
+
}> | null;
|
|
2425
|
+
minLength?: number | null;
|
|
2426
|
+
maxLength?: number | null;
|
|
2427
|
+
minValue?: string | null;
|
|
2428
|
+
maxValue?: string | null;
|
|
2429
|
+
dateAvailability?: unknown;
|
|
2430
|
+
translations?: Record<string, unknown> | null;
|
|
2431
|
+
createdAt: string;
|
|
2432
|
+
updatedAt: string;
|
|
2433
|
+
}
|
|
2434
|
+
/** The custom field values stored on one order, keyed by definition `key`. */
|
|
2435
|
+
interface OrderCustomFieldValues {
|
|
2436
|
+
orderId: string;
|
|
2437
|
+
/**
|
|
2438
|
+
* Values AFTER coercion to each field's type — a NUMBER field written as
|
|
2439
|
+
* `'5'` reads back as `5`. Keys with no matching definition were never
|
|
2440
|
+
* stored and so never appear here.
|
|
2441
|
+
*/
|
|
2442
|
+
fields: Record<string, unknown>;
|
|
2443
|
+
}
|
|
2384
2444
|
interface UpdateInventoryDto {
|
|
2385
2445
|
quantity: number;
|
|
2386
2446
|
variantId?: string;
|
|
@@ -4970,9 +5030,38 @@ interface PublishProductResponse {
|
|
|
4970
5030
|
* Returned by the backend in provider config and payment intents.
|
|
4971
5031
|
* The frontend dynamically loads the SDK script and calls init/render methods.
|
|
4972
5032
|
*/
|
|
5033
|
+
/**
|
|
5034
|
+
* Every way a provider can present its payment surface. `PaymentClientSdk.renderType`
|
|
5035
|
+
* is one of these; `PaymentClientSdk.displayModes` lists the ones the provider
|
|
5036
|
+
* can serve.
|
|
5037
|
+
*/
|
|
5038
|
+
type PaymentRenderType = 'sdk-widget' | 'iframe' | 'redirect' | 'sandbox' | 'embedded-fields';
|
|
5039
|
+
/**
|
|
5040
|
+
* The render modes a storefront may ASK for via
|
|
5041
|
+
* `createPaymentIntent(id, { preferredRenderType })`. Deliberately only the
|
|
5042
|
+
* two presentation choices: `sdk-widget`, `embedded-fields` and `sandbox` are
|
|
5043
|
+
* integration mechanisms a storefront cannot substitute at will.
|
|
5044
|
+
*/
|
|
5045
|
+
type PreferredRenderType = 'redirect' | 'iframe';
|
|
5046
|
+
/**
|
|
5047
|
+
* Why the `clientSdk.renderType` on a `PaymentIntent` is what it is.
|
|
5048
|
+
*
|
|
5049
|
+
* - `'preferred'` — you asked for a mode and the provider supports it.
|
|
5050
|
+
* - `'fallback'` — you asked for a mode the provider does not declare;
|
|
5051
|
+
* you got the provider's default instead.
|
|
5052
|
+
* - `'provider-default'` — you did not ask (or the intent is a sandbox one).
|
|
5053
|
+
*/
|
|
5054
|
+
type RenderModeResolution = 'preferred' | 'fallback' | 'provider-default';
|
|
4973
5055
|
interface PaymentClientSdk {
|
|
4974
5056
|
/** How the payment UI is rendered: 'sdk-widget' (JS SDK), 'iframe', 'redirect', 'sandbox' (test orders), or 'embedded-fields' (PCI-compliant provider-hosted fields embedded in merchant DOM, e.g. Cardcom OpenFields, Stripe Elements) */
|
|
4975
|
-
renderType:
|
|
5057
|
+
renderType: PaymentRenderType;
|
|
5058
|
+
/**
|
|
5059
|
+
* Every render mode this provider can serve. `renderType` is the default;
|
|
5060
|
+
* `preferredRenderType` on `createPaymentIntent` is honoured only if it is in
|
|
5061
|
+
* this list. Absent on legacy manifests — treat as `[renderType]`, which is
|
|
5062
|
+
* exactly what `resolveRenderType()` does.
|
|
5063
|
+
*/
|
|
5064
|
+
displayModes?: PaymentRenderType[];
|
|
4976
5065
|
/** URL of the main SDK script to load */
|
|
4977
5066
|
scriptUrl?: string;
|
|
4978
5067
|
/** Name of the global variable set by the SDK script (e.g., 'growPayment') */
|
|
@@ -5142,6 +5231,14 @@ interface PaymentIntent {
|
|
|
5142
5231
|
provider?: string;
|
|
5143
5232
|
/** Runtime client SDK overrides (merged with provider manifest config) */
|
|
5144
5233
|
clientSdk?: PaymentClientSdk;
|
|
5234
|
+
/**
|
|
5235
|
+
* Why the returned `clientSdk.renderType` is what it is — see
|
|
5236
|
+
* `RenderModeResolution`. Lets a storefront that asked for `iframe` and got
|
|
5237
|
+
* `redirect` tell "the provider does not support iframe" (`'fallback'`) from
|
|
5238
|
+
* "I never asked" (`'provider-default'`). Absent from older backends; always
|
|
5239
|
+
* branch on the `renderType` you got back, never on what you asked for.
|
|
5240
|
+
*/
|
|
5241
|
+
renderModeResolution?: RenderModeResolution;
|
|
5145
5242
|
}
|
|
5146
5243
|
/**
|
|
5147
5244
|
* The stored payment-record vocabulary. **UPPERCASE.**
|
|
@@ -8122,8 +8219,20 @@ interface TrackEventPayload {
|
|
|
8122
8219
|
/** Active dwell time in ms. Only meaningful for `eventType: 'engagement'`. Max 1 800 000 (30 min). */
|
|
8123
8220
|
engagedMs?: number;
|
|
8124
8221
|
}
|
|
8222
|
+
/**
|
|
8223
|
+
* The JSON body of any non-2xx response. `BrainerceError.details` holds a value
|
|
8224
|
+
* of this shape (the raw parsed body), so from a caught SDK error the code is
|
|
8225
|
+
* at `err.details.code`, one level deeper than it sits on the wire.
|
|
8226
|
+
*/
|
|
8125
8227
|
interface BrainerceApiError {
|
|
8126
8228
|
statusCode: number;
|
|
8229
|
+
/**
|
|
8230
|
+
* The stable, machine-readable error code — switch on THIS, never on
|
|
8231
|
+
* `message`, whose wording can change at any time. Always present: the API
|
|
8232
|
+
* derives a generic code from the status when a route supplies none.
|
|
8233
|
+
* The full list is at https://brainerce.com/docs/api/errors.
|
|
8234
|
+
*/
|
|
8235
|
+
code?: string;
|
|
8127
8236
|
message: string;
|
|
8128
8237
|
error?: string;
|
|
8129
8238
|
details?: unknown;
|
|
@@ -9121,6 +9230,63 @@ declare class BrainerceClient {
|
|
|
9121
9230
|
* Update an order (e.g., change status)
|
|
9122
9231
|
*/
|
|
9123
9232
|
updateOrder(orderId: string, data: UpdateOrderDto): Promise<Order>;
|
|
9233
|
+
/**
|
|
9234
|
+
* List the store's order custom field definitions.
|
|
9235
|
+
*
|
|
9236
|
+
* Call this before writing values: the `key` of each definition is what
|
|
9237
|
+
* {@link setOrderCustomFieldValues} accepts, and `type` is what a value has
|
|
9238
|
+
* to fit. Inactive definitions are included, so you can tell "the merchant
|
|
9239
|
+
* turned this field off" apart from "the merchant never created it".
|
|
9240
|
+
*
|
|
9241
|
+
* Requires an API key with the `orders:read` scope.
|
|
9242
|
+
*/
|
|
9243
|
+
getOrderCustomFieldDefinitions(): Promise<OrderCustomFieldDefinition[]>;
|
|
9244
|
+
/**
|
|
9245
|
+
* Read the custom field values stored on one order.
|
|
9246
|
+
*
|
|
9247
|
+
* Requires an API key with the `orders:read` scope.
|
|
9248
|
+
*/
|
|
9249
|
+
getOrderCustomFieldValues(orderId: string): Promise<OrderCustomFieldValues>;
|
|
9250
|
+
/**
|
|
9251
|
+
* Write custom field values onto an order.
|
|
9252
|
+
*
|
|
9253
|
+
* This is how work that finishes OUTSIDE Brainerce gets back onto the order
|
|
9254
|
+
* it belongs to. Subscribe to the `order.paid` webhook, call whatever third
|
|
9255
|
+
* party issues the thing you sell — a licence key, a booking reference, a
|
|
9256
|
+
* warranty number — then write the answer here. The value travels to the
|
|
9257
|
+
* merchant's own order email templates as `orderCustomFields` and, when the
|
|
9258
|
+
* definition is `isPublic`, to the customer's own order page. No email
|
|
9259
|
+
* template or endpoint has to be built per integration.
|
|
9260
|
+
*
|
|
9261
|
+
* ⛔ No default template PRINTS `orderCustomFields`. The variable reaches
|
|
9262
|
+
* every order email, but until the merchant adds the block to their template
|
|
9263
|
+
* once, a value written here is invisible to the customer. Writing the field
|
|
9264
|
+
* is not the same as the customer being told.
|
|
9265
|
+
*
|
|
9266
|
+
* The write is a MERGE: keys you leave out keep their current value, and
|
|
9267
|
+
* `null` clears a field that is not required. Values are coerced to the
|
|
9268
|
+
* definition's type and rejected with a 400 when they cannot be — but a key
|
|
9269
|
+
* with no active definition on the store is IGNORED rather than failing the
|
|
9270
|
+
* whole call, so read the returned `fields` to confirm what was stored.
|
|
9271
|
+
*
|
|
9272
|
+
* Pass an `idempotencyKey` when the caller may retry: an identical re-send
|
|
9273
|
+
* then replays the original response instead of writing again.
|
|
9274
|
+
*
|
|
9275
|
+
* Requires an API key with the `orders:write` scope.
|
|
9276
|
+
*
|
|
9277
|
+
* @example
|
|
9278
|
+
* ```typescript
|
|
9279
|
+
* // after the third party answered
|
|
9280
|
+
* await client.setOrderCustomFieldValues(
|
|
9281
|
+
* order.id,
|
|
9282
|
+
* { licence_key: 'ABCD-EFGH-IJKL' },
|
|
9283
|
+
* { idempotencyKey: `licence-${order.id}` }
|
|
9284
|
+
* );
|
|
9285
|
+
* // fires the "order completed" email, which carries the field
|
|
9286
|
+
* await client.updateOrder(order.id, { status: 'COMPLETED' });
|
|
9287
|
+
* ```
|
|
9288
|
+
*/
|
|
9289
|
+
setOrderCustomFieldValues(orderId: string, fields: Record<string, unknown>, options?: IdempotentRequestOptions): Promise<OrderCustomFieldValues>;
|
|
9124
9290
|
/**
|
|
9125
9291
|
* Update order status.
|
|
9126
9292
|
*
|
|
@@ -12028,6 +12194,25 @@ declare class BrainerceClient {
|
|
|
12028
12194
|
* subscription features.
|
|
12029
12195
|
*/
|
|
12030
12196
|
saveCard?: boolean;
|
|
12197
|
+
/**
|
|
12198
|
+
* How you would like the provider's payment surface presented. The
|
|
12199
|
+
* platform honours it when the provider supports that mode (it is
|
|
12200
|
+
* listed in the provider's `clientSdk.displayModes`), and otherwise
|
|
12201
|
+
* falls back to the provider's default — so always branch on the
|
|
12202
|
+
* `clientSdk.renderType` you get BACK, never on what you asked for.
|
|
12203
|
+
* The response's `renderModeResolution` says which happened. Omit to
|
|
12204
|
+
* take the provider's default.
|
|
12205
|
+
*
|
|
12206
|
+
* To pick the matching `successUrl` up front, call
|
|
12207
|
+
* `resolveRenderType(provider.clientSdk, preferred)` on the entry from
|
|
12208
|
+
* `getPaymentProviders()` — it applies the same rule the platform does.
|
|
12209
|
+
* An iframe intent returns the shopper INSIDE the frame, so its
|
|
12210
|
+
* `successUrl` must be a same-origin page that posts to the parent; a
|
|
12211
|
+
* redirect intent can return straight to the confirmation page.
|
|
12212
|
+
*
|
|
12213
|
+
* A value outside `'redirect' | 'iframe'` is rejected with 400.
|
|
12214
|
+
*/
|
|
12215
|
+
preferredRenderType?: PreferredRenderType;
|
|
12031
12216
|
}): Promise<PaymentIntent>;
|
|
12032
12217
|
/**
|
|
12033
12218
|
* Get payment status for a checkout.
|
|
@@ -14186,7 +14371,7 @@ declare class BrainerceError extends Error {
|
|
|
14186
14371
|
constructor(message: string, statusCode: number, details?: unknown);
|
|
14187
14372
|
}
|
|
14188
14373
|
|
|
14189
|
-
declare const SDK_VERSION = "2.
|
|
14374
|
+
declare const SDK_VERSION = "2.9.0";
|
|
14190
14375
|
|
|
14191
14376
|
/**
|
|
14192
14377
|
* Verify a webhook signature from Brainerce
|
|
@@ -14289,6 +14474,40 @@ declare function isAllowedPaymentUrl(url: string, options?: PaymentUrlOptions):
|
|
|
14289
14474
|
*/
|
|
14290
14475
|
declare function safePaymentRedirect(url: string, options?: PaymentUrlOptions): void;
|
|
14291
14476
|
|
|
14477
|
+
/**
|
|
14478
|
+
* Predict the `clientSdk.renderType` the platform will return for a given
|
|
14479
|
+
* provider and preference.
|
|
14480
|
+
*
|
|
14481
|
+
* Rules (identical to the platform's):
|
|
14482
|
+
* 1. No preference → the provider default.
|
|
14483
|
+
* 2. Preference declared in `displayModes` → the preference.
|
|
14484
|
+
* 3. Preference NOT declared → the provider default (the platform reports
|
|
14485
|
+
* `renderModeResolution: 'fallback'` on the intent).
|
|
14486
|
+
* 4. `displayModes` absent (legacy manifest) → treated as `[renderType]`.
|
|
14487
|
+
*
|
|
14488
|
+
* @param sdk - The `clientSdk` of an entry from `getPaymentProviders()`
|
|
14489
|
+
* (`defaultProvider.clientSdk` or `providers[i].clientSdk`).
|
|
14490
|
+
* @param preferred - The mode you intend to pass as `preferredRenderType`.
|
|
14491
|
+
* @returns The mode the intent will come back with. `'redirect'` when there is
|
|
14492
|
+
* no provider at all, so a storefront can always pick a return URL.
|
|
14493
|
+
*
|
|
14494
|
+
* @example
|
|
14495
|
+
* ```typescript
|
|
14496
|
+
* const { defaultProvider } = await client.getPaymentProviders();
|
|
14497
|
+
* const expected = resolveRenderType(defaultProvider?.clientSdk, 'iframe');
|
|
14498
|
+
* const successUrl = expected === 'iframe'
|
|
14499
|
+
* ? `${origin}/payment-complete?checkout_id=${checkoutId}`
|
|
14500
|
+
* : `${origin}/order-confirmation?checkout_id=${checkoutId}`;
|
|
14501
|
+
* const intent = await client.createPaymentIntent(checkoutId, {
|
|
14502
|
+
* preferredRenderType: 'iframe',
|
|
14503
|
+
* successUrl,
|
|
14504
|
+
* });
|
|
14505
|
+
* // Still branch on what came BACK — never on what you asked for.
|
|
14506
|
+
* if (intent.clientSdk?.renderType === 'iframe') { ... }
|
|
14507
|
+
* ```
|
|
14508
|
+
*/
|
|
14509
|
+
declare function resolveRenderType(sdk: Pick<PaymentClientSdk, 'renderType' | 'displayModes'> | null | undefined, preferred?: PreferredRenderType): PaymentRenderType;
|
|
14510
|
+
|
|
14292
14511
|
interface FormatProductPriceOptions {
|
|
14293
14512
|
/**
|
|
14294
14513
|
* BCP-47 locale for `Intl.NumberFormat`. Controls number grouping and
|
|
@@ -14687,4 +14906,4 @@ interface CategorySitemapOptions {
|
|
|
14687
14906
|
*/
|
|
14688
14907
|
declare function getCategorySitemapEntries(client: BrainerceClient, opts: CategorySitemapOptions): Promise<SitemapEntry[]>;
|
|
14689
14908
|
|
|
14690
|
-
export { type AddToCartDto, type AddressDetailsResult, type AddressSuggestion, type AiTranslateBulkInput, type AiTranslateBulkResult, type AiTranslateSingleInput, type AnnouncementContent, type AnnouncementSeverity, type AppliedDiscount, type ApplyCouponDto, type AssignTaxClassDto, type AttachModifierGroupInput, type Attribute, type AttributeDisplayType, type AttributeOption, type AttributeSource, type AutoRegionResponse, type AvailabilityClock, type BlogPost, type BlogPostListParams, type BlogPostListResponse, type BlogSitemapOptions, type BrainerceApiError, BrainerceClient, type BrainerceClientOptions, BrainerceError, type Brand, type BulkCreateProductsDto, type BulkCreateProductsError, type BulkCreateProductsJob, type BulkCreateProductsStatus, type BulkInventoryResponse, type BulkSaveVariantsDto, type BulkSaveVariantsResponse, type BulkVariantInput, type BusinessHoursWindow, type Cart, type CartAppliedDiscount, type CartBundleOffer, type CartBundleOfferOfferedProduct, type CartBundlesResponse, type CartIncludeOption, type CartIncludeOptions, type CartItem, type CartItemModifierLine, type CartItemUnavailableReason, type CartNudge, type CartRecommendationsResponse, type CartStatus, type CartUpgradeSuggestion, type CartUpgradesResponse, type CartWithIncludes, type Category, type CategoryDetail, type CategoryNode, type CategorySitemapOptions, type CategorySuggestion, type Checkout, type CheckoutAddress, type CheckoutBumpsResponse, type CheckoutCustomFieldDefinition, type CheckoutFieldPricing, type CheckoutFieldVisibility, type CheckoutLineItem, type CheckoutPrefillData, type CheckoutStatus, type CheckoutTender, type CompleteCheckoutResponse, type CompleteDraftDto, type ConfigureOAuthProviderDto as ConfigureOAuthProviderInput, type ConflictStatus, type ConnectorPlatform, type ContactFormFieldType, type ContactFormFieldValidation, type ContactFormPublic, type ContactFormPublicField, type ContactFormSummary, type Content, type ContentDataMap, type ContentStatus, type ContentSummary, type ContentType, type Coupon, type CouponCreateResponse, type CouponQueryParams, type CouponStatus, type CouponType, type CouponValidationWarning, type CreateAddressDto, type CreateAttributeDto as CreateAttributeInput, type CreateAttributeOptionDto as CreateAttributeOptionInput, type CreateBrandDto as CreateBrandInput, type CreateCategoryDto as CreateCategoryInput, type CreateCheckoutDto, type CreateContentInput, type CreateCouponDto, type CreateCustomerDto, type CreateEmailTemplateDto as CreateEmailTemplateInput, type CreateGuestOrderDto, type CreateInquiryInput, type CreateInquiryResponse, type CreateMetafieldDefinitionDto as CreateMetafieldDefinitionInput, type CreateModifierGroupInput, type CreateModifierInput, type CreateOrderDto, type CreateProductDto, type CreateRefundDto, type CreateRegionDto, type CreateReturnLabelDto as CreateReturnLabelInput, type CreateReturnLabelResponse, type CreateShippingRateDto as CreateShippingRateInput, type CreateShippingZoneDto as CreateShippingZoneInput, type CreateStockAlertInput, type CreateTagDto as CreateTagInput, type CreateTaxClassDto, type CreateTaxRateDto as CreateTaxRateInput, type CreateVariantDto, type Customer, type CustomerAddress, type CustomerAuthResponse, type CustomerOAuthProvider, type CustomerProfile, type CustomerQueryParams, type CustomizationFieldOption, type DateAvailabilityConstraints, type DateAvailabilitySurface, type DateFieldParseResult, type DeleteProductResponse, type DeliveryType, type DiscountBanner, type DiscountRuleType, type DownloadFile, type DraftLineItem, type EditInventoryDto, type EmailDomain, type EmailEventSettings, type EmailEventType, type EmailSettings, type EmailTemplate, type EmailTemplatePreview, type EmailTemplatesResponse, type EmailVerificationResponse, type ExtendReservationResponse, type FaqContent, type FaqItem, type FooterColumn, type FooterContent, type FooterLink, type FooterSocialLink, type FormatPriceOptions, type FormatProductPriceOptions, type FreeAllocationPolicy, type FulfillOrderDto, type GiftCardAdmin, type GiftCardAdminDetail, type GiftCardBalance, type GiftCardLiability, type GiftCardTransaction, type GuestCheckoutStartResponse, type GuestOrderResponse, type HeaderContent, type HeaderCta, type HeaderLogo, type HeaderNavItem, type I18nSettings, type IdempotentRequestOptions, type InsufficientStockError, type InventoryInfo, type InventoryReservationStrategy, type InventorySyncStatus, type InventoryTrackingMode, type InvitationStatus, type InviteMemberDto as InviteMemberInput, type InviteStoreMemberDto as InviteStoreMemberInput, type IssueGiftCardAdminDto, type IssuedGiftCardAdmin, type JsonLdOptions, type ListModifierGroupsParams, type ListNewsletterBenefitGrantsParams, type LocalCart, type LocalCartItem, type LocaleTranslation, type LockedVariant, type LoyaltyBadge, type LoyaltyMembershipPlan, type LoyaltyNextTierSummary, type LoyaltyReward, type LoyaltyRewardRecommendation, type LoyaltyStatus, type LoyaltyTierSummary, type MergeCartsDto, type MetafieldConflict, type MetafieldConflictResolution, type MetafieldDefinition, type MetafieldFilter, type MetafieldFilterValue, type MetafieldFiltersResponse, type MetafieldType, type Modifier, type ModifierGroup, type ModifierSelection, type ModifierSelectionType, type ModifierValidationCode, type ModifierValidationError, type ModifierValidationFailedError, type MyProductReview, type NestedModifierSelection, type NewsletterBenefitDiscountKind, type NewsletterBenefitGrant, type NewsletterBenefitGrantState, type NewsletterBenefitSettings, type OAuthAuthorizeResponse, type OAuthCallbackResponse, type OAuthConnection, type OAuthConnectionsResponse, type OAuthErrorCode, type OAuthProviderConfig, type OAuthProviderType, type OAuthProvidersResponse, type Order, type OrderAddress, type OrderBump, type OrderCustomer, type OrderDownloadLink, type OrderItem, type OrderQueryParams, type OrderStatus, type OrderStatusChange, type PageContent, type PageSeo, type PaginatedResponse, type PaidMembershipInfo, type ParsedDateFieldValue, type PaymentClientSdk, type PaymentConfig, type PaymentIntent, type PaymentProvider, type PaymentProviderConfig, type PaymentProvidersConfig, type PaymentRecordStatus, type PaymentStatus, type PaymentUrlOptions, type PickupLocation, type PlatformCouponCapabilities, type PlatformMetafieldMetadata, type PreviewEmailTemplateDto as PreviewEmailTemplateInput, type PriceDriftError, type Product, type ProductAttributeInput, type ProductAvailability, type ProductCustomizationField, type ProductDiscount, type ProductDiscountBadge, type ProductImage, type ProductInventoryResponse, type ProductMetafield, type ProductMetafieldValue, type ProductModifierGroupAttachment, type ProductQueryParams, type ProductRecommendation, type ProductRecommendationsResponse, type ProductRelationType, type ProductReview, type ProductReviewAdmin, type ProductReviewImage, type ProductReviewImageAdmin, type ProductSitemapOptions, type ProductStatus, type ProductSuggestion, type ProductUnavailableError, type ProductVariant, type PublicMetafieldDefinition, type PublicNewsletterBenefitOffer, type PublicRegion, type PublicRegionDetail, type PublicRegionPaymentProvider, type PublicTaxClass, type PublishProductResponse, RTL_LOCALES, type RecommendationVariant, type ReconcileInventoryResponse, type RedeemRewardResult, type ReferralInfo, type Refund, type RefundLineItem, type RefundLineItemResponse, type RefundType, type Region, type RegionPaymentProvider, type RegisterCustomerDto, type ReissuedGiftCardAdmin, type RelativeDateBounds, type ResendNewsletterBenefitResult, type ReservationInfo, type ResolveMetafieldConflictDto as ResolveMetafieldConflictInput, type ResolveSyncConflictDto as ResolveSyncConflictInput, type ReturnLabelParcel, type ReviewPhotoUpload, type ReviewStatus, type RichTextContent, SDK_VERSION, type SavedPaymentMethodSummary, type SearchSuggestions, type SelectPickupLocationDto, type SelectShippingMethodDto, type SendInvoiceDto, type SessionCartRef, type SetBillingAddressDto, type SetCheckoutCustomFieldsDto, type SetCheckoutCustomerDto, type SetDefinitionProductsDto as SetDefinitionProductsInput, type SetMetafieldPlatformsDto as SetMetafieldPlatformsInput, type SetShippingAddressDto, type SetShippingAddressResponse, type SetTranslationFields, type ShippingDestinations, type ShippingLine, type ShippingRate, type ShippingRateConfig, type ShippingRateType, type ShippingSummaryEntry, type ShippingZone, type ShippingZoneQueryParams, type SitemapEntry, type StockAlertResponse, type StockAvailabilityRequest, type StockAvailabilityResponse, type StockAvailabilityResult, type StoreCapabilities, type StoreInfo, type StoreInvitation, type StoreInvitationDetails, type StoreMember, type StorePermission, type StoreRole, type StoreTeamResponse, type StoreTracking, type StorefrontSavedPaymentMethod, type SubmitProductReviewInput, type SubscribeMarketingInput, type SubscribeMarketingResponse, type SupportedLocaleObject, type SyncConflict, type SyncConflictResolution, type SyncJob, type Tag, type TaxBreakdown, type TaxBreakdownItem, type TaxClass, type TaxEstimateResponse, type TaxRate, type TaxonomyQueryParams, type TeamInvitation, type TeamInvitationsResponse, type TeamMember, type TeamMembersResponse, type TeamRole, type TrackingEventItem, type TrackingEventName, type TrackingEventPayload, type TranslatableEntityType, type TranslationStatusEntry, type TranslationsMap, type UpdateAddressDto, type UpdateAttachmentInput, type UpdateAttributeDto as UpdateAttributeInput, type UpdateAttributeOptionDto as UpdateAttributeOptionInput, type UpdateBrandDto as UpdateBrandInput, type UpdateCartItemDto, type UpdateCategoryDto as UpdateCategoryInput, type UpdateContentInput, type UpdateCouponDto, type UpdateCustomerDto, type UpdateDraftDto, type UpdateEmailSettingsDto as UpdateEmailSettingsInput, type UpdateEmailTemplateDto as UpdateEmailTemplateInput, type UpdateInventoryDto, type UpdateMemberRoleDto as UpdateMemberRoleInput, type UpdateMetafieldDefinitionDto as UpdateMetafieldDefinitionInput, type UpdateModifierGroupInput, type UpdateModifierInput, type UpdateNewsletterBenefitSettingsInput, type UpdateOAuthProviderDto as UpdateOAuthProviderInput, type UpdateOrderDto, type UpdateOrderShippingDto, type UpdateProductDto, type UpdateRegionDto, type UpdateShippingRateDto as UpdateShippingRateInput, type UpdateShippingZoneDto as UpdateShippingZoneInput, type UpdateStoreMemberDto as UpdateStoreMemberInput, type UpdateTagDto as UpdateTagInput, type UpdateTaxClassDto, type UpdateTaxRateDto as UpdateTaxRateInput, type UpdateVariantDto, type UpdateVariantInventoryDto, type UpsellSettings, type UpsertProductMetafieldDto as UpsertProductMetafieldInput, type UserStore, type UserStorePermissions, type VariantInventoryResponse, type VariantPlatformOverlay, type VariantStatus, type WaitForOrderOptions, type WaitForOrderResult, type WebhookEvent, type WebhookEventType, type WriteProductReviewInput, buildArticleJsonLd, buildBreadcrumbJsonLd, buildCollectionPageJsonLd, buildOrganizationJsonLd, buildProductFaqJsonLd, buildProductJsonLd, buildWebsiteJsonLd, computeAvailableSlots, createWebhookHandler, deriveSeoDescription, enableDevGuards, formatMoney, formatPrice, formatProductPrice, formatVariantPrice, getBlogSitemapEntries, getBusinessHoursForDate, getCartItemImage, getCartItemName, getCartTotals, getCategorySitemapEntries, getDescriptionContent, getDirectionForLocale, formatPrice as getPriceDisplay, getProductCustomizationFields, getProductMetafield, getProductMetafieldValue, getProductMetafieldsByType, getProductPrice, getProductPriceInfo, getProductSitemapEntries, getProductSwatches, getStockStatus, getVariantOptions, getVariantPrice, isAllowedPaymentUrl, isCalendarDateAllowed, isCouponApplicableToProduct, isDateValueAllowed, isHtmlDescription, isWebhookEventType, jsonLdScriptProps, parseDateFieldValue, parseWebhookEvent, resolveRelativeBounds, resolveStoreLocalParts, safePaymentRedirect, stripHtml, validateDateAvailabilityConfig, verifyWebhook };
|
|
14909
|
+
export { type AddToCartDto, type AddressDetailsResult, type AddressSuggestion, type AiTranslateBulkInput, type AiTranslateBulkResult, type AiTranslateSingleInput, type AnnouncementContent, type AnnouncementSeverity, type AppliedDiscount, type ApplyCouponDto, type AssignTaxClassDto, type AttachModifierGroupInput, type Attribute, type AttributeDisplayType, type AttributeOption, type AttributeSource, type AutoRegionResponse, type AvailabilityClock, type BlogPost, type BlogPostListParams, type BlogPostListResponse, type BlogSitemapOptions, type BrainerceApiError, BrainerceClient, type BrainerceClientOptions, BrainerceError, type Brand, type BulkCreateProductsDto, type BulkCreateProductsError, type BulkCreateProductsJob, type BulkCreateProductsStatus, type BulkInventoryResponse, type BulkSaveVariantsDto, type BulkSaveVariantsResponse, type BulkVariantInput, type BusinessHoursWindow, type Cart, type CartAppliedDiscount, type CartBundleOffer, type CartBundleOfferOfferedProduct, type CartBundlesResponse, type CartIncludeOption, type CartIncludeOptions, type CartItem, type CartItemModifierLine, type CartItemUnavailableReason, type CartNudge, type CartRecommendationsResponse, type CartStatus, type CartUpgradeSuggestion, type CartUpgradesResponse, type CartWithIncludes, type Category, type CategoryDetail, type CategoryNode, type CategorySitemapOptions, type CategorySuggestion, type Checkout, type CheckoutAddress, type CheckoutBumpsResponse, type CheckoutCustomFieldDefinition, type CheckoutFieldPricing, type CheckoutFieldVisibility, type CheckoutLineItem, type CheckoutPrefillData, type CheckoutStatus, type CheckoutTender, type CompleteCheckoutResponse, type CompleteDraftDto, type ConfigureOAuthProviderDto as ConfigureOAuthProviderInput, type ConflictStatus, type ConnectorPlatform, type ContactFormFieldType, type ContactFormFieldValidation, type ContactFormPublic, type ContactFormPublicField, type ContactFormSummary, type Content, type ContentDataMap, type ContentStatus, type ContentSummary, type ContentType, type Coupon, type CouponCreateResponse, type CouponQueryParams, type CouponStatus, type CouponType, type CouponValidationWarning, type CreateAddressDto, type CreateAttributeDto as CreateAttributeInput, type CreateAttributeOptionDto as CreateAttributeOptionInput, type CreateBrandDto as CreateBrandInput, type CreateCategoryDto as CreateCategoryInput, type CreateCheckoutDto, type CreateContentInput, type CreateCouponDto, type CreateCustomerDto, type CreateEmailTemplateDto as CreateEmailTemplateInput, type CreateGuestOrderDto, type CreateInquiryInput, type CreateInquiryResponse, type CreateMetafieldDefinitionDto as CreateMetafieldDefinitionInput, type CreateModifierGroupInput, type CreateModifierInput, type CreateOrderDto, type CreateProductDto, type CreateRefundDto, type CreateRegionDto, type CreateReturnLabelDto as CreateReturnLabelInput, type CreateReturnLabelResponse, type CreateShippingRateDto as CreateShippingRateInput, type CreateShippingZoneDto as CreateShippingZoneInput, type CreateStockAlertInput, type CreateTagDto as CreateTagInput, type CreateTaxClassDto, type CreateTaxRateDto as CreateTaxRateInput, type CreateVariantDto, type Customer, type CustomerAddress, type CustomerAuthResponse, type CustomerOAuthProvider, type CustomerProfile, type CustomerQueryParams, type CustomizationFieldOption, type DateAvailabilityConstraints, type DateAvailabilitySurface, type DateFieldParseResult, type DeleteProductResponse, type DeliveryType, type DiscountBanner, type DiscountRuleType, type DownloadFile, type DraftLineItem, type EditInventoryDto, type EmailDomain, type EmailEventSettings, type EmailEventType, type EmailSettings, type EmailTemplate, type EmailTemplatePreview, type EmailTemplatesResponse, type EmailVerificationResponse, type ExtendReservationResponse, type FaqContent, type FaqItem, type FooterColumn, type FooterContent, type FooterLink, type FooterSocialLink, type FormatPriceOptions, type FormatProductPriceOptions, type FreeAllocationPolicy, type FulfillOrderDto, type GiftCardAdmin, type GiftCardAdminDetail, type GiftCardBalance, type GiftCardLiability, type GiftCardTransaction, type GuestCheckoutStartResponse, type GuestOrderResponse, type HeaderContent, type HeaderCta, type HeaderLogo, type HeaderNavItem, type I18nSettings, type IdempotentRequestOptions, type InsufficientStockError, type InventoryInfo, type InventoryReservationStrategy, type InventorySyncStatus, type InventoryTrackingMode, type InvitationStatus, type InviteMemberDto as InviteMemberInput, type InviteStoreMemberDto as InviteStoreMemberInput, type IssueGiftCardAdminDto, type IssuedGiftCardAdmin, type JsonLdOptions, type ListModifierGroupsParams, type ListNewsletterBenefitGrantsParams, type LocalCart, type LocalCartItem, type LocaleTranslation, type LockedVariant, type LoyaltyBadge, type LoyaltyMembershipPlan, type LoyaltyNextTierSummary, type LoyaltyReward, type LoyaltyRewardRecommendation, type LoyaltyStatus, type LoyaltyTierSummary, type MergeCartsDto, type MetafieldConflict, type MetafieldConflictResolution, type MetafieldDefinition, type MetafieldFilter, type MetafieldFilterValue, type MetafieldFiltersResponse, type MetafieldType, type Modifier, type ModifierGroup, type ModifierSelection, type ModifierSelectionType, type ModifierValidationCode, type ModifierValidationError, type ModifierValidationFailedError, type MyProductReview, type NestedModifierSelection, type NewsletterBenefitDiscountKind, type NewsletterBenefitGrant, type NewsletterBenefitGrantState, type NewsletterBenefitSettings, type OAuthAuthorizeResponse, type OAuthCallbackResponse, type OAuthConnection, type OAuthConnectionsResponse, type OAuthErrorCode, type OAuthProviderConfig, type OAuthProviderType, type OAuthProvidersResponse, type Order, type OrderAddress, type OrderBump, type OrderCustomFieldDefinition, type OrderCustomFieldValues, type OrderCustomer, type OrderDownloadLink, type OrderItem, type OrderQueryParams, type OrderStatus, type OrderStatusChange, type PageContent, type PageSeo, type PaginatedResponse, type PaidMembershipInfo, type ParsedDateFieldValue, type PaymentClientSdk, type PaymentConfig, type PaymentIntent, type PaymentProvider, type PaymentProviderConfig, type PaymentProvidersConfig, type PaymentRecordStatus, type PaymentRenderType, type PaymentStatus, type PaymentUrlOptions, type PickupLocation, type PlatformCouponCapabilities, type PlatformMetafieldMetadata, type PreferredRenderType, type PreviewEmailTemplateDto as PreviewEmailTemplateInput, type PriceDriftError, type Product, type ProductAttributeInput, type ProductAvailability, type ProductCustomizationField, type ProductDiscount, type ProductDiscountBadge, type ProductImage, type ProductInventoryResponse, type ProductMetafield, type ProductMetafieldValue, type ProductModifierGroupAttachment, type ProductQueryParams, type ProductRecommendation, type ProductRecommendationsResponse, type ProductRelationType, type ProductReview, type ProductReviewAdmin, type ProductReviewImage, type ProductReviewImageAdmin, type ProductSitemapOptions, type ProductStatus, type ProductSuggestion, type ProductUnavailableError, type ProductVariant, type PublicMetafieldDefinition, type PublicNewsletterBenefitOffer, type PublicRegion, type PublicRegionDetail, type PublicRegionPaymentProvider, type PublicTaxClass, type PublishProductResponse, RTL_LOCALES, type RecommendationVariant, type ReconcileInventoryResponse, type RedeemRewardResult, type ReferralInfo, type Refund, type RefundLineItem, type RefundLineItemResponse, type RefundType, type Region, type RegionPaymentProvider, type RegisterCustomerDto, type ReissuedGiftCardAdmin, type RelativeDateBounds, type RenderModeResolution, type ResendNewsletterBenefitResult, type ReservationInfo, type ResolveMetafieldConflictDto as ResolveMetafieldConflictInput, type ResolveSyncConflictDto as ResolveSyncConflictInput, type ReturnLabelParcel, type ReviewPhotoUpload, type ReviewStatus, type RichTextContent, SDK_VERSION, type SavedPaymentMethodSummary, type SearchSuggestions, type SelectPickupLocationDto, type SelectShippingMethodDto, type SendInvoiceDto, type SessionCartRef, type SetBillingAddressDto, type SetCheckoutCustomFieldsDto, type SetCheckoutCustomerDto, type SetDefinitionProductsDto as SetDefinitionProductsInput, type SetMetafieldPlatformsDto as SetMetafieldPlatformsInput, type SetShippingAddressDto, type SetShippingAddressResponse, type SetTranslationFields, type ShippingDestinations, type ShippingLine, type ShippingRate, type ShippingRateConfig, type ShippingRateType, type ShippingSummaryEntry, type ShippingZone, type ShippingZoneQueryParams, type SitemapEntry, type StockAlertResponse, type StockAvailabilityRequest, type StockAvailabilityResponse, type StockAvailabilityResult, type StoreCapabilities, type StoreInfo, type StoreInvitation, type StoreInvitationDetails, type StoreMember, type StorePermission, type StoreRole, type StoreTeamResponse, type StoreTracking, type StorefrontSavedPaymentMethod, type SubmitProductReviewInput, type SubscribeMarketingInput, type SubscribeMarketingResponse, type SupportedLocaleObject, type SyncConflict, type SyncConflictResolution, type SyncJob, type Tag, type TaxBreakdown, type TaxBreakdownItem, type TaxClass, type TaxEstimateResponse, type TaxRate, type TaxonomyQueryParams, type TeamInvitation, type TeamInvitationsResponse, type TeamMember, type TeamMembersResponse, type TeamRole, type TrackingEventItem, type TrackingEventName, type TrackingEventPayload, type TranslatableEntityType, type TranslationStatusEntry, type TranslationsMap, type UpdateAddressDto, type UpdateAttachmentInput, type UpdateAttributeDto as UpdateAttributeInput, type UpdateAttributeOptionDto as UpdateAttributeOptionInput, type UpdateBrandDto as UpdateBrandInput, type UpdateCartItemDto, type UpdateCategoryDto as UpdateCategoryInput, type UpdateContentInput, type UpdateCouponDto, type UpdateCustomerDto, type UpdateDraftDto, type UpdateEmailSettingsDto as UpdateEmailSettingsInput, type UpdateEmailTemplateDto as UpdateEmailTemplateInput, type UpdateInventoryDto, type UpdateMemberRoleDto as UpdateMemberRoleInput, type UpdateMetafieldDefinitionDto as UpdateMetafieldDefinitionInput, type UpdateModifierGroupInput, type UpdateModifierInput, type UpdateNewsletterBenefitSettingsInput, type UpdateOAuthProviderDto as UpdateOAuthProviderInput, type UpdateOrderDto, type UpdateOrderShippingDto, type UpdateProductDto, type UpdateRegionDto, type UpdateShippingRateDto as UpdateShippingRateInput, type UpdateShippingZoneDto as UpdateShippingZoneInput, type UpdateStoreMemberDto as UpdateStoreMemberInput, type UpdateTagDto as UpdateTagInput, type UpdateTaxClassDto, type UpdateTaxRateDto as UpdateTaxRateInput, type UpdateVariantDto, type UpdateVariantInventoryDto, type UpsellSettings, type UpsertProductMetafieldDto as UpsertProductMetafieldInput, type UserStore, type UserStorePermissions, type VariantInventoryResponse, type VariantPlatformOverlay, type VariantStatus, type WaitForOrderOptions, type WaitForOrderResult, type WebhookEvent, type WebhookEventType, type WriteProductReviewInput, buildArticleJsonLd, buildBreadcrumbJsonLd, buildCollectionPageJsonLd, buildOrganizationJsonLd, buildProductFaqJsonLd, buildProductJsonLd, buildWebsiteJsonLd, computeAvailableSlots, createWebhookHandler, deriveSeoDescription, enableDevGuards, formatMoney, formatPrice, formatProductPrice, formatVariantPrice, getBlogSitemapEntries, getBusinessHoursForDate, getCartItemImage, getCartItemName, getCartTotals, getCategorySitemapEntries, getDescriptionContent, getDirectionForLocale, formatPrice as getPriceDisplay, getProductCustomizationFields, getProductMetafield, getProductMetafieldValue, getProductMetafieldsByType, getProductPrice, getProductPriceInfo, getProductSitemapEntries, getProductSwatches, getStockStatus, getVariantOptions, getVariantPrice, isAllowedPaymentUrl, isCalendarDateAllowed, isCouponApplicableToProduct, isDateValueAllowed, isHtmlDescription, isWebhookEventType, jsonLdScriptProps, parseDateFieldValue, parseWebhookEvent, resolveRelativeBounds, resolveRenderType, resolveStoreLocalParts, safePaymentRedirect, stripHtml, validateDateAvailabilityConfig, verifyWebhook };
|
package/dist/index.js
CHANGED
|
@@ -79,6 +79,7 @@ __export(index_exports, {
|
|
|
79
79
|
parseDateFieldValue: () => parseDateFieldValue,
|
|
80
80
|
parseWebhookEvent: () => parseWebhookEvent,
|
|
81
81
|
resolveRelativeBounds: () => resolveRelativeBounds,
|
|
82
|
+
resolveRenderType: () => resolveRenderType,
|
|
82
83
|
resolveStoreLocalParts: () => resolveStoreLocalParts,
|
|
83
84
|
safePaymentRedirect: () => safePaymentRedirect,
|
|
84
85
|
stripHtml: () => stripHtml2,
|
|
@@ -204,7 +205,7 @@ function isDevGuardsEnabled() {
|
|
|
204
205
|
}
|
|
205
206
|
|
|
206
207
|
// src/version.ts
|
|
207
|
-
var SDK_VERSION = "2.
|
|
208
|
+
var SDK_VERSION = "2.9.0";
|
|
208
209
|
|
|
209
210
|
// src/client.ts
|
|
210
211
|
var DEFAULT_BASE_URL = "https://api.brainerce.com";
|
|
@@ -2961,6 +2962,79 @@ var _BrainerceClient = class _BrainerceClient {
|
|
|
2961
2962
|
async updateOrder(orderId, data) {
|
|
2962
2963
|
return this.request("PATCH", `/api/v1/orders/${encodePathSegment(orderId)}`, data);
|
|
2963
2964
|
}
|
|
2965
|
+
/**
|
|
2966
|
+
* List the store's order custom field definitions.
|
|
2967
|
+
*
|
|
2968
|
+
* Call this before writing values: the `key` of each definition is what
|
|
2969
|
+
* {@link setOrderCustomFieldValues} accepts, and `type` is what a value has
|
|
2970
|
+
* to fit. Inactive definitions are included, so you can tell "the merchant
|
|
2971
|
+
* turned this field off" apart from "the merchant never created it".
|
|
2972
|
+
*
|
|
2973
|
+
* Requires an API key with the `orders:read` scope.
|
|
2974
|
+
*/
|
|
2975
|
+
async getOrderCustomFieldDefinitions() {
|
|
2976
|
+
return this.adminRequest("GET", "/api/v1/order-custom-fields");
|
|
2977
|
+
}
|
|
2978
|
+
/**
|
|
2979
|
+
* Read the custom field values stored on one order.
|
|
2980
|
+
*
|
|
2981
|
+
* Requires an API key with the `orders:read` scope.
|
|
2982
|
+
*/
|
|
2983
|
+
async getOrderCustomFieldValues(orderId) {
|
|
2984
|
+
return this.adminRequest(
|
|
2985
|
+
"GET",
|
|
2986
|
+
`/api/v1/orders/${encodePathSegment(orderId)}/custom-fields`
|
|
2987
|
+
);
|
|
2988
|
+
}
|
|
2989
|
+
/**
|
|
2990
|
+
* Write custom field values onto an order.
|
|
2991
|
+
*
|
|
2992
|
+
* This is how work that finishes OUTSIDE Brainerce gets back onto the order
|
|
2993
|
+
* it belongs to. Subscribe to the `order.paid` webhook, call whatever third
|
|
2994
|
+
* party issues the thing you sell — a licence key, a booking reference, a
|
|
2995
|
+
* warranty number — then write the answer here. The value travels to the
|
|
2996
|
+
* merchant's own order email templates as `orderCustomFields` and, when the
|
|
2997
|
+
* definition is `isPublic`, to the customer's own order page. No email
|
|
2998
|
+
* template or endpoint has to be built per integration.
|
|
2999
|
+
*
|
|
3000
|
+
* ⛔ No default template PRINTS `orderCustomFields`. The variable reaches
|
|
3001
|
+
* every order email, but until the merchant adds the block to their template
|
|
3002
|
+
* once, a value written here is invisible to the customer. Writing the field
|
|
3003
|
+
* is not the same as the customer being told.
|
|
3004
|
+
*
|
|
3005
|
+
* The write is a MERGE: keys you leave out keep their current value, and
|
|
3006
|
+
* `null` clears a field that is not required. Values are coerced to the
|
|
3007
|
+
* definition's type and rejected with a 400 when they cannot be — but a key
|
|
3008
|
+
* with no active definition on the store is IGNORED rather than failing the
|
|
3009
|
+
* whole call, so read the returned `fields` to confirm what was stored.
|
|
3010
|
+
*
|
|
3011
|
+
* Pass an `idempotencyKey` when the caller may retry: an identical re-send
|
|
3012
|
+
* then replays the original response instead of writing again.
|
|
3013
|
+
*
|
|
3014
|
+
* Requires an API key with the `orders:write` scope.
|
|
3015
|
+
*
|
|
3016
|
+
* @example
|
|
3017
|
+
* ```typescript
|
|
3018
|
+
* // after the third party answered
|
|
3019
|
+
* await client.setOrderCustomFieldValues(
|
|
3020
|
+
* order.id,
|
|
3021
|
+
* { licence_key: 'ABCD-EFGH-IJKL' },
|
|
3022
|
+
* { idempotencyKey: `licence-${order.id}` }
|
|
3023
|
+
* );
|
|
3024
|
+
* // fires the "order completed" email, which carries the field
|
|
3025
|
+
* await client.updateOrder(order.id, { status: 'COMPLETED' });
|
|
3026
|
+
* ```
|
|
3027
|
+
*/
|
|
3028
|
+
async setOrderCustomFieldValues(orderId, fields, options) {
|
|
3029
|
+
return this.adminRequest(
|
|
3030
|
+
"PATCH",
|
|
3031
|
+
`/api/v1/orders/${encodePathSegment(orderId)}/custom-fields`,
|
|
3032
|
+
{ fields },
|
|
3033
|
+
void 0,
|
|
3034
|
+
"json",
|
|
3035
|
+
this.idempotencyHeaders(options)
|
|
3036
|
+
);
|
|
3037
|
+
}
|
|
2964
3038
|
/**
|
|
2965
3039
|
* Update order status.
|
|
2966
3040
|
*
|
|
@@ -11267,6 +11341,13 @@ var ALLOWED_PAYMENT_HOSTS = [
|
|
|
11267
11341
|
// reachable, so a terminal configured against it keeps working.
|
|
11268
11342
|
"pay.hyp.co.il",
|
|
11269
11343
|
"icom.yaad.net",
|
|
11344
|
+
// iCredit (ריווחית) — the hosted payment page returned by
|
|
11345
|
+
// PaymentPageRequest. Both environments are listed EXPLICITLY rather than
|
|
11346
|
+
// allowing `rivhit.co.il`: the matcher below also accepts `*.<host>`, so a
|
|
11347
|
+
// bare parent entry would open every Rivhit subdomain (their accounting app,
|
|
11348
|
+
// marketing site, anything they add later) to a payment redirect.
|
|
11349
|
+
"icredit.rivhit.co.il",
|
|
11350
|
+
"testicredit.rivhit.co.il",
|
|
11270
11351
|
// Brainerce-hosted payment embeds (backend payment-embed proxy at
|
|
11271
11352
|
// `/api/payment/embed/...` that fronts provider apps' embed shells —
|
|
11272
11353
|
// e.g. cardcom-payments OpenFields wrapper). The match also covers
|
|
@@ -11298,6 +11379,13 @@ function safePaymentRedirect(url, options) {
|
|
|
11298
11379
|
}
|
|
11299
11380
|
}
|
|
11300
11381
|
|
|
11382
|
+
// src/render-mode.ts
|
|
11383
|
+
function resolveRenderType(sdk, preferred) {
|
|
11384
|
+
if (!sdk) return "redirect";
|
|
11385
|
+
const declared = sdk.displayModes?.length ? sdk.displayModes : [sdk.renderType];
|
|
11386
|
+
return preferred && declared.includes(preferred) ? preferred : sdk.renderType;
|
|
11387
|
+
}
|
|
11388
|
+
|
|
11301
11389
|
// src/format-price.ts
|
|
11302
11390
|
var DEFAULT_LOCALE = "en";
|
|
11303
11391
|
function formatProductPrice(product, options = {}) {
|
|
@@ -12340,6 +12428,7 @@ function isCouponApplicableToProduct(coupon, productId) {
|
|
|
12340
12428
|
parseDateFieldValue,
|
|
12341
12429
|
parseWebhookEvent,
|
|
12342
12430
|
resolveRelativeBounds,
|
|
12431
|
+
resolveRenderType,
|
|
12343
12432
|
resolveStoreLocalParts,
|
|
12344
12433
|
safePaymentRedirect,
|
|
12345
12434
|
stripHtml,
|
package/dist/index.mjs
CHANGED
|
@@ -115,7 +115,7 @@ function isDevGuardsEnabled() {
|
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
// src/version.ts
|
|
118
|
-
var SDK_VERSION = "2.
|
|
118
|
+
var SDK_VERSION = "2.9.0";
|
|
119
119
|
|
|
120
120
|
// src/client.ts
|
|
121
121
|
var DEFAULT_BASE_URL = "https://api.brainerce.com";
|
|
@@ -2872,6 +2872,79 @@ var _BrainerceClient = class _BrainerceClient {
|
|
|
2872
2872
|
async updateOrder(orderId, data) {
|
|
2873
2873
|
return this.request("PATCH", `/api/v1/orders/${encodePathSegment(orderId)}`, data);
|
|
2874
2874
|
}
|
|
2875
|
+
/**
|
|
2876
|
+
* List the store's order custom field definitions.
|
|
2877
|
+
*
|
|
2878
|
+
* Call this before writing values: the `key` of each definition is what
|
|
2879
|
+
* {@link setOrderCustomFieldValues} accepts, and `type` is what a value has
|
|
2880
|
+
* to fit. Inactive definitions are included, so you can tell "the merchant
|
|
2881
|
+
* turned this field off" apart from "the merchant never created it".
|
|
2882
|
+
*
|
|
2883
|
+
* Requires an API key with the `orders:read` scope.
|
|
2884
|
+
*/
|
|
2885
|
+
async getOrderCustomFieldDefinitions() {
|
|
2886
|
+
return this.adminRequest("GET", "/api/v1/order-custom-fields");
|
|
2887
|
+
}
|
|
2888
|
+
/**
|
|
2889
|
+
* Read the custom field values stored on one order.
|
|
2890
|
+
*
|
|
2891
|
+
* Requires an API key with the `orders:read` scope.
|
|
2892
|
+
*/
|
|
2893
|
+
async getOrderCustomFieldValues(orderId) {
|
|
2894
|
+
return this.adminRequest(
|
|
2895
|
+
"GET",
|
|
2896
|
+
`/api/v1/orders/${encodePathSegment(orderId)}/custom-fields`
|
|
2897
|
+
);
|
|
2898
|
+
}
|
|
2899
|
+
/**
|
|
2900
|
+
* Write custom field values onto an order.
|
|
2901
|
+
*
|
|
2902
|
+
* This is how work that finishes OUTSIDE Brainerce gets back onto the order
|
|
2903
|
+
* it belongs to. Subscribe to the `order.paid` webhook, call whatever third
|
|
2904
|
+
* party issues the thing you sell — a licence key, a booking reference, a
|
|
2905
|
+
* warranty number — then write the answer here. The value travels to the
|
|
2906
|
+
* merchant's own order email templates as `orderCustomFields` and, when the
|
|
2907
|
+
* definition is `isPublic`, to the customer's own order page. No email
|
|
2908
|
+
* template or endpoint has to be built per integration.
|
|
2909
|
+
*
|
|
2910
|
+
* ⛔ No default template PRINTS `orderCustomFields`. The variable reaches
|
|
2911
|
+
* every order email, but until the merchant adds the block to their template
|
|
2912
|
+
* once, a value written here is invisible to the customer. Writing the field
|
|
2913
|
+
* is not the same as the customer being told.
|
|
2914
|
+
*
|
|
2915
|
+
* The write is a MERGE: keys you leave out keep their current value, and
|
|
2916
|
+
* `null` clears a field that is not required. Values are coerced to the
|
|
2917
|
+
* definition's type and rejected with a 400 when they cannot be — but a key
|
|
2918
|
+
* with no active definition on the store is IGNORED rather than failing the
|
|
2919
|
+
* whole call, so read the returned `fields` to confirm what was stored.
|
|
2920
|
+
*
|
|
2921
|
+
* Pass an `idempotencyKey` when the caller may retry: an identical re-send
|
|
2922
|
+
* then replays the original response instead of writing again.
|
|
2923
|
+
*
|
|
2924
|
+
* Requires an API key with the `orders:write` scope.
|
|
2925
|
+
*
|
|
2926
|
+
* @example
|
|
2927
|
+
* ```typescript
|
|
2928
|
+
* // after the third party answered
|
|
2929
|
+
* await client.setOrderCustomFieldValues(
|
|
2930
|
+
* order.id,
|
|
2931
|
+
* { licence_key: 'ABCD-EFGH-IJKL' },
|
|
2932
|
+
* { idempotencyKey: `licence-${order.id}` }
|
|
2933
|
+
* );
|
|
2934
|
+
* // fires the "order completed" email, which carries the field
|
|
2935
|
+
* await client.updateOrder(order.id, { status: 'COMPLETED' });
|
|
2936
|
+
* ```
|
|
2937
|
+
*/
|
|
2938
|
+
async setOrderCustomFieldValues(orderId, fields, options) {
|
|
2939
|
+
return this.adminRequest(
|
|
2940
|
+
"PATCH",
|
|
2941
|
+
`/api/v1/orders/${encodePathSegment(orderId)}/custom-fields`,
|
|
2942
|
+
{ fields },
|
|
2943
|
+
void 0,
|
|
2944
|
+
"json",
|
|
2945
|
+
this.idempotencyHeaders(options)
|
|
2946
|
+
);
|
|
2947
|
+
}
|
|
2875
2948
|
/**
|
|
2876
2949
|
* Update order status.
|
|
2877
2950
|
*
|
|
@@ -11178,6 +11251,13 @@ var ALLOWED_PAYMENT_HOSTS = [
|
|
|
11178
11251
|
// reachable, so a terminal configured against it keeps working.
|
|
11179
11252
|
"pay.hyp.co.il",
|
|
11180
11253
|
"icom.yaad.net",
|
|
11254
|
+
// iCredit (ריווחית) — the hosted payment page returned by
|
|
11255
|
+
// PaymentPageRequest. Both environments are listed EXPLICITLY rather than
|
|
11256
|
+
// allowing `rivhit.co.il`: the matcher below also accepts `*.<host>`, so a
|
|
11257
|
+
// bare parent entry would open every Rivhit subdomain (their accounting app,
|
|
11258
|
+
// marketing site, anything they add later) to a payment redirect.
|
|
11259
|
+
"icredit.rivhit.co.il",
|
|
11260
|
+
"testicredit.rivhit.co.il",
|
|
11181
11261
|
// Brainerce-hosted payment embeds (backend payment-embed proxy at
|
|
11182
11262
|
// `/api/payment/embed/...` that fronts provider apps' embed shells —
|
|
11183
11263
|
// e.g. cardcom-payments OpenFields wrapper). The match also covers
|
|
@@ -11209,6 +11289,13 @@ function safePaymentRedirect(url, options) {
|
|
|
11209
11289
|
}
|
|
11210
11290
|
}
|
|
11211
11291
|
|
|
11292
|
+
// src/render-mode.ts
|
|
11293
|
+
function resolveRenderType(sdk, preferred) {
|
|
11294
|
+
if (!sdk) return "redirect";
|
|
11295
|
+
const declared = sdk.displayModes?.length ? sdk.displayModes : [sdk.renderType];
|
|
11296
|
+
return preferred && declared.includes(preferred) ? preferred : sdk.renderType;
|
|
11297
|
+
}
|
|
11298
|
+
|
|
11212
11299
|
// src/format-price.ts
|
|
11213
11300
|
var DEFAULT_LOCALE = "en";
|
|
11214
11301
|
function formatProductPrice(product, options = {}) {
|
|
@@ -12250,6 +12337,7 @@ export {
|
|
|
12250
12337
|
parseDateFieldValue,
|
|
12251
12338
|
parseWebhookEvent,
|
|
12252
12339
|
resolveRelativeBounds,
|
|
12340
|
+
resolveRenderType,
|
|
12253
12341
|
resolveStoreLocalParts,
|
|
12254
12342
|
safePaymentRedirect,
|
|
12255
12343
|
stripHtml2 as stripHtml,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "brainerce",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.0",
|
|
4
4
|
"description": "Official SDK for building e-commerce storefronts with Brainerce Platform. Perfect for vibe-coded sites, AI-built stores (Cursor, Lovable, v0), and custom storefronts.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|