Source of file PaymentMethod.php
Size: 1,777 Bytes - Last Modified: 2021-12-24T06:35:03+00:00
/var/www/docs.ssmods.com/process/src/src/Checkout/Step/PaymentMethod.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 | <?php namespace SilverShop\Checkout\Step; use SilverShop\Cart\ShoppingCart; use SilverShop\Checkout\Checkout; use SilverShop\Checkout\CheckoutComponentConfig; use SilverShop\Checkout\Component\Payment; use SilverShop\Forms\CheckoutForm; use SilverStripe\Forms\FieldList; use SilverStripe\Forms\FormAction; use SilverStripe\Omnipay\GatewayInfo; class PaymentMethod extends CheckoutStep { private static $allowed_actions = [ 'paymentmethod', 'PaymentMethodForm', ]; protected function checkoutconfig() { $config = CheckoutComponentConfig::create(ShoppingCart::curr(), false); $config->addComponent(Payment::create()); return $config; } public function paymentmethod() { $gateways = GatewayInfo::getSupportedGateways(); if (count($gateways) == 1) { return $this->owner->redirect($this->NextStepLink()); } return array( 'OrderForm' => $this->PaymentMethodForm(), ); } public function PaymentMethodForm() { $form = CheckoutForm::create($this->owner, 'PaymentMethodForm', $this->checkoutconfig()); $form->setActions( FieldList::create( FormAction::create('setpaymentmethod', _t('SilverShop\Checkout\Step\CheckoutStep.Continue', 'Continue')) ) ); $this->owner->extend('updatePaymentMethodForm', $form); return $form; } public function setpaymentmethod($data, $form) { $this->checkoutconfig()->setData($form->getData()); return $this->owner->redirect($this->NextStepLink()); } public function SelectedPaymentMethod() { return Checkout::get($this->owner->Cart())->getSelectedPaymentMethod(true); } } |