#nugax_api

1 messages ¡ Page 1 of 1 (latest)

earnest tokenBOT
#

👋 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/1239581687969484842

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

magic laurelBOT
#

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.

main mantle
#

Hello there

fresh shard
#

Hi bismarck

main mantle
#

Hmm the request you provided is an erroring Price creation request since you didn't pass an amount

#

Can you tell me more about the issue you are having?

fresh shard
#

So i will probably need to explain my issue

#

I have code written for stripe api that creates an item, then creates a price_id as well as prod_id. Then it adds invoice items to the invoice.

#

When the calc is done, it is only (seemling) attaching tax to one of the items even if you set the item qty > 1

main mantle
#

Can you provide an example Invoice ID that you tested with where you saw this?

fresh shard
#

yes

#

I am probably not creating it all correctly. just an FYI so thats why i chatted in

main mantle
#

Yep no worries

#

Just seeing an example helps to see exactly what you are doing

fresh shard
#

look at ref: req_erBRaEs8LxAItT

#

then the product call, price call, the invoiceitem call

main mantle
#

Looking

fresh shard
#

invlice item: req_ysHkH9T0jX71Mx

#

and you will see quantity 3:

#

and a tax rate added

#
    {
      "id": "txr_1PEfaWRvXSuLCvvAcFGYxiTT",
      "object": "tax_rate",
      "active": true,
      "country": null,
      "created": 1715294240,
      "description": null,
      "display_name": "Local Sales Tax",
      "effective_percentage": 8.5,
      "inclusive": false,
      "jurisdiction": null,
      "jurisdiction_level": null,
      "livemode": false,
      "metadata": {
      },
      "percentage": 8.5,
      "state": null,
      "tax_type": null
    } ````
#

8/5 %

#

8.5 %

#

and finally the draft finalized

main mantle
#

Looks like it charged 8.5% tax on $89.95 which is $7.64 which all seems correct

fresh shard
#

one sec

#

im creating one right now. TEST ITEM, QTY 3, PRICE 10, TAX 8.5%

#

This is my program and how it shows

#

Just finlaized

#

wait never mind

#

i think its right

#

'wtf..

#

I know tis title wrong

#

but, the tax is a collective tax.

main mantle
#

Not sure what you mean by that

#

Are you talking about where you have Local Tax?

fresh shard
#

i think the tax shoiws correctly.

main mantle
#

Because this is all your own UI here

fresh shard
#

Right. yes

main mantle
#

And it looks like the Stripe side of things is working as expected

fresh shard
#

Local tax is
$invoice->tax

#

Is there a way for each lineitem in the invoiceitem array to show just the tax on that one item?

#

//Create Draft Invoice
$invoice = $stripe->invoices->retrieve($stripe_invoice_id_given);

main mantle
#

lines.data.tax_amounts shows you the amount of tax for that line item

fresh shard
#

$lineitem->tax_amounts[0]->amount;

main mantle
#

Yep seems right

fresh shard
#

well

#

sorry for wasting your time. evidently i had it correct. I have no idea why i thought it wasnt correct.

main mantle
#

No worries at all

#

Glad it is working!

fresh shard
#

ill clean up ui, and everything.

#

all the time stamps are just epoch right?

main mantle
#

Yep

fresh shard
#

i have one more question if you have a moment

main mantle
#

Sure

fresh shard
#

this is unrelated

main mantle
#

That's fine

fresh shard
#

ok, so when I create an invoice, I get a paymentintent, corret

#

correct.

#

when i finalize it

main mantle
#

Yes

fresh shard
#

Assuming I have a payment id for a payment method, i think its a pm_ - how do you actually apply the payment to the open invoice?

#

is the payment intent all i need?

#

have the pms entered into stripe account and also keep their default PM in my database.

#

ive seen so many articles on accepting payments, its confused me on exactly what I need to do to iniate payment.

main mantle
#

You can do this in place of finalization

#

As using that endpoint will both finalize and attempt to charge in one API request

fresh shard
#

cant do it that way. some of these may be pre-billed invoices

#

which do not need to collect right then

main mantle
#

Yeah that's fine

#

You can always call that later on

fresh shard
#

im making a apply payment call

main mantle
#

You can finalize and then use that endpoint later

fresh shard
#

but then their invocies will show draft

#

not open

#

oh

main mantle
#

Not if you finalize?

#

If you use that endpoint and don't specify payment_method then it will attempt to charge the Customer's invoice_settings.default_payment_method

fresh shard
#

so does that pay endpoint just use API?

#

no forms from stripe?

main mantle
#

Otherwise, you can specify the PM ID you want to charge

#

Yes

#

That is assuming you already collected the PaymentMethod ID

#

That would be the way to charge

#

If you need to collect a payment method then you would go a different route

#

But I thought you said you already had payment methods above

fresh shard
#

$stripe->invoices->pay('in_1MtGmCLkdIwHu7ix6PgS6g8S', [payment_method => $payment_method_i_want]);

#

i do

#

it would look like that above

#

my next question would be cash and check, and this is the answer i assume: paid_out_of_band
boolean
Boolean representing whether an invoice is paid outside of Stripe. This will result in no charge being made. Defaults to false.

main mantle
#

Yep

fresh shard
#

is there a way to mark PAID via CASH or VIA check?

#

or just out of band

main mantle
#

Nope just out_of_band but you can set metadata if you want to indicate that

fresh shard
#

i didnt see metadata in the parameters

main mantle
#

Yeah would be a separate request

#

To update the Invoice

fresh shard
#

so metadata on the invoice, not payment

main mantle
#

Either

#

Up to you

#

metadata is your own arbitrary data

#

That you can use how you want

fresh shard
#

true, but how doI find it. if there are so many objects.

#

i assume it would go on invoice

#

because this doesnt create a seperate object

#

its part of invoice.

#

ok, so if i do this function, pass a valid payment method, I will get back a status if card or bank account?>

main mantle
#

Not sure what you mean by "how do I find it"? Do you mean how would you retrieve that metadata?

fresh shard
#

i was thinking this created a new object. but its part of invoice.

main mantle
#

Yes you set metadata on the objects themselves

main mantle
#

Are you familiar with expansion?

fresh shard
#

no sir

main mantle
fresh shard
#

so, $stripe->paymentIntents->all([
'customer' => '{{CUSTOMER_ID}}',
'expand' => ['data.payment_method'],
]);

#

would create an object llike $payment_intent that has all the data in a list format of the payment

main mantle
#

Well that method lists PaymentIntents

#

It doesn't create them

#

But it would list them and expand the properties for the PaymentMethod object, yes.

fresh shard
#

it would return the info on the poayment intent linked to that object

#

i mean

#

and what property would show approved, declined, etc

main mantle
#

You want the latest_charge for the PaymentIntent

#

Which has all the details for both what happened with the Charge and it includes a payment_method_details property as well

#

Best thing for you to do at this point is test this stuff out

#

It will give you a better understanding than I can

fresh shard
#

thats what im doing, but I have to know what to code to make it work. what properties to include.

#

there only a billion properties. lol

main mantle
#

Yep and I just explained above what you want to look at

fresh shard
#

so is this charge object created automatically when pay is called?

main mantle
#

Yes

fresh shard
#

so pseduo code would be like this. 1) call pay on invoice, 2) get payment intent id 3) retrieve charge details from charge

main mantle
#

You can do that all in one request using expansion

#

When you call /pay you also use expand => ['payment_intent.latest_charge']

fresh shard
#

oh i see

#

wow

#

'payment_intent.latest_charge' returns the charge id?

main mantle
#

Yes

#

It returns the full Charge object

#

At this point we should pause and you should just test it!

fresh shard
#

ok, leave this open or chat back in later?

main mantle
#

It will close automatically after a time of inactivity but you can always chat back in later if that happens!

fresh shard
#

and one last question, when i expand something, like payment_intent, that is calling the payment _info info attached to the object (invoice) that is referenced in original call

#

i would only work in that specfic call

#

so you can exapand anything related to get info?

#

expand

main mantle
fresh shard
#

ok

#

the little + button?

main mantle
#

That Expandable