feat: Implement getInvoices graphQL query
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import axios from 'axios';
|
||||
import appConfig from '../../config/app';
|
||||
import { DateTime } from 'luxon';
|
||||
|
||||
const PADDLE_VENDOR_URL = appConfig.isDev
|
||||
? 'https://sandbox-vendors.paddle.com'
|
||||
@@ -22,8 +23,29 @@ const getSubscription = async (subscriptionId: number) => {
|
||||
return subscription;
|
||||
};
|
||||
|
||||
const getInvoices = async (subscriptionId: number) => {
|
||||
const data = {
|
||||
vendor_id: appConfig.paddleVendorId,
|
||||
vendor_auth_code: appConfig.paddleVendorAuthCode,
|
||||
subscription_id: subscriptionId,
|
||||
is_paid: 1,
|
||||
from: DateTime.now().minus({ years: 3 }).toISODate(),
|
||||
to: DateTime.now().plus({ days: 3 }).toISODate(),
|
||||
};
|
||||
|
||||
const response = await axiosInstance.post(
|
||||
'/api/2.0/subscription/payments',
|
||||
data
|
||||
);
|
||||
|
||||
const invoices = response.data.response;
|
||||
|
||||
return invoices;
|
||||
};
|
||||
|
||||
const paddleClient = {
|
||||
getSubscription,
|
||||
getInvoices,
|
||||
};
|
||||
|
||||
export default paddleClient;
|
||||
|
Reference in New Issue
Block a user