public function testSetToBitcoinAddress()
 {
     $transaction = new Transaction();
     $transaction->setToBitcoinAddress('ADDRESS');
     $this->assertInstanceOf(BitcoinAddress::class, $transaction->getTo());
     $this->assertEquals('ADDRESS', $transaction->getTo()->getAddress());
 }
Example #2
0
 public function testFromTransaction()
 {
     $transaction = new Transaction(TransactionType::SEND);
     $transaction->setTo(new Email('*****@*****.**'));
     $transaction->setAmount(new Money(1, CurrencyCode::BTC));
     $transaction->setDescription('test description');
     $data = $this->mapper->fromTransaction($transaction);
     $this->assertEquals(['type' => 'send', 'amount' => '1', 'currency' => 'BTC', 'description' => 'test description', 'to' => '*****@*****.**'], $data);
 }
 public function cancelTransaction(Transaction $transaction, array $params = [])
 {
     $this->http->delete($transaction->getResourcePath(), $params);
 }
Example #4
0
 /** @return array */
 public function fromTransaction(Transaction $transaction)
 {
     // validate
     $to = $transaction->getTo();
     if ($to && !$to instanceof Email && !$to instanceof BitcoinAddress && !$to instanceof Account) {
         throw new LogicException('The Coinbase API only accepts transactions to an account, email, or bitcoin address');
     }
     // filter
     $data = array_intersect_key($this->extractData($transaction), array_flip(['type', 'to', 'amount', 'description']));
     // to
     if (isset($data['to']['address'])) {
         $data['to'] = $data['to']['address'];
     } elseif (isset($data['to']['email'])) {
         $data['to'] = $data['to']['email'];
     } elseif (isset($data['to']['id'])) {
         $data['to'] = $data['to']['id'];
     }
     // currency
     if (isset($data['amount']['currency'])) {
         $data['currency'] = $data['amount']['currency'];
     }
     // amount
     if (isset($data['amount']['amount'])) {
         $data['amount'] = $data['amount']['amount'];
     }
     return $data;
 }
Example #5
0
 public function testCancelRequestTransaction()
 {
     $transaction = Transaction::reference('ACCOUNT_ID', 'TRANSACTION_ID');
     $this->http->expects($this->once())->method('delete')->with('/v2/accounts/ACCOUNT_ID/transactions/TRANSACTION_ID', ['foo' => 'bar']);
     $this->client->cancelTransaction($transaction, ['foo' => 'bar']);
 }