mirror of
https://github.com/bitinflow/accounts.git
synced 2026-03-13 21:45:52 +00:00
Add test implementation for charges, documents & payment intents
This commit is contained in:
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace GhostZero\BitinflowAccounts\ApiOperations;
|
||||
|
||||
use GhostZero\BitinflowAccounts\Helpers\Paginator;
|
||||
use GhostZero\BitinflowAccounts\Result;
|
||||
|
||||
/**
|
||||
* @author René Preuß <rene@preuss.io>
|
||||
@@ -12,5 +13,5 @@ use GhostZero\BitinflowAccounts\Helpers\Paginator;
|
||||
trait Delete
|
||||
{
|
||||
|
||||
abstract public function delete(string $path = '', array $parameters = [], Paginator $paginator = null);
|
||||
abstract public function delete(string $path = '', array $parameters = [], Paginator $paginator = null): Result;
|
||||
}
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace GhostZero\BitinflowAccounts\ApiOperations;
|
||||
|
||||
use GhostZero\BitinflowAccounts\Helpers\Paginator;
|
||||
use GhostZero\BitinflowAccounts\Result;
|
||||
|
||||
/**
|
||||
* @author René Preuß <rene@preuss.io>
|
||||
@@ -12,5 +13,5 @@ use GhostZero\BitinflowAccounts\Helpers\Paginator;
|
||||
trait Get
|
||||
{
|
||||
|
||||
abstract public function get(string $path = '', array $parameters = [], Paginator $paginator = null);
|
||||
abstract public function get(string $path = '', array $parameters = [], Paginator $paginator = null): Result;
|
||||
}
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace GhostZero\BitinflowAccounts\ApiOperations;
|
||||
|
||||
use GhostZero\BitinflowAccounts\Helpers\Paginator;
|
||||
use GhostZero\BitinflowAccounts\Result;
|
||||
|
||||
/**
|
||||
* @author René Preuß <rene@preuss.io>
|
||||
@@ -12,5 +13,5 @@ use GhostZero\BitinflowAccounts\Helpers\Paginator;
|
||||
trait Post
|
||||
{
|
||||
|
||||
abstract public function post(string $path = '', array $parameters = [], Paginator $paginator = null);
|
||||
abstract public function post(string $path = '', array $parameters = [], Paginator $paginator = null): Result;
|
||||
}
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace GhostZero\BitinflowAccounts\ApiOperations;
|
||||
|
||||
use GhostZero\BitinflowAccounts\Helpers\Paginator;
|
||||
use GhostZero\BitinflowAccounts\Result;
|
||||
|
||||
/**
|
||||
* @author René Preuß <rene@preuss.io>
|
||||
@@ -12,5 +13,5 @@ use GhostZero\BitinflowAccounts\Helpers\Paginator;
|
||||
trait Put
|
||||
{
|
||||
|
||||
abstract public function put(string $path = '', array $parameters = [], Paginator $paginator = null);
|
||||
abstract public function put(string $path = '', array $parameters = [], Paginator $paginator = null): Result;
|
||||
}
|
||||
@@ -18,12 +18,13 @@ class BitinflowAccounts
|
||||
{
|
||||
|
||||
use Traits\ChargesTrait;
|
||||
use Traits\CheckoutSessionsTrait;
|
||||
use Traits\DocumentsTrait;
|
||||
use Traits\PaymentIntentsTrait;
|
||||
use Traits\SshKeysTrait;
|
||||
use Traits\UsersTrait;
|
||||
|
||||
const BASE_URI = 'https://accounts.bitinflow.com/api/';
|
||||
const OAUTH_BASE_URI = 'https://accounts.bitinflow.com/api/';
|
||||
private const BASE_URI = 'https://accounts.bitinflow.com/api/';
|
||||
private const OAUTH_BASE_URI = 'https://accounts.bitinflow.com/api/';
|
||||
|
||||
/**
|
||||
* Guzzle is used to make http requests.
|
||||
|
||||
17
src/GhostZero/BitinflowAccounts/Enums/DocumentType.php
Normal file
17
src/GhostZero/BitinflowAccounts/Enums/DocumentType.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GhostZero\BitinflowAccounts\Enums;
|
||||
|
||||
/**
|
||||
* @author René Preuß <rene@preuss.io>
|
||||
*/
|
||||
class DocumentType
|
||||
{
|
||||
// Read authorized user´s email address.
|
||||
public const TYPE_PDF_INVOICE = 'pdf.invoice';
|
||||
|
||||
// Manage a authorized user object.
|
||||
public const TYPE_PDF_ORDER = 'pdf.order';
|
||||
}
|
||||
@@ -15,24 +15,24 @@ class Scope
|
||||
*/
|
||||
|
||||
// Deprecated scope.
|
||||
const API = 'api';
|
||||
public const API = 'api';
|
||||
|
||||
// Read nonpublic user information, including email address.
|
||||
const READ_USER = 'read_user';
|
||||
public const READ_USER = 'read_user';
|
||||
|
||||
/*
|
||||
* v1 API
|
||||
*/
|
||||
|
||||
// Read authorized user´s email address.
|
||||
const USERS_READ_EMAIL = 'users:read:email';
|
||||
public const USERS_READ_EMAIL = 'users:read:email';
|
||||
|
||||
// Manage a authorized user object.
|
||||
const USERS_EDIT = 'users:edit';
|
||||
public const USERS_EDIT = 'users:edit';
|
||||
|
||||
// Read authorized user´s transactions.
|
||||
const TRANSACTIONS_READ = 'transactions:read';
|
||||
public const TRANSACTIONS_READ = 'transactions:read';
|
||||
|
||||
// Create a new charge for the authorized user.
|
||||
const CHARGES_CREATE = 'charges:create';
|
||||
public const CHARGES_CREATE = 'charges:create';
|
||||
}
|
||||
48
src/GhostZero/BitinflowAccounts/Traits/DocumentsTrait.php
Normal file
48
src/GhostZero/BitinflowAccounts/Traits/DocumentsTrait.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GhostZero\BitinflowAccounts\Traits;
|
||||
|
||||
use Carbon\CarbonInterface;
|
||||
use GhostZero\BitinflowAccounts\ApiOperations\Get;
|
||||
use GhostZero\BitinflowAccounts\ApiOperations\Post;
|
||||
use GhostZero\BitinflowAccounts\Result;
|
||||
|
||||
/**
|
||||
* @author René Preuß <rene@preuss.io>
|
||||
*/
|
||||
trait DocumentsTrait
|
||||
{
|
||||
|
||||
use Get, Post;
|
||||
|
||||
/**
|
||||
* Create a Documents object
|
||||
*
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return Result
|
||||
*/
|
||||
public function createDocument(array $parameters): Result
|
||||
{
|
||||
return $this->post('documents', $parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a Documents download url
|
||||
*
|
||||
* @param mixed $identifier
|
||||
* @param CarbonInterface|null $expiresAt
|
||||
*
|
||||
* @return Result
|
||||
*/
|
||||
public function createDocumentDownloadUrl($identifier, ?CarbonInterface $expiresAt = null): Result
|
||||
{
|
||||
return $this->post("documents/$identifier/download-url", [
|
||||
'expires_at' => $expiresAt
|
||||
? $expiresAt->toDateTimeString()
|
||||
: now()->addHour()->toDateTimeString(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -11,32 +11,32 @@ use GhostZero\BitinflowAccounts\Result;
|
||||
/**
|
||||
* @author René Preuß <rene@preuss.io>
|
||||
*/
|
||||
trait CheckoutSessionsTrait
|
||||
trait PaymentIntentsTrait
|
||||
{
|
||||
|
||||
use Get, Post;
|
||||
|
||||
/**
|
||||
* Get a Session object
|
||||
* Get a Payment Intent object
|
||||
*
|
||||
* @param string $id
|
||||
*
|
||||
* @return Result Result object
|
||||
*/
|
||||
public function getCheckoutSession(string $id): Result
|
||||
public function getPaymentIntent(string $id): Result
|
||||
{
|
||||
return $this->get("checkout/sessions/$id");
|
||||
return $this->get("payment-intents/$id");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a Session object
|
||||
* Create a Payment Intent object
|
||||
*
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return Result
|
||||
*/
|
||||
public function createCheckoutSession(array $parameters): Result
|
||||
public function createPaymentIntent(array $parameters): Result
|
||||
{
|
||||
return $this->post('payments/sessions', $parameters);
|
||||
return $this->post('payment-intents', $parameters);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user