@payabli/component-contracts 0.2.0 → 0.3.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 CHANGED
@@ -386,16 +386,21 @@ const payin = payabli.create('payin', {
386
386
  #### Success and errors
387
387
 
388
388
  `success` and React's `onSuccess` report confirmed success only. `submit()` resolves with the same result data.
389
- `PayInSuccessPayload.transactionId` identifies a pay or auth transaction when present.
390
- The wire success data remains an open record. The SDK preserves fields it does not interpret.
391
-
392
- For tokenize sessions, `SUBMIT_RESULT.data`, the `success` event, and the `submit()` result contain:
389
+ The payload is `PayInSuccessPayload`, one closed shape for every operation:
393
390
 
394
391
  ```ts
395
- { referenceId: string, customerId?: number, methodReferenceId?: string }
392
+ {
393
+ operation: 'pay' | 'auth' | 'tokenize',
394
+ method: 'card' | 'ach' | 'check' | 'applepay' | 'googlepay',
395
+ transactionId?: string, // pay, auth
396
+ storedMethodId?: string, // tokenize; pay or auth that saved the method
397
+ customerId?: number, // when the API created or matched a customer
398
+ paymentMethod?: { maskedAccount?, accountType?, expiration?, holderName? },
399
+ amount?: { total: number, serviceFee?: number, currency?: string }, // pay, auth
400
+ }
396
401
  ```
397
402
 
398
- `referenceId` is the saved payment method ID, not a transaction ID. `PayInSuccessPayload` declares it as an optional string.
403
+ `transactionId` is the Payabli transaction id. `storedMethodId` is the saved payment method id: pass it back as `storedMethodId` on a later payment. The API response body does not reach the page.
399
404
 
400
405
  A failed `SUBMIT_RESULT` rejects `submit()` and emits `error`, mapped to React's `onError`.
401
406
  Errors have `{ code, message, recoverable, details? }`. The SDK forwards the code and message unchanged.
@@ -92,13 +92,41 @@ export declare const payinEvents: {
92
92
  vendorId: z.ZodMiniString<string>;
93
93
  }, z.core.$strip>;
94
94
  };
95
+ /** The session operation the payload reports on. */
96
+ export type PayInOperation = 'pay' | 'auth' | 'tokenize';
95
97
  /**
96
- * SUBMIT_RESULT.data for PayIn. Open on purpose: the transaction result grows
97
- * fields the SDK does not interpret, and it forwards all of them.
98
+ * SUBMIT_RESULT.data for PayIn: the `success` event payload and the `submit()`
99
+ * result. One closed shape for every operation, so a partner handles the
100
+ * result without branching on the operation. payhub builds it from the API
101
+ * result; the API body itself never reaches the page.
98
102
  */
99
103
  export type PayInSuccessPayload = {
100
- /** The transaction ID for pay or auth sessions. */
104
+ operation: PayInOperation;
105
+ /** The method the buyer used. */
106
+ method: PaymentMethodName;
107
+ /** The Payabli transaction id. Present for `pay` and `auth`. */
101
108
  transactionId?: string;
102
- /** The saved payment method ID for tokenize sessions. */
103
- referenceId?: string;
104
- } & Record<string, unknown>;
109
+ /**
110
+ * The saved payment method id. Present for `tokenize`, and for `pay` or `auth`
111
+ * when the session saved the method. Pass it back as `storedMethodId` on a
112
+ * later payment.
113
+ */
114
+ storedMethodId?: string;
115
+ /** The Payabli customer id when the API created or matched a customer. */
116
+ customerId?: number;
117
+ paymentMethod?: {
118
+ /** The account with every digit but the last four hidden, for example `5XXXXXXXXXXX0055`. */
119
+ maskedAccount?: string;
120
+ /** The card brand (`mastercard`) or the bank account type (`checking`). */
121
+ accountType?: string;
122
+ /** The card expiration, `MM/YY`. */
123
+ expiration?: string;
124
+ holderName?: string;
125
+ };
126
+ /** The charged or authorized amount. Present for `pay` and `auth`. */
127
+ amount?: {
128
+ total: number;
129
+ serviceFee?: number;
130
+ currency?: string;
131
+ };
132
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payabli/component-contracts",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Wire schemas, component registry, and partner-facing types shared by the Payabli embedded components SDK and payhub.",
5
5
  "private": false,
6
6
  "license": "MIT",