diff --git a/samples/transaction/details.php b/samples/transaction/details.php new file mode 100644 index 00000000..40ab0b8f --- /dev/null +++ b/samples/transaction/details.php @@ -0,0 +1,95 @@ + + * + * 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 . + */ + +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(); +} + diff --git a/samples/transaction/status.php b/samples/transaction/status.php new file mode 100644 index 00000000..1bf3f3a6 --- /dev/null +++ b/samples/transaction/status.php @@ -0,0 +1,47 @@ + + * + * 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 . + */ + +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(); +} diff --git a/src/Api/Transaction/Details.php b/src/Api/Transaction/Details.php new file mode 100644 index 00000000..6f45d6c7 --- /dev/null +++ b/src/Api/Transaction/Details.php @@ -0,0 +1,94 @@ + + */ +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'); + } +} diff --git a/src/Result/Transaction/Details.php b/src/Result/Transaction/Details.php new file mode 100644 index 00000000..6eb1bf24 --- /dev/null +++ b/src/Result/Transaction/Details.php @@ -0,0 +1,279 @@ + + */ +class Details extends Result +{ + + /** + * @return string Full array paymentDetails + */ + public function getPaymentDetails() + { + return (isset($this->data['paymentDetails'])) ? $this->data['paymentDetails'] : array(); + } + + /** + * @return string The transactionId + */ + public function getTransactionId() + { + return (isset($this->data['paymentDetails']['transactionId'])) ? $this->data['paymentDetails']['transactionId'] : ''; + } + + /** + * @return string The orderId + */ + public function getOrderId() + { + return (isset($this->data['paymentDetails']['orderId'])) ? $this->data['paymentDetails']['orderId'] : ''; + } + + /** + * @return string The orderNumber + */ + public function getOrderNumber() + { + return (isset($this->data['paymentDetails']['orderNumber'])) ? $this->data['paymentDetails']['orderNumber'] : ''; + } + + /** + * @return string The paymentProfileId + */ + public function getPaymentProfileId() + { + return (isset($this->data['paymentDetails']['paymentProfileId'])) ? $this->data['paymentDetails']['paymentProfileId'] : ''; + } + + /** + * @return string The paymentProfileName + */ + public function getPaymentProfileName() + { + return (isset($this->data['paymentDetails']['paymentProfileName'])) ? $this->data['paymentDetails']['paymentProfileName'] : ''; + } + + /** + * @return string The state + */ + public function getState() + { + return (isset($this->data['paymentDetails']['state'])) ? $this->data['paymentDetails']['state'] : ''; + } + + /** + * @return string The stateName + */ + public function getStateName() + { + return (isset($this->data['paymentDetails']['stateName'])) ? $this->data['paymentDetails']['stateName'] : ''; + } + + /** + * @return string The language + */ + public function getLanguage() + { + return (isset($this->data['paymentDetails']['language'])) ? $this->data['paymentDetails']['language'] : ''; + } + + /** + * @return string The startDate + */ + public function getStartDate() + { + return (isset($this->data['paymentDetails']['startDate'])) ? $this->data['paymentDetails']['startDate'] : ''; + } + + /** + * @return string The completeDate + */ + public function getCompleteDate() + { + return (isset($this->data['paymentDetails']['completeDate'])) ? $this->data['paymentDetails']['completeDate'] : ''; + } + + /** + * @return string The startIpAddress + */ + public function getStartIpAddress() + { + return (isset($this->data['paymentDetails']['startIpAddress'])) ? $this->data['paymentDetails']['startIpAddress'] : ''; + } + + /** + * @return string The completedIpAddress + */ + public function getCompletedIpAddress() + { + return (isset($this->data['paymentDetails']['completedIpAddress'])) ? $this->data['paymentDetails']['completedIpAddress'] : ''; + } + + /** + * @return string The amount + */ + public function getAmount() + { + return (isset($this->data['paymentDetails']['amount'])) ? $this->data['paymentDetails']['amount'] : ''; + } + + /** + * @return string The amount Value + */ + public function getAmountValue() + { + return (isset($this->data['paymentDetails']['amount']['value'])) ? $this->data['paymentDetails']['amount']['value'] : ''; + } + + /** + * @return string The amount Currency + */ + public function getAmountCurrency() + { + return (isset($this->data['paymentDetails']['amount']['currency'])) ? $this->data['paymentDetails']['amount']['currency'] : ''; + } + + + /** + * @return string The amountOriginal + */ + public function getAmountOriginal() + { + return (isset($this->data['paymentDetails']['amountOriginal'])) ? $this->data['paymentDetails']['amountOriginal'] : ''; + } + + /** + * @return string The amountOriginal Value + */ + public function getAmountOriginalValue() + { + return (isset($this->data['paymentDetails']['amountOriginal']['value'])) ? $this->data['paymentDetails']['amountOriginal']['value'] : ''; + } + + /** + * @return string The amountOriginal Currency + */ + public function getAmountOriginalCurrency() + { + return (isset($this->data['paymentDetails']['amountOriginal']['currency'])) ? $this->data['paymentDetails']['amountOriginal']['currency'] : ''; + } + + /** + * @return string The amountPaidOriginal + */ + public function getAmountPaidOriginal() + { + return (isset($this->data['paymentDetails']['amountPaidOriginal'])) ? $this->data['paymentDetails']['amountPaidOriginal'] : ''; + } + + /** + * @return string The amountPaidOriginal Value + */ + public function getAmountPaidOriginalValue() + { + return (isset($this->data['paymentDetails']['amountPaidOriginal']['value'])) ? $this->data['paymentDetails']['amountPaidOriginal']['value'] : ''; + } + + /** + * @return string The amountPaidOriginal Currency + */ + public function getAmountPaidOriginalCurrency() + { + return (isset($this->data['paymentDetails']['amountPaidOriginal']['currency'])) ? $this->data['paymentDetails']['amountPaidOriginal']['currency'] : ''; + } + + /** + * @return string The amountPaid + */ + public function getAmountPaid() + { + return (isset($this->data['paymentDetails']['amountPaid'])) ? $this->data['paymentDetails']['amountPaid'] : ''; + } + + /** + * @return string The amountPaid Value + */ + public function getAmountPaidValue() + { + return (isset($this->data['paymentDetails']['amountPaid']['value'])) ? $this->data['paymentDetails']['amountPaid']['value'] : ''; + } + + /** + * @return string The amountPaid Currency + */ + public function getAmountPaidCurrency() + { + return (isset($this->data['paymentDetails']['amountPaid']['currency'])) ? $this->data['paymentDetails']['amountPaid']['currency'] : ''; + } + + /** + * @return string The amountRefundOriginal + */ + public function getAmountRefundOriginal() + { + return (isset($this->data['paymentDetails']['amountRefundOriginal'])) ? $this->data['paymentDetails']['amountRefundOriginal'] : ''; + } + + /** + * @return string The amountRefundOriginal Value + */ + public function getAmountRefundOriginalValue() + { + return (isset($this->data['paymentDetails']['amountRefundOriginal']['value'])) ? $this->data['paymentDetails']['amountRefundOriginal']['value'] : ''; + } + + /** + * @return string The amountRefundOriginal Currency + */ + public function getAmountRefundOriginalCurrency() + { + return (isset($this->data['paymentDetails']['amountRefundOriginal']['currency'])) ? $this->data['paymentDetails']['amountRefundOriginal']['currency'] : ''; + } + + /** + * @return string The amountRefund + */ + public function getAmountRefund() + { + return (isset($this->data['paymentDetails']['amountRefund'])) ? $this->data['paymentDetails']['amountRefund'] : ''; + } + + /** + * @return string The amountRefund Value + */ + public function getAmountRefundValue() + { + return (isset($this->data['paymentDetails']['amountRefund']['value'])) ? $this->data['paymentDetails']['amountRefund']['value'] : ''; + } + + /** + * @return string The amountRefund Currency + */ + public function getAmountRefundCurrency() + { + return (isset($this->data['paymentDetails']['amountRefund']['currency'])) ? $this->data['paymentDetails']['amountRefund']['currency'] : ''; + } + + /** + * @return TransactionDetails[] + */ + public function getTransactionDetails() + { + $arrResult = array(); + $transactionDetails = (isset($this->data['paymentDetails']['transactionDetails'])) ? $this->data['paymentDetails']['transactionDetails'] : array(); + + foreach ($transactionDetails as $arrTransactionDetails) { + $transactionDetails = new TransactionDetails($arrTransactionDetails); + array_push($arrResult, $transactionDetails); + } + return $arrResult; + } + +} diff --git a/src/Result/Transaction/TransactionDetails.php b/src/Result/Transaction/TransactionDetails.php new file mode 100644 index 00000000..e27c1ee8 --- /dev/null +++ b/src/Result/Transaction/TransactionDetails.php @@ -0,0 +1,146 @@ + + */ +class transactionDetails extends Result +{ + + + /** + * @return string The transactionId + */ + public function getTransactionId() + { + return (isset($this->data['transactionId'])) ? $this->data['transactionId'] : ''; + } + + /** + * @return string The orderId + */ + public function getOrderId() + { + return (isset($this->data['orderId'])) ? $this->data['orderId'] : ''; + } + + /** + * @return string The reportingId + */ + public function getReportingId() + { + return (isset($this->data['reportingId'])) ? $this->data['reportingId'] : ''; + } + + /** + * @return string The state + */ + public function getState() + { + return (isset($this->data['state'])) ? $this->data['state'] : ''; + } + + /** + * @return string The stateName + */ + public function getStateName() + { + return (isset($this->data['stateName'])) ? $this->data['stateName'] : ''; + } + + /** + * @return string The startDate + */ + public function getStartDate() + { + return (isset($this->data['startDate'])) ? $this->data['startDate'] : ''; + } + + /** + * @return string The completeDate + */ + public function getCompleteDate() + { + return (isset($this->data['completeDate'])) ? $this->data['completeDate'] : ''; + } + + /** + * @return string The paymentProfileId + */ + public function getPaymentProfileId() + { + return (isset($this->data['paymentProfileId'])) ? $this->data['paymentProfileId'] : ''; + } + + /** + * @return string The paymentProfileName + */ + public function getPaymentProfileName() + { + return (isset($this->data['paymentProfileName'])) ? $this->data['paymentProfileName'] : ''; + } + + /** + * @return string The identifierName + */ + public function getIdentifierName() + { + return (isset($this->data['identifierName'])) ? $this->data['identifierName'] : ''; + } + + /** + * @return string The identifierType + */ + public function getIdentifierType() + { + return (isset($this->data['identifierType'])) ? $this->data['identifierType'] : ''; + } + + /** + * @return string The identifierPublic + */ + public function getIdentifierPublic() + { + return (isset($this->data['identifierPublic'])) ? $this->data['identifierPublic'] : ''; + } + + /** + * @return string The identifierHash + */ + public function getIdentifierHash() + { + return (isset($this->data['identifierHash'])) ? $this->data['identifierHash'] : ''; + } + + /** + * @return string The amount + */ + public function getAmount() + { + return (isset($this->data['amount'])) ? $this->data['amount'] : ''; + } + + /** + * @return string The amount Value + */ + public function getAmountValue() + { + return (isset($this->data['amount']['value'])) ? $this->data['amount']['value'] : ''; + } + + /** + * @return string The amount Currency + */ + public function getAmountCurrency() + { + return (isset($this->data['amount']['currency'])) ? $this->data['amount']['currency'] : ''; + } + + + +} diff --git a/src/Transaction.php b/src/Transaction.php index 26933908..0c066551 100644 --- a/src/Transaction.php +++ b/src/Transaction.php @@ -304,6 +304,35 @@ public static function status($transactionId) return new Result\Status($result); } + /** + * Gets details of a transaction + * + * @param string $transactionId + * @param string|null $entranceCode + * + * @return Result\Details + * @throws Error\Api + * @throws Error\Error + * @throws Error\Required\ApiToken + */ + public static function details( + $transactionId, + $entranceCode = null + ) + { + + $api = new Api\Details(); + + $api->setTransactionId($transactionId); + + if ($entranceCode !== null) { + $api->setEntranceCode($entranceCode); + } + $result = $api->doRequest(); + + return new Result\Details($result); + } + /** * Get the transaction in an exchange script. * This will work for all kinds of exchange calls (GET, POST AND POST_XML)