Skip to content

Commit

Permalink
Added orderNumber to the transaction/start method
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Pieters committed Feb 21, 2018
1 parent f42a7be commit 8262e2b
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 59 deletions.
10 changes: 10 additions & 0 deletions samples/transaction/get.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
require_once '../../vendor/autoload.php';
require_once '../config.php';

$transactionId = '926417524Xe71be3';

/** @var \Paynl\Result\Transaction\Transaction $transaction */
$transaction = \Paynl\Transaction::get($transactionId);

var_dump($transaction->getData());
1 change: 1 addition & 0 deletions samples/transaction/start.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
'currency' => 'EUR',
'expireDate' => new \DateTime('2016-04-01'),
// 'bank' => 1,
'orderNumber' => 'ABCDEFG',
'description' => '123456',
'testmode' => 0,
'extra1' => 'ext1',
Expand Down
109 changes: 67 additions & 42 deletions src/Api/Transaction/Start.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,13 @@ class Start extends Transaction
*/
private $_currency;
/**
* @var string the exchagne url
* @var string the exchange url
*/
private $_exchangeUrl;
/**
* @var string Your order number
*/
private $_orderNumber;
/**
* @var string the description
*/
Expand Down Expand Up @@ -171,6 +175,14 @@ public function setPromotorId($promotorId)
$this->_promotorId = $promotorId;
}

/**
* @param string $orderNumber
*/
public function setOrderNumber($orderNumber)
{
$this->_orderNumber = $orderNumber;
}

public function setCurrency($currency)
{
$this->_currency = $currency;
Expand Down Expand Up @@ -217,27 +229,34 @@ public function setTransferValue($transferValue)
* @param int $quantity
* @param int $vatCode
* @param string $vatPercentage
*
* @throws Error
*/
public function addProduct($id, $description, $productType, $price, $quantity,
$vatCode, $vatPercentage)
{
if (!is_numeric($price)) {
public function addProduct(
$id,
$description,
$productType,
$price,
$quantity,
$vatCode,
$vatPercentage
) {
if ( ! is_numeric($price)) {
throw new Error('Price must be numeric', 1);
}
if (!is_numeric($quantity)) {
if ( ! is_numeric($quantity)) {
throw new Error('Quantity must be numeric', 1);
}

$this->_products[] = array(
'productId' => $id,
'productType' => $productType,
'productId' => $id,
'productType' => $productType,
//description mag maar 45 chars lang zijn
'description' => substr($description, 0, 45),
'price' => $price,
'quantity' => $quantity * 1,
'vatCode' => $vatCode,
'vatPercentage' => $vatPercentage
'description' => substr($description, 0, 45),
'price' => $price,
'quantity' => $quantity * 1,
'vatCode' => $vatCode,
'vatPercentage' => $vatPercentage
);
}

Expand Down Expand Up @@ -275,6 +294,7 @@ public function addProduct($id, $description, $productType, $price, $quantity,
* countryCode
* ]
* ]
*
* @param array $enduser
*/
public function setEnduser($enduser)
Expand All @@ -286,19 +306,20 @@ public function setEnduser($enduser)
* Set the amount(in cents) of the transaction
*
* @param int $amount
*
* @throws Error
*/
public function setAmount($amount)
{
if (!is_numeric($amount)) {
if ( ! is_numeric($amount)) {
throw new Error('Amount is niet numeriek', 1);
}
$this->_amount = $amount;
}

public function setPaymentOptionId($paymentOptionId)
{
if (!is_numeric($paymentOptionId)) {
if ( ! is_numeric($paymentOptionId)) {
throw new Error('PaymentOptionId is niet numeriek', 1);
}
$this->_paymentOptionId = $paymentOptionId;
Expand Down Expand Up @@ -356,13 +377,22 @@ public function setDomainId($domainId)

/**
* Set the description for the transaction
*
* @param string $description
*/
public function setDescription($description)
{
$this->_description = $description;
}

/**
* @inheritdoc
*/
public function doRequest($endpoint = null, $version = null)
{
return parent::doRequest('transaction/start');
}

/**
* @inheritdoc
* @throws Required Amount is required
Expand All @@ -380,18 +410,21 @@ protected function getData()
}

$data['serviceId'] = Config::getServiceId();
$data['testMode'] = (int) ($this->_testMode === true);
$data['amount'] = $this->_amount;
$data['testMode'] = (int)($this->_testMode === true);
$data['amount'] = $this->_amount;
$data['finishUrl'] = $this->_finishUrl;


if (!empty($this->_paymentOptionId)) {
if ( ! empty($this->_paymentOptionId)) {
$data['paymentOptionId'] = $this->_paymentOptionId;
}
if (!empty($this->_exchangeUrl)) {
if ( ! empty($this->_exchangeUrl)) {
$data['transaction']['orderExchangeUrl'] = $this->_exchangeUrl;
}
if (!empty($this->_description)) {
if ( ! empty($this->_orderNumber)) {
$data['transaction']['orderNumber'] = $this->_orderNumber;
}
if ( ! empty($this->_description)) {
$data['transaction']['description'] = $this->_description;
}
if (isset($this->_currency)) {
Expand All @@ -400,13 +433,13 @@ protected function getData()
if (isset($this->_expireDate)) {
$data['transaction']['expireDate'] = $this->_expireDate->format('d-m-Y H:i:s');
}
if (!empty($this->_paymentOptionSubId)) {
if ( ! empty($this->_paymentOptionSubId)) {
$data['paymentOptionSubId'] = $this->_paymentOptionSubId;
}

$data['ipAddress'] = isset($this->_ipaddress) ? $this->_ipaddress : Helper::getIp();

if (!empty($this->_products)) {
if ( ! empty($this->_products)) {
$data['saleData']['orderData'] = $this->_products;
}
if ($this->_deliveryDate instanceof \DateTime) {
Expand All @@ -416,58 +449,50 @@ protected function getData()
$data['saleData']['invoiceDate'] = $this->_invoiceDate->format('d-m-Y');
}

if (!empty($this->_enduser)) {
if ( ! empty($this->_enduser)) {
if (isset($this->_enduser['birthDate']) && $this->_enduser['birthDate'] instanceof \DateTime) {
$this->_enduser['dob'] = $this->_enduser['birthDate']->format('d-m-Y');
unset($this->_enduser['birthDate']);
}
$data['enduser'] = $this->_enduser;
}

if (!empty($this->_extra1)) {
if ( ! empty($this->_extra1)) {
$data['statsData']['extra1'] = $this->_extra1;
}
if (!empty($this->_extra2)) {
if ( ! empty($this->_extra2)) {
$data['statsData']['extra2'] = $this->_extra2;
}
if (!empty($this->_extra3)) {
if ( ! empty($this->_extra3)) {
$data['statsData']['extra3'] = $this->_extra3;
}
if (!empty($this->_promotorId)) {
if ( ! empty($this->_promotorId)) {
$data['statsData']['promotorId'] = $this->_promotorId;
}
if (!empty($this->_info)) {
if ( ! empty($this->_info)) {
$data['statsData']['info'] = $this->_info;
}
if (!empty($this->_tool)) {
if ( ! empty($this->_tool)) {
$data['statsData']['tool'] = $this->_tool;
}
if (!empty($this->_object)) {
if ( ! empty($this->_object)) {
$data['statsData']['object'] = $this->_object;
}
if (!empty($this->_domainId)) {
if ( ! empty($this->_domainId)) {
$data['statsData']['domain_id'] = $this->_domainId;
}
if (!empty($this->_transferData)) {
if ( ! empty($this->_transferData)) {
$data['statsData']['transferData'] = $this->_transferData;
}
if (!empty($this->_transferType)) {
if ( ! empty($this->_transferType)) {
$data['transferType'] = $this->_transferType;
}
if (!empty($this->_transferValue)) {
if ( ! empty($this->_transferValue)) {
$data['transferValue'] = $this->_transferValue;
}

$this->data = array_merge($data, $this->data);

return parent::getData();
}

/**
* @inheritdoc
*/
public function doRequest($endpoint = null, $version = null)
{
return parent::doRequest('transaction/start');
}
}
Loading

0 comments on commit 8262e2b

Please sign in to comment.