-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from RF1705/master
add Refund to ShopServerGateway
- Loading branch information
Showing
8 changed files
with
235 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace Omnipay\Payone\Message; | ||
|
||
/** | ||
* PAYONE Shop Authorize Request | ||
*/ | ||
|
||
class ShopServerManageMandateRequest extends ShopServerAuthorizeRequest | ||
{ | ||
/** | ||
* The "request" parameter. | ||
*/ | ||
protected $request_code = 'managemandate'; | ||
|
||
protected function createResponse($data) | ||
{ | ||
return $this->response = new ShopServerManageMandateResponse($this, $data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace Omnipay\Payone\Message; | ||
|
||
/** | ||
* Shop Payment Response | ||
*/ | ||
|
||
class ShopServerManageMandateResponse extends ShopServerAuthorizeResponse | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
<?php | ||
|
||
namespace Omnipay\Payone\Message; | ||
|
||
/** | ||
* PAYONE Shop Capture Request | ||
*/ | ||
|
||
use Omnipay\Common\Exception\InvalidRequestException; | ||
|
||
class ShopServerRefundRequest extends ShopServerAuthorizeRequest | ||
{ | ||
/** | ||
* Values for the settleAccount parameter. | ||
*/ | ||
const SETTLE_ACCOUNT_YES = 'yes'; | ||
const SETTLE_ACCOUNT_NO = 'no'; | ||
const SETTLE_ACCOUNT_AUTO = 'auto'; | ||
|
||
/** | ||
* Values for the invoiceDeliveryMode parameter. | ||
*/ | ||
const INVOICE_DELIVERY_MODE_POST = 'M'; // aka Mail | ||
const INVOICE_DELIVERY_MODE_PDF = 'P'; // via email | ||
const INVOICE_DELIVERY_MODE_NONE = 'N'; // no delivery | ||
|
||
/** | ||
* The "request" parameter. | ||
*/ | ||
protected $request_code = 'refund'; | ||
|
||
/** | ||
* Collect the data together to send to the Gateway. | ||
*/ | ||
public function getData() | ||
{ | ||
$data = $this->getBaseData(); | ||
|
||
$data['txid'] = $this->getTransactionReference(); | ||
|
||
$sequence_number = $this->getSequenceNumber(); | ||
if (isset($sequence_number)) { | ||
$data['sequencenumber'] = $sequence_number; | ||
} | ||
|
||
// Amount is in minor units. | ||
$data['amount'] = $this->getAmountInteger() * -1; | ||
|
||
// Currency is (i.e. has to be) ISO 4217 | ||
$data['currency'] = $this->getCurrency(); | ||
|
||
$data['transactiontype'] = 'RT'; | ||
|
||
if ($this->getDescription()) { | ||
$data['narrative_text'] = substr($this->getDescription(), 0, 80); | ||
} | ||
|
||
if ($this->getSettleAccount()) { | ||
$data['settleaccount'] = $this->getSettleAccount(); | ||
} | ||
|
||
if ($this->getDataItems()) { | ||
$data = array_merge($data, $this->getDataItems()); | ||
} | ||
|
||
if ($this->getMerchantInvoiceId()) { | ||
$data['invoiceid'] = $this->getMerchantInvoiceId(); | ||
} | ||
|
||
if ($this->getInvoiceDeliveryMode()) { | ||
$data['invoice_deliverymode'] = $this->getInvoiceDeliveryMode(); | ||
} | ||
|
||
if ($this->getInvoiceDeliveryDate()) { | ||
$data['invoice_deliverydate'] = $this->getInvoiceDeliveryDate(); | ||
} | ||
|
||
if ($this->getInvoiceDeliveryEndDate()) { | ||
$data['invoice_deliveryenddate'] = $this->getInvoiceDeliveryEndDate(); | ||
} | ||
|
||
if ($this->getInvoiceAppendix()) { | ||
$data['invoiceappendix'] = $this->getInvoiceAppendix(); | ||
} | ||
|
||
if ($this->getMandateId()) { | ||
$data['mandate_identification'] = $this->getMandateId(); | ||
} | ||
|
||
return $data; | ||
} | ||
|
||
protected function createResponse($data) | ||
{ | ||
return $this->response = new ShopServerCaptureResponse($this, $data); | ||
} | ||
|
||
/** | ||
* The sequence number is used to capture the total in smaller amounts. | ||
*/ | ||
public function setSequenceNumber($sequenceNumber) | ||
{ | ||
if (!is_numeric($sequenceNumber)) { | ||
throw new InvalidRequestException('Sequence Number must be numeric.'); | ||
} | ||
|
||
return $this->setParameter('sequenceNumber', $sequenceNumber); | ||
} | ||
|
||
public function getSequenceNumber() | ||
{ | ||
return $this->getParameter('sequenceNumber'); | ||
} | ||
|
||
/** | ||
* The PAYONE gateway identifier. | ||
*/ | ||
public function getTransactionReference() | ||
{ | ||
return $this->getParameter('txid'); | ||
} | ||
|
||
|
||
/** | ||
* Sets whether you want to settle the account or not. | ||
*/ | ||
public function setSettleAccount($settleAccount) | ||
{ | ||
// Allow tre/false/null for convenience. | ||
if ($settleAccount === true) { | ||
$settleAccount = static::SETTLE_ACCOUNT_YES; | ||
} elseif ($settleAccount === false) { | ||
$settleAccount = static::SETTLE_ACCOUNT_NO; | ||
} elseif (!isset($settleAccount)) { | ||
$settleAccount = static::SETTLE_ACCOUNT_AUTO; | ||
} | ||
|
||
if ($settleAccount != static::SETTLE_ACCOUNT_YES | ||
&& $settleAccount != static::SETTLE_ACCOUNT_NO | ||
&& $settleAccount != static::SETTLE_ACCOUNT_AUTO | ||
) { | ||
throw new InvalidRequestException('Invalid value for settleAccount.'); | ||
} | ||
|
||
return $this->setParameter('settleAccount', $settleAccount); | ||
} | ||
|
||
public function getSettleAccount() | ||
{ | ||
return $this->getParameter('settleAccount'); | ||
} | ||
|
||
public function setTxid($txid) | ||
{ | ||
return $this->setParameter('txid', $txid); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace Omnipay\Payone\Message; | ||
|
||
/** | ||
* Shop Payment Response | ||
*/ | ||
|
||
class ShopServerRefundResponse extends ShopServerAuthorizeResponse | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters