@amboras-dev/authorize-net 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +101 -0
- package/dist/index.d.ts +101 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +36 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { ComponentType } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Session data returned by Amboras' multi-tenant Authorize.Net Accept Hosted
|
|
5
|
+
* provider. Authorize.Net hosts the card form, but unlike iyzico it does not
|
|
6
|
+
* hand back a navigable URL: `getHostedPaymentPageRequest` returns a token
|
|
7
|
+
* that has to be form-POSTed as `token` to the environment's Accept Hosted
|
|
8
|
+
* endpoint. Storefront adapters therefore auto-submit a hidden form instead
|
|
9
|
+
* of assigning `window.location`, and the token is minted at redirect time
|
|
10
|
+
* because it expires 15 minutes after it is issued.
|
|
11
|
+
*/
|
|
12
|
+
interface AuthorizeNetSessionData {
|
|
13
|
+
authorize_net_environment_id: string;
|
|
14
|
+
/** Accept Hosted form target for the selected environment. */
|
|
15
|
+
post_url?: AuthorizeNetPostUrl;
|
|
16
|
+
/** Accept Hosted token. Valid 15 minutes from mint; minted at redirect time. */
|
|
17
|
+
token?: string;
|
|
18
|
+
/** Only 'redirect' in T1. 'lightbox' and 'iframe' are T2. */
|
|
19
|
+
mode: AuthorizeNetHostedMode;
|
|
20
|
+
environment: AuthorizeNetEnvironment;
|
|
21
|
+
currency_code: AuthorizeNetCurrency;
|
|
22
|
+
/** Two-decimal string, already converted out of Amboras minor units. */
|
|
23
|
+
amount: string;
|
|
24
|
+
ref_id?: string;
|
|
25
|
+
trans_id?: string;
|
|
26
|
+
/** Masked account number from transactionResponse.accountNumber, e.g. 'XXXX0015'. */
|
|
27
|
+
account_number_masked?: string;
|
|
28
|
+
transaction_status?: AuthorizeNetTransactionStatus;
|
|
29
|
+
payment_status?: AuthorizeNetPaymentStatus;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Single-member union on purpose: adding Accept Hosted's lightbox and iframe
|
|
33
|
+
* modes in T2 is then a compile-visible widening rather than a silent string
|
|
34
|
+
* change.
|
|
35
|
+
*/
|
|
36
|
+
type AuthorizeNetHostedMode = 'redirect';
|
|
37
|
+
type AuthorizeNetEnvironment = 'sandbox' | 'production';
|
|
38
|
+
/**
|
|
39
|
+
* Accept Hosted form targets. The pair is fixed by Authorize.Net and is
|
|
40
|
+
* selected by `environment`, so it is spelled as a literal union to keep a
|
|
41
|
+
* sandbox token from ever being posted at the production host.
|
|
42
|
+
*/
|
|
43
|
+
type AuthorizeNetPostUrl = 'https://test.authorize.net/payment/payment' | 'https://accept.authorize.net/payment/payment';
|
|
44
|
+
/**
|
|
45
|
+
* The eleven currencies Authorize.Net settles. An account is denominated in
|
|
46
|
+
* exactly one of them, so this is an allowlist for the merchant's account,
|
|
47
|
+
* not a per-cart choice.
|
|
48
|
+
*/
|
|
49
|
+
type AuthorizeNetCurrency = 'USD' | 'CAD' | 'GBP' | 'EUR' | 'AUD' | 'NZD' | 'CHF' | 'DKK' | 'NOK' | 'SEK' | 'PLN';
|
|
50
|
+
/** `transactionStatus` from getTransactionDetailsRequest, which drives the void-vs-refund branch. */
|
|
51
|
+
type AuthorizeNetTransactionStatus = 'authorizedPendingCapture' | 'capturedPendingSettlement' | 'authorizedPendingRelease' | 'settledSuccessfully' | 'declined' | 'voided' | 'refundSettledSuccessfully' | 'refundPendingSettlement' | 'FDSPendingReview' | 'FDSAuthorizedPendingReview';
|
|
52
|
+
/** Collapsed outcome for the storefront. 'held' means the transaction is sitting in Fraud Detection Suite review. */
|
|
53
|
+
type AuthorizeNetPaymentStatus = 'approved' | 'declined' | 'error' | 'held';
|
|
54
|
+
/** Prefix every Medusa payment provider id in the Authorize.Net family carries. */
|
|
55
|
+
type AuthorizeNetProviderIdPrefix = 'pp_authorize-net_';
|
|
56
|
+
/** Canonical id is `pp_authorize-net_authorize-net`; the template matches the whole family by prefix. */
|
|
57
|
+
type AuthorizeNetProviderId = `${AuthorizeNetProviderIdPrefix}${string}`;
|
|
58
|
+
/**
|
|
59
|
+
* Props the payment-adapter component receives from the storefront checkout.
|
|
60
|
+
* Field-for-field mirror of the starter-template storefront's
|
|
61
|
+
* `PaymentProviderComponentProps`. `cart` is `unknown` so this package keeps
|
|
62
|
+
* zero dependency on the storefront's path aliases.
|
|
63
|
+
*/
|
|
64
|
+
interface AuthorizeNetAdapterProps {
|
|
65
|
+
/** Active cart, for currency and total. Storefront's `Cart` shape. */
|
|
66
|
+
cart: unknown;
|
|
67
|
+
/** Raw `data` field from the initialized payment session, or null while loading. */
|
|
68
|
+
sessionData: Record<string, unknown> | null;
|
|
69
|
+
/** True while a network request (e.g. cart.complete()) is in flight. */
|
|
70
|
+
isCompleting: boolean;
|
|
71
|
+
/** Called after the buyer authorizes payment. */
|
|
72
|
+
onApproved: () => Promise<void>;
|
|
73
|
+
/** Called on provider-side error or buyer cancellation. */
|
|
74
|
+
onError: (msg: string) => void;
|
|
75
|
+
/**
|
|
76
|
+
* One-page checkout hook. When provided, the adapter must not render its
|
|
77
|
+
* own submit button and instead registers a confirm function with the outer
|
|
78
|
+
* "Pay now" bar. Call `registerConfirm(null)` on unmount.
|
|
79
|
+
*/
|
|
80
|
+
registerConfirm?: (fn: (() => Promise<void>) | null) => void;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Shape of the provider object the orchestrator-owned adapter template
|
|
84
|
+
* exports into `lib/payment-providers/authorize-net.tsx`. Mirrors the
|
|
85
|
+
* storefront's `PaymentProviderConfig` and is kept local for the same
|
|
86
|
+
* zero-storefront-dependency reason as `AuthorizeNetAdapterProps`.
|
|
87
|
+
*/
|
|
88
|
+
interface AuthorizeNetProviderRegistryEntry {
|
|
89
|
+
/** Canonical Medusa payment provider id, `pp_authorize-net_authorize-net`. */
|
|
90
|
+
id: AuthorizeNetProviderId;
|
|
91
|
+
/** Short human label for the picker button. */
|
|
92
|
+
label: string;
|
|
93
|
+
/** Layout hint for the stacked checkout. Accept Hosted leaves our origin, so it is 'redirect'. */
|
|
94
|
+
kind: 'express' | 'form' | 'redirect';
|
|
95
|
+
/** Matches every provider id in the family: `(id) => id.startsWith('pp_authorize-net_')`. */
|
|
96
|
+
matches?: (providerId: string) => boolean;
|
|
97
|
+
/** React component that mints the token and auto-submits the Accept Hosted form. */
|
|
98
|
+
Component: ComponentType<AuthorizeNetAdapterProps>;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export type { AuthorizeNetAdapterProps, AuthorizeNetCurrency, AuthorizeNetEnvironment, AuthorizeNetHostedMode, AuthorizeNetPaymentStatus, AuthorizeNetPostUrl, AuthorizeNetProviderId, AuthorizeNetProviderIdPrefix, AuthorizeNetProviderRegistryEntry, AuthorizeNetSessionData, AuthorizeNetTransactionStatus };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { ComponentType } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Session data returned by Amboras' multi-tenant Authorize.Net Accept Hosted
|
|
5
|
+
* provider. Authorize.Net hosts the card form, but unlike iyzico it does not
|
|
6
|
+
* hand back a navigable URL: `getHostedPaymentPageRequest` returns a token
|
|
7
|
+
* that has to be form-POSTed as `token` to the environment's Accept Hosted
|
|
8
|
+
* endpoint. Storefront adapters therefore auto-submit a hidden form instead
|
|
9
|
+
* of assigning `window.location`, and the token is minted at redirect time
|
|
10
|
+
* because it expires 15 minutes after it is issued.
|
|
11
|
+
*/
|
|
12
|
+
interface AuthorizeNetSessionData {
|
|
13
|
+
authorize_net_environment_id: string;
|
|
14
|
+
/** Accept Hosted form target for the selected environment. */
|
|
15
|
+
post_url?: AuthorizeNetPostUrl;
|
|
16
|
+
/** Accept Hosted token. Valid 15 minutes from mint; minted at redirect time. */
|
|
17
|
+
token?: string;
|
|
18
|
+
/** Only 'redirect' in T1. 'lightbox' and 'iframe' are T2. */
|
|
19
|
+
mode: AuthorizeNetHostedMode;
|
|
20
|
+
environment: AuthorizeNetEnvironment;
|
|
21
|
+
currency_code: AuthorizeNetCurrency;
|
|
22
|
+
/** Two-decimal string, already converted out of Amboras minor units. */
|
|
23
|
+
amount: string;
|
|
24
|
+
ref_id?: string;
|
|
25
|
+
trans_id?: string;
|
|
26
|
+
/** Masked account number from transactionResponse.accountNumber, e.g. 'XXXX0015'. */
|
|
27
|
+
account_number_masked?: string;
|
|
28
|
+
transaction_status?: AuthorizeNetTransactionStatus;
|
|
29
|
+
payment_status?: AuthorizeNetPaymentStatus;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Single-member union on purpose: adding Accept Hosted's lightbox and iframe
|
|
33
|
+
* modes in T2 is then a compile-visible widening rather than a silent string
|
|
34
|
+
* change.
|
|
35
|
+
*/
|
|
36
|
+
type AuthorizeNetHostedMode = 'redirect';
|
|
37
|
+
type AuthorizeNetEnvironment = 'sandbox' | 'production';
|
|
38
|
+
/**
|
|
39
|
+
* Accept Hosted form targets. The pair is fixed by Authorize.Net and is
|
|
40
|
+
* selected by `environment`, so it is spelled as a literal union to keep a
|
|
41
|
+
* sandbox token from ever being posted at the production host.
|
|
42
|
+
*/
|
|
43
|
+
type AuthorizeNetPostUrl = 'https://test.authorize.net/payment/payment' | 'https://accept.authorize.net/payment/payment';
|
|
44
|
+
/**
|
|
45
|
+
* The eleven currencies Authorize.Net settles. An account is denominated in
|
|
46
|
+
* exactly one of them, so this is an allowlist for the merchant's account,
|
|
47
|
+
* not a per-cart choice.
|
|
48
|
+
*/
|
|
49
|
+
type AuthorizeNetCurrency = 'USD' | 'CAD' | 'GBP' | 'EUR' | 'AUD' | 'NZD' | 'CHF' | 'DKK' | 'NOK' | 'SEK' | 'PLN';
|
|
50
|
+
/** `transactionStatus` from getTransactionDetailsRequest, which drives the void-vs-refund branch. */
|
|
51
|
+
type AuthorizeNetTransactionStatus = 'authorizedPendingCapture' | 'capturedPendingSettlement' | 'authorizedPendingRelease' | 'settledSuccessfully' | 'declined' | 'voided' | 'refundSettledSuccessfully' | 'refundPendingSettlement' | 'FDSPendingReview' | 'FDSAuthorizedPendingReview';
|
|
52
|
+
/** Collapsed outcome for the storefront. 'held' means the transaction is sitting in Fraud Detection Suite review. */
|
|
53
|
+
type AuthorizeNetPaymentStatus = 'approved' | 'declined' | 'error' | 'held';
|
|
54
|
+
/** Prefix every Medusa payment provider id in the Authorize.Net family carries. */
|
|
55
|
+
type AuthorizeNetProviderIdPrefix = 'pp_authorize-net_';
|
|
56
|
+
/** Canonical id is `pp_authorize-net_authorize-net`; the template matches the whole family by prefix. */
|
|
57
|
+
type AuthorizeNetProviderId = `${AuthorizeNetProviderIdPrefix}${string}`;
|
|
58
|
+
/**
|
|
59
|
+
* Props the payment-adapter component receives from the storefront checkout.
|
|
60
|
+
* Field-for-field mirror of the starter-template storefront's
|
|
61
|
+
* `PaymentProviderComponentProps`. `cart` is `unknown` so this package keeps
|
|
62
|
+
* zero dependency on the storefront's path aliases.
|
|
63
|
+
*/
|
|
64
|
+
interface AuthorizeNetAdapterProps {
|
|
65
|
+
/** Active cart, for currency and total. Storefront's `Cart` shape. */
|
|
66
|
+
cart: unknown;
|
|
67
|
+
/** Raw `data` field from the initialized payment session, or null while loading. */
|
|
68
|
+
sessionData: Record<string, unknown> | null;
|
|
69
|
+
/** True while a network request (e.g. cart.complete()) is in flight. */
|
|
70
|
+
isCompleting: boolean;
|
|
71
|
+
/** Called after the buyer authorizes payment. */
|
|
72
|
+
onApproved: () => Promise<void>;
|
|
73
|
+
/** Called on provider-side error or buyer cancellation. */
|
|
74
|
+
onError: (msg: string) => void;
|
|
75
|
+
/**
|
|
76
|
+
* One-page checkout hook. When provided, the adapter must not render its
|
|
77
|
+
* own submit button and instead registers a confirm function with the outer
|
|
78
|
+
* "Pay now" bar. Call `registerConfirm(null)` on unmount.
|
|
79
|
+
*/
|
|
80
|
+
registerConfirm?: (fn: (() => Promise<void>) | null) => void;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Shape of the provider object the orchestrator-owned adapter template
|
|
84
|
+
* exports into `lib/payment-providers/authorize-net.tsx`. Mirrors the
|
|
85
|
+
* storefront's `PaymentProviderConfig` and is kept local for the same
|
|
86
|
+
* zero-storefront-dependency reason as `AuthorizeNetAdapterProps`.
|
|
87
|
+
*/
|
|
88
|
+
interface AuthorizeNetProviderRegistryEntry {
|
|
89
|
+
/** Canonical Medusa payment provider id, `pp_authorize-net_authorize-net`. */
|
|
90
|
+
id: AuthorizeNetProviderId;
|
|
91
|
+
/** Short human label for the picker button. */
|
|
92
|
+
label: string;
|
|
93
|
+
/** Layout hint for the stacked checkout. Accept Hosted leaves our origin, so it is 'redirect'. */
|
|
94
|
+
kind: 'express' | 'form' | 'redirect';
|
|
95
|
+
/** Matches every provider id in the family: `(id) => id.startsWith('pp_authorize-net_')`. */
|
|
96
|
+
matches?: (providerId: string) => boolean;
|
|
97
|
+
/** React component that mints the token and auto-submits the Accept Hosted form. */
|
|
98
|
+
Component: ComponentType<AuthorizeNetAdapterProps>;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export type { AuthorizeNetAdapterProps, AuthorizeNetCurrency, AuthorizeNetEnvironment, AuthorizeNetHostedMode, AuthorizeNetPaymentStatus, AuthorizeNetPostUrl, AuthorizeNetProviderId, AuthorizeNetProviderIdPrefix, AuthorizeNetProviderRegistryEntry, AuthorizeNetSessionData, AuthorizeNetTransactionStatus };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/index.ts
|
|
17
|
+
var src_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(src_exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export type {\n AuthorizeNetSessionData,\n AuthorizeNetHostedMode,\n AuthorizeNetEnvironment,\n AuthorizeNetPostUrl,\n AuthorizeNetCurrency,\n AuthorizeNetTransactionStatus,\n AuthorizeNetPaymentStatus,\n AuthorizeNetProviderIdPrefix,\n AuthorizeNetProviderId,\n AuthorizeNetAdapterProps,\n AuthorizeNetProviderRegistryEntry,\n} from './types'\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@amboras-dev/authorize-net",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Authorize.Net Accept Hosted payment provider types for Amboras storefronts",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"require": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./package.json": "./package.json"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"peerDependencies": {
|
|
20
|
+
"react": ">=18"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@types/node": "^20.0.0",
|
|
25
|
+
"@types/react": "^18.0.0",
|
|
26
|
+
"tsup": "^8.0.0",
|
|
27
|
+
"typescript": "^5.0.0"
|
|
28
|
+
},
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "tsup",
|
|
34
|
+
"typecheck": "tsc --noEmit"
|
|
35
|
+
}
|
|
36
|
+
}
|