/**
  * (non-PHPdoc)
  * @see \JMS\Payment\CoreBundle\Plugin\AbstractPlugin::checkPaymentInstruction()
  */
 public function checkPaymentInstruction(PaymentInstructionInterface $paymentInstruction)
 {
     // TODO: use validators
     $errorBuilder = new ErrorBuilder();
     $extendedData = $paymentInstruction->getExtendedData();
     //         if (!$extendedData->has('price')) {
     //             $errorBuilder->addDataError('price', 'form.error.required');
     //         }
     //         if ($extendedData->get('price')<=0) {
     //             $errorBuilder->addDataError('price', 'form.error.invalid');
     //         }
     //         if (!$extendedData->has('currency')) {
     //             $errorBuilder->addDataError('currency', 'form.error.required');
     //         }
     //         if (!$extendedData->has('orderId')) {
     //             $errorBuilder->addDataError('orderId', 'form.error.required');
     //         }
     //         if (!$extendedData->has('posData')) {
     //             $errorBuilder->addDataError('posData', 'form.error.required');
     //         }
     //         if (!$extendedData->has('options')) {
     //             $errorBuilder->addDataError('options', 'form.error.required');
     //         }
     if ($errorBuilder->hasErrors()) {
         throw $errorBuilder->getException();
     }
 }
 public function checkPaymentInstruction(PaymentInstructionInterface $instruction)
 {
     $errorBuilder = new ErrorBuilder();
     /**
      * @var \JMS\Payment\CoreBundle\Entity\ExtendedData $data
      */
     $data = $instruction->getExtendedData();
     if (!$data->get('bank')) {
         $errorBuilder->addDataError('data_multisafepay_ideal.bank', 'form.error.bank_required');
     }
     if ($errorBuilder->hasErrors()) {
         throw $errorBuilder->getException();
     }
 }
 /**
  * This method checks whether all required parameters exist in the given
  * PaymentInstruction, and whether they are syntactically correct.
  *
  * This method is meant to perform a fast parameter validation; no connection
  * to any payment back-end system should be made at this stage.
  *
  * In case, this method is not implemented. The PaymentInstruction will
  * be considered to be valid.
  *
  * @param PaymentInstructionInterface $instruction
  *
  * @throws \JMS\Payment\CoreBundle\Plugin\Exception\InvalidPaymentInstructionException if the the PaymentInstruction is not valid
  */
 public function checkPaymentInstruction(PaymentInstructionInterface $instruction)
 {
     // define form validators
     $constraints = new Assert\Collection(array('name' => array(new Assert\NotBlank(array('message' => 'Required'))), 'number' => array(new Assert\NotBlank(array('message' => 'Required')), new Assert\Length(array('min' => 12, 'max' => 19, 'minMessage' => 'Invalid card number 1', 'maxMessage' => 'Invalid card number 2')), new Assert\Luhn(array('message' => 'Invalid card number'))), 'exp_month' => array(new Assert\NotBlank(array('message' => 'Required')), new Assert\Range(array('min' => 1, 'max' => 12, 'minMessage' => 'Invalid code value', 'maxMessage' => 'Invalid code value'))), 'exp_year' => array(new Assert\NotBlank(array('message' => 'Required')), new Assert\Range(array('min' => date('Y'), 'max' => date('Y', strtotime('+20 years')), 'minMessage' => 'Invalid date', 'maxMessage' => 'Invalid date'))), 'cvc' => array(new Assert\NotBlank(array('message' => 'Required')), new Assert\Length(array('min' => 3, 'max' => 4, 'minMessage' => 'Invalid code value', 'maxMessage' => 'Invalid code value'))), 'address_line1' => array(new Assert\NotBlank(array('message' => 'Required'))), 'address_line2' => array(), 'address_city' => array(new Assert\NotBlank(array('message' => 'Required'))), 'address_state' => array(new Assert\NotBlank(array('message' => 'Required'))), 'address_country' => array(new Assert\NotBlank(array('message' => 'Required'))), 'address_zip' => array(new Assert\NotBlank(array('message' => 'Required')))));
     // extract form values from extended data
     $dateToValidate = array();
     foreach ($constraints->fields as $name => $constraint) {
         $dateToValidate[$name] = $instruction->getExtendedData()->get($name);
     }
     // validate input data
     $errors = $this->validator->validateValue($dateToValidate, $constraints);
     // transform validator errors into payment exceptions
     $errorBuilder = new ErrorBuilder();
     foreach ($errors as $error) {
         // KLUDGE: remove [] around field name
         $field = substr($error->getPropertyPath(), 1, -1);
         $errorBuilder->addDataError('data_stripe_credit_card.' . $field, $error->getMessage());
     }
     if ($errorBuilder->hasErrors()) {
         throw $errorBuilder->getException();
     }
 }
 /**
  * This method checks whether all required parameters exist in the given
  * PaymentInstruction, and whether they are syntactically correct.
  *
  * This method is meant to perform a fast parameter validation; no connection
  * to any payment back-end system should be made at this stage.
  *
  * In case, this method is not implemented. The PaymentInstruction will
  * be considered to be valid.
  *
  * @param PaymentInstructionInterface $paymentInstruction
  *
  * @throws \JMS\Payment\CoreBundle\Plugin\Exception\InvalidPaymentInstructionException if the the PaymentInstruction is not valid
  */
 public function checkPaymentInstruction(PaymentInstructionInterface $paymentInstruction)
 {
     $errorBuilder = new ErrorBuilder();
     if (!$paymentInstruction->getExtendedData()->has('lang')) {
         $errorBuilder->addDataError('lang', 'form.error.required');
     }
     if ($errorBuilder->hasErrors()) {
         throw $errorBuilder->getException();
     }
 }
 /**
  * @param PaymentInstructionInterface $paymentInstruction
  *
  * @throws \JMS\Payment\CoreBundle\Plugin\Exception\InvalidPaymentInstructionException
  */
 public function checkPaymentInstruction(PaymentInstructionInterface $paymentInstruction)
 {
     $errorBuilder = new ErrorBuilder();
     $data = $paymentInstruction->getExtendedData();
     // TODO Check requirements here
     if ($errorBuilder->hasErrors()) {
         throw $errorBuilder->getException();
     }
 }