tixbit 0.2.0 → 0.2.1
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 +2 -0
- package/dist/cli.js +27 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -97,6 +97,8 @@ tixbit link complete <order-reference>
|
|
|
97
97
|
|
|
98
98
|
The second command checks approval, sends one Stripe MPP credential, and reports whether the ticket was issued. If approval is still pending, it returns the same URL without sending payment. If the payment result is uncertain, use `link complete` with the same order reference. The CLI stores the purchase key in a private file under `~/.local/state/tixbit/link` (or `XDG_STATE_HOME`) and never prints or saves the Link payment token. Keep that file until the order is settled. Each command returns JSON; `approval_required` and payment failures use exit code 2.
|
|
99
99
|
|
|
100
|
+
Each spend request includes its TixBit order reference in the approval details. Link can still rate limit a matching amount and merchant for a short time, even after a request is canceled. If Link rejects a request, the CLI reports a safe error code such as `LINK_DUPLICATE_REQUEST` or `LINK_NETWORK_UNAVAILABLE` without printing Link credentials.
|
|
101
|
+
|
|
100
102
|
`--email` is always required and is never inferred from git or local account state. If a request times out or returns `pending` or `manual_review_required`, reuse the same idempotency key and follow the returned `action`; do not start another payment.
|
|
101
103
|
|
|
102
104
|
### Link agent checkout
|
package/dist/cli.js
CHANGED
|
@@ -923,8 +923,30 @@ async function linkCli(args) {
|
|
|
923
923
|
windowsHide: true
|
|
924
924
|
});
|
|
925
925
|
stdout = typeof result === "string" ? result : result.stdout;
|
|
926
|
-
} catch {
|
|
927
|
-
|
|
926
|
+
} catch (error) {
|
|
927
|
+
const output2 = error && typeof error === "object" && "stdout" in error ? String(error.stdout) : "";
|
|
928
|
+
let message = "";
|
|
929
|
+
try {
|
|
930
|
+
const parsed = JSON.parse(output2);
|
|
931
|
+
const data = parsed && typeof parsed === "object" && !Array.isArray(parsed) && "data" in parsed ? parsed.data : parsed;
|
|
932
|
+
const item = Array.isArray(data) ? data[0] : data;
|
|
933
|
+
if (item && typeof item === "object" && "message" in item) {
|
|
934
|
+
message = String(item.message);
|
|
935
|
+
} else {
|
|
936
|
+
const nested = parsed && typeof parsed === "object" && !Array.isArray(parsed) && "error" in parsed ? parsed.error : void 0;
|
|
937
|
+
if (nested && typeof nested === "object" && "message" in nested) {
|
|
938
|
+
message = String(nested.message);
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
} catch {
|
|
942
|
+
}
|
|
943
|
+
if (/duplicate spend requests|matching spend request/i.test(message)) {
|
|
944
|
+
throw new LinkCheckoutError("LINK_DUPLICATE_REQUEST", "Link blocked a matching spend request. Wait a few minutes, then start a new checkout.");
|
|
945
|
+
}
|
|
946
|
+
if (/Invalid network_id|could not retrieve merchant information/i.test(message)) {
|
|
947
|
+
throw new LinkCheckoutError("LINK_NETWORK_UNAVAILABLE", "Link could not resolve the merchant profile in this account and mode. No payment was sent.");
|
|
948
|
+
}
|
|
949
|
+
throw new LinkCheckoutError("LINK_CLI_FAILED", "Link could not complete this step. Check Link sign-in and payment methods, then retry.");
|
|
928
950
|
}
|
|
929
951
|
try {
|
|
930
952
|
const parsed = JSON.parse(stdout);
|
|
@@ -984,7 +1006,7 @@ async function startLinkPurchase(input) {
|
|
|
984
1006
|
if (typeof body.orderReference !== "string" || !ORDER_REFERENCE.test(body.orderReference)) {
|
|
985
1007
|
throw new LinkCheckoutError("ORDER_REFERENCE_MISSING", "TixBit did not return an order reference.");
|
|
986
1008
|
}
|
|
987
|
-
const context = `Approve one TixBit ticket purchase for listing ${purchase.listingId}, quantity ${purchase.quantity}. The total charge is USD ${(amountCents / 100).toFixed(2)}. This request permits one machine payment for this selected order only.`;
|
|
1009
|
+
const context = `Approve one TixBit ticket purchase for order ${body.orderReference}, listing ${purchase.listingId}, quantity ${purchase.quantity}. The total charge is USD ${(amountCents / 100).toFixed(2)}. This request permits one machine payment for this selected order only.`;
|
|
988
1010
|
const created = await linkCli([
|
|
989
1011
|
"spend-request",
|
|
990
1012
|
"create",
|
|
@@ -998,6 +1020,8 @@ async function startLinkPurchase(input) {
|
|
|
998
1020
|
"usd",
|
|
999
1021
|
"--context",
|
|
1000
1022
|
context,
|
|
1023
|
+
"--metadata",
|
|
1024
|
+
`order_reference:${body.orderReference}`,
|
|
1001
1025
|
"--request-approval"
|
|
1002
1026
|
]);
|
|
1003
1027
|
if (typeof created.id !== "string" || !SPEND_REQUEST_ID.test(created.id)) {
|