Skip to content
This repository was archived by the owner on Sep 4, 2021. It is now read-only.

Commit cda72a2

Browse files
author
zorn
committed
payto request
1 parent f3af4bf commit cda72a2

1 file changed

Lines changed: 97 additions & 0 deletions

File tree

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
<?php
2+
3+
namespace Electrum\Request\Method\Payment;
4+
5+
use Electrum\Request\AbstractMethod;
6+
use Electrum\Request\MethodInterface;
7+
use Electrum\Response\Exception\ElectrumResponseException;
8+
9+
/**
10+
* Return a payment request.
11+
* @author Pascal Krason <p.krason@padr.io>
12+
*/
13+
class PayTo extends AbstractMethod implements MethodInterface
14+
{
15+
16+
/**
17+
* @var string
18+
*/
19+
private $method = 'payto';
20+
21+
/**
22+
* @var string
23+
* '!' for maximum available
24+
*/
25+
private $amount = '!';
26+
27+
/**
28+
* @var string
29+
*/
30+
private $destination = '';
31+
32+
/**
33+
* @param array $optional
34+
*
35+
* @return PaymentRequestResponse|null
36+
* @throws \Electrum\Request\Exception\BadRequestException
37+
* @throws \Electrum\Response\Exception\ElectrumResponseException
38+
*/
39+
public function execute(array $optional = [])
40+
{
41+
$data = $this->getClient()->execute($this->method, array_merge([
42+
'destination' => $this->getDestination(),
43+
'amount' => $this->getAmount()
44+
], $optional));
45+
46+
return $data['hex'];
47+
}
48+
49+
/**
50+
* Get the value of Amount
51+
*
52+
* @return string
53+
*/
54+
public function getAmount()
55+
{
56+
return $this->amount;
57+
}
58+
59+
/**
60+
* Set the value of Amount
61+
*
62+
* @param string amount
63+
*
64+
* @return self
65+
*/
66+
public function setAmount($amount)
67+
{
68+
$this->amount = $amount;
69+
70+
return $this;
71+
}
72+
73+
/**
74+
* Get the value of Destination
75+
*
76+
* @return string
77+
*/
78+
public function getDestination()
79+
{
80+
return $this->destination;
81+
}
82+
83+
/**
84+
* Set the value of Destination
85+
*
86+
* @param string destination
87+
*
88+
* @return self
89+
*/
90+
public function setDestination($destination)
91+
{
92+
$this->destination = $destination;
93+
94+
return $this;
95+
}
96+
97+
}

0 commit comments

Comments
 (0)