#damonstrr

1 messages · Page 1 of 1 (latest)

supple schoonerBOT
neon arrow
#

Hello!

#

I'm not quite sure what you mean by that question - can you clarify?

minor lark
#

So i am using laravel cashier to test stripe subscription. i trying to subscribe with one email but with different countries currency and it does not seem to work.

#

does that affect how subscription works in stripe??

neon arrow
#

Does this customer already have a subscription in a different currency? (In other words, are you reusing the same customer for both subscriptions?)

minor lark
#

yes i am

neon arrow
#

That's the issue then - customers are only allowed to have subscriptions in a single currency

minor lark
#

Ahahah now i get it lol

#

I was wondering lol

#

Nice One Karbi

#

How do i ensure that a single currency is used then is that possible??

neon arrow
minor lark
#

In the link you sent i only see this

currency
string
Three-letter ISO code for the currency the customer can be charged in for recurring billing purposes.
#

This is how my subscription code look like in laravel

 $response = app('stripe')->checkout->sessions->create([
            'payment_method_types' => ['card'],
            'mode' => 'subscription',
            // 'allow_promotion_codes' => true,
            'line_items' => [
                [
                    'price' => $plan->stripe_price_id,
                    'quantity' => 1,

                ],
            ],

            'subscription_data' => [
                'application_fee_percent' => $plan->applicationPercentage(),

                'metadata' => [
                    'blog_id' => $blog->id,
                    'post_id' => $latestPost->id,
                    'user_id' => $blog->user->id,
                    'user_email' => $blog->user->email,
                    'name' => $plan->name,
                    'reader_id' => Auth::user()->id,
                    'price_id' => $plan->stripe_price_id,
                    'product_id' => $plan->stripe_product_id,
                ]
            ],

            'client_reference_id' => Auth::user()->id,
            'success_url' => route('blog.post.show', [$blog->name, 'post' => $latestPost->slug]),
            'cancel_url' => route('blog.post.show', [$blog->name, 'post' => $latestPost->slug]),
            'metadata' => [
                'post_id' => $latestPost->id,
                'user_id' => Auth::user()->id,
                'name' => $plan->abbreviation
            ],
            'customer_email' => Auth::user()->email,
        ], [
            'stripe_account' => $stripeAccount,
        ]);

neon arrow
#

Backing up for a minute because I think I misunderstood your question - are you just asking what you can do on your end to make sure you're only creating subscriptions in the correct currency?

minor lark
supple schoonerBOT
neon arrow
#

It's possible but you'll have to use two separate Customers for this. YOu can have two customers with the same email address and create a subscription for each of them in a different currency

minor lark
#

Because when i did this in my laravel code it does not seem to work

neon arrow
#

Are you sure your laravel code is using two separate customers? If you share an example failing request ID that you believe used two separate customers we can take a look

minor lark
#

That's the thing it is not failing, the subscription is created actually

#

But this part of the code does not seem to work

$subscribed = $isBlogOwner || $blog->plans->contains(function ($plan) use ($user) {
            return $user && $user->subscribedToProduct($plan->stripe_product_id, $plan->stripe_name); // Adjust this logic based on your setup
        });
neon arrow
#

What specifically isn't working? What output/result are you getting, and what were you expecting instead?

minor lark
#

That's the event ID evt_1NtEVoPL8Hb0nCvuOtSjbDCr

#

So when the user subscribes to a yearly plan it does not work for some reason not sure why

neon arrow
#

Yeah saying it doesn't work, but what specificalyl isn't working? The subscription is created right? What part isn't behaving like you expect

minor lark
#

So in my application if a premium post you then subscribe and after subscribing be able to view the post.

that is not working

hollow hemlock
#

Taking over here. karbi has to head out. Give me a bit to catch up

#

Not sure I understand

#

Can you share a request id where this is failing?

minor lark
#

I think it's my code and how i am checking for the subscription like if user have many subscriptions

hollow hemlock
#

Could be

#

I really don't understand the problem though

#

Like I need way more context for what isn't working to be able to help in any way

minor lark
#

Quick question when you are saving a product name for multiple connect account.

does it havev to be unique??

hollow hemlock
#

No name doesn't have to be

minor lark
#

Because I have this in my database with multiple user subscribed to but it doesn’t seem to return the correct subscription value

hollow hemlock
#

I don't understand

minor lark
#

i did this in my controller

foreach ($subscriptions as $subscription) {
            var_dump($user->subscribedToPrice($subscription->stripe_price, $subscription->name));
        }

        exit;

but it returns bool(true) bool(true) bool(false) bool(false)

minor lark
hollow hemlock
#

I get that that's your database. I just didn't understand the sentence. I don't get the problem/issue

minor lark
#

The problem is that if user has multiple subscriptions i get false on some when i check it in the code i gave above

hollow hemlock
#

I don't know how to help. I have no idea what your code is doing in the subscribedToPrice function

#

You need to use a debugger to go through things on your end