Open andreslora opened 3 years ago
Check your JS console, do you get any errors? Also, did you set the includeStripeJs
and ìncludeCss
properties to true?
https://github.com/OFFLINE-GmbH/oc-cashier-plugin/blob/master/components/StripeElementsForm.php#L44
Hi,
There's a listener error:
And I am setting JS and CSS like this in the plugin component:
The JS error is because I am not passing the cost of the subscription I think, but I am not sure where should I define it.
Do you have any other plugins installed? The code that generates the error does not look related to this plugin (if you search the repo there is no createCheckoutSession
function anywhere).
My bad, It was me trying to set up stripe by myself and I forgot to delete the code.
Now I do not have any errors but still getting this:
The CSS and JS:
Also I have those options checked in the component settings.
Do you have a {% scripts %}
placeholder somewhere on your layout? This is required so the JS can be loaded.
https://octobercms.com/docs/markup/tag-scripts
Check your page source if you can see this code (once the placeholder is added to the layout): https://github.com/OFFLINE-GmbH/oc-cashier-plugin/blob/master/components/stripeelementsform/script.htm#L9
Yes I do:
If i check the source this is what I see:
Alright, then start debugging. Add some console.logs or use your brower's script debugger.
Check to see if the elements
var gets populated (this means Stripe is loaded) and see if the #card-element
in your DOM is being replaced. You should see a error somewhere or at least be able to find out where the script stops working.
The #card-element has an iframe and It's been loaded:
I am not getting an error =/
So everything seems to be working as expected, but for some reason the iframe is invisible. Please check that no browser extension is removing the frame. Also disable any CSS styles that might interfere with the iframe.
According to your screenshot above everything is working fine
You're right, my css is not working properly with the iframe. I disabled my css and now I can put the credit card, expiration date and zip code, but when I hit the pay with card button, it returns an empty array, I am using a test credit card from https://stripe.com/docs/testing#regulatory-cards
Also I am wondering, how to specify the subscription price? I mean in Stripe Dashboard I set up a product (which is a subscription) but I'm confused about how to set it up with the plugin, also there are some special things the website that needs extra payment, for example, subscribed users can download anything but special songs if they want those special songs they have to single pay for them.
Also I am wondering, how to specify the subscription price?
AFAIK you set that on Stripe's end by creating a product. As for how to assign it to a user, check out Laravel Cashier's docs (this plugin is just a wrapper around it): https://laravel.com/docs/8.x/billing#creating-subscriptions
The code from the docs could be executed in the offline.cashier::stripeElementForm.submit
event listener as described in the README.
subscribed users can download anything
You can easily check if a user has a subscription by calling $user->subscribed('your-subscription')
. There is also the needsSubscription
componenent to block access to a certain page.
if they want those special songs they have to single pay for them.
Single charges are supported by Cashier as well: https://laravel.com/docs/8.x/billing#single-charges
Thank you, I am working on what you said.
Why the ends_at
field is empty? even with a successful subscription?
Is the subscription needed component validating that the payment was successful? Because I created a subscription with pending payment, and I was allowed to navigate to a restricted area.
I think I have to modify this event offline.cashier::subscription.check but I am not pretty sure how to specify that only return true with succesful payments.
How can I access to the payment error, so I can tell the user what happened?
Why the ends_at field is empty? even with a successful subscription?
IIRC this is used if the user has cancelled the subscription. Empty = the subscription is active and not cancelled.
Is the subscription needed component validating that the payment was successful? Because I created a subscription with pending payment, and I was allowed to navigate to a restricted area.
We simply redirect the call to Cashier's subscribed
method, so you would have to check there if pending payments are considered as a "valid subscription":
https://github.com/OFFLINE-GmbH/oc-cashier-plugin/blob/master/components/NeedsSubscription.php#L48
How can I access to the payment error, so I can tell the user what happened?
You can use the webhook events to react to failed payments: https://github.com/OFFLINE-GmbH/oc-cashier-plugin#handle-stripe-webhooks
For example:
Event::listen('offline.cashier::stripe.webhook.invoice.payment_failed', function ($payload, $request) {
$subscription = $payload['data']['object']['subscription'];
try {
$user = User::fromSubscriptionId($subscription);
// Do something with $user
} catch (\Exception $e) {
// do nothing.
}
logger()->error('Payment failed', compact('user', 'payload'));
});
Hi,
So, I have a project with a deadline for this next monday 😆 and I haven't integrated stripe yet. I think this plugin accomplishes all I need but I am having some difficulties trying to set it up properly.
When I try to use the stripeElementsForm component, I am getting this:
Am I missing a CSS or something like that?
Also, is just a credit card field enough to get a subscription? I thought I would need something like this:
Would it be possible to get in touch with you through slack, telegram, discord, or any channel where I could bother you a bit with some questions? This is a rush and I'd love to have some quick answers (I swear I won't bother you a lot).
NOTE: I have already set up the raindlab user plugin and all that. Now I need to allow those users to pay a monthly subscription, if they are not subscribed they will be redirected to a payment page.
Please, Help ðŸ˜