recurrente-js 1.0.3 → 1.0.4
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/api/recurrente.d.ts +14 -1
- package/dist/api/recurrente.js +33 -1
- package/dist/types/globals.d.ts +54 -0
- package/package.json +1 -1
package/dist/api/recurrente.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ProductSubscription, CreateSubscriptionResponse, SubscriptionStatusResponse, CreateProductRequest, CreateProductResponse, GetProductResponse, GetAllProductsResponse, UpdateProductRequest, CreateCheckoutRequest, CreateCheckoutResponse } from '../types/globals';
|
|
1
|
+
import { ProductSubscription, CreateSubscriptionResponse, SubscriptionStatusResponse, CreateProductRequest, CreateProductResponse, GetProductResponse, GetAllProductsResponse, UpdateProductRequest, CreateCheckoutRequest, CreateCheckoutResponse, CreateRefundRequest, CreateRefundResponse } from '../types/globals';
|
|
2
2
|
/**
|
|
3
3
|
* Recurrente API utility for managing product subscriptions, cancellations, and product deletions.
|
|
4
4
|
*
|
|
@@ -15,6 +15,8 @@ import { ProductSubscription, CreateSubscriptionResponse, SubscriptionStatusResp
|
|
|
15
15
|
* @property {Function} createSubscription - Creates a new subscription for a product.
|
|
16
16
|
* @property {Function} cancelSubscription - Cancels an existing subscription by its ID.
|
|
17
17
|
* @property {Function} getSubscription - Retrieves details of a specific subscription by its ID.
|
|
18
|
+
* @property {Function} createCheckout - Creates a new checkout with provided product ID.
|
|
19
|
+
* @property {Function} createRefund - Creates a new refund for a specific payment intent.
|
|
18
20
|
*/
|
|
19
21
|
declare const recurrente: {
|
|
20
22
|
/**
|
|
@@ -138,5 +140,16 @@ declare const recurrente: {
|
|
|
138
140
|
* @throws {ErrorResponse} Throws an error if the checkout creation fails.
|
|
139
141
|
*/
|
|
140
142
|
createCheckout: (checkoutData: CreateCheckoutRequest) => Promise<CreateCheckoutResponse>;
|
|
143
|
+
/**
|
|
144
|
+
* Creates a new refund for a specific payment intent.
|
|
145
|
+
*
|
|
146
|
+
* @function
|
|
147
|
+
* @memberof recurrente
|
|
148
|
+
* @see createRefund
|
|
149
|
+
* @param {CreateRefundRequest} refundData - The data containing the paymentIntentId to refund.
|
|
150
|
+
* @returns {Promise<CreateRefundResponse>} A promise that resolves with the refund details.
|
|
151
|
+
* @throws {ErrorResponse} Throws an error if the refund creation fails.
|
|
152
|
+
*/
|
|
153
|
+
createRefund: (refundData: CreateRefundRequest) => Promise<CreateRefundResponse>;
|
|
141
154
|
};
|
|
142
155
|
export default recurrente;
|
package/dist/api/recurrente.js
CHANGED
|
@@ -15,7 +15,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
const axios_1 = __importDefault(require("axios"));
|
|
16
16
|
const axiosInstance_1 = __importDefault(require("../config/axiosInstance"));
|
|
17
17
|
const conversion_1 = require("../utils/conversion");
|
|
18
|
-
// TODO: Implement namespaces
|
|
19
18
|
/**
|
|
20
19
|
* Creates a new checkout session.
|
|
21
20
|
*
|
|
@@ -251,6 +250,26 @@ const test = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
251
250
|
throw handleAxiosError(error);
|
|
252
251
|
}
|
|
253
252
|
});
|
|
253
|
+
/**
|
|
254
|
+
* Creates a new refund for a specific payment intent.
|
|
255
|
+
*
|
|
256
|
+
* This function takes a payment_intent_id, converts the payload to snake_case,
|
|
257
|
+
* and sends it to the API to process a refund.
|
|
258
|
+
*
|
|
259
|
+
* @param {CreateRefundRequest} refundData - The data containing the paymentIntentId to refund.
|
|
260
|
+
* @returns {Promise<CreateRefundResponse>} The response containing the details of the created refund.
|
|
261
|
+
* @throws {ErrorResponse} Throws an error if the refund creation fails.
|
|
262
|
+
*/
|
|
263
|
+
const createRefund = (refundData) => __awaiter(void 0, void 0, void 0, function* () {
|
|
264
|
+
try {
|
|
265
|
+
const refundDataInSnakeCase = (0, conversion_1.toSnakeCase)(refundData);
|
|
266
|
+
const response = yield axiosInstance_1.default.post('/refunds/', refundDataInSnakeCase);
|
|
267
|
+
return (0, conversion_1.toCamelCase)(response.data);
|
|
268
|
+
}
|
|
269
|
+
catch (error) {
|
|
270
|
+
throw handleAxiosError(error);
|
|
271
|
+
}
|
|
272
|
+
});
|
|
254
273
|
/**
|
|
255
274
|
* Recurrente API utility for managing product subscriptions, cancellations, and product deletions.
|
|
256
275
|
*
|
|
@@ -267,6 +286,8 @@ const test = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
267
286
|
* @property {Function} createSubscription - Creates a new subscription for a product.
|
|
268
287
|
* @property {Function} cancelSubscription - Cancels an existing subscription by its ID.
|
|
269
288
|
* @property {Function} getSubscription - Retrieves details of a specific subscription by its ID.
|
|
289
|
+
* @property {Function} createCheckout - Creates a new checkout with provided product ID.
|
|
290
|
+
* @property {Function} createRefund - Creates a new refund for a specific payment intent.
|
|
270
291
|
*/
|
|
271
292
|
const recurrente = {
|
|
272
293
|
/**
|
|
@@ -384,5 +405,16 @@ const recurrente = {
|
|
|
384
405
|
* @throws {ErrorResponse} Throws an error if the checkout creation fails.
|
|
385
406
|
*/
|
|
386
407
|
createCheckout,
|
|
408
|
+
/**
|
|
409
|
+
* Creates a new refund for a specific payment intent.
|
|
410
|
+
*
|
|
411
|
+
* @function
|
|
412
|
+
* @memberof recurrente
|
|
413
|
+
* @see createRefund
|
|
414
|
+
* @param {CreateRefundRequest} refundData - The data containing the paymentIntentId to refund.
|
|
415
|
+
* @returns {Promise<CreateRefundResponse>} A promise that resolves with the refund details.
|
|
416
|
+
* @throws {ErrorResponse} Throws an error if the refund creation fails.
|
|
417
|
+
*/
|
|
418
|
+
createRefund,
|
|
387
419
|
};
|
|
388
420
|
exports.default = recurrente;
|
package/dist/types/globals.d.ts
CHANGED
|
@@ -1333,3 +1333,57 @@ export type RecurrenteWebhookEvent = PaymentIntentSucceeded | PaymentIntentFaile
|
|
|
1333
1333
|
* @param event - The webhook event object.
|
|
1334
1334
|
*/
|
|
1335
1335
|
export type WebhookHandler<T> = (event: T) => void;
|
|
1336
|
+
/**
|
|
1337
|
+
* Represents the payload for creating a refund.
|
|
1338
|
+
*/
|
|
1339
|
+
export interface CreateRefundRequest {
|
|
1340
|
+
/**
|
|
1341
|
+
* The ID of the payment intent (`pa_...`) to be refunded.
|
|
1342
|
+
* @required
|
|
1343
|
+
*/
|
|
1344
|
+
paymentIntentId: string;
|
|
1345
|
+
}
|
|
1346
|
+
/**
|
|
1347
|
+
* Represents the response after successfully creating a refund.
|
|
1348
|
+
*/
|
|
1349
|
+
export interface CreateRefundResponse {
|
|
1350
|
+
/**
|
|
1351
|
+
* The unique identifier for the refund object (e.g., "re_...").
|
|
1352
|
+
* @required
|
|
1353
|
+
*/
|
|
1354
|
+
id: string;
|
|
1355
|
+
/**
|
|
1356
|
+
* The status of the refund.
|
|
1357
|
+
* @required
|
|
1358
|
+
*/
|
|
1359
|
+
status: 'succeeded' | 'pending' | 'failed';
|
|
1360
|
+
/**
|
|
1361
|
+
* The customer associated with the refunded payment.
|
|
1362
|
+
* @required
|
|
1363
|
+
*/
|
|
1364
|
+
customer: {
|
|
1365
|
+
id: string;
|
|
1366
|
+
email: string;
|
|
1367
|
+
fullName: string;
|
|
1368
|
+
};
|
|
1369
|
+
/**
|
|
1370
|
+
* The amount in cents that was refunded to your account balance.
|
|
1371
|
+
* @required
|
|
1372
|
+
*/
|
|
1373
|
+
accountRefundedAmountInCents: number;
|
|
1374
|
+
/**
|
|
1375
|
+
* The amount in cents that was refunded to the customer.
|
|
1376
|
+
* @required
|
|
1377
|
+
*/
|
|
1378
|
+
customerRefundedAmountInCents: number;
|
|
1379
|
+
/**
|
|
1380
|
+
* The currency of the refund.
|
|
1381
|
+
* @required
|
|
1382
|
+
*/
|
|
1383
|
+
currency: string;
|
|
1384
|
+
/**
|
|
1385
|
+
* The timestamp of when the refund was created.
|
|
1386
|
+
* @required
|
|
1387
|
+
*/
|
|
1388
|
+
createdAt: string;
|
|
1389
|
+
}
|