public function testTokenResponse() { $Response = TokenResponse::initializeByString('{ "id": "11fe4b4d430eccc4ca59b8df31bc5d161b4d54020082362a7d389486f5349066", "expiresAt": "2015-05-22T11:21:37+03:00", "card": { "lastFour": "4242", "mask": "************4242", "type": "visa", "expirationMonth": "4", "expirationYear": "2020" } }'); $this->assertEquals('11fe4b4d430eccc4ca59b8df31bc5d161b4d54020082362a7d389486f5349066', $Response->getId()); $this->assertEquals(1432282897, $Response->getExpiresAt()); $this->assertEquals('4242', $Response->getCard()->getLastFour()); $this->assertEquals('************4242', $Response->getCard()->getMask()); $this->assertEquals(4, $Response->getCard()->getExpirationMonth()); $this->assertEquals(2020, $Response->getCard()->getExpirationYear()); $this->assertEquals('token\'s data id: 11fe4b4d430eccc4ca59b8df31bc5d161b4d54020082362a7d389486f5349066 expiresAt: 2015-05-22T08:21:37+0000 card four: 4242 mask: ************4242 type: visa exp. month: 4 exp. year: 2020', (string) $Response); }
/** * REST API method card/getToken implementation * @param string $number credit card's number * @param int $expirationMonth credit card's expiration month, without leading zero * @param int $expirationYear credit card's expiration year (4 digits) * @param string $securityCode credit card's security code: CVC, CVV2 * @param null|string $callback callback function name for JSONP * @return Request card/getToken request instance * @throws ErrorException if there is an API error */ public function cardGetToken($number, $expirationMonth, $expirationYear, $securityCode, $callback = null) { $parameters = ['number' => (string) $number, 'expiration_month' => (int) $expirationMonth, 'expiration_year' => (int) $expirationYear, 'security_code' => (string) $securityCode]; if (!is_null($callback)) { $parameters['callback'] = (string) $callback; } return $this->getRequest('card/getToken', $parameters, function ($string) { return TokenResponse::initializeByString($string); }); }