示例#1
0
 public function configureOptions(OptionsResolver $resolver)
 {
     $keys = array_keys($this->registry->getGateways());
     $resolver->setDefaults(['choices_as_values' => true, 'choices' => array_combine($keys, $keys), 'choice_label' => function ($currentChoiceKey) {
         return 'form.choice.' . $currentChoiceKey;
     }]);
 }
 /**
  * @test
  */
 public function shouldReturnGatewayFactorySetToContainer()
 {
     $container = new Container();
     $container->set('fooFactoryServiceId', $this->getMock('Payum\\Core\\Storage\\StorageInterface'));
     $registry = new ContainerAwareRegistry(array(), array(), array('fooName' => 'fooFactoryServiceId'));
     $registry->setContainer($container);
     $this->assertSame($container->get('fooFactoryServiceId'), $registry->getGatewayFactory('fooName'));
 }
示例#3
0
 public function verifyRequest(VerifyRequestCommand $command)
 {
     $token = $this->requestVerifier->verify($command->getRequest());
     $gateway = $this->registry->getGateway($token->getGatewayName());
     $gateway->execute($status = new GetHumanStatus($token));
     $payment = $status->getFirstModel();
     $this->requestVerifier->invalidate($token);
     $event = new RequestVerifiedEvent($status, $payment);
     $this->eventBus->handle($event);
 }
示例#4
0
 /**
  * @param Order $order
  * @return Payment
  */
 protected function createPayment(Order $order)
 {
     /** @var $payment Payment */
     $payment = $this->registry->getStorage(Payment::class)->create();
     $payment->setNumber($order->getId()->getValue());
     $payment->setCurrencyCode($this->currency);
     $payment->setTotalAmount($order->getTotal()->getAmount());
     $payment->setClientId($order->getCustomer()->getId()->getValue());
     $payment->setClientEmail($order->getCustomer()->getEmail());
     $payment->setDescription('Payment for order #' . $order->getId()->getValue());
     return $payment;
 }
 /**
  * @test
  */
 public function shouldReturnStorageSetToContainer()
 {
     $payments = array();
     $storages = array('stdClass' => 'fooStorageServiceId');
     $paymentName = 'fooName';
     $storageName = 'barName';
     $container = new Container();
     $container->set('fooStorageServiceId', $this->getMock('Payum\\Core\\Storage\\StorageInterface'));
     $registry = new ContainerAwareRegistry($payments, $storages, $paymentName, $storageName);
     $registry->setContainer($container);
     $this->assertSame($container->get('fooStorageServiceId'), $registry->getStorage('stdClass'));
 }