chargeInvoice - better operation result feedback
MODIFY
src/integration/billing/stripe/StripeBillingIntegration.ts
src/integration/billing/stripe/StripeBillingIntegration.ts
@@ -460,12 +460,7 @@ export default class StripeBillingIntegration extends BillingIntegration<StripeB
// Fetch the invoice from stripe (do NOT TRUST the local copy)
let stripeInvoice: invoices.IInvoice = await this.stripe.invoices.retrieve(invoice.invoiceID);
// Check the current invoice status
- if (stripeInvoice.status === 'paid') {
- return {
- // TODO - Handle inconsistencies - Operation failed - unexpected status
- invoiceStatus: stripeInvoice.status
- };
- }
+ if (stripeInvoice.status !== 'paid') {
// Finalize the invoice (if necessary)
if (stripeInvoice.status === 'draft') {
stripeInvoice = await this.stripe.invoices.finalizeInvoice(invoice.invoiceID);
@@ -474,15 +469,14 @@ export default class StripeBillingIntegration extends BillingIntegration<StripeB
if (stripeInvoice.status === 'open') {
// Set the payment options
// TODO - default payment is used by default - is this ok?
- const paymentOptions: invoices.IInvoicePayOptions = {
- };
- const operationResult: invoices.IInvoice = await this.stripe.invoices.pay(invoice.invoiceID, paymentOptions);
- return operationResult;
+ const paymentOptions: invoices.IInvoicePayOptions = {};
+ stripeInvoice = await this.stripe.invoices.pay(invoice.invoiceID, paymentOptions);
+ }
}
// TODO - Handle inconsistencies - Operation failed - unexpected status
return {
- // ##CR - to be clarified
- invoiceStatus: stripeInvoice.status
+ invoiceStatus: stripeInvoice.status,
+ rawData: stripeInvoice
};
}

chargeInvoice - better operation result feedback