public function testTokenAccessors() { $request = new ChargeRequest(); $token = new Token('card-a'); $request->setToken($token); $this->assertEquals('card-a', $request->getToken()); $request->setToken('card-b'); $token = $request->getToken(); $this->assertInstanceOf('Issei\\Spike\\Model\\Token', $token, '$card is allowed to be a string.'); $this->assertEquals('card-b', $token->getId(), '$card is allowed to be a string.'); }
/** * Creates a new charge. * * @param ChargeRequest $request * @return Charge * * @throws RequestException */ public function charge(ChargeRequest $request) { $result = $this->request('POST', '/charges', ['card' => $request->getToken(), 'amount' => $request->getAmount() ? $request->getAmount()->getAmount() : null, 'currency' => $request->getAmount() ? $request->getAmount()->getCurrency() : null, 'capture' => $request->isCapture() ? 'true' : 'false', 'products' => json_encode($request->getProducts())]); return $this->objectConverter->convert($result); }