Skip to content

Commit

Permalink
Docs
Browse files Browse the repository at this point in the history
  • Loading branch information
michalsanger committed Jun 30, 2015
1 parent 460c5d9 commit 990e81c
Show file tree
Hide file tree
Showing 2 changed files with 164 additions and 7 deletions.
33 changes: 29 additions & 4 deletions src/CartItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,40 @@

namespace Omnipay\Csob;

/**
* Cart item entity
* @package Omnipay\Csob
* @see https://github.com/csob/paymentgateway/wiki/eAPI-v1-(English-version)#cart-items
*/
class CartItem
{
/** @var string */
/**
* Item’s name, maximum length 20 characters
*
* @var string
*/
private $name;

/** @var int */
/**
* Quantity, must be >=1
*
* @var int
*/
private $quantity;

/** @var int */
/**
* Total price for the quantity of the items in hundredths of the currency.
* The item currency of all the requests will be automatically used as the price.
*
* @var int
*/
private $amount;

/** @var string */
/**
* Cart item’s description, maximum length 40 characters
*
* @var string
*/
private $description;

function __construct($name, $quantity, $amount, $description = null)
Expand Down Expand Up @@ -88,6 +110,9 @@ public function getDescription()
return $this->description;
}

/**
* @return array
*/
public function toArray()
{
return [
Expand Down
138 changes: 135 additions & 3 deletions src/Purchase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,146 @@

namespace Omnipay\Csob;

/**
* Entity for payment init step
* @package Omnipay\Csob
* @see https://github.com/csob/paymentgateway/wiki/eAPI-v1-(English-version)#payment-init-operation
*/
class Purchase
{
/**
* Merchant’s ID assigned by the payment gateway
*
* @var string
*/
private $merchantId;

/**
* Reference number of the order used to match payments.
* The number will also be indicated on the bank statement.
* A numeric value, 10 digits max.
*
* @var string
*/
private $orderNo;

/**
* Date and time of sending the request in the YYYYMMDDHHMMSS format
*
* @var string
*/
private $dttm;

/**
* Type of payment operation.
* Approved values: payment
*
* @var string
*/
private $payOperation = 'payment';

/**
* Type of implicit payment method to be offered to the customer.
* Approved values: card
*
* @var string
*/
private $payMethod = 'card';

/**
* Total amount in hundredths of the basic currency.
* This value will appear on the payment gateway as the total amount to be paid
*
* @var float
*/
private $totalAmount;

/**
* Currency code.
* Approved values: CZK, EUR, USD, GBP
*
* @var string
*/
private $currency = 'CZK';

/**
* It indicates whether the payment should automatically be put in the queue
* for settlement and paid.
*
* @var bool
*/
private $closePayment = true;

/**
* URL to which the customer will be redirected after the payment has
* been completed. Maximum length is 300 characters.
*
* @see https://github.com/csob/paymentgateway/wiki/eAPI-v1-(English-version)#return-params
* @var string
*/
private $returnUrl;

/**
* The return method to e-shop’s URL.
* Approved values POST, GET.
* Recommended method is POST
*
* @var string
*/
private $returnMethod = 'POST';

/**
* A list of items to be displayed on the payment gateway.
*
* @var CartItem[]
*/
private $cart = [];

/**
* Brief description of the purchase for 3DS page:
* In case of customer verification on the issuing bank’s side, the
* detail of the cart cannot be displayed as it is possible on the
* payment gateway. Therefore, a brief description is sent to the bank.
* Maximum length is 255 characters
*
* @var string
*/
private $description;

/**
* Any additional data which are returned in the redirect from the payment gateway
* to the merchant’s page. Such data may be used to keep continuity of the process
* in the e-shop, they must be BASE64 encoded.
* Maximum length for encoding is 255 characters
*
* @var string
*/
private $merchantData;

/**
* Unique customer ID assigned by the e-shop. It is used if the customer’s card
* is stored and used again in the next visit of the e-shop
* Maximum length is 50 characters.
*
* @var string
*/
private $customerId;

/**
* Preferred language mutation to be displayed on the payment gateway.
* Czech mutation is by default.
* Approved values: CZ, EN, DE, SK
*
* @var string
*/
private $language = 'CZ';

/**
* @param string $merchantId
* @param string $orderNo
* @param string $returnUrl
* @param string $description
*/
function __construct($merchantId, $orderNo, $returnUrl, $description)
{
$this->merchantId = $merchantId;
Expand Down Expand Up @@ -101,7 +223,12 @@ public function setReturnMethod($returnMethod)
}

/**
* @param array $cart
* In version v1, at least 1 item (e.g. “credit charge”) and at most 2 items
* must be in the cart (e.g. “purchase for my shop” and “shipment costs”).
* The limit is caused by the graphic layout of the payment gateway, in another
* version the limit will be much higher.
*
* @param CartItem[] $cart
*/
public function setCart(array $cartItems)
{
Expand All @@ -114,6 +241,11 @@ public function setCart(array $cartItems)
}

/**
* In version v1, at least 1 item (e.g. “credit charge”) and at most 2 items
* must be in the cart (e.g. “purchase for my shop” and “shipment costs”).
* The limit is caused by the graphic layout of the payment gateway, in another
* version the limit will be much higher.
*
* @param CartItem $cartItem
*/
public function addCartItem(CartItem $cartItem)
Expand Down Expand Up @@ -235,7 +367,7 @@ public function getReturnMethod()
}

/**
* @return array
* @return CartItem[]
*/
public function getCart()
{
Expand Down Expand Up @@ -315,7 +447,7 @@ public function toArray()
*/
protected function generateDttm()
{
// should be private, but has to be protected for mocking
// should be private, but has to be protected because of mocking
return date('Ymdhis');
}
}

0 comments on commit 990e81c

Please sign in to comment.