@simpleapps-com/augur-api
Version:
TypeScript client library for Augur microservices API endpoints
137 lines • 5.36 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PaymentsClient = void 0;
const base_client_1 = require("../../core/base-client");
const schemas_1 = require("./schemas");
/**
* Client for the Payments API service
*
* Provides access to payment processing operations through Element Express integration,
* including transaction setup, account management, and billing operations.
*
* @example
* ```typescript
* const api = new AugurAPI({ bearerToken: 'token', siteId: 'site' });
*
* // Create transaction setup
* const setup = await api.payments.unified.transactionSetup({ customerId: '123' });
*
* // Query account information
* const account = await api.payments.unified.accountQuery({
* customerId: '123',
* transactionSetupId: setup.data.transactionSetupId
* });
* ```
*/
class PaymentsClient extends base_client_1.BaseServiceClient {
constructor(http, baseUrl = 'https://payments.augur-api.com') {
super('payments', http, baseUrl);
/**
* Unified payment operations through Element Express
*/
this.unified = {
/**
* Creates a new payment transaction session with customer and account information
*/
transactionSetup: async (params) => {
return this.executeRequest({
method: 'GET',
path: '/api/unified/transaction-setup',
paramsSchema: schemas_1.TransactionSetupParamsSchema,
responseSchema: schemas_1.TransactionSetupResponseSchema,
}, params);
},
/**
* Retrieves payment account information using a transaction setup ID
*/
accountQuery: async (params) => {
return this.executeRequest({
method: 'GET',
path: '/api/unified/account-query',
paramsSchema: schemas_1.AccountQueryParamsSchema,
responseSchema: schemas_1.AccountQueryResponseSchema,
}, params);
},
/**
* Updates billing information for an existing transaction
*/
billingUpdate: async (params) => {
return this.executeRequest({
method: 'GET',
path: '/api/unified/billing-update',
paramsSchema: schemas_1.BillingUpdateParamsSchema,
responseSchema: schemas_1.BillingUpdateResponseSchema,
}, params);
},
/**
* Retrieves formatted card information for a transaction
*/
cardInfo: async (params) => {
return this.executeRequest({
method: 'GET',
path: '/api/unified/card-info',
paramsSchema: schemas_1.CardInfoParamsSchema,
responseSchema: schemas_1.CardInfoResponseSchema,
}, params);
},
/**
* Calculates payment processing surcharges based on location and payment details
*/
surcharge: async (params) => {
return this.executeRequest({
method: 'GET',
path: '/api/unified/surcharge',
paramsSchema: schemas_1.SurchargeParamsSchema,
responseSchema: schemas_1.SurchargeResponseSchema,
}, params);
},
/**
* Validates an existing transaction setup
*/
validate: async (params) => {
return this.executeRequest({
method: 'GET',
path: '/api/unified/validate',
paramsSchema: schemas_1.ValidateParamsSchema,
responseSchema: schemas_1.ValidateResponseSchema,
}, params);
},
};
/**
* Legacy Element Express payment processing
*
* @deprecated This endpoint appears to be a legacy Element Express integration
* and may be deprecated in favor of the unified endpoints.
*/
this.element = {
/**
* Process payment through legacy Element Express integration
*/
payment: async (params) => {
return this.executeRequest({
method: 'GET',
path: '/element/payment',
paramsSchema: schemas_1.ElementPaymentParamsSchema,
responseSchema: schemas_1.ElementPaymentResponseSchema,
}, params);
},
};
/**
* Comprehensive health check that validates site configuration and triggers seeding jobs
*/
this.getHealthCheck = this.createHealthCheckMethod(schemas_1.HealthCheckResponseSchema);
/**
* Simple availability check endpoint
*/
this.getPing = async () => {
return this.executeRequest({
method: 'GET',
path: '/api/ping',
responseSchema: schemas_1.PingResponseSchema,
requiresAuth: false,
});
};
}
}
exports.PaymentsClient = PaymentsClient;
//# sourceMappingURL=client.js.map