9

I realise this is a bit of an old question, but I was faced with the same problem recently so I thought I'd document my solution here for anyone in the future that comes along needing to apply tax to a subscription in Craft Commerce. There are two problems here: Subscriptions aren't purchasables in Commerce at the moment, so they can't be added to a cart ...


4

The following code allows the customisation of the fields using Stripe Elements. This code will replace the payment form with gateway.getPaymentFormHtml({}). The thing to note here is this is provided unsupported as it is custom code and does not use the payment form template or javascript file that is in the Commerce Stripe plugin. This also means that it ...


3

I've solved this in the past by just showing the payment sources, and allowing the user to delete existing payment sources: {% set paymentSources = craft.commerce.paymentSources.getAllPaymentSourcesByUserId(currentUser.id) %} {% if paymentSources %} <table> <thead> <tr> <th scope="col"&...


2

Update: it looks like it was an issue with the secure cert on the site.  Once we got that updated, purchases are going through as normal.


2

OK so here's how to go about it. On checkout, you'll need at minimum a form with the following elements: <form method="post" id="card-info"> <input type="hidden" name="action" value="commerce/payments/pay"> <input type="hidden" name="paymentMethodId" value="[fill this via JS]"> <input type="hidden" name="orderEmail" value="[your ...


2

The getPaymentFormHtml() method will output a huge chunk of code, including Stripe's iframe and all its nested fields and functionality - you can't simply wrap that in a label element and expect it to work, as the click event of the label will not reach inside the iFrame. The default output of Commerce Stripe's getPaymentFormHtml leaves a lot to be desired, ...


1

OK, this was caused by a simple oversight on my part. To simplify matters for anyone else trying to set up Stripe, here is your checklist: In your templates Verify that you are using the latest version of JQuery. Verify that you are NOT using deprecated onLoad. It should be $('#paymentMethodId').on('load', function(){, not $('#paymentMethodId').onLoad(...


1

Commerce needs an actual user for subscriptions but you can make onboarding pretty simple by doing a couple things: Uncheck "Verify email addresses" in the CP under Settings -> Users -> Settings. Set deferPublicRegistrationPassword to true so you don't need the user to set a password Set the autoLoginAfterAccountActivation config to true. ...


1

This can definitely be done, but I don't think it's possible to do it all in the same form without using a custom module to handle either creating the user programmatically and then submitting to the Commerce controller or vice versa. Craft has support for creating a user account via a front-end form (see the User Registration Form in the Craft docs) but you ...


1

Listen to the invoice.payment_succeeded webhook and check the billing_reason for subscription_cycle. Full answer here: https://stackoverflow.com/a/54165193/1215040 use craft\commerce\stripe\base\Gateway as StripeGateway; use craft\commerce\stripe\events\ReceiveWebhookEvent; use yii\base\Event; Event::on( StripeGateway::class, StripeGateway::...


Only top voted, non community-wiki answers of a minimum length are eligible