/** * @throws \Openpay\Client\Exception\OpenpayException */ public function test_store_new_card() { $openpayCustomers = $this->customerAdapter->getList(); $testCustomerId = $openpayCustomers[count($openpayCustomers) - 1]->getId(); $mockCardInfo = json_decode($this->getMockCardInfo(), true); $openpayCardToken = $this->tokenAdapter->store($mockCardInfo); $parameters = $this->getMockRequest(); $parametersArray = json_decode($parameters, true); $parametersArray['token_id'] = $openpayCardToken['token_id']; $openpayCard = $this->cardAdapter->store($testCustomerId, $parametersArray); $this->assertInstanceOf('Openpay\\Client\\Type\\OpenpayCardType', $openpayCard); $this->assertNotEmpty($openpayCard->getId(), 'Id is not empty'); }
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 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()); }