public static function registerAddPaymentButtons(Binder $binder, AbstractPaymentService $service)
{
$class = new ReflectionClass($service);
$method = lcfirst(str_replace('Service', '', $class->getShortName()));
FormContainer::extensionMethod('add' . $method . 'Buttons', function ($container, $callbacks) use($binder, $service) {
$binder->bindPaymentButtons($service, $container, $callbacks);
});
FormContainer::extensionMethod('add' . $method . 'Button', function ($container, $channel, $callback = NULL) use($binder, $service) {
$channels = $service->getChannels();
if (!isset($channels[$channel])) {
throw new InvalidArgumentException("Channel '{$channel}' is not allowed.");
}
return $binder->bindPaymentButton($channels[$channel], $container, $callback = []);
});
}