示例#1
0
 /**
  * @test
  */
 public function shouldCorrectlyConvertCreditCard()
 {
     $creditCard = new CreditCard();
     $creditCard->setNumber('4111111111111111');
     $creditCard->setExpireAt(new \DateTime('2018-05-12'));
     $creditCard->setSecurityCode(123);
     $creditCard->setHolder('John Doe');
     $order = new Payment();
     $order->setCreditCard($creditCard);
     $action = new ConvertPaymentAction();
     $action->execute($convert = new Convert($order, 'array'));
     $details = $convert->getResult();
     $this->assertNotEmpty($details);
     $this->assertArrayHasKey('card', $details);
     $this->assertInstanceOf('Payum\\Core\\Security\\SensitiveValue', $details['card']);
     $card = $details['card']->peek();
     $this->assertInternalType('array', $card);
     $this->assertArrayHasKey('number', $card);
     $this->assertEquals('4111111111111111', $card['number']);
     $this->assertArrayHasKey('exp_month', $card);
     $this->assertEquals('05', $card['exp_month']);
     $this->assertArrayHasKey('exp_year', $card);
     $this->assertEquals('2018', $card['exp_year']);
     $this->assertArrayHasKey('cvc', $card);
     $this->assertEquals('123', $card['cvc']);
 }
示例#2
0
 /**
  * @test
  */
 public function shouldCorrectlyConvertCreditCardToken()
 {
     $creditCard = new CreditCard();
     $creditCard->setToken('theCustomerId');
     $order = new Payment();
     $order->setCreditCard($creditCard);
     $action = new ConvertPaymentAction();
     $action->execute($convert = new Convert($order, 'array'));
     $details = $convert->getResult();
     $this->assertNotEmpty($details);
     $this->assertArrayHasKey('customer', $details);
     $this->assertEquals('theCustomerId', $details['customer']);
 }