#arsani-sinout_api

1 messages ยท Page 1 of 1 (latest)

hoary nightBOT
#

๐Ÿ‘‹ Welcome to your new thread!

โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

๐Ÿ”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1221919220535656468

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

humble riverBOT
#

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

idle tapir
#

Can you double check that:

  • The full API key was copied correctly in to Postman
  • There isn't extra whitespace around your key
#

I am not sure if Postman trims whitespace but I suspect not

next zenith
#

Sure , one sec

#

Just checked , and both are already correct

#

Is it relates to the key being test ?

idle tapir
#

Yes, that error should only relate to the key. If it was the right key but the wrong customer we would have an error about the customer

next zenith
#

Should i use the Publishable key instead of the secret key ?

idle tapir
#

Secret key for creating customers, the public key only has read access and only to certain data on your account

hoary nightBOT
next zenith
#

I dont quite understand , which key should i be using then ?

idle tapir
#

Your secret key is the right one for this call. It looks like the secret key that you used for that successful call is similar to the one you used for this one. Trying to see if I can get more insight in to what was wrong with that second call

next zenith
#

Yes , please

next zenith
#

Maybe the header ?

fast whale
#

๐Ÿ‘‹ stepping in for my teammate.

#

I deleted your last message since you shared the full string of your test secret key.

next zenith
#

Yes , thanks for that

fast whale
#

Since this is a public channel, I recommend rolling your key. I looked through our logs and, while the key you used in Postman ends in the same characters/letters as the key you used with some Python code earlier today, the key is slightly different

#

I'm not sure if perhaps you accidentally added some characters somewhere in the middle of that key but they don't match

next zenith
#

One sec , will reroll it

#

Just did, but nothing changed

fast whale
#

"Just did, but nothing changed" - what does this mean exactly?

next zenith
#

I did reroll the key , but still getting the same response

#

Just retried my python code and it worked

#

Dont know how is that possible

fast whale
#

Not sure how you rolled it/if you opted to expire at a later time

next zenith
#

What do you mean by reroll it ?

#

Also , how do i charge a customer using their existing balance and how to i charge them to add to their balance ?

#

What parts of the documentation will i find this in ?

fast whale
next zenith
#

Just used this python , but it gave bad request

#

Any suggestions ?

fast whale
#

What are you trying to do exactly?

next zenith
#

To charge the customer

fast whale
#

Are you following a specific guide/doc?

next zenith
#

Yes , the one you sent

fast whale
#

This doesn't look correct. I'm not sure why you're using customer and payment_method in the body of your request.

next zenith
#

I removed them ,but still getting bad access

fast whale
#

Can you share the ID of the customer you're working with? If you make a get call to retrieve that customer, do they have a balance?

next zenith
#

req_W7ouUegbzLSTgh

next zenith
fast whale
#

Got it. I think there's a misunderstanding. By "recharge their balance", do you mean you want to give them a credit because you overcharged them or want to reduce the amount they need to pay later?

#

What's your ultimate goal here?

next zenith
#

So , my ultimate goal is to charge them from the credit (balance) they already have, if this credit (balance) falls under a certain threshold , i charge their card to recharge their credit (balance)

#

So here , i am trying to recharge their balance , then charge them by deducting from their balance

#

Any thoughts ?

fast whale
#

I still don't quite follow what you're trying to do.

#

charge them from the credit (balance) they already have
How do you want them to accumulate this balance? Like, do you plan on having them pay for this amount?

hoary nightBOT
next zenith
#

Say my customer will pay 5000 , this is their balance
Whenever they buy something (say for 50) , i deduct the 50 from the 5000

#

If their balance falls below 10 , i add 4990 to make it 5000 agin

#

So these are the 2 API request i want to acheive

#

1- recharge their balance
2- charge them (by deductng from their balance)

fast whale
#

Got it. The customer balance is not what you think it is. If you want to charge customers for the 5000, you'll need to create a PaymentIntent with the appropriate amount so that customer pays you that amount. You'll need to keep track of any "credits" they have on your end and charge them again by creating another PaymentIntent for the right amount when they deplete their credits/when they fall below a threshold

next zenith
#

Okay so 2 questions:
1- how to make a PaymentIntent
2- how to creat an API request to credit them (deduct from their balance) ?

fast whale
#

For # 2, you'll need to keep track of this yourself. I'm assuming you want to charge customers the 5000, have these funds to into your Stripe balance, and then charge the customer again at a later time, correct? You'll need to keep track of when you need to charge them again and what amount.

next zenith
#

I am trying to do this using python , so what is the API endpoint to check the customer's "balance" (or the remaining from the 5000 in this case) ?

fast whale
#

I'm not sure we're understanding each other. When a customer pays 5000, is your goal to use Stripe to charge them the full amount immediately?

next zenith
#

I am using Stripe to do several things

#

1- check for the balance (remaining from 5000)

#

2- deduct from this balance

fast whale
#

Let's focus on your example flow:

Say my customer will pay 5000 , this is their balance
Whenever they buy something (say for 50) , i deduct the 50 from the 5000
If their balance falls below 10 , i add 4990 to make it 5000 agin

next zenith
#

3- recharge the balance

#

Sure

#

1- read the balance of the customer (remaining from 5000)
2- deduct 5 from the 5000 (balance or what is remaining)

#

3- on a certain condition based on step 1 , recharge the 5000

fast whale
#

I think you're still lost. Let's try another approach. When is money being transferred from the customer to your Stripe account's balance?

next zenith
#

when the balance fall below a threshold , also this money is saved as the customer's balance that i deduct from it whenever a payment is needed

#

Is the balance we're talking about the same as credit balance ?

fast whale
#

No, I don't think we're talking about the same thing. Can you answer this question: when is money being transferred from the customer to your Stripe account's balance?

next zenith
#

when the balance fall below a threshold

#

I dont want in my own balance , this is what i am talking about , i want it as the customer's balance on my Stripe

#

Is that considered a subscription ?

#

I need to understand in order to talk to you in the right terminaology

fast whale
#

i want it as the customer's balance on my Stripe
I don't understand what you mean by this. When exactly do you want a customer to pay?

next zenith
#

I want him to have a balance not to pay and thats it , i want them to have a balance that i deduct from it whenever a paymenet is done

#

I am talking about my customers prepaying

fast whale
#

If customers prepay, you'll create a PaymentIntent for the full amount they're prepaying. This full amount is charged to their credit card (or whatever other payment method they choose when paying) and the full amount is transferred to your Stripe account's balance.

If your goal is to allow the customer to do different things on your app up to the amount they prepaid, you will need to keep track of this activity. Then, when they "use up" the activity that covers the amount they prepaid, you can create another PaymentIntent for the next amount they should pay. Does that make sense?

next zenith
#

Meaning that i can never know how much of the 5000 have they "used up" in a certain point of time ?

#

Because i think Stripe has this option

fast whale
#

I think that's where there's a misunderstanding. There's a concept of "usage" on Stripe (with Subscriptions) but we don't calculate this. Users are responsible for reporting usage data to us

next zenith
#

So how do subscriptions work ? in steps ?

fast whale
#

Testing this out will give you an idea of what's possible in Stripe and if this fits with the flow you have in mind

#

If you have any questions as you test, you can come back here and share with us specific examples of what you've tried and what you're trying to achieve

next zenith
#

So i just succeeded in doing what i want using credit balance and invoices , but using the GUI

#

Can you help me develop APIs fo these please

fast whale
#

Any adjustments to a customer's balance in the Dashboard doesn't result in charging the customer so I'm not quite sure what you're doing

next zenith
#

What happens when i adjust credit balance or create an invoice ?

fast whale
#

adjusting a customer's credit balance means they'll either see a credit on their next invoice (the invoice amount will be decreased) or a debit on their next invoice (the invoice amount will be increased). you still need to create an invoice and prompt the customer to pay that invoice

next zenith
#

That is what i am trying to do

#

Can you help me technically ?

#

data = {
"customer": CustomerID, # ID of the customer to be billed
# Optional fields (see Stripe documentation for details):
"line_items": [
{
"amount": ChargeAmount,
"currency": "usd",
"description": "ACA call"
}
]
}
response = requests.post(url="https://api.stripe.com/v1/invoices", headers=headers, json=data)
response.raise_for_status()
invoice = response.json()

#

I did this now , but got bad request as a response

vestal oriole
#

Hi, taking over as roadrunner_stripe needs to step away. Let me catch up

next zenith
#

Okay thanks

#

Can you please tell me what's wrong with the API above ?

vestal oriole
next zenith
#

It gives bad request so it doesnt show on stripe

vestal oriole
#

Ah, I miss interpreted that.

#

What languare are you using?

next zenith
#

Python

vestal oriole
#

Can you try that?

next zenith
#

Here is what i did , i get bad request for this request

vestal oriole
#

What is the specific error? Can you share that here?

next zenith
#

bad request

vestal oriole
#

It looks like you're passing the 'data' as json. Our API expects you to pass the data in form-encoded request bodies. I highly recommend that you use our official library, https://github.com/stripe/stripe-python instead. Or, you can also try to pass the 'data' in a form-encoded request

next zenith
#

thank you , can you leave this ticket open for tomorrow ?

vestal oriole
#

I'm afraid we can't leave this thread open. Feel free to come back tomorrow and fill out the form again. We're happy to help.