コード例 #1
0
ファイル: Payline.php プロジェクト: Alban-io/Payline
 /**
  *
  * This method is call on Payment loop.
  *
  * If you return true, the payment method will de display
  * If you return false, the payment method will not be display
  *
  * @return boolean
  */
 public function isValidPayment()
 {
     $paylineConfig = new PaylineConfig();
     if (!$paylineConfig->checkRequireConfig()) {
         $logger = new PaylineLogger();
         $logger->getLogger()->addError('Payline payment module is not properly configured. Please check module configuration in your back-office.');
         return false;
     }
     $maximum = $paylineConfig->getMaximumAmount();
     $minimum = $paylineConfig->getMinimumAmount();
     $orderAmount = $this->getCurrentOrderTotalAmount();
     if ($orderAmount === 0) {
         return false;
     }
     return ($minimum <= 0 || $orderAmount >= $minimum) && ($maximum <= 0 || $orderAmount <= $maximum);
 }
コード例 #2
0
 /**
  *
  * in this function you add all the fields you need for your Form.
  * Form this you have to call add method on $this->formBuilder attribute :
  */
 protected function buildForm()
 {
     $paylineConfig = new PaylineConfig();
     $this->formBuilder->add('merchantId', 'text', ['constraints' => [new NotBlank()], 'label' => $this->trans('Merchant id :'), 'data' => $paylineConfig->getMerchantId()])->add('merchantAccesskey', 'text', ['constraints' => [new NotBlank()], 'label' => $this->trans('Merchant access key :'), 'data' => $paylineConfig->getMerchantAccesskey()])->add('contractNumber', 'text', ['constraints' => [new NotBlank()], 'label' => $this->trans('Contract number :'), 'data' => $paylineConfig->getContractNumber()])->add('env', 'choice', ['constraints' => [new NotBlank()], 'label' => $this->trans('Environment :'), 'choices' => [PaylineConfig::ENV_DEV => $this->trans('Development'), PaylineConfig::ENV_HOMO => $this->trans('Approval'), PaylineConfig::ENV_PROD => $this->trans('Production')], 'expanded' => false, 'multiple' => false, 'data' => $paylineConfig->getEnv()])->add('minimumAmount', 'money', ['constraints' => [new NotBlank(), new GreaterThanOrEqual(['value' => 0])], 'label' => $this->trans('Minimum order total'), 'data' => $paylineConfig->getMinimumAmount(), 'label_attr' => ['for' => 'minimum_amount', 'help' => $this->trans('Minimum order total in the default currency for which this payment method is available. Enter 0 for no minimum')]])->add('maximumAmount', 'money', ['constraints' => [new NotBlank(), new GreaterThanOrEqual(['value' => 0])], 'label' => $this->trans('Maximum order total'), 'data' => $paylineConfig->getMaximumAmount(), 'label_attr' => ['for' => 'maximum_amount', 'help' => $this->trans('Maximum order total in the default currency for which this payment method is available. Enter 0 for no maximum')]]);
 }