Skip to content

Commit

Permalink
Merge pull request #1 from albertmueller/master
Browse files Browse the repository at this point in the history
allow to change the reference param, add new api params narrative_text and transaction_param
  • Loading branch information
albertmueller authored Sep 25, 2019
2 parents 808db40 + cde5998 commit d58b075
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 39 deletions.
7 changes: 7 additions & 0 deletions src/Request/GenericAuthRequestFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public static function create($requestType, $data)
$customerAddressData['town'],
$customerAddressData['country']
);

$customerData = $data['customer'];
$customer = new Customer(
$customerData['title'],
Expand All @@ -36,10 +37,16 @@ public static function create($requestType, $data)
$customerData['gender'],
$customerData['ip']
);

$reference = isset($data['order']['orderId']) && $data['order']['orderId'] ?
'order-' . $data['order']['orderId'] : 'basket-' . $data['basket']['id'];

$genericRequest = GenericRequestFactory::create($requestType, $data);

if ($genericRequest->getReference()) {
$reference = $genericRequest->getReference();
}

return new GenericAuthorizationRequest(
$genericRequest,
$reference,
Expand Down
119 changes: 81 additions & 38 deletions src/Request/GenericRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,89 +10,101 @@
*/
class GenericRequest implements RequestDataContract
{
/**
* @var string
*/

/** @var string */
protected $request;

/**
* @var int
*/
/** @var int */
private $amount;

/**
* @var string
*/
/** @var string */
private $currency;

/** @var Config */
private $config;

/** @var SystemInfo */
private $info;

/** @var string|null */
private $sequencenumber;

/**
* @var SystemInfo
*/
private $info;
/** @var string|null */
private $param;

/** @var string|null */
private $reference;

/** @var string|null */
private $narrative_text;

/** @var string|null */
private $transaction_param;


/**
* GenericRequest constructor.
*
* @param Config $config
* @param string $request
* @param int $amount
* @param string $currency
* @param string|null $sequencenumber
* @param SystemInfo $info
* @param null $sequencenumber
* @param null $param
* @param null $reference
* @param null $narrative_text
* @param null $transaction_param
*/
public function __construct(
Config $config,
$request,
string $request,
int $amount,
$currency,
string $currency,
SystemInfo $info,
$sequencenumber = null
$sequencenumber = null,
$param = null,
$reference = null,
$narrative_text = null,
$transaction_param = null
) {
$this->config = $config;
$this->request = $request;
$this->amount = $amount;
$this->currency = $currency;
$this->sequencenumber = $sequencenumber;
$this->info = $info;
$this->sequencenumber = $sequencenumber;
$this->param = $param;
$this->reference = $reference;
$this->narrative_text = $narrative_text;
$this->transaction_param = $transaction_param;
}


/**
* Getter for Sequencenumber
* @return string
*/
public function getSequencenumber()
public function getRequest(): string
{
return $this->sequencenumber;
return $this->request;
}

/**
* Getter for Amount
*
* @return int
*/
public function getAmount()
public function getAmount(): int
{
return $this->amount;
}

/**
* Getter for Currency
*
* @return string
*/
public function getCurrency()
public function getCurrency(): string
{
return $this->currency;
}

/**
* Getter for Config
*
* @return Config
*/
public function getConfig(): Config
Expand All @@ -101,20 +113,51 @@ public function getConfig(): Config
}

/**
* @return string
* @return SystemInfo
*/
public function getRequest()
public function getInfo(): SystemInfo
{
return $this->request;
return $this->info;
}

/**
* Getter for Info
*
* @return SystemInfo
* @return string|null
*/
public function getInfo()
public function getSequencenumber(): ?string
{
return $this->info;
return $this->sequencenumber;
}

/**
* @return string|null
*/
public function getParam(): ?string
{
return $this->param;
}

/**
* @return string|null
*/
public function getReference(): ?string
{
return $this->reference;
}

/**
* @return string|null
*/
public function getNarrativeText(): ?string
{
return $this->narrative_text;
}

/**
* @return string|null
*/
public function getTransactionParam(): ?string
{
return $this->transaction_param;
}

}
6 changes: 5 additions & 1 deletion src/Request/GenericRequestFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ public static function create($requestType, $data)
$basket['basketAmount'],
$basket['currency'],
$systemInfo,
$context['sequencenumber'] ?? null
$context['sequencenumber'] ?? null,
$data['param'] ?? null,
$data['reference'] ?? null,
$data['narrative_text'] ?? null,
$data['transaction_param'] ?? null
);
}
}

0 comments on commit d58b075

Please sign in to comment.