public static function createFromDTO(CreditCardDTO $creditCardDTO)
 {
     $creditCard = new CreditCard();
     $creditCard->setName($creditCardDTO->name);
     $creditCard->setZip5($creditCardDTO->zip5);
     $creditCard->setNumber($creditCardDTO->number);
     $creditCard->setCvc($creditCardDTO->cvc);
     $creditCard->setExpirationMonth($creditCardDTO->expirationMonth);
     $creditCard->setExpirationYear($creditCardDTO->expirationYear);
     return $creditCard;
 }
 public function testCreate()
 {
     $creditCard = new CreditCard();
     $creditCard->setName('John Doe');
     $creditCard->setZip5('90210');
     $creditCard->setNumber('4242424242424242');
     $creditCard->setCvc('123');
     $creditCard->setExpirationMonth('1');
     $creditCard->setExpirationYear('2020');
     $this->assertEntityValid($creditCard);
     $this->assertSame('John Doe', $creditCard->getName());
     $this->assertSame('4242424242424242', $creditCard->getNumber());
     $this->assertSame('123', $creditCard->getCvc());
     $this->assertSame('01', $creditCard->getExpirationMonth());
     $this->assertSame('2020', $creditCard->getExpirationYear());
 }
 public function testCreate()
 {
     $creditCard = new CreditCard();
     $creditCard->setName('John Doe');
     $creditCard->setZip5('90210');
     $creditCard->setNumber('4242424242424242');
     $creditCard->setCvc('123');
     $creditCard->setExpirationMonth('1');
     $creditCard->setExpirationYear('2020');
     $chargeRequest = new ChargeRequest();
     $chargeRequest->setCreditCard($creditCard);
     $chargeRequest->setAmount(2000);
     $chargeRequest->setCurrency('usd');
     $chargeRequest->setDescription('*****@*****.**');
     $this->assertEntityValid($chargeRequest);
     $this->assertSame(2000, $chargeRequest->getAmount());
     $this->assertSame('usd', $chargeRequest->getCurrency());
     $this->assertSame('*****@*****.**', $chargeRequest->getDescription());
     $this->assertTrue($chargeRequest->getCreditCard() instanceof CreditCard);
 }
 public function testGetCharge()
 {
     $creditCard = new CreditCard();
     $creditCard->setName('John Doe');
     $creditCard->setZip5('90210');
     $creditCard->setNumber('4242424242424242');
     $creditCard->setCvc('123');
     $creditCard->setExpirationMonth('1');
     $creditCard->setExpirationYear('2020');
     $chargeRequest = new ChargeRequest();
     $chargeRequest->setCreditCard($creditCard);
     $chargeRequest->setAmount(2000);
     $chargeRequest->setCurrency('usd');
     $chargeRequest->setDescription('*****@*****.**');
     $paymentGateway = new FakePaymentGateway();
     $charge = $paymentGateway->getCharge($chargeRequest);
     $this->assertSame(2000, $charge->getAmount());
     $this->assertSame('usd', $charge->getCurrency());
     $this->assertSame('*****@*****.**', $charge->getDescription());
     $this->assertSame('ch_xxxxxxxxxxxxxx', $charge->getExternalId());
     $this->assertSame('4242', $charge->getLast4());
     $this->assertTrue($charge->getCreated() > 0);
 }
Beispiel #5
0
 public function getCreditCard()
 {
     $creditCard = new CreditCard();
     $creditCard->setName('John Doe');
     $creditCard->setZip5('90210');
     $creditCard->setNumber('4242424242424242');
     $creditCard->setCvc('123');
     $creditCard->setExpirationMonth('1');
     $creditCard->setExpirationYear('2020');
     return $creditCard;
 }