If you're building a large site and using Charge as part of your payment process sometimes you'll need to add your own custom logic to certain parts of the process. Charge helps you by exposing a few hooks and events for you to trigger your own custom logic against.
The following hooks are available as part of Charge :
charge.onCharge
charge.onBeforeCharge
charge.onCharge
#Fires as soon as a payment successfully completes. Recieves a ChargeModel object containing all the details of the transaction, including populated Stripe response data.
charge
ChargeModelUsage of the event is a standard Craft event. In your main plugin class' init function you might have this :
craft()->on('charge.onCharge', function (Event $event) {
$chargeModel = $event->params['charge'];
//.. add your custom usage of the charge model
});
charge.onBeforeCharge
#Fires just before a charge is attempted. Includes the ChargeModel object containing all the details of the payment about to be attempted.
charge
ChargeModelUsage of the event is a standard Craft event. In your main plugin class' init function you might have this :
craft()->on('charge.onBeforeCharge', function (Event $event) {
$chargeModel = $event->params['charge'];
//.. add your custom usage of the charge model
});
Need a hook or event that's not listed here? Just get in touch.