#damonstrr
1 messages · Page 1 of 1 (latest)
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.
Take for example i try subscribing to a blog post on domain.com with email sample@sample.com but with different currency
does that affect how subscription works in stripe??
Does this customer already have a subscription in a different currency? (In other words, are you reusing the same customer for both subscriptions?)
yes i am
That's the issue then - customers are only allowed to have subscriptions in a single currency
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??
You can check if the customer has a default currency (https://stripe.com/docs/api/customers/object#customer_object-currency) to make sure you only create subscription with that currency
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
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,
]);
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?
I do not think you misunderstood it because i have a user with same email subscribed to different stripe connect blogs with different currencies. is that possible??
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
Two customers??
Because when i did this in my laravel code it does not seem to work
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
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
});
What specifically isn't working? What output/result are you getting, and what were you expecting instead?
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
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
So in my application if a premium post you then subscribe and after subscribing be able to view the post.
that is not working
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?
I think it's my code and how i am checking for the subscription like if user have many subscriptions
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
Quick question when you are saving a product name for multiple connect account.
does it havev to be unique??
No name doesn't have to be
Because I have this in my database with multiple user subscribed to but it doesn’t seem to return the correct subscription value
I don't understand
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)
That's my database
I get that that's your database. I just didn't understand the sentence. I don't get the problem/issue
The problem is that if user has multiple subscriptions i get false on some when i check it in the code i gave above