/**
  * 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', '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());
 }