mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-17 04:55:42 +09:00
fix(api): mirror Stripe billing data using the shapes the pinned API version sends (#1708)
This commit is contained in:
1 parent
1922d56188
commit
7e1ca9ed6a
13 files changed
+160
-153
No files matched your search
@@ -742,6 +742,9 @@ class BillingAdminControllerService {
|
||||
refundTarget,
|
||||
subscription,
|
||||
});
|
||||
if (refundDecision.amountCents !== null && !refundTarget) {
|
||||
throw new StripeError('No paid Stripe invoice with a refundable payment was found for this subscription');
|
||||
}
|
||||
const intentId = await this.billingRepository.actionIntents.create({
|
||||
userId: BigInt(syncedTargetUser.id),
|
||||
actorAdminId: BigInt(params.adminUserId),
|
||||
@@ -758,10 +761,7 @@ class BillingAdminControllerService {
|
||||
await this.billingRepository.actionIntents.markStage(intentId, 'sub_canceled', {
|
||||
sub_canceled_at: new Date(),
|
||||
});
|
||||
if (refundDecision.amountCents !== null) {
|
||||
if (!refundTarget) {
|
||||
throw new StripeError('No paid Stripe invoice with a refundable payment was found for this subscription');
|
||||
}
|
||||
if (refundDecision.amountCents !== null && refundTarget) {
|
||||
refund = await this.stripe.refunds.create(
|
||||
{
|
||||
...(refundTarget.paymentIntentId
|
||||
|
||||
@@ -283,7 +283,7 @@ describe('Admin billing overview', () => {
|
||||
invoices: {
|
||||
[params.invoiceId]: {
|
||||
customer: params.stripeCustomerId,
|
||||
subscription: params.stripeSubscriptionId,
|
||||
subscriptionId: params.stripeSubscriptionId,
|
||||
amount_due: params.amountPaidCents,
|
||||
amount_paid: params.amountPaidCents,
|
||||
billing_reason: 'subscription_cycle',
|
||||
@@ -359,7 +359,7 @@ describe('Admin billing overview', () => {
|
||||
invoices: {
|
||||
in_local_checkout_1: {
|
||||
customer: stripeCustomerId,
|
||||
subscription: 'sub_billing_target',
|
||||
subscriptionId: 'sub_billing_target',
|
||||
amount_due: 499,
|
||||
amount_paid: 499,
|
||||
billing_reason: 'subscription_create',
|
||||
@@ -396,7 +396,7 @@ describe('Admin billing overview', () => {
|
||||
},
|
||||
in_renewal_1: {
|
||||
customer: stripeCustomerId,
|
||||
subscription: 'sub_billing_target',
|
||||
subscriptionId: 'sub_billing_target',
|
||||
amount_due: 499,
|
||||
amount_paid: 499,
|
||||
billing_reason: 'subscription_cycle',
|
||||
@@ -545,7 +545,7 @@ describe('Admin billing overview', () => {
|
||||
invoices: {
|
||||
[invoiceId]: {
|
||||
customer: stripeCustomerId,
|
||||
subscription: stripeSubscriptionId,
|
||||
subscriptionId: stripeSubscriptionId,
|
||||
amount_due: 499,
|
||||
amount_paid: 499,
|
||||
billing_reason: 'subscription_create',
|
||||
|
||||
Reference in new issue
Block a user