示例#1
0
 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.');
 }
示例#2
0
 /**
  * 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);
 }