/**
  * Configure options
  *
  * @param OptionsResolver $resolver
  * @return void
  */
 protected function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setRequired(['terminal', 'shop_orderid', 'amount', 'currency', 'type', 'payment_source']);
     $resolver->setAllowedValues('type', Types\PaymentTypes::getAllowed());
     $resolver->setDefault('type', 'payment');
     $resolver->setAllowedValues('payment_source', Types\PaymentSources::getAllowed());
     $resolver->setDefault('payment_source', 'moto');
     $resolver->setDefined(['cardnum', 'emonth', 'eyear', 'cvc', 'credit_card_token', 'transaction_info', 'fraud_service', 'surcharge', 'customer_info', 'shipping_method', 'customer_created_date']);
     $resolver->setAllowedValues('fraud_service', Types\FraudServices::getAllowed());
     $resolver->setAllowedTypes('surcharge', ['int', 'float']);
     $resolver->setAllowedValues('shipping_method', Types\ShippingMethods::getAllowed());
     $resolver->setNormalizer('cardnum', function (Options $options, $value) {
         if (isset($options['credit_card_token'])) {
             throw new \InvalidArgumentException(sprintf('You can not set both a credit card and a credit card token'));
         }
         return $value;
     });
     $resolver->setNormalizer('credit_card_token', function (Options $options, $value) {
         $fields = ['cardnum', 'emonth', 'eyear'];
         foreach ($fields as $field) {
             if (isset($options[$field])) {
                 throw new \InvalidArgumentException(sprintf('You can not set both a credit card token and a credit card'));
             }
         }
         return $value;
     });
 }
Ejemplo n.º 2
0
 /**
  * Configure options
  *
  * @param OptionsResolver $resolver
  * @return void
  */
 protected function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setRequired(['terminal', 'shop_orderid', 'amount', 'currency']);
     $resolver->setDefined(['language', 'transaction_info', 'type', 'ccToken', 'sale_reconciliation_identifier', 'sale_invoice_number', 'sales_tax', 'cookie', 'payment_source', 'customer_info', 'customer_created_date', 'config', 'fraud_service', 'shipping_method', 'organisation_number', 'account_offer', 'orderLines']);
     $resolver->setAllowedValues('language', Types\LanguageTypes::getAllowed());
     $resolver->setDefault('type', 'payment');
     $resolver->setAllowedValues('type', Types\PaymentTypes::getAllowed());
     $resolver->setAllowedValues('ccToken', function ($value) {
         return preg_match('/^[0-9a-f]{41}$/', $value);
     });
     $resolver->setAllowedValues('sale_reconciliation_identifier', function ($value) {
         return strlen($value) <= 100;
     });
     $resolver->setAllowedValues('sale_invoice_number', function ($value) {
         return strlen($value) <= 100;
     });
     $resolver->setAllowedTypes('sales_tax', ['int', 'float']);
     $resolver->setDefault('payment_source', 'eCommerce');
     $resolver->setAllowedValues('payment_source', Types\PaymentSources::getAllowed());
     $resolver->setAllowedTypes('config', Config::class);
     /** @noinspection PhpUnusedParameterInspection */
     $resolver->setNormalizer('config', function (Options $options, Config $value) {
         return $value->serialize();
     });
     $resolver->setAllowedValues('organisation_number', function ($value) {
         return strlen($value) <= 20;
     });
     $resolver->setAllowedTypes('account_offer', 'bool');
     /** @noinspection PhpUnusedParameterInspection */
     $resolver->setNormalizer('account_offer', function (Options $options, $value) {
         return $value ? 'required' : 'disabled';
     });
 }
Ejemplo n.º 3
0
 /**
  * Configure options
  *
  * @param OptionsResolver $resolver
  * @return void
  */
 protected function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setRequired(['terminal', 'shop_orderid', 'amount', 'currency', 'type', 'payment_source']);
     $resolver->setAllowedValues('type', Types\PaymentTypes::getAllowed());
     $resolver->setDefault('type', 'payment');
     $resolver->setAllowedValues('payment_source', Types\PaymentSources::getAllowed());
     $resolver->setDefault('payment_source', 'eCommerce');
     $resolver->setDefined(['accountNumber', 'bankCode', 'fraud_service', 'customer_info', 'orderLines', 'transaction_info']);
     $resolver->setAllowedTypes('accountNumber', 'string');
     $resolver->setAllowedTypes('bankCode', 'string');
     $resolver->setAllowedValues('fraud_service', Types\FraudServices::getAllowed());
 }
Ejemplo n.º 4
0
 /**
  * Configure options
  *
  * @param OptionsResolver $resolver
  * @return void
  */
 protected function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setRequired(['terminal', 'shop_orderid', 'amount', 'currency']);
     $resolver->setDefined(['transaction_info', 'payment_source', 'credit_card_token', 'cardnum', 'emonth', 'eyear', 'cvc']);
     $resolver->setAllowedValues('payment_source', PaymentSources::getAllowed());
     $resolver->setDefault('payment_source', 'moto');
     $resolver->setNormalizer('credit_card_token', function (Options $options, $value) {
         if ($value && isset($options['cardnum'])) {
             throw new CreditCardTokenAndCardUsedException('Both "credit_card_token" and "card" can not be set at the same time, please use only one of them');
         }
         return $value;
     });
 }