Skip to content
This repository was archived by the owner on Jul 5, 2023. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added abstracts/.gitkeep
Empty file.
28 changes: 28 additions & 0 deletions abstracts/abstractbasiccardnetwork.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
namespace shgysk8zer0\Payment\Abstracts;
use \shgysk8zer0\Payment\Interfaces\{BasicCardNetworkInterface};

abstract class AbstractBasicCardNetwork implements BasicCardNetworkInterface
{
public const AMEX = 'amex';
public const CARTEBANCAIRE = 'cartebancaire';
public const DINERS = 'diners';
public const DISCOVER = 'discover';
public const JCB = 'jcb';
public const MASTERCARD = 'mastercard';
public const MIR = 'mir';
public const UNIONPAY = 'unionpay';
public const VISA = 'visa';

final public function getValue(): string
{
return $this::NETWORK;
}

final public function jsonSerialize(): string
{
return $this->getValue();
}

abstract public static function validate(string $ccnum): bool;
}
22 changes: 22 additions & 0 deletions abstracts/abstractshippingtype.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
namespace shgysk8zer0\Payment\Abstracts;
use \shgysk8zer0\Payment\Interfaces\{ShippingTypeInterface};

abstract class AbstractShippingType implements ShippingTypeInterface
{
// have to prefix with all "TYPE_" so that `NULL_TYPE` can be valid
public const TYPE_SHIPPING = 'shipping';

public const TYPE_DELIVERY = 'delivery';

public const TYPE_PICKUP = 'pickup';

public const TYPE_NULL = null;

public const TYPE = self::TYPE_NULL;

final public function getValue():? string
{
return $this::TYPE;
}
}
13 changes: 13 additions & 0 deletions cardnetwork/amex.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
namespace shgysk8zer0\Payment\CardNetwork;
use \shgysk8zer0\Payment\Abstracts\{AbstractBasicCardNetwork};

final class Amex extends AbstractBasicCardNetwork
{
public const NETWORK = self::AMEX;

public static function validate(): bool
{
return true;
}
}
13 changes: 13 additions & 0 deletions cardnetwork/cartebancaire.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
namespace shgysk8zer0\Payment\CardNetwork;
use \shgysk8zer0\Payment\Abstracts\{AbstractBasicCardNetwork};

final class UnionPay extends AbstractBasicCardNetwork
{
public const NETWORK = self::UNIIONPAY;

public static function validate(string $ccnum): bool
{
return true;
}
}
13 changes: 13 additions & 0 deletions cardnetwork/diners.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
namespace shgysk8zer0\Payment\CardNetwork;
use \shgysk8zer0\Payment\Abstracts\{AbstractBasicCardNetwork};

final class Diners extends AbstractBasicCardNetwork
{
public const NETWORK = self::DINERS;

public static function validate(): bool
{
return true;
}
}
13 changes: 13 additions & 0 deletions cardnetwork/discover.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
namespace shgysk8zer0\Payment\CardNetwork;
use \shgysk8zer0\Payment\Abstracts\{AbstractBasicCardNetwork};

final class Discover extends AbstractBasicCardNetwork
{
public const NETWORK = self::DISCOVER;

public static function validate(): bool
{
return true;
}
}
13 changes: 13 additions & 0 deletions cardnetwork/jcb.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
namespace shgysk8zer0\Payment\CardNetwork;
use \shgysk8zer0\Payment\Abstracts\{AbstractBasicCardNetwork};

final class JCB extends AbstractBasicCardNetwork
{
public const NETWORK = self::JCB;

public static function validate(string $ccnum): bool
{
return true;
}
}
13 changes: 13 additions & 0 deletions cardnetwork/mastercard.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
namespace shgysk8zer0\Payment\CardNetwork;
use \shgysk8zer0\Payment\Abstracts\{AbstractBasicCardNetwork};

final class MasterCard extends AbstractBasicCardNetwork
{
public const NETWORK = self::MASTERCARD;

public static function validate(string $ccnum): bool
{
return true;
}
}
13 changes: 13 additions & 0 deletions cardnetwork/mir.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
namespace shgysk8zer0\Payment\CardNetwork;
use \shgysk8zer0\Payment\Abstracts\{AbstractBasicCardNetwork};

final class MIR extends AbstractBasicCardNetwork
{
public const NETWORK = self::MIT;

public static function validate(string $ccnum): bool
{
return true;
}
}
13 changes: 13 additions & 0 deletions cardnetwork/unionpay.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
namespace shgysk8zer0\Payment\CardNetwork;
use \shgysk8zer0\Payment\Abstracts\{AbstractBasicCardNetwork};

final class UnionPay extends AbstractBasicCardNetwork
{
public const NETWORK = self::UNIIONPAY;

public static function validate(string $ccnum): bool
{
return true;
}
}
13 changes: 13 additions & 0 deletions cardnetwork/visa.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
namespace shgysk8zer0\Payment\CardNetwork;
use \shgysk8zer0\Payment\Abstracts\{AbstractBasicCardNetwork};

final class Visa extends AbstractBasicCardNetwork
{
public const NETWORK = self::VISA;

public static function validate(string $ccnum): bool
{
return true;
}
}
Empty file added interfaces/.gitkeep
Empty file.
14 changes: 14 additions & 0 deletions interfaces/amountinterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
namespace shgysk8zer0\Payment\Interfaces;
use \JsonSerializable;

interface AmountInterface extends JsonSerializable
{
public function getCurrency(): string;

public function setCurrency(string $val): void;

public function getValue(): float;

public function setValue(float $val): void;
}
10 changes: 10 additions & 0 deletions interfaces/basiccardnetworkinterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
namespace shgysk8zer0\Payment\Interfaces;

use \JsonSerializable;
interface BasicCardNetworkInterface extends JsonSerializable
{
public function getValue(): string;

public static function validate(string $ccnum): bool;
}
9 changes: 9 additions & 0 deletions interfaces/basiccardrequestinterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
namespace shgysk8zer0\Payment\Interfaces;

interface BasicCardRequestInterface extends PaymentRequestDataInterface
{
public function getSupportedNetworks(): iterable;

public function setSupportedMethods(BasicCardNetworkInterface... $vals): void;
}
37 changes: 37 additions & 0 deletions interfaces/basiccardresponseinterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
namespace shgysk8zer0\Payment\Interfaces;
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/BasicCardResponse
*/
use \DateTimeInterface;

interface BasicCardResponseInterface extends PaymentResponseDetailsInterface
{
public function getCardNumber(): string;

public function setCardNumber(string $val): void;

public function getCardholderName(): string;

public function setCardholderName(string $val): void;

public function getCardSecurityCode(): string;

public function setCardSecurityCode(string $val): void;

public function getExpiryMonth(): int;

public function setExpiryMonth(int $val): void;

public function getExpiryYear(): int;

public function setExpiryYear(int $val): void;

public function getBillingAddress():? PaymentAddressInterface;

public function setBillingAddress(?PaymentAddressInterface $val): void;

public function getExpiry(): DateTimeInterface;

public function getExpired(): bool;
}
15 changes: 15 additions & 0 deletions interfaces/displayiteminterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
namespace shgysk8zer0\Payment\Interfaces;

use \JsonSerializable;

interface DisplayItemInterface extends JsonSerializable
{
public function getLabel(): string;

public function setLabel(string $val): void;

public function getAmount(): AmountInterface;

public function setAmount(AmountInterface $val): void;
}
9 changes: 9 additions & 0 deletions interfaces/paymenntrequestdetailsinterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
namespace shgysk8zer0\Payment\Interfaces;

use \JsonSerializable;

interface PaymentRequestDetailsInterface extends JsonSerializable
{

}
107 changes: 107 additions & 0 deletions interfaces/paymentaddressinterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<?php
namespace shgysk8zer0\Payment\Interfaces;

use \JsonSerializable;

interface PaymentAddressInterface extends JsonSerializable
{
/**
* Returns an array of strings providing each line of the address not included among
* the other properties. The exact size and content varies by country or
* location and can include, for example, a street name, house number,
* apartment number, rural delivery route, descriptive instructions, or
* post office box number.
* @return array Lines of the address
*/
public function getAddressLine(): array;

/**
* Sets an array of strings providing each line of the address not included among
* the other properties. The exact size and content varies by country or
* location and can include, for example, a street name, house number,
* apartment number, rural delivery route, descriptive instructions, or
* post office box number.
* @param string... $vals Lines of the address
*/
public function setAddressLine(string... $vals): void;

public function getCountry(): string;

public function setCountry(string $val): void;

public function getCity(): string;

public function setCity(string $val): void;

/**
* Returns a string giving the dependent locality or sublocality within a city,
* for example, a neighborhood, borough, district, or UK dependent locality.
* @return string Dependent locality
*/
public function getDependentLocality():? string;

/**
* Sets a string giving the dependent locality or sublocality within a city,
* for example, a neighborhood, borough, district, or UK dependent locality.
* @param ?string $val Dependent locality
*/
public function setDependentLocality(?string $val): void;

public function getOrganization():? string;

public function setOrganization(?string $val): void;

public function getPhone():? string;

public function setPhone(?string $val): void;

public function getPostalCode():? string;

public function setPostalCode(?string $val): void;

public function getRecipient():? string;

public function setRecipient(?string $val): void;

/**
* Returns a string containing the top level administrative subdivision of
* the country, for example a state, province, oblast, or prefecture.
* @return string The set region
*/
public function getRegion(): string;

/**
* Sets the string containing the top level administrative subdivision of
* the country, for example a state, province, oblast, or prefecture.
* @param string $val The region to set
*/
public function setRegion(string $val): void;

/**
* Returns A string specifying the region of the address, represented as a
* "code element" of an ISO3166-2 country subdivision name (e.g. "QLD" for
* Queensland, Australia, "CA" for California, and so on).
* @return string The region code / abbreviation
*/
public function getRegionCode():? string;

/**
* Sets a string specifying the region of the address, represented as a
* "code element" of an ISO3166-2 country subdivision name (e.g. "QLD" for
* Queensland, Australia, "CA" for California, and so on).
* @param ?string $val Region code
*/
public function setRegionCode(?string $val): void;

/**
* Returns a string providing a postal sorting code such as is used in France.
* @return string Sorting Code
*/
public function getSortingCode():? string;

/**
* Sets a string providing a postal sorting code such as is used in France.
* @param ?string $val Sorting Code
*/
public function setSortingCode(?string $val): void;
}
9 changes: 9 additions & 0 deletions interfaces/paymentgatewayinterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
namespace shgysk8zer0\Payment\Interfaces;

interface PaymentGatewayInterface
{
public function setPaymentRequest(PaymentRequestInterface $val): void;

public function setPaymentResponse(PaymentResponseInterface $val): void;
}
Loading