-
Notifications
You must be signed in to change notification settings - Fork 48
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 #98 from paynl/feature/details
Add details function to transaction and Add sample for status
- Loading branch information
Showing
6 changed files
with
690 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<?php | ||
/* | ||
* Copyright (C) 2020 PAY. <[email protected]> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
require_once '../../vendor/autoload.php'; | ||
require_once '../config.php'; | ||
|
||
$transactionId = 'EX-1234-5678-9012'; | ||
|
||
try { | ||
/*$example = \Paynl\Transaction::details( | ||
TransactionId(string) - Required, | ||
entranceCode(string) - Optional | ||
);*/ | ||
|
||
$result = \Paynl\Transaction::details($transactionId); | ||
|
||
/** | ||
* GETTERS | ||
* | ||
* paymentDetails = getPaymentDetails() @var array | ||
* TransactionId = getTransactionId() @var string | ||
* OrderId = getOrderId() @var string | ||
* OrderNumber = getOrderNumber() @var string | ||
* PaymentProfileId = getPaymentProfileId() @var string | ||
* PaymentProfileName = getPaymentProfileName() @var string | ||
* State = getState() @var string | ||
* StateName = getStateName() @var string | ||
* Language = getLanguage() @var string | ||
* StartDate = getStartDate() @var string | ||
* CompleteDate = getCompleteDate() @var string | ||
* StartIpAddress = getStartIpAddress() @var string | ||
* CompletedIpAddress = getCompletedIpAddress() @var string | ||
* Amount = getAmount() @var array | ||
* AmountValue = getAmountValue() @var string | ||
* AmountCurrency = getAmountCurrency() @var string | ||
* AmountOriginal = getAmountOriginal() @var array | ||
* AmountOriginalValue = getAmountOriginalValue() @var string | ||
* AmountOriginalCurrency = getAmountOriginalCurrency() @var string | ||
* AmountPaidOriginal = getAmountPaidOriginal() @var array | ||
* AmountPaidOriginalValue = getAmountPaidOriginalValue() @var string | ||
* AmountPaidOriginalCurrency = getAmountPaidOriginalCurrency() @var string | ||
* AmountPaid = getAmountPaid() @var array | ||
* AmountPaidValue = getAmountPaidValue() @var string | ||
* AmountPaidCurrency = getAmountPaidCurrency() @var string | ||
* AmountRefundOriginal = getAmountRefundOriginal() @var array | ||
* AmountRefundOriginalValue = getAmountRefundOriginalValue() @var string | ||
* AmountRefundOriginalCurrency = getAmountRefundOriginalCurrency() @var string | ||
* AmountRefund = getAmountRefund() @var array | ||
* AmountRefundValue = getAmountRefundValue() @var string | ||
* AmountRefundCurrency = getAmountRefundCurrency() @var string | ||
* Request = getRequest() @var array | ||
* Data = getData() @var array | ||
* TransactionDetails = getTransactionDetails() @var array | ||
* TransactionId = getTransactionDetails()[0]->getTransactionId() @var string | ||
* OrderId = getTransactionDetails()[0]->getOrderId() @var string | ||
* ReportingId = getTransactionDetails()[0]->getReportingId() @var string | ||
* State = getTransactionDetails()[0]->getState() @var string | ||
* StateName = getTransactionDetails()[0]->getStateName() @var string | ||
* StartDate = getTransactionDetails()[0]->getStartDate() @var string | ||
* CompleteDate = getTransactionDetails()[0]->getCompleteDate() @var string | ||
* PaymentProfileId = getTransactionDetails()[0]->getPaymentProfileId() @var string | ||
* PaymentProfileName = getTransactionDetails()[0]->getPaymentProfileName() @var string | ||
* IdentifierName = getTransactionDetails()[0]->getIdentifierName() @var string | ||
* IdentifierType = getTransactionDetails()[0]->getIdentifierType() @var string | ||
* IdentifierPublic = getTransactionDetails()[0]->getIdentifierPublic() @var string | ||
* IdentifierHash = getTransactionDetails()[0]->getIdentifierHash() @var string | ||
* Amount = getTransactionDetails()[0]->getAmount() @var array | ||
* AmountValue = getTransactionDetails()[0]->getAmountValue() @var string | ||
* AmountCurrency = getTransactionDetails()[0]->getAmountCurrency() @var string | ||
* Request = getTransactionDetails()[0]->getRequest() @var array | ||
* Data = getTransactionDetails()[0]->getData() @var array | ||
*/ | ||
|
||
} catch (\Paynl\Error\Error $e) { | ||
echo $e->getMessage(); | ||
} | ||
|
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,47 @@ | ||
<?php | ||
/* | ||
* Copyright (C) 2020 PAY. <[email protected]> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
require_once '../../vendor/autoload.php'; | ||
require_once '../config.php'; | ||
|
||
try { | ||
/*$example = \Paynl\Transaction::status( | ||
TRANSACTION ID(string) - Required | ||
);*/ | ||
|
||
$result = \Paynl\Transaction::status($transactionId); | ||
|
||
/* | ||
* Getters | ||
* transactionId = $result->getTransactionId(); | ||
* orderId = $result->getOrderId(); | ||
* paymentProfileId = $result->getPaymentProfileId(); | ||
* state = $result->getState(); | ||
* stateName = $result->getStateName(); | ||
* currency = $result->getCurrency(); | ||
* amount = $result->getAmount(); | ||
* currencyAmount = $result->getCurrencyAmount(); | ||
* paidAmount = $result->getPaidAmount(); | ||
* paidCurrencyAmount = $result->getPaidCurrencyAmount(); | ||
* refundedAmount = $result->getRefundedAmount(); | ||
* refundedCurrencyAmount = $result->getRefundedCurrencyAmount(); | ||
*/ | ||
|
||
} catch (\Paynl\Error\Error $e) { | ||
echo $e->getMessage(); | ||
} |
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,94 @@ | ||
<?php | ||
|
||
namespace Paynl\Api\Transaction; | ||
|
||
use Paynl\Error; | ||
use Paynl\Helper; | ||
|
||
/** | ||
* Api class to get the details of a transaction | ||
* | ||
* @author PAY. <[email protected]> | ||
*/ | ||
class Details extends Transaction | ||
{ | ||
protected $apiTokenRequired = true; | ||
|
||
protected $version = 15; | ||
|
||
/** | ||
* @var string The order ID of the transaction | ||
*/ | ||
private $transactionId; | ||
/** | ||
* @var string Unique code related to the order. | ||
*/ | ||
private $entranceCode; | ||
|
||
|
||
/** | ||
* @param string $transactionId | ||
*/ | ||
public function setTransactionId($transactionId) | ||
{ | ||
$this->transactionId = $transactionId; | ||
} | ||
|
||
/** | ||
* @param int $entranceCode | ||
*/ | ||
public function setEntranceCode($entranceCode) | ||
{ | ||
$this->entranceCode = $entranceCode; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
* @throws Error\Required TransactionId is required | ||
*/ | ||
protected function getData() | ||
{ | ||
if (empty($this->transactionId)) { | ||
throw new Error\Required('TransactionId is required'); | ||
} | ||
|
||
$this->data['transactionId'] = $this->transactionId; | ||
|
||
if (!empty($this->entranceCode)) { | ||
$this->data['entranceCode'] = $this->entranceCode; | ||
} | ||
|
||
return parent::getData(); | ||
} | ||
|
||
/** | ||
* @param object|array $result | ||
* | ||
* @return array | ||
* @throws Error\Api | ||
*/ | ||
protected function processResult($result) | ||
{ | ||
$output = Helper::objectToArray($result); | ||
|
||
if (!is_array($output)) { | ||
throw new Error\Api($output); | ||
} | ||
|
||
if ( | ||
isset($output['request']) && | ||
$output['request']['result'] != 1 && | ||
$output['request']['result'] !== 'TRUE') { | ||
throw new Error\Api($output['request']['errorId'] . ' - ' . $output['request']['errorMessage']. ' '. (isset($output['description']) ? $output['description'] : '')); | ||
} | ||
|
||
return parent::processResult($result); | ||
} | ||
/** | ||
* @inheritdoc | ||
*/ | ||
public function doRequest($endpoint = null, $version = null) | ||
{ | ||
return parent::doRequest('transaction/details'); | ||
} | ||
} |
Oops, something went wrong.