verbb / formie

The most user-friendly forms plugin for Craft CMS.
Other
94 stars 70 forks source link

Stripe: billing_cycle_anchor #1748

Open hassanmah opened 4 months ago

hassanmah commented 4 months ago

Question

Is it possible to pass the 1st of the following month as billing_cycle_anchor when using a payment field?

Thanks

Additional context

No response

engram-design commented 4 months ago

Not via the UI, but you can achieve this with module code to add your own content to the payload sent to Stripe.

use verbb\formie\events\ModifyPaymentPayloadEvent;
use verbb\formie\integrations\payments\Stripe;
use yii\base\Event;

Event::on(Stripe::class, Stripe::EVENT_MODIFY_SINGLE_PAYLOAD, function(ModifyPaymentPayloadEvent $event) {
    $event->payload['billing_cycle_anchor'] = '123';
});
hassanmah commented 4 months ago

@engram-design that event doesn't get fired...

Event::on(Stripe::class, Stripe::EVENT_MODIFY_SINGLE_PAYLOAD, function(ModifyPaymentPayloadEvent $event) {
            // log the event
            Craft::info('Stripe event fired', __METHOD__);

          });

Nothing is being logged

engram-design commented 4 months ago

The event does get triggered and have just confirmed on my end. Can you report what version of Formie you're on?

Then again, if this is for a subscription payment, that event will be a different one.

Not via the UI, but you can achieve this with module code to add your own content to the payload sent to Stripe.

use verbb\formie\events\ModifyPaymentPayloadEvent;
use verbb\formie\integrations\payments\Stripe;
use yii\base\Event;

Event::on(Stripe::class, Stripe::EVENT_MODIFY_SUBSCRIPTION_PAYLOAD, function(ModifyPaymentPayloadEvent $event) {
    $event->payload['billing_cycle_anchor'] = '123';
});