@simpleapps-com/augur-api
Version:
TypeScript client library for Augur microservices API endpoints
139 lines • 5.53 kB
JavaScript
import { BaseServiceClient } from '../../core/base-client';
import {
// Health schemas
HealthCheckResponseSchema, PingResponseSchema,
// Unified payment schemas
TransactionSetupParamsSchema, TransactionSetupResponseSchema, AccountQueryParamsSchema, AccountQueryResponseSchema, BillingUpdateParamsSchema, BillingUpdateResponseSchema, CardInfoParamsSchema, CardInfoResponseSchema, SurchargeParamsSchema, SurchargeResponseSchema, ValidateParamsSchema, ValidateResponseSchema,
// Element payment schemas
ElementPaymentParamsSchema, ElementPaymentResponseSchema, } from './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
* });
* ```
*/
export class PaymentsClient extends 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: TransactionSetupParamsSchema,
responseSchema: 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: AccountQueryParamsSchema,
responseSchema: AccountQueryResponseSchema,
}, params);
},
/**
* Updates billing information for an existing transaction
*/
billingUpdate: async (params) => {
return this.executeRequest({
method: 'GET',
path: '/api/unified/billing-update',
paramsSchema: BillingUpdateParamsSchema,
responseSchema: BillingUpdateResponseSchema,
}, params);
},
/**
* Retrieves formatted card information for a transaction
*/
cardInfo: async (params) => {
return this.executeRequest({
method: 'GET',
path: '/api/unified/card-info',
paramsSchema: CardInfoParamsSchema,
responseSchema: 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: SurchargeParamsSchema,
responseSchema: SurchargeResponseSchema,
}, params);
},
/**
* Validates an existing transaction setup
*/
validate: async (params) => {
return this.executeRequest({
method: 'GET',
path: '/api/unified/validate',
paramsSchema: ValidateParamsSchema,
responseSchema: 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: ElementPaymentParamsSchema,
responseSchema: ElementPaymentResponseSchema,
}, params);
},
};
/**
* Comprehensive health check that validates site configuration and triggers seeding jobs
*/
this.getHealthCheck = this.createHealthCheckMethod(HealthCheckResponseSchema);
/**
* Simple availability check endpoint
*/
this.getPing = async () => {
return this.executeRequest({
method: 'GET',
path: '/api/ping',
responseSchema: PingResponseSchema,
requiresAuth: false,
});
};
}
}
//# sourceMappingURL=client.js.map