first steps with Pix class
This commit is contained in:
parent
17ebac8300
commit
bfe904943c
2 changed files with 27 additions and 7 deletions
10
src/Kore.php
10
src/Kore.php
|
@ -2,21 +2,17 @@
|
||||||
|
|
||||||
namespace Kontrl\PhpKore;
|
namespace Kontrl\PhpKore;
|
||||||
|
|
||||||
use phpseclib3\Common\Functions\Strings;
|
|
||||||
use phpseclib3\Crypt\EC;
|
|
||||||
use phpseclib3\Crypt\EC\PublicKey;
|
|
||||||
use phpseclib3\Crypt\PublicKeyLoader;
|
use phpseclib3\Crypt\PublicKeyLoader;
|
||||||
use phpseclib3\Crypt\RSA;
|
|
||||||
|
|
||||||
class Kore
|
class Kore
|
||||||
{
|
{
|
||||||
private $url = 'https://httpbin.org';
|
private $url = 'https://httpbin.org';
|
||||||
|
|
||||||
public function __construct() {}
|
public function __construct(public $privateKey) {}
|
||||||
|
|
||||||
public function signBody(string|array $body, string|array $key, string|bool $password = false)
|
public function signBody(string|array $body, string|bool $password = false)
|
||||||
{
|
{
|
||||||
$privateKey = PublicKeyLoader::loadPrivateKey(base64_decode($key), $password);
|
$privateKey = PublicKeyLoader::loadPrivateKey(base64_decode($this->privateKey), $password);
|
||||||
$sig = $privateKey->sign(json_encode($body));
|
$sig = $privateKey->sign(json_encode($body));
|
||||||
return base64_encode($sig);
|
return base64_encode($sig);
|
||||||
}
|
}
|
||||||
|
|
24
src/Pix.php
Normal file
24
src/Pix.php
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Kontrl\PhpKore;
|
||||||
|
|
||||||
|
class Pix extends Kore
|
||||||
|
{
|
||||||
|
public function newPixCharge($amount, $pix_key)
|
||||||
|
{
|
||||||
|
$payload = [
|
||||||
|
'amount' => $amount,
|
||||||
|
'pix_key' => $pix_key
|
||||||
|
];
|
||||||
|
return curlRequest(
|
||||||
|
'https://httpbin.org/post',
|
||||||
|
'POST',
|
||||||
|
[],
|
||||||
|
[
|
||||||
|
'x-kore-drone-uid: drone:f8f19d43660d7bbdd2c63d428de6d7b1ff33554311adbe35c784b0584aa007fd',
|
||||||
|
'x-kore-drone-sign: ' . $this->signBody($payload)
|
||||||
|
],
|
||||||
|
$payload
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue