Exemplo n.º 1
0
 /**
  * @param ChargeFactoryInterface $factory
  */
 private function refundAndCancel($factory)
 {
     // creating a new charge.
     $charge = $factory->create($this->cards->getSuccess());
     $amount = rand(2000, 9999);
     $charge_id = $charge->charge($amount);
     $this->assertTrue(strlen($charge_id) > 0);
     // now retrieve and refund it.
     $list = $factory->getList(1);
     $this->assertEquals(1, count($list));
     $retrieved = $list[0];
     $this->assertEquals($charge_id, $retrieved->getId());
     $this->assertEquals($amount, $retrieved->getAmount());
     $this->assertTrue($retrieved->getAmount() > 1000);
     // now refund 1000 yen.
     $retrieved->refund(1000);
     // retrieve again.
     $retrieved = $factory->getList(1)[0];
     $this->assertEquals($amount, $retrieved->getAmount());
     $this->assertEquals(1000, $retrieved->getAmountRefund());
     $this->assertTrue($retrieved->isRefund());
     // now cancel the charge.
     $retrieved->cancel();
     // retrieve again.
     $retrieved = $factory->getList(1)[0];
     $this->assertEquals($amount, $retrieved->getAmount());
     $this->assertEquals($amount, $retrieved->getAmountRefund());
     $this->assertTrue($retrieved->isRefund());
 }
Exemplo n.º 2
0
 /**
  * @param ChargeFactoryInterface $factory
  * @return UpdatePayInterface
  */
 private function createAndRetrieve($factory)
 {
     // creating a new charge.
     $charge = $factory->create($this->cards->getSuccess());
     $amount = rand(1000, 9999);
     $charge_id = $charge->charge($amount);
     $this->assertTrue(strlen($charge_id) > 0);
     // retrieving the created charge.
     $list = $factory->getList(1);
     $this->assertEquals($charge_id, $list[0]->getId());
     $this->assertEquals($amount, $list[0]->getAmount());
     return $list[0];
 }