Exemplo n.º 1
0
 public function test_charge_fee_to_customer()
 {
     $openpayCustomers = $this->customerAdapter->getList();
     $testCustomerId = $openpayCustomers[count($openpayCustomers) - 1]->getId();
     $mockCardInfo = json_decode($this->getMockCardInfo(), true);
     $openpayCardToken = $this->tokenAdapter->store($mockCardInfo);
     $parameters = $this->getCardMockRequest();
     $parametersArray = json_decode($parameters, true);
     $parametersArray['token_id'] = $openpayCardToken['token_id'];
     $openpayCard = $this->cardAdapter->store($testCustomerId, $parametersArray);
     $chargeMockRequest = $this->getChargeMockRequest();
     $cardId = $openpayCard->getId();
     $parameters = json_decode($chargeMockRequest, true);
     $parameters['source_id'] = $cardId;
     $openpayChargeTransaction = $this->chargeAdapter->chargeCustomerCard($testCustomerId, $parameters);
     $feeMockRequest = $this->getFeeMockRequest();
     $parameters = json_decode($feeMockRequest, true);
     $parameters['customer_id'] = $testCustomerId;
     $now = new \DateTime();
     $parameters['order_id'] = 'TEST_ORDER-' . $now->format(\DateTime::ISO8601);
     $openpayFeeTransaction = $this->feeAdapter->chargeFee($parameters);
     $this->assertInstanceOf('Openpay\\Client\\Type\\OpenpayTransactionType', $openpayFeeTransaction);
     $this->assertNotEmpty($openpayFeeTransaction->getId(), 'Id is not empty');
     $this->assertNull($openpayFeeTransaction->getAuthorization(), 'Authorization number is not empty');
     $this->assertEquals($openpayFeeTransaction->getStatus(), 'completed');
     $this->assertEquals($openpayFeeTransaction->getOperationType(), 'out');
     $this->assertEquals($openpayFeeTransaction->getTransactionType(), 'fee');
     $this->assertGreaterThan(0, $openpayFeeTransaction->getAmount());
 }
 public function __construct(ClientInterface $client, OpenpayCardMapper $cardMapper, OpenpayExceptionMapper $exceptionMapper, EncryptorInterface $encryptor, ScopeConfigInterface $config)
 {
     $paymentOpenpayConfig = $config->getValue('payment/openpay');
     $paymentOpenpayConfig['merchantId'] = $encryptor->decrypt($paymentOpenpayConfig['merchantId']);
     $paymentOpenpayConfig['apiKey'] = $encryptor->decrypt($paymentOpenpayConfig['apiKey']);
     $paymentOpenpayConfig['publicKey'] = $encryptor->decrypt($paymentOpenpayConfig['publicKey']);
     parent::__construct($client, $cardMapper, $exceptionMapper, $paymentOpenpayConfig);
 }
 public function test_delete_card()
 {
     $openpayCustomers = $this->customerAdapter->getList();
     $testCustomerId = $openpayCustomers[count($openpayCustomers) - 1]->getId();
     $openpayCards = $this->cardAdapter->getList($testCustomerId);
     $deleted = $this->cardAdapter->delete($testCustomerId, $openpayCards[0]->getId());
     $this->assertTrue($deleted);
 }
 public function test_charge_customer_account_with_card()
 {
     $openpayCustomers = $this->customerAdapter->getList();
     $testCustomerId = $openpayCustomers[count($openpayCustomers) - 1]->getId();
     $mockCardInfo = json_decode($this->getMockCardInfo(), true);
     $openpayCardToken = $this->tokenAdapter->store($mockCardInfo);
     $parameters = $this->getCardMockRequest();
     $parametersArray = json_decode($parameters, true);
     $parametersArray['token_id'] = $openpayCardToken['token_id'];
     $openpayCard = $this->cardAdapter->store($testCustomerId, $parametersArray);
     $chargeMockRequest = $this->getChargeMockRequest();
     $cardId = $openpayCard->getId();
     $parameters = json_decode($chargeMockRequest, true);
     $parameters['source_id'] = $cardId;
     $openpayTransaction = $this->chargeAdapter->chargeCustomerCard($testCustomerId, $parameters);
     $this->assertInstanceOf('Openpay\\Client\\Type\\OpenpayTransactionType', $openpayTransaction);
     $this->assertNotEmpty($openpayTransaction->getId(), 'Id is not empty');
     $this->assertNotEmpty($openpayTransaction->getAuthorization(), 'Authorization number is not empty');
     $this->assertEquals($openpayTransaction->getStatus(), 'completed');
     $this->assertGreaterThan(0, $openpayTransaction->getAmount());
 }