#bioworkflows

1 messages · Page 1 of 1 (latest)

main berryBOT
tepid creek
#

How did you set up the customer balance, do you have an example you can share?

#

Note this only applies to invoices, not one time payments

floral herald
#

I call stripe.Customer.create_balance_transaction to directly credit the customer or when they redeem a giftcard.

#

I can see their balance from Customer.balance , and I can also adjust balance directly, but it appears better to keep a record of Charge and Refund for their purchases to avoid having two sets of records in the system (pay with card checkout session and direct balance adjustment).

tepid creek
#

There wouldn't be any actual charge/payment though, right?

floral herald
#

Yes.

#

Since my system keeps tracks of Charge (obtained from Checkout Session and Payment Intent after successful checkout) and Refund, all I need is a valid Charge object that charges directly from customers' credit balance.

tepid creek
#

That's not how that works for customer credits -- the invoice and balance is adjusted, there's no charge/payment

floral herald
#

OK. I am fine with creating an Invoice, but I would like Invoice.pay to happen silently when users have enough credit balance.

tepid creek
#

You'd see these as customer balance transactions debitting against that credit you set up

floral herald
#

Right now the system requires customers to have a working payment method.

tepid creek
#

Do you have an example invoice I can look at?

#

I can try out and see what i see

floral herald
#

No. I removed all test data yesterday and changed the code since Invoice.pay did not work. I can try it again this weekend though.

#

Basically, I created (through API) InvoiceItem and Invoice. I then called Invoice.finalize and hoped that the credit balance would be applied (and it did not). I then called Invoice.pay but the system asks for a vlid payment method for the Customer. So essentially users have to register a credit card before they can use their credit balance, which I would like to avoid.

tepid creek
#

I then called Invoice.finalize and hoped that the credit balance would be applied (and it did not).
This should happen, and did during my testing just now

#

I was also able to call /pay for the draft invoice and it similar required no payment method

#

So I think it would be best to retry carefully and share a specific example invoice/request if it doesn't do what you expect

floral herald
#

Thanks. Maybe I did something wrong. I will test again this weekend. Assuming Invoice.finalize will trigger a balance transaction, I can keep a record of Invoices as a source of Refund, which will reverse the balance adjustment, right?

#

The API says Refund -> charge: ID of the charge that was refunded. So to create a refund from the Invoice, the Invoice must have a Charge to start with. Hopefully Invoice.finalize will create a Charge.

tepid creek
#

If there is no actual payment required it will not create a payment intent/ charge, no. It will create customer balance transaction only.

#

There's no payment, so there is no "refund" possible

#

(assuming the credit covers the invoice entirely)