@agent-cards/sdk 0.24.1 → 0.25.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/CHANGELOG.md +6 -0
- package/dist/approvals.d.ts +44 -0
- package/dist/approvals.js +10 -0
- package/dist/capabilities.generated.js +1 -1
- package/dist/card-fields.generated.js +357 -263
- package/dist/cdp.js +34 -13
- package/dist/client.d.ts +9 -0
- package/dist/client.js +9 -0
- package/dist/datatrans.generated.js +3 -1
- package/dist/index.d.ts +1 -1
- package/dist/lifecycle.d.ts +23 -5
- package/dist/lifecycle.js +45 -22
- package/dist/merchant-card-endpoints.generated.js +30 -3
- package/dist/payrails.generated.js +3 -1
- package/dist/pre-claim.d.ts +3 -0
- package/dist/pre-claim.js +45 -1
- package/dist/preflight-catalog.json +25 -0
- package/dist/preflight-schemas.json +2 -0
- package/dist/preflight.generated.js +10 -1
- package/dist/primer.generated.js +366 -273
- package/dist/stripe-checkout.generated.js +336 -242
- package/dist/stripe-continuation.d.ts +45 -0
- package/dist/stripe-continuation.js +106 -0
- package/dist/stripe-setup.d.ts +5 -10
- package/dist/stripe-setup.js +11 -39
- package/dist/token-repeats.d.ts +32 -0
- package/dist/token-repeats.js +64 -0
- package/examples/preflight/kernel-native/inventory.json +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,12 @@ An unreleased change waits as a file of its own in `changes/` (`changes/README.m
|
|
|
4
4
|
|
|
5
5
|
## Unreleased
|
|
6
6
|
|
|
7
|
+
## 0.24.2
|
|
8
|
+
|
|
9
|
+
- Pause the payment a BigCommerce store's own card form sends to `https://payments.bigcommerce.com/api/public/v1/orders/payments`, for the cardholder's device, for a company Agentcard turned BigCommerce on for. The sync now also asks for `capabilities=bigcommerce_card_form`. The SDK pauses only a body that carries a new card; a card saved at the store, another processor's token and a wallet on the same URL pass through untouched, and a card the store would keep fails in your browser before anything is created. The payment names the store's total, which is the amount the cardholder approves. A BigCommerce payment also needs the matching Vault release.
|
|
10
|
+
|
|
11
|
+
- Answer a store page's identical re-send of a card request the cardholder already approved. Once the approved token reached the page and the checkout awaits the merchant, a POST to the same URL with the same body under the same authorization gets the stored answer again, with a `repeat_answered` event (`psp: 'token'`) and no second prompt, only after `resolveMerchantResult` reports the order still `pending`, and at most three times. Before, a `pending` answer held every card request, so a Shopify checkout that sent its card session again never got a token it would submit, and the order stayed unconfirmed. A hold from anything else still refuses the re-send: an amount the processor charged that differs from the approval's, an unbound Stripe token, a hosted form or card endpoint answer, `requireMerchantResult`, a follow-up send in flight, an unsupported request or a cancel. Another body, URL or authorization, a completed, failed or unknown order, and an attachment with no resolver each stay a new question, held as before.
|
|
12
|
+
|
|
7
13
|
## 0.24.1
|
|
8
14
|
|
|
9
15
|
- Pause eGHL's payment page entry for the cardholder's device. This build declares `eghl_hosted_payment_page`, and for a company the API turns the lane on for, Agentcard's own for now, it pauses the merchant's entry, a `GET` of `https://securepay.e-ghl.com/IPG/payment.aspx` whose query names the payment, creates a `hosted_form` authorization for it, and fails every post a page it watches sends to eGHL's hosts, so eGHL never receives the card your agent typed. The entry names its amount, and the API answers `amount_mismatch` for any other. No eGHL payment completes yet: while the relay route stays closed the API answers every create with `503 eghl_relay_unavailable`, which is expected, not a setup error.
|
package/dist/approvals.d.ts
CHANGED
|
@@ -39,6 +39,50 @@ export interface CreateAuthorizationInput {
|
|
|
39
39
|
checkout_origin?: string;
|
|
40
40
|
/** Pins the card that pays: one of the person's stored cards. Absent, the person's recommended card pays, else their only card, and `card` on the answer says which. */
|
|
41
41
|
card_id?: string;
|
|
42
|
+
/**
|
|
43
|
+
* The products the purchase is for, as your agent's cart has them (1 to 20 lines): the approval page lists them
|
|
44
|
+
* above the total, labelled as sent by your company. Shown, never charged: the person approves `amount`.
|
|
45
|
+
* Every amount is in the smallest unit of `currency`. A line the API cannot read is refused by name
|
|
46
|
+
* (`invalid_request`), never dropped.
|
|
47
|
+
*/
|
|
48
|
+
line_items?: OrderLineItem[];
|
|
49
|
+
/** The cart's subtotal, shipping, tax and discount, in the smallest unit of `currency`, each shown only when named. Need `line_items`. */
|
|
50
|
+
subtotal?: number;
|
|
51
|
+
shipping?: number;
|
|
52
|
+
tax?: number;
|
|
53
|
+
discount?: number;
|
|
54
|
+
/** Where the order ships, shown in the approval page's Ship to box. Needs `line_items`. Never returned on your reads. */
|
|
55
|
+
ship_to?: OrderShipTo;
|
|
56
|
+
}
|
|
57
|
+
/** One product of the cart an approval shows. */
|
|
58
|
+
export interface OrderLineItem {
|
|
59
|
+
/** The product's name as the store shows it. */
|
|
60
|
+
title: string;
|
|
61
|
+
/** A positive integer. */
|
|
62
|
+
quantity: number;
|
|
63
|
+
/** The price of one, in the smallest unit of the create's `currency`; the line shows `unit_amount × quantity`. */
|
|
64
|
+
unit_amount?: number;
|
|
65
|
+
/** The line's own total, in the smallest unit; shown over `unit_amount × quantity` when both are named. */
|
|
66
|
+
amount?: number;
|
|
67
|
+
brand?: string;
|
|
68
|
+
/** The options chosen, as one string (`'Size S · Pink'`) or by name (`{ Size: 'S', Color: 'Pink' }`, shown as `S · Pink`). */
|
|
69
|
+
options?: string | Record<string, string>;
|
|
70
|
+
/** An https picture of the product. Shown only from the image hosts the approval page loads; any other shows the line without one. */
|
|
71
|
+
image_url?: string;
|
|
72
|
+
}
|
|
73
|
+
/** Where an approval's order ships. */
|
|
74
|
+
export interface OrderShipTo {
|
|
75
|
+
name: string;
|
|
76
|
+
phone?: string;
|
|
77
|
+
/** `country` is a two-letter ISO code; absent means `US`. */
|
|
78
|
+
address: {
|
|
79
|
+
line1: string;
|
|
80
|
+
line2?: string;
|
|
81
|
+
city: string;
|
|
82
|
+
state?: string;
|
|
83
|
+
postal_code: string;
|
|
84
|
+
country?: string;
|
|
85
|
+
};
|
|
42
86
|
}
|
|
43
87
|
/** The card that pays, as every read names it. */
|
|
44
88
|
export interface PayingCard {
|
package/dist/approvals.js
CHANGED
|
@@ -99,6 +99,15 @@ function resultOf(a) {
|
|
|
99
99
|
...(approvalUrl && a.status === 'awaiting_approval' ? { approval_url: approvalUrl } : {}),
|
|
100
100
|
};
|
|
101
101
|
}
|
|
102
|
+
/** The cart fields a create names, passed as given: the API checks them and refuses a bad one by name. */
|
|
103
|
+
function orderFieldsOf(input) {
|
|
104
|
+
const out = {};
|
|
105
|
+
for (const key of ['line_items', 'subtotal', 'shipping', 'tax', 'discount', 'ship_to']) {
|
|
106
|
+
if (input[key] !== undefined)
|
|
107
|
+
out[key] = input[key];
|
|
108
|
+
}
|
|
109
|
+
return out;
|
|
110
|
+
}
|
|
102
111
|
/** A random idempotency key for one create, so a retried call makes one purchase. */
|
|
103
112
|
function idempotencyKey() {
|
|
104
113
|
const c = globalThis.crypto;
|
|
@@ -148,6 +157,7 @@ export class ApprovalsModule extends ApiModule {
|
|
|
148
157
|
body: {
|
|
149
158
|
user, merchant: input.merchant, amount: input.amount, currency: input.currency, psp: input.psp ?? 'stripe', mode: input.mode ?? 'token', request,
|
|
150
159
|
...(input.return_url ? { return_url: input.return_url } : {}), ...(checkoutOrigin ? { checkout_origin: checkoutOrigin } : {}), ...(input.card_id ? { card_id: input.card_id } : {}),
|
|
160
|
+
...orderFieldsOf(input),
|
|
151
161
|
},
|
|
152
162
|
headers: { 'idempotency-key': input.idempotency_key ?? idempotencyKey() },
|
|
153
163
|
});
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// Written by scripts/generate-capabilities.mjs from capabilities.json. Do not edit; git ignores it.
|
|
2
2
|
/** capabilities.json's list, sorted; client.ts exports it as SUPPORTED_CAPABILITIES. */
|
|
3
|
-
export const DECLARED_CAPABILITIES = ["aci_split_card.v1", "amadeus_checkout_actions.v1", "aps_custom_merchant_page", "aurus_one_time_token", "authorize_net_dpm_form", "barion_hosted_payment_page", "bluesnap_hosted_payment_fields", "capture_context", "cardlink_vpos_hosted_payment_page", "clover_card_token", "comgate_hosted_payment_page", "converge_hpp_process", "creditguard_pps_process", "cybersource_sa_token_create", "datatrans_secure_fields_tokenize", "eghl_hosted_payment_page", "ekashu_hosted_payment_page", "eximbay_hosted_payment_page", "fastspring_card_payment", "fiserv_card_capture", "frisbii_card_token", "gmo_shared_pk", "gopay_card_form", "gravy_session_fields_put", "hipay_vault_token", "iyzico_checkout_form", "juspay_txns.v1", "lyra_krypton_payment", "makecommerce_card_frame", "midtrans_card_token", "monei_card_token", "moneris_hosted_tokenization", "nexi_checkout_pay", "oceanpayment_hosted_payment_page", "omise_card_token", "openpay_tokenizer", "paddle_tokenex_pay", "paddle_vgs_cards", "pay_nl_card_token", "payfast_card_pay", "paygent_token", "paymentwall_card_token", "paymob_checkout_pay", "paymongo_checkout_pay", "paypal_card_fields", "payplug_hosted_payment_page", "payrails_device_encrypt", "payrexx_card_frame", "paystack_pinned_key", "paytrail_hosted_payment_page", "payu_latam_webcheckout_card", "pelecard_transaction", "pin_payments_card_token", "poynt_collect_nonce", "primer_payment_instruments", "processout_card_token", "przelewy24_hosted_payment_page", "quickpay_hosted_payment_page", "redsys_hosted_payment_page", "revolut_card_field", "sbps_token_jsonp", "shiji_sts_pinned_key", "sumup_checkout_process", "tap_card_sdk_token", "toast_pinned_key", "tokenex_iframe_tokenize", "transbank_webpay_hosted_payment_page", "twoc2p_secure_pay", "usaepay_payment_key", "verifone_card_capture", "viva_smart_checkout_chargetoken", "vtex_payments_card_payment", "wix_payments_tokenize", "worldline_mycheckout_form", "worldpay_eprotect_jsonp", "wspay_confirm", "xendit_card_token"];
|
|
3
|
+
export const DECLARED_CAPABILITIES = ["aci_split_card.v1", "amadeus_checkout_actions.v1", "aps_custom_merchant_page", "aurus_one_time_token", "authorize_net_dpm_form", "barion_hosted_payment_page", "bigcommerce_card_form", "bluesnap_hosted_payment_fields", "capture_context", "cardlink_vpos_hosted_payment_page", "clover_card_token", "comgate_hosted_payment_page", "converge_hpp_process", "creditguard_pps_process", "cybersource_sa_token_create", "datatrans_secure_fields_tokenize", "eghl_hosted_payment_page", "ekashu_hosted_payment_page", "eximbay_hosted_payment_page", "fastspring_card_payment", "fiserv_card_capture", "frisbii_card_token", "gmo_shared_pk", "gopay_card_form", "gravy_session_fields_put", "hipay_vault_token", "iyzico_checkout_form", "juspay_txns.v1", "lyra_krypton_payment", "makecommerce_card_frame", "midtrans_card_token", "monei_card_token", "moneris_hosted_tokenization", "nexi_checkout_pay", "oceanpayment_hosted_payment_page", "omise_card_token", "openpay_tokenizer", "paddle_tokenex_pay", "paddle_vgs_cards", "pay_nl_card_token", "payfast_card_pay", "paygent_token", "paymentwall_card_token", "paymob_checkout_pay", "paymongo_checkout_pay", "paypal_card_fields", "payplug_hosted_payment_page", "payrails_device_encrypt", "payrexx_card_frame", "paystack_pinned_key", "paytrail_hosted_payment_page", "payu_latam_webcheckout_card", "pelecard_transaction", "pin_payments_card_token", "poynt_collect_nonce", "primer_payment_instruments", "processout_card_token", "przelewy24_hosted_payment_page", "quickpay_hosted_payment_page", "redsys_hosted_payment_page", "revolut_card_field", "sbps_token_jsonp", "shiji_sts_pinned_key", "sumup_checkout_process", "tap_card_sdk_token", "toast_pinned_key", "tokenex_iframe_tokenize", "transbank_webpay_hosted_payment_page", "twoc2p_secure_pay", "usaepay_payment_key", "verifone_card_capture", "viva_smart_checkout_chargetoken", "vtex_payments_card_payment", "wix_payments_tokenize", "worldline_mycheckout_form", "worldpay_eprotect_jsonp", "wspay_confirm", "xendit_card_token"];
|