/** * Make an successful call * Create a transaction then do the reserve call */ public function testSuccessfulApiCall() { if (is_null($this->config)) { $this->markTestSkipped('Config is not set, please set up the required environment variables'); return false; } $userId = "REGISTED:" . hash('md5', microtime()); $billingRecipient = $this->faker->name; $shippingRecipient = $this->faker->name; $registerRequest = new RegisterUserRequest($this->config); $registerRequest->setUserID($userId)->setUserType(\Upg\Library\User\Type::USER_TYPE_PRIVATE)->setUserRiskClass(RiskClass::RISK_CLASS_DEFAULT)->setUserData($this->getUser())->setBillingAddress($this->getAddress())->setBillingRecipient($billingRecipient)->setShippingAddress($this->getAddress())->setShippingRecipient($shippingRecipient)->setLocale(Codes::LOCALE_EN); $registerUserApi = new RegisterUserApi($this->config, $registerRequest); $registerUserResult = $registerUserApi->sendRequest(); $this->assertEquals(0, $registerUserResult->getData('resultCode')); $this->assertEmpty($registerUserResult->getData('message')); $this->assertNotEmpty($registerUserResult->getData('salt')); $registerUserPaymentInstrumentRequest = new RegisterUserPaymentInstrumentRequest($this->config); $registerUserPaymentInstrumentRequest->setUserID($userId)->setPaymentInstrument($this->getPaymentInstrument()); $registerUserPaymentInstrument = new RegisterUserPaymentInstrumentApi($this->config, $registerUserPaymentInstrumentRequest); $registerUserPaymentInstrumentResult = $registerUserPaymentInstrument->sendRequest(); $paymentId = $registerUserPaymentInstrumentResult->getData('paymentInstrumentID'); $getUserPaymentInstrumentRequest = new GetUserPaymentInstrumentRequest($this->config); $getUserPaymentInstrumentRequest->setUserID($userId); $getUserPaymentInstrumentApi = new GetUserPaymentInstrumentApi($this->config, $getUserPaymentInstrumentRequest); $getUserPaymentInstrumentResult = $getUserPaymentInstrumentApi->sendRequest(); $this->assertEquals(0, $getUserPaymentInstrumentResult->getData('resultCode')); $this->assertEmpty($getUserPaymentInstrumentResult->getData('message')); $this->assertNotEmpty($getUserPaymentInstrumentResult->getData('salt')); $this->assertEquals(1, count($getUserPaymentInstrumentResult->getData('paymentInstruments'))); $paymentInstruments = $getUserPaymentInstrumentResult->getData('paymentInstruments'); $paymentInstrument = $paymentInstruments[0]; $this->assertEquals($this->getPaymentInstrument()->getIssuer(), $paymentInstrument->getIssuer()); $this->assertEquals($this->getPaymentInstrument()->getPaymentInstrumentType(), $paymentInstrument->getPaymentInstrumentType()); $this->assertEquals($this->getPaymentInstrument()->getValidity()->format('Y-m'), $paymentInstrument->getValidity()->format('Y-m')); }
public function testGetUrl() { $request = new GetUserPaymentInstrument($this->config); $api = new GetUserPaymentInstrumentApi($this->config, $request); $this->assertEquals('http://www.something.com/getUserPaymentInstrument', $api->getUrl()); }