#_kitem

1 messages ยท Page 1 of 1 (latest)

crimson shuttleBOT
magic axle
#

hi there!

surreal sable
#

how can I print out directly with PHP?

#

not finding the request on the logs

magic axle
surreal sable
#

I'm printing all the error message from the catch

#

but that is all I have

#

let's me investiagte

magic axle
#

also I would recommend to update your stripe-php version to the latest version.

surreal sable
#

using the code to print out all the catches

#

got the sameissue

#

(Status 404) Unrecognized request URL (POST: /v1/subscription_items//usage_records). If you are trying to list objects, remove the trailing slash. If you are trying to retrieve an object, make sure you passed a valid (non-empty) identifier in your code. Please see https://stripe.com/docs or we can help at https://support.stripe.com/.

Explore our guides and examples to integrate Stripe.

#

the strange thing is that it adds two slashes to the call

#

but actually I am using the Stripe libarry, don't understand from where is coming the secondo slash

magic axle
#

which version of stripe-php are you using?

surreal sable
#

7.0.2 I think

#

seeing the code

#

but it was working some time before

#

now just debugging why it stops works

#

and found that double slashes

#

but we haven't updated the library on the code

magic axle
#

something must have changed

#

is the issue only with usage record? or with all Stripe endpoints?

#

could you try upgrading to the latest version of stripe-phpe?

surreal sable
#

it is only with that endpoint

#

the other things are working as expected

#

it could be an issue upgrade the library

#

just for this one thing :/

magic axle
surreal sable
#

sure

#

acct_1A4syEE9n8wrXE2i

magic axle
#

thanks! give me a few minutes to look into this.

surreal sable
#

sure I am here, thanks

magic axle
#

was the issue in test mode or live mode?

surreal sable
#

test mode

#

but live mode seems it not works, for this I was investigating

#

but we've found that because some customers are not paying some things, so I was just investigating and got that log error about the double slash

magic axle
#

thanks, looking into this

shut citrus
#

๐Ÿ‘‹ taking over for my colleague.

surreal sable
#

hello, thank you ๐Ÿ™‚

shut citrus
#

would you mind logging $subscriptionItemId?

surreal sable
#

let me check

shut citrus
#

I'm suspecting that the ID is empty space or null

surreal sable
#

it make sense

#

let me check

#

seems it is not empty, it's value is si_PQBUNeEpj4irXu

#

but passing it forced into the function has hardcoded it seems it find it and returns another error (maybe due to test settings wrong on my side)

#

(Status 400) (Request req_WsX3PVhmfMqzZV) Cannot create a usage record with usage type licensed. You can only create a usage record for metered plans.

#
    var_dump($subscriptionItemId);

    try {
        $stripe->subscriptionItems->createUsageRecord(
            $subscriptionItemId,
            [
                'quantity' => $usage,
                'timestamp' => $currentTimestamp,
            ]
        ); 

from this code I got this error
object(stdClass)#64 (1) {
["plan"]=>
string(17) "si_PQBUNeEpj4irXu"
}
(Status 404) Unrecognized request URL (POST: /v1/subscription_items//usage_records). If you are trying to list objects, remove the trailing slash. If you are trying to retrieve an object, make sure you passed a valid (non-empty) identifier in your code. Please see https://stripe.com/docs or we can help at https://support.stripe.com/.

Explore our guides and examples to integrate Stripe.

shut citrus
#

ok so there are 2 issues here

#

let's try to handle them one by one

#

so basically the error is that you're passing an object where instead the createUsageRecord needs the string

#

so basically in order for your current code to work

surreal sable
#

ohhh you're right

shut citrus
#

$$subscriptionItemId needs to be $subscriptionItemId->plan

surreal sable
#

ok and this is fixed

#

you're right it was passing the entire object

#

my bad

shut citrus
#

the second issue is basically regarding the price on which you're applying the usage record

#

which is price_1O0PSNE9n8wrXE2irb8T7ThA

#

that is not a metered price

surreal sable
#

ok, please just to check

#

is this product in production metered? prod_OqIGLnes9gzXyx

shut citrus
#

it's not the product

surreal sable
#

oh ok

shut citrus
#

but rather the price that can be licensed or metered

#

the product is just a way to describe what you're selling

#

which can have multiple prices

surreal sable
#

ok, our use case is to send all the cosumption of the period when the upcoming is coming to our webhook

#

and for this we add the usage through that createUsageRecord

#

so where I can check if it is metered or not? and from where I can set it?

shut citrus
#

you can look at the price object

#

just paste the price ID I shared in your dashboard

#

and it will give you all the details

#

or you can retrieve the price by ID and you can check its values

surreal sable
#

I does not find it into the dashboard into the test mode and neither into production mode

#

found rightnow

#

ok but wait

#

that is monthly, buty actually the user has other prices into the subscription

#

that should be updated with consumption

#

let me send you it

#

sub_1ObL7LE9n8wrXE2iFQ2QHByk

#

this contains si_PQBU0ZSPPYWhmN si_PQBUnwA7Ycs8y4 si_PQBUZJCFfSn8aV

#

that should be metered and updated, are they correct?

#

because maybe we are just pointing on the wrong value for some reason, need to investiagte

shut citrus
#

you need to pass in the subscription item that is metered

#

not any subscription item

#

a subscription can have multiple Subscription Items that are related to metered prices

#

this is why you need to specify which one is the one you're creating usage record for

surreal sable
#

okok

surreal sable
#

I'll check it

shut citrus
#

you're pointing to the wrong subscription item

surreal sable
#

okok

#

thank you for your time

#

let me investigate and in case I've some doubt I'll come back to you

shut citrus
#

sure thing

#

let me know if you need any more help

crimson shuttleBOT
surreal sable
#

seems working now

#

thank you everyone