start adding payment api wrapper

This commit is contained in:
Dennis Eichhorn 2022-12-24 23:55:07 +01:00
parent a125925f29
commit af4dca3ee4
4 changed files with 275 additions and 13 deletions

View File

@ -0,0 +1,27 @@
<?php
/**
* Karaka
*
* PHP Version 8.1
*
* @package phpOMS\Api\Payment
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace phpOMS\Api\Payment;
/**
* Payment charge.
*
* @package phpOMS\Api\Payment
* @license OMS License 1.0
* @link https://jingga.app
* @since 1.0.0
*/
final class Charge
{
}

View File

@ -0,0 +1,157 @@
<?php
/**
* Karaka
*
* PHP Version 8.1
*
* @package phpOMS\Api\Payment
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace phpOMS\Api\Payment;
/**
* Abstract payment.
*
* @package phpOMS\Api\Payment
* @license OMS License 1.0
* @link https://jingga.app
* @since 1.0.0
*/
abstract class PaymentAbstract
{
/**
* Create/execute a charge
*
* @param int $customer Customer id
* @param Charge $charge Charge to execute
*
* @return void
*
* @since 1.0.0
*/
abstract public function createCharge(int $customer, Charge $charge) : void;
/**
* Refund a charge
*
* @param int $customer Customer id
* @param Charge $charge Charge to execute
*
* @return void
*
* @since 1.0.0
*/
abstract public function refundCharge(int $customer, Charge $charge) : void;
/**
* Get all charges of a customer
*
* @param int $customer Customer id
* @param \DateTime $start Start date
* @param \DateTime $end End date
*
* @return void
*
* @since 1.0.0
*/
abstract public function listCharges(int $customer, \DateTime $start, \DateTime $end) : void;
/**
* Create/add a new payment method
*
* @param int $customer Customer id
* @param mixed $paymentMethod Payment method (e.g. cc card)
*
* @return void
*
* @since 1.0.0
*/
abstract public function addPaymentMethod(int $customer, mixed $paymentMethod) : void;
/**
* Remove a new payment method
*
* @param int $customer Customer id
* @param mixed $paymentMethod Payment method (e.g. cc card)
*
* @return void
*
* @since 1.0.0
*/
abstract public function removePaymentMethod(int $customer, mixed $paymentMethod) : void;
/**
* Modify a new payment method
*
* @param int $customer Customer id
* @param mixed $paymentMethod Payment method (e.g. cc card)
*
* @return void
*
* @since 1.0.0
*/
abstract public function modifyPaymentMethod(int $customer, mixed $paymentMethod) : void;
/**
* Get all payment methods of a customer
*
* @param int $customer Customer id
*
* @return void
*
* @since 1.0.0
*/
abstract public function listPaymentMethods(int $customer) : void;
/**
* Create/add a new subscription
*
* @param int $customer Customer id
* @param mixed $subscription Subscription details
*
* @return void
*
* @since 1.0.0
*/
abstract public function addSubscription(int $customer, mixed $subscription) : void;
/**
* Remove a new subscription
*
* @param int $customer Customer id
* @param mixed $subscription Subscription details
*
* @return void
*
* @since 1.0.0
*/
abstract public function removeSubscription(int $customer, mixed $subscription) : void;
/**
* Modify a new subscription
*
* @param int $customer Customer id
* @param mixed $subscription Subscription details
*
* @return void
*
* @since 1.0.0
*/
abstract public function modifySubscription(int $customer, mixed $subscription) : void;
/**
* Get all subscriptions of a customer
*
* @param int $customer Customer id
*
* @return void
*
* @since 1.0.0
*/
abstract public function listSubscriptions(int $customer) : void;
}

View File

@ -0,0 +1,27 @@
<?php
/**
* Karaka
*
* PHP Version 8.1
*
* @package phpOMS\Api\Payment
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace phpOMS\Api\Payment;
/**
* Create a payment.
*
* @package phpOMS\Api\Payment
* @license OMS License 1.0
* @link https://jingga.app
* @since 1.0.0
*/
final class PaymentFactory
{
}

View File

@ -14,7 +14,7 @@ declare(strict_types=1);
namespace phpOMS\Api\Payment;
use \Stripe\StripeClient;
use Stripe\StripeClient;
/**
* Strip generator.
@ -26,24 +26,75 @@ use \Stripe\StripeClient;
*/
final class Stripe extends PaymentAbstract
{
private Stripe\StripeClient $con;
private \Stripe\StripeClient $con;
/**
* Constructor.
*
* @param string $apiKey Api key
*
* @since 1.0.0
*/
public function __construct(string $apiKey)
{
$this->con = new \Stripe\StripeClient($apiKey);
}
public function createCharge(int $customer, Charge $charge) {}
public function refundCharge(int $customer, int $charge) {}
public function listCharges(int $customer) {}
/**
* {@inheritdoc}
*/
public function createCharge(int $customer, Charge $charge) : void {}
public function addPaymentMethod(int $customer, mixed $paymentMethod) {}
public function removePaymentMethod(int $customer, int $paymentMethod) {}
public function modifyPaymentMethod(int $customer, mixed $paymentMethod) {}
public function listPaymentMethods(int $customer) {}
/**
* {@inheritdoc}
*/
public function refundCharge(int $customer, Charge $charge) : void {}
public function addSubscription(int $customer, mixed $subscription) {}
public function removeSubscription(int $customer, int $subscription) {}
public function modifySubscription(int $customer, mixed $subscription) {}
public function listSubscriptions(int $customer) {}
/**
* {@inheritdoc}
*/
public function listCharges(int $customer, \DateTime $start, \DateTime $end) : void {}
/**
* {@inheritdoc}
*/
public function addPaymentMethod(int $customer, mixed $paymentMethod) : void
{
$this->con->paymentMethods->attach();
}
/**
* {@inheritdoc}
*/
public function removePaymentMethod(int $customer, mixed $paymentMethod) : void {}
/**
* {@inheritdoc}
*/
public function modifyPaymentMethod(int $customer, mixed $paymentMethod) : void {}
/**
* {@inheritdoc}
*/
public function listPaymentMethods(int $customer) : void {}
/**
* {@inheritdoc}
*/
public function addSubscription(int $customer, mixed $subscription) : void {}
/**
* {@inheritdoc}
*/
public function removeSubscription(int $customer, mixed $subscription) : void {}
/**
* {@inheritdoc}
*/
public function modifySubscription(int $customer, mixed $subscription) : void {}
/**
* {@inheritdoc}
*/
public function listSubscriptions(int $customer) : void {}
}