#JCrags - bug

1 messages ยท Page 1 of 1 (latest)

brazen brook
#

What kind of bug have you encountered?

#

We have a bug bounty program through hackerone

distant panther
#

Like I described, and let's say I have credited all invoice line items, then there is still an amount left to be credited, but I simply can't credit it.

#

Let's say I have an invoice:

#

Now I want to credit this invoice so I would click "Create credit note" button, then I select all the line items. and done, but the problem is the amounts are not correct.

#

Not only that, when I have selected all the lines to be credited, there is still this amount left to be credited and I can't do anything about it...

#

You can see an example in this picture.

#

The only way to correct this would be to create an additional invoice and set a negative amount, but Stripe doesn't allow this either, so I am completely stuck here.

#

I'd have to use a different invoice system in order to create an credit invoice now.

#

Anyway, I got dinner, I will check back later. I hope this can be resolved though. I have also submitted a ticket to stripe via email (just so you know, but I thought it would be good idea to share it here too).

brazen brook
#

Apologies I dropped off this thread, we are looking in to this and will get back with you on what we can find.

distant panther
#

Thank you ๐Ÿ™‚

#

On thing I did notice is this:

#

When I did a test with an invoice that had VAT - Netherlands (21% inclusive) I was able to credit all the lines correctly without a problem. The amounts were correct and everything was OK. So maybe it has something to do with the following situation:

  • API request to create invoice item with tax behavior set to "inclusive"
  • API request to create invoice with automatic tax enabled
  • The customer invoices has a Business number (Tax ID) and thus the VAT rule is "reverse charge", or the customer has no Tax ID but is outside my home country (NL) and thus no Tax is displayed on the invoice itself
brittle roost
#

Hi ๐Ÿ‘‹
Thank you for this. To be clear, are these the steps you took to produce the bug behavior or was this the flow that resulted in the correct behavior?

#

It would be super helpful to have a set of steps we can use to reproduce this error so we can be sure we are creating/refunding the invoice in the same way you did

distant panther
#

Ok, I will try to explain it in full details please give me a sec.

brittle roost
#

Sure thing and thanks in advance for this

distant panther
#

1.0) User registers with just email and password
1.2) We create a customer account in stripe (without any billing details)
1.1) We create an account in our database, we also store the cus_XXXX ID (without any billing details)

2.0) User now makes a payment via Paypal, we store the Order ID in our database, we still do not store any billing details also not from paypal data

3.0) We do not yet generate an invoice either, user will first have to enter their billing details inside their dashboard in our system

4.0) User receives email that hey must enter their billing details

5.0) User logs into our system, enters billing details and clicks "Save" button

6.0) Our system makes a couple of API requests to stripe now which are as follows:
6.1) Get the customer based on cus_XXXX ID that we previously stored
6.2) If user entered Tax ID number we will create and store it in stripe along with billing details
6.3) If user already had a Tax ID but it is different we update the tax ID on Stripe side
6.4) If user had a Tax ID but emptied it we delete it on Stripe side

#

7.0) Now we check if the user entered their billing details for the first time, and if so we lookup any Paypal transactions that belong to the user based on the Order ID previously stored
7.1) If there are transactions we create a new invoice item for each of them by calling the Stripe API
7.2) We set the Tax behavior for the line item to "inclusive", the full code used as below (probably important here):

params := &stripe.InvoiceItemParams{
    Currency:    stripe.String(i.UnitAmount.Currency),
    Customer:    stripe.String(u.StripeCustomerId),
    Description: stripe.String(i.Name + " - " + transactionId),
    Period: &stripe.InvoiceItemPeriodParams{
        Start: stripe.Int64(periodStart),
        End:   stripe.Int64(periodEnd),
    },
    Quantity: stripe.Int64(1),
    PriceData: &stripe.InvoiceItemPriceDataParams{
        Currency:    stripe.String("USD"),
        Product:     stripe.String(productId),
        TaxBehavior: stripe.String("inclusive"),
        UnitAmount:  stripe.Int64(newAmount),
    },
}

8.0) Now we create the new Invoice by calling the Stripe API, note that we have automatic tax enabled

iparams := &stripe.InvoiceParams{
    Customer:    stripe.String(u.StripeCustomerId),
    Description: stripe.String("Paid with Paypal"),
    AutomaticTax: &stripe.InvoiceAutomaticTaxParams{
        Enabled: stripe.Bool(true),
    },
}

9.0) Since we want to marke the invoice as paid outside of Stripe, soe we call this final API endpoint:

ipParams := &stripe.InvoicePayParams{
    PaidOutOfBand: stripe.Bool(true),
}
newIn, err = stripeInvoice.Pay(
    newIn.ID,
    ipParams,
)
  1. The invoice is created without a problem, the amounts are correct, the tax if any is also correct, however whenever you'd want to credit the invoice, for invoices that had no Tax or reverse charge the values are incorrect for the credit note
#

as shown in the pictures that I sent earlier.

brittle roost
#

Thank you for this. I have taken down these steps and will be investigating. If this is a bug it will be raised internally. Thanks again

distant panther
#

You're welcome, have a good day ๐Ÿ™‚

#

ps. I still have an invoice that has this issue, and I haven't created any credit note(s) for it just yet. So I will leave it untouched until a solution / patch is found. It's invoice ID: in_1KVuNzFKn7uROhgCgZkFzQD1 (in case it might help the investigation)