Skip to content

Commit

Permalink
Merge pull request #1 from Axent96/patch-1
Browse files Browse the repository at this point in the history
Extension for Recurring Request
  • Loading branch information
Axent96 authored Dec 8, 2020
2 parents 7407f06 + 900a38b commit 64e4f8a
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions src/Message/AbstractRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ abstract class AbstractRequest extends OmnipayAbstractRequest
const ITEM_TYPE_HANDLING = 'handling';
// Voucher / discount
const ITEM_TYPE_VOUCHER = 'voucher';

/**
* recurring method for PAYONE.
*
* https://docs.payone.com/display/public/PLATFORM/Special+remarks+-+Recurring+transactions+credit+card#expand-SampleInitialRequest
*/
const RECURRENCE_TYPE_RECURRING = 'recurring';
const RECURRENCE_TYPE_ONECLICK = 'oneclick';

/**
* The list of raw data fields that must be hashed to protect from
Expand Down Expand Up @@ -89,6 +97,10 @@ abstract class AbstractRequest extends OmnipayAbstractRequest
'clearingtype',
'encoding',
//
//Special remarks - Recurring transactions credit card (https://docs.payone.com/display/public/PLATFORM/Special+remarks+-+Recurring+transactions+credit+card#expand-SampleInitialRequest)
'customer_is_present',
'recurrence',
//
// Listed in documentation only, either in a dedicated list or
// or marked as requiring a hash in the field tables.
'amount_recurring',
Expand Down Expand Up @@ -259,6 +271,14 @@ public function getDataPersonal(array $data = [])
$data['customerid'] = $this->getCustomerId();
}

if ($this->getCustomerIsPresent()) {
$data['customer_is_present'] = $this->getCustomerIsPresent();
}

if ($this->getRecurrence()) {
$data['recurrence'] = $this->getRecurrence();
}

if ($this->getDebtorId()) {
$data['userid'] = $this->getDebtorId();
}
Expand Down Expand Up @@ -695,6 +715,40 @@ public function getDebtorId()
{
return $this->getParameter('debtorId');
}

public function getCustomerIsPresent()
{
return $this->getParameter('customer_is_present');
}

/**
* is Customer present by payment
*/
public function setCustomerIsPresent($isPresent)
{
if (!is_bool($isPresent)) {
throw new InvalidRequestException('"customer_is_present" must be boolean.');
}
return $this->setParameter('customer_is_present', $isPresent ? 'yes' : 'no');
}

public function getRecurrence()
{
return $this->getParameter('recurrence');
}

/**
* recurring method for PAYONE.
*
* https://docs.payone.com/display/public/PLATFORM/Special+remarks+-+Recurring+transactions+credit+card#expand-SampleInitialRequest
*/
public function setRecurrence($recurrence)
{
if ($recurrence !== self::RECURRENCE_TYPE_ONECLICK && $recurrence !== self::RECURRENCE_TYPE_RECURRING) {
throw new InvalidRequestException('"recurrence" must have a value of "oneclick" or "recurring".');
}
return $this->setParameter('recurrence', $recurrence);
}

/**
* The VAT number (optional).
Expand Down

0 comments on commit 64e4f8a

Please sign in to comment.