コード例 #1
0
 /**
  * @param  Contribution              $contribution
  * @throws \InvalidArgumentException If $contribution is not valid
  */
 public function __construct(Contribution $contribution)
 {
     if ($contribution->isValidImmediateContribution() === false) {
         throw new \InvalidArgumentException("Contribution::isValidImmediateContribution() returned false");
     }
     $this->setModel($contribution);
 }
コード例 #2
0
 public function testRequiredFields()
 {
     $user = $this->createUser();
     $wallet = $this->createWallet();
     $card = $this->createPaymentCard($user);
     $entity = new Contribution();
     $entity->setUserID($user->getID());
     $entity->setWalletId($wallet->getID());
     $entity->setAmount(100);
     $entity->setPaymentCardID($card->getID());
     $entity->setCulture('en');
     $response = $this->getClient()->request(new CreateImmediateContribution($entity));
     $this->assertInstanceOf('Gordalina\\Mangopay\\Response\\ResponseInterface', $response);
     // the card is not valid
     $this->assertFalse($response->isSuccessful());
     $this->assertSame(400, $response->getStatusCode());
     $this->assertSame(sprintf('card %d is not active', $card->getID()), $response->getUserMessage());
 }
コード例 #3
0
 public function testRequiredFields()
 {
     $user = $this->createUser();
     $wallet = $this->createWallet();
     $entity = new Contribution();
     $entity->setUserID($user->getID());
     $entity->setWalletId($wallet->getID());
     $entity->setAmount(1000);
     $entity->setReturnURL('http://inpakt.com/ok');
     $entity->setCulture('en');
     $response = $this->getClient()->request(new CreateContribution($entity));
     $this->assertInstanceOf('Gordalina\\Mangopay\\Response\\ResponseInterface', $response);
     $this->assertTrue($response->isSuccessful());
     $entity = $response->getModel();
     $response = $this->getClient()->request(new FetchContribution($entity->getID()));
     $this->assertInstanceOf('Gordalina\\Mangopay\\Response\\ResponseInterface', $response);
     $this->assertTrue($response->isSuccessful());
     $responseEntity = $response->getModel();
     $this->assertFalse($entity === $responseEntity);
     $this->assertSame($entity->getID(), $responseEntity->getID());
     $this->assertSame($entity->getCreationDate(), $responseEntity->getCreationDate());
     $this->assertSame($entity->getUpdateDate(), $responseEntity->getUpdateDate());
     $this->assertSame($entity->getUserID(), $responseEntity->getUserID());
     $this->assertSame($entity->getWalletID(), $responseEntity->getWalletID());
     $this->assertSame($entity->getAmount(), $responseEntity->getAmount());
     $this->assertSame($entity->getClientFeeAmount(), $responseEntity->getClientFeeAmount());
     $this->assertSame($entity->getLeetchiFeeAmount(), $responseEntity->getLeetchiFeeAmount());
     $this->assertSame($entity->getIsSucceeded(), $responseEntity->getIsSucceeded());
     $this->assertSame($entity->getIsCompleted(), $responseEntity->getIsCompleted());
     $this->assertSame($entity->getPaymentURL(), $responseEntity->getPaymentURL());
     $this->assertSame($entity->getTemplateURL(), $responseEntity->getTemplateURL());
     $this->assertSame($entity->getReturnURL(), $responseEntity->getReturnURL());
     $this->assertSame($entity->getRegisterMeanOfPayment(), $responseEntity->getRegisterMeanOfPayment());
     $this->assertSame($entity->getError(), $responseEntity->getError());
     $this->assertSame($entity->getPaymentCardID(), $responseEntity->getPaymentCardID());
     $this->assertSame($entity->getCulture(), $responseEntity->getCulture());
     $this->assertSame($entity->getType(), $responseEntity->getType());
     $this->assertSame($entity->getPaymentMethodType(), $responseEntity->getPaymentMethodType());
     $this->assertSame($entity->getAnswerCode(), $responseEntity->getAnswerCode());
     $this->assertSame($entity->getAnswerMessage(), $responseEntity->getAnswerMessage());
 }