Laravel Cashier Subscriptions for Featured Posts - laravel

I am currently using Laravel Cashier for my users so they can subscribe for premium accounts.
I also want to let any user make Featured Posts that are different from regular posts.
I want to charge the user $10/week for a featured post. I assume a Laravel Cashier subscription would work for this.
But I do not know how to link the Post, the User, and the Subscription together with Laravel Cashier.
Ideally there would be a post_id field in the subscriptions table. But there is not.
I need a way to check if a post is a featured post and if the user who owns the post has paid for it (the subscription is active)
With Laravel Cashier I can check if a user is subscribed for a premium account, but I don't know how to check if a post is subscribed to be featured by the post owner.
Does anyone know how this can be done?

Related

Stripe Customer Portal: How to update the subscription with multiple products?

I have a subscription with multiple products, how can I update this subscription in the customer portal? (I implemented the customer portal, but the Update Plan button is hidden with the subscription with multiple products.)
I know this is the limitation of stripe but is there another solution?
I asked Stripe and got a solution: Cancel the old subscription and resubscribe.
enter image description here

Laravel Cashier (Stripe) subscribing using the existing customer with token

I am developing a Laravel application that involves subscription payment. Now I am struggling with subscribing the user with token but using the existing customer. This is the scenario. In my application, user can update their payment/ billing information (basically card). When they update the payment info, they are just adding the card information. Then later, user can make payment or subscribe to whatever they want.
First user will add they payment method or card information. So I create the customer like this.
$user->createAsStripeCustomer($token, array_merge($options, [
'email' => 'email address',
]));
So the above method will create the stripe customer for the user along with the card. Then tomorrow, user might want to subscribe to a channel. Laravel Cashier provide the following method to subscribe.
$user->newSubscription('subscription-name', 'my-plan')->create($token);
Then issue with the above code is that, I have to pass the token again. If I have to pass the token, again, I will have to generate the token again in the Javascript. If I have to generate the token again in the javascript, I will have to ask the user to enter the card information again to get token. So what can I do to get user to subscribe using the existing customer info? How can I do that?
One method is whenever you create a stripe customer, add the user to a free subscription plan so that he doesn't have to pay anything until he subscribes. When the user starts subscription we can simply change the subscription plan to the desired plan using the following method:
$user->subscription('main')
->skipTrial()
->swap('provider-plan-id');
Another method is whenever we create a stripe customer, ask the user to select a subscription plan and put him on the trial period until he subscribes.

Bigcommerce Mailchimp integration creates users without subscribtion status

Good morning, i installed mailchimp app into my bigcommerce store, i can now see the new bigcommerce customer appera in mymailchimp list when they sign up in bigcommerce. The problem is that the "Email marketing" status is not "Sbuscribed" but it is blank, and i cannot use theese contacts to send emails.
I create the bigcommerce users using API and not the template signup form, and the "accepts_marketing" flat is false by default and it is readonly.
How can i solve this problem? i need the users as Subscribed in my mailchimp.
The "accepts_marketing" flag on the customer record indicates whether the customer has opted in to receive abandoned cart recovery and review emails--it's not used to track marketing newsletter preferences. Newsletter subscriptions fall under the Subscribers resource:
https://developer.bigcommerce.com/api-reference/customer-subscribers/subscribers-api/subscribers/createsubscriber
The Mailchimp app will be listening for a POST to the /customers/subscribers resource to create a new newsletter subscriber, so if you're creating users programmatically, you'll need to create the subscriber separately from the customer record.

creating subscription with laravel cashier

Documentation lists this example:
$user = User::find(1);
$user->newSubscription('main', 'monthly')->create($creditCardToken);
The create method will begin the subscription as well as update your database with the customer ID and other relevant billing information.
Does anyone know where do I get $creditCardToken from? I am using Braintree and perhaps this example is for Stripe?
Ps. I have no reputation to comment yet.
On Braintree doc (https://developers.braintreepayments.com/guides/recurring-billing/create/php) it do not ask for a Credit Card Token.
Which kind of error do you get if you do not pass any argument to create?

Google Checkout subscription: How to identify the user

We are using Google Checkout - google handled subscriptions. In our html form we are using merchant-item-id parameter to store the subscription plan id and user id, so when Google Checkout send us back the notification for the new orders (merchant-item-id is there) we know what user for what plan to charge. So far this works perfect.
But now, when a month is passed, and Google Checkout start creating the reoccurring orders, there is no merchant-item-id parameter in the notifications they send. So we don't know what user for what plan is charged.
What should we use as user identifier, so we can handle properly the subscription on our site?
Any ideas?
Btw. I know about the "buyer-id" parameter which is send with each new order notification, but that will not work for us, because it is possible that the same google buyer is paying for several of our users accounts.
I would try putting some unique info in "shopping-cart.items.item-1.merchant-private-item-data" to something unique that I can identify the subscription by.
Nikolaj

Resources