@abdelrahman.rabie/payment-sdk-react-native
Version:
React Native SDK for payment processing with E_API and E_LINKS support
48 lines (47 loc) • 1.48 kB
JavaScript
import { HttpClient } from '../services/httpClient';
import { PaymentService } from '../services/paymentService';
export class PaymentSDK {
constructor(config) {
this.config = config;
this.httpClient = new HttpClient(config);
this.paymentService = new PaymentService(this.httpClient);
}
/**
* Initialize payment info
*/
async initializePayment(product, paymentToken) {
return this.paymentService.getPaymentInfo(product, paymentToken);
}
/**
* Execute payment
*/
async executePayment(product, paymentToken, payload) {
return this.paymentService.processPayment(product, paymentToken, payload);
}
/**
* Get payment status/details
*/
async getPaymentStatus(product, paymentToken) {
return this.paymentService.getPaymentInfo(product, paymentToken);
}
/**
* Validate Apple Pay merchant for Apple Pay payments
*/
async validateApplePayMerchant(validationURL) {
return this.paymentService.validateApplePayMerchant(validationURL);
}
/**
* Update SDK configuration
*/
updateConfig(newConfig) {
this.config = Object.assign(Object.assign({}, this.config), newConfig);
this.httpClient = new HttpClient(this.config);
this.paymentService = new PaymentService(this.httpClient);
}
/**
* Get current configuration
*/
getConfig() {
return Object.assign({}, this.config);
}
}