From 85512dbde44c1767c93c30c41d9b156182b8ae69 Mon Sep 17 00:00:00 2001 From: Sabrina Buchegger Date: Thu, 24 Jun 2021 10:24:39 +0200 Subject: [PATCH 1/7] added splits to the transaction types --- src/Data/Split.php | 134 +++++++++++++++++++++++ src/Json/JsonGenerator.php | 33 +++++- src/Transaction/Base/SplitsInterface.php | 30 +++++ src/Transaction/Base/SplitsTrait.php | 42 +++++++ src/Transaction/Capture.php | 7 +- src/Transaction/Debit.php | 6 +- src/Transaction/Payout.php | 8 +- src/Transaction/Preauthorize.php | 8 +- src/Transaction/Refund.php | 9 +- 9 files changed, 266 insertions(+), 11 deletions(-) create mode 100644 src/Data/Split.php create mode 100644 src/Transaction/Base/SplitsInterface.php create mode 100644 src/Transaction/Base/SplitsTrait.php diff --git a/src/Data/Split.php b/src/Data/Split.php new file mode 100644 index 0000000..7f50893 --- /dev/null +++ b/src/Data/Split.php @@ -0,0 +1,134 @@ +id; + } + + /** + * @param int $id + */ + public function setId($id) + { + $this->id = $id; + } + + /** + * @return string + */ + public function getTransactionInternalId() + { + return $this->transactionInternalId; + } + + /** + * @param string $transactionInternalId + */ + public function setTransactionInternalId($transactionInternalId) + { + $this->transactionInternalId = $transactionInternalId; + } + + /** + * @return string + */ + public function getAmount() + { + return $this->amount; + } + + /** + * @param string $amount + */ + public function setAmount($amount) + { + $this->amount = $amount; + } + + /** + * @return string + */ + public function getCurrency() + { + return $this->currency; + } + + /** + * @param string $currency + */ + public function setCurrency($currency) + { + $this->currency = $currency; + } + + /** + * @return string + */ + public function getSellerMerchantGuid() + { + return $this->sellerMerchantGuid; + } + + /** + * @param string $sellerMerchantGuid + */ + public function setSellerMerchantGuid($sellerMerchantGuid) + { + $this->sellerMerchantGuid = $sellerMerchantGuid; + } + + /** + * @return string + */ + public function getSellerMerchantExternalId() + { + return $this->sellerMerchantExternalId; + } + + /** + * @param string $sellerMerchantExternalId + */ + public function setSellerMerchantExternalId($sellerMerchantExternalId) + { + $this->sellerMerchantExternalId = $sellerMerchantExternalId; + } +} \ No newline at end of file diff --git a/src/Json/JsonGenerator.php b/src/Json/JsonGenerator.php index a54daff..b1d6cfd 100644 --- a/src/Json/JsonGenerator.php +++ b/src/Json/JsonGenerator.php @@ -12,6 +12,7 @@ use Ixopay\Client\Data\PaymentData\IbanData; use Ixopay\Client\Data\PaymentData\PaymentData; use Ixopay\Client\Data\PaymentData\WalletData; +use Ixopay\Client\Data\Split; use Ixopay\Client\Data\ThreeDSecureData; use Ixopay\Client\Schedule\ContinueSchedule; use Ixopay\Client\Schedule\ScheduleData; @@ -153,6 +154,7 @@ protected function createDebit($transaction, $language){ 'transactionToken' => $transaction->getTransactionToken(), 'description' => $transaction->getDescription(), 'items' => $this->createItems($transaction->getItems()), + 'splits' => $this->createSplits($transaction->getSplits()), 'withRegister' => $transaction->isWithRegister(), 'transactionIndicator' => $transaction->getTransactionIndicator(), 'customer' => $this->createCustomer($transaction->getCustomer()), @@ -334,6 +336,35 @@ protected function createItems($items){ return $data; } + /** + * splits data + * + * @param $splits + * + * @return array + */ + protected function createSplits($splits){ + + if(!$splits){ + return null; + } + + $data = []; + + /** @var Split $split */ + foreach($splits as $split){ + $data[] = [ + 'identification' => $split->getTransactionInternalId(), + 'amount' => $split->getAmount(), + 'currency' => $split->getCurrency(), + 'sellerMerchantGuid' => $split->getSellerMerchantGuid(), + 'sellerMerchantExternalId' => $split->getSellerMerchantExternalId() + ]; + } + + return $data; + } + /** * customer data * - includes paymentData @@ -604,4 +635,4 @@ protected function stringifyExtraData($extraData) { } return $extraData; } -} \ No newline at end of file +} diff --git a/src/Transaction/Base/SplitsInterface.php b/src/Transaction/Base/SplitsInterface.php new file mode 100644 index 0000000..2b9fe64 --- /dev/null +++ b/src/Transaction/Base/SplitsInterface.php @@ -0,0 +1,30 @@ +splits = $splits; + return $this; + } + + /** + * @return Split[] + */ + public function getSplits() { + return $this->splits; + } + + /** + * @param Split $item + * + * @return $this + */ + public function addSplit($item) { + $this->splits[] = $item; + return $this; + } +} \ No newline at end of file diff --git a/src/Transaction/Capture.php b/src/Transaction/Capture.php index 15f552d..c019638 100644 --- a/src/Transaction/Capture.php +++ b/src/Transaction/Capture.php @@ -7,13 +7,16 @@ use Ixopay\Client\Transaction\Base\AmountableTrait; use Ixopay\Client\Transaction\Base\ItemsInterface; use Ixopay\Client\Transaction\Base\ItemsTrait; +use Ixopay\Client\Transaction\Base\SplitsInterface; +use Ixopay\Client\Transaction\Base\SplitsTrait; /** * Capture: Charge a previously preauthorized transaction. * * @package Ixopay\Client\Transaction */ -class Capture extends AbstractTransactionWithReference implements AmountableInterface, ItemsInterface { +class Capture extends AbstractTransactionWithReference implements AmountableInterface, ItemsInterface, SplitsInterface { use AmountableTrait; use ItemsTrait; -} \ No newline at end of file + use SplitsTrait; +} diff --git a/src/Transaction/Debit.php b/src/Transaction/Debit.php index aa2f46b..d324dab 100644 --- a/src/Transaction/Debit.php +++ b/src/Transaction/Debit.php @@ -15,6 +15,8 @@ use Ixopay\Client\Transaction\Base\OffsiteTrait; use Ixopay\Client\Transaction\Base\ScheduleInterface; use Ixopay\Client\Transaction\Base\ScheduleTrait; +use Ixopay\Client\Transaction\Base\SplitsInterface; +use Ixopay\Client\Transaction\Base\SplitsTrait; use Ixopay\Client\Transaction\Base\ThreeDSecureInterface; use Ixopay\Client\Transaction\Base\ThreeDSecureTrait; @@ -28,6 +30,7 @@ class Debit extends AbstractTransactionWithReference AmountableInterface, CustomerInterface, ItemsInterface, + SplitsInterface, OffsiteInterface, ScheduleInterface, ThreeDSecureInterface @@ -37,6 +40,7 @@ class Debit extends AbstractTransactionWithReference use AmountableTrait; use CustomerTrait; use ItemsTrait; + use SplitsTrait; use OffsiteTrait; use ScheduleTrait; use ThreeDSecureTrait; @@ -126,4 +130,4 @@ public function setLanguage($language) { $this->language = $language; } -} \ No newline at end of file +} diff --git a/src/Transaction/Payout.php b/src/Transaction/Payout.php index 4f906e8..1ee22e2 100644 --- a/src/Transaction/Payout.php +++ b/src/Transaction/Payout.php @@ -9,6 +9,8 @@ use Ixopay\Client\Transaction\Base\CustomerTrait; use Ixopay\Client\Transaction\Base\ItemsInterface; use Ixopay\Client\Transaction\Base\ItemsTrait; +use Ixopay\Client\Transaction\Base\SplitsInterface; +use Ixopay\Client\Transaction\Base\SplitsTrait; /** * Payout: Payout a certain amount of money to the customer. (Debits the merchant's account, Credits the customer's account) @@ -18,12 +20,14 @@ class Payout extends AbstractTransactionWithReference implements AmountableInterface, CustomerInterface, - ItemsInterface + ItemsInterface, + SplitsInterface { use AmountableTrait; use CustomerTrait; use ItemsTrait; + use SplitsTrait; /** @var string */ protected $callbackUrl; @@ -97,4 +101,4 @@ public function setLanguage($language) $this->language = $language; } -} \ No newline at end of file +} diff --git a/src/Transaction/Preauthorize.php b/src/Transaction/Preauthorize.php index 5dea029..716bab7 100644 --- a/src/Transaction/Preauthorize.php +++ b/src/Transaction/Preauthorize.php @@ -15,6 +15,8 @@ use Ixopay\Client\Transaction\Base\OffsiteTrait; use Ixopay\Client\Transaction\Base\ScheduleInterface; use Ixopay\Client\Transaction\Base\ScheduleTrait; +use Ixopay\Client\Transaction\Base\SplitsInterface; +use Ixopay\Client\Transaction\Base\SplitsTrait; use Ixopay\Client\Transaction\Base\ThreeDSecureInterface; use Ixopay\Client\Transaction\Base\ThreeDSecureTrait; @@ -28,6 +30,7 @@ class Preauthorize extends AbstractTransactionWithReference AmountableInterface, CustomerInterface, ItemsInterface, + SplitsInterface, OffsiteInterface, ScheduleInterface, ThreeDSecureInterface @@ -37,10 +40,11 @@ class Preauthorize extends AbstractTransactionWithReference use AmountableTrait; use CustomerTrait; use ItemsTrait; + use SplitsTrait; use OffsiteTrait; use ScheduleTrait; use ThreeDSecureTrait; - + const TRANSACTION_INDICATOR_SINGLE = 'SINGLE'; const TRANSACTION_INDICATOR_INITIAL = 'INITIAL'; const TRANSACTION_INDICATOR_RECURRING = 'RECURRING'; @@ -126,4 +130,4 @@ public function setLanguage($language) { $this->language = $language; } -} \ No newline at end of file +} diff --git a/src/Transaction/Refund.php b/src/Transaction/Refund.php index 22549ec..9139f23 100644 --- a/src/Transaction/Refund.php +++ b/src/Transaction/Refund.php @@ -7,6 +7,8 @@ use Ixopay\Client\Transaction\Base\AmountableTrait; use Ixopay\Client\Transaction\Base\ItemsInterface; use Ixopay\Client\Transaction\Base\ItemsTrait; +use Ixopay\Client\Transaction\Base\SplitsInterface; +use Ixopay\Client\Transaction\Base\SplitsTrait; /** * Refund: Refund money from a previous Debit (or Capture) transaction to the customer. @@ -15,13 +17,14 @@ * * @package Ixopay\Client\Transaction */ -class Refund extends AbstractTransactionWithReference implements AmountableInterface, ItemsInterface { +class Refund extends AbstractTransactionWithReference implements AmountableInterface, ItemsInterface, SplitsInterface { use AmountableTrait; use ItemsTrait; + use SplitsTrait; /** @var string */ protected $callbackUrl; - + /** @var string */ protected $transactionToken; @@ -72,4 +75,4 @@ public function setDescription($description) { $this->description = $description; } -} \ No newline at end of file +} From 101b82da1bf188b4b277fed6b0445b7b30639675 Mon Sep 17 00:00:00 2001 From: Sabrina Buchegger Date: Tue, 3 Aug 2021 09:38:21 +0200 Subject: [PATCH 2/7] added fees to splits --- src/Data/Split.php | 40 +++++++++++++++++++++++++++++++++++++- src/Json/JsonGenerator.php | 6 +++++- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/src/Data/Split.php b/src/Data/Split.php index 7f50893..183feda 100644 --- a/src/Data/Split.php +++ b/src/Data/Split.php @@ -36,6 +36,12 @@ class Split */ private $sellerMerchantExternalId; + /** @var string */ + private $commissionFeeAmount; + + /** @var string */ + private $commissionFeeCurrency; + /** * @return int */ @@ -131,4 +137,36 @@ public function setSellerMerchantExternalId($sellerMerchantExternalId) { $this->sellerMerchantExternalId = $sellerMerchantExternalId; } -} \ No newline at end of file + + /** + * @return string + */ + public function getCommissionFeeAmount() + { + return $this->commissionFeeAmount; + } + + /** + * @param string $commissionFeeAmount + */ + public function setCommissionFeeAmount($commissionFeeAmount) + { + $this->commissionFeeAmount = $commissionFeeAmount; + } + + /** + * @return string + */ + public function getCommissionFeeCurrency() + { + return $this->commissionFeeCurrency; + } + + /** + * @param string $commissionFeeCurrency + */ + public function setCommissionFeeCurrency($commissionFeeCurrency) + { + $this->commissionFeeCurrency = $commissionFeeCurrency; + } +} diff --git a/src/Json/JsonGenerator.php b/src/Json/JsonGenerator.php index b1d6cfd..db993dd 100644 --- a/src/Json/JsonGenerator.php +++ b/src/Json/JsonGenerator.php @@ -358,7 +358,11 @@ protected function createSplits($splits){ 'amount' => $split->getAmount(), 'currency' => $split->getCurrency(), 'sellerMerchantGuid' => $split->getSellerMerchantGuid(), - 'sellerMerchantExternalId' => $split->getSellerMerchantExternalId() + 'sellerMerchantExternalId' => $split->getSellerMerchantExternalId(), + 'commissionFee' => [ + 'amount' => $split->getCommissionFeeAmount(), + 'currency' => $split->getCommissionFeeCurrency() + ] ]; } From 1d48869bed884e2bb52c0a8cf65d35847d90de1d Mon Sep 17 00:00:00 2001 From: Sabrina Buchegger Date: Tue, 3 Aug 2021 14:22:31 +0200 Subject: [PATCH 3/7] generate splits also for capture, refund and payouts --- src/Json/JsonGenerator.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Json/JsonGenerator.php b/src/Json/JsonGenerator.php index db993dd..f1ec59d 100644 --- a/src/Json/JsonGenerator.php +++ b/src/Json/JsonGenerator.php @@ -194,6 +194,7 @@ protected function createCapture($transaction){ 'amount' => (string)$transaction->getAmount(), 'currency' => $transaction->getCurrency(), 'items' => $this->createItems($transaction->getItems()), + 'splits' => $this->createSplits($transaction->getSplits()), ]; return $data; @@ -275,6 +276,7 @@ protected function createRefund($transaction){ 'transactionToken' => $transaction->getTransactionToken(), 'description' => $transaction->getDescription(), 'items' => $this->createItems($transaction->getItems()), + 'splits' => $this->createSplits($transaction->getSplits()), ]; return $data; @@ -298,6 +300,7 @@ protected function createPayout($transaction, $language){ 'transactionToken' => $transaction->getTransactionToken(), 'description' => $transaction->getDescription(), 'items' => $this->createItems($transaction->getItems()), + 'splits' => $this->createSplits($transaction->getSplits()), 'customer' => $this->createCustomer($transaction->getCustomer()), 'language' => $language, ]; From af6323f0eedff180ba7bcc5a2f23bd74595f6629 Mon Sep 17 00:00:00 2001 From: Sabrina Buchegger Date: Thu, 12 Aug 2021 15:47:56 +0200 Subject: [PATCH 4/7] splits: renaming to transactionSplits and addition to status api response --- src/Data/{Split.php => TransactionSplit.php} | 2 +- src/Json/JsonGenerator.php | 12 +++--- src/Json/JsonParser.php | 39 +++++++++++++++++ src/StatusApi/StatusResult.php | 22 ++++++++++ src/Transaction/Base/SplitsInterface.php | 30 ------------- src/Transaction/Base/SplitsTrait.php | 42 ------------------- .../Base/TransactionSplitsInterface.php | 30 +++++++++++++ .../Base/TransactionSplitsTrait.php | 40 ++++++++++++++++++ src/Transaction/Capture.php | 8 ++-- src/Transaction/Debit.php | 8 ++-- src/Transaction/Payout.php | 8 ++-- src/Transaction/Preauthorize.php | 8 ++-- src/Transaction/Refund.php | 8 ++-- 13 files changed, 158 insertions(+), 99 deletions(-) rename src/Data/{Split.php => TransactionSplit.php} (99%) delete mode 100644 src/Transaction/Base/SplitsInterface.php delete mode 100644 src/Transaction/Base/SplitsTrait.php create mode 100644 src/Transaction/Base/TransactionSplitsInterface.php create mode 100644 src/Transaction/Base/TransactionSplitsTrait.php diff --git a/src/Data/Split.php b/src/Data/TransactionSplit.php similarity index 99% rename from src/Data/Split.php rename to src/Data/TransactionSplit.php index 183feda..a14614b 100644 --- a/src/Data/Split.php +++ b/src/Data/TransactionSplit.php @@ -4,7 +4,7 @@ namespace Ixopay\Client\Data; -class Split +class TransactionSplit { /** * @var int diff --git a/src/Json/JsonGenerator.php b/src/Json/JsonGenerator.php index f1ec59d..e41a018 100644 --- a/src/Json/JsonGenerator.php +++ b/src/Json/JsonGenerator.php @@ -12,7 +12,7 @@ use Ixopay\Client\Data\PaymentData\IbanData; use Ixopay\Client\Data\PaymentData\PaymentData; use Ixopay\Client\Data\PaymentData\WalletData; -use Ixopay\Client\Data\Split; +use Ixopay\Client\Data\TransactionSplit; use Ixopay\Client\Data\ThreeDSecureData; use Ixopay\Client\Schedule\ContinueSchedule; use Ixopay\Client\Schedule\ScheduleData; @@ -342,20 +342,20 @@ protected function createItems($items){ /** * splits data * - * @param $splits + * @param $transactionSplits * * @return array */ - protected function createSplits($splits){ + protected function createSplits($transactionSplits){ - if(!$splits){ + if(!$transactionSplits){ return null; } $data = []; - /** @var Split $split */ - foreach($splits as $split){ + /** @var TransactionSplit $split */ + foreach($transactionSplits as $split){ $data[] = [ 'identification' => $split->getTransactionInternalId(), 'amount' => $split->getAmount(), diff --git a/src/Json/JsonParser.php b/src/Json/JsonParser.php index 2f18cbb..db60aa3 100644 --- a/src/Json/JsonParser.php +++ b/src/Json/JsonParser.php @@ -14,6 +14,7 @@ use Ixopay\Client\Data\Result\ScheduleResultData; use Ixopay\Client\Data\Result\WalletData as ReturnWalletData; use Ixopay\Client\Data\RiskCheckData; +use Ixopay\Client\Data\TransactionSplit; use Ixopay\Client\Options\OptionsResult; use Ixopay\Client\Schedule\ScheduleResult; use Ixopay\Client\StatusApi\StatusResult; @@ -170,6 +171,11 @@ public function parseStatusResult($jsonString) { $result->setCustomerProfileData($customerProfileData); } + if(isset($json['splits'])) { + $splits = $this->parseTransactionSplits($json['splits']); + $result->setTransactionSplits($splits); + } + return $result; } @@ -502,4 +508,37 @@ protected function arrGet($arr, $key, $default=null){ } return $default; } + + /** + * @param $data + * + * @return TransactionSplit + */ + protected function parseTransactionSplit($data){ + $split = new TransactionSplit(); + $split->setTransactionInternalId($this->arrGet($data, 'identification')); + $split->setAmount($this->arrGet($data, 'amount')); + $split->setCurrency($this->arrGet($data, 'currency')); + $split->setSellerMerchantGuid($this->arrGet($data, 'sellerMerchantGuid')); + $split->setSellerMerchantExternalId($this->arrGet($data, 'sellerMerchantExternalId')); + + $commissionFee = $data['commissionFee']; + $split->setCommissionFeeAmount($this->arrGet($commissionFee, 'commissionFeeAmount')); + $split->setCommissionFeeCurrency($this->arrGet($commissionFee, 'commissionFeeCurrency')); + + return $split; + } + + /** + * @param $data + * + * @return array + */ + protected function parseTransactionSplits($data){ + $splits = []; + foreach($data as $split){ + $splits[] = $this->parseTransactionSplit($split); + } + return $splits; + } } diff --git a/src/StatusApi/StatusResult.php b/src/StatusApi/StatusResult.php index 0a88164..2173bbc 100644 --- a/src/StatusApi/StatusResult.php +++ b/src/StatusApi/StatusResult.php @@ -8,6 +8,7 @@ use Ixopay\Client\Data\CustomerProfileData; use Ixopay\Client\Data\Result\ResultData; use Ixopay\Client\Data\Result\ScheduleResultData; +use Ixopay\Client\Data\TransactionSplit; use Ixopay\Client\Transaction\Error; /** @@ -165,6 +166,11 @@ class StatusResult { */ protected $errorCode = null; + /** + * @var TransactionSplit[] + */ + protected $transactionSplits = []; + /** * @return bool */ @@ -594,6 +600,22 @@ public function setErrorCode($errorCode) return $this; } + /** + * @return TransactionSplit[] + */ + public function getTransactionSplits() + { + return $this->transactionSplits; + } + + /** + * @param TransactionSplit[] $transactionSplits + */ + public function setTransactionSplits($transactionSplits) + { + $this->transactionSplits = $transactionSplits; + } + /** * @return array */ diff --git a/src/Transaction/Base/SplitsInterface.php b/src/Transaction/Base/SplitsInterface.php deleted file mode 100644 index 2b9fe64..0000000 --- a/src/Transaction/Base/SplitsInterface.php +++ /dev/null @@ -1,30 +0,0 @@ -splits = $splits; - return $this; - } - - /** - * @return Split[] - */ - public function getSplits() { - return $this->splits; - } - - /** - * @param Split $item - * - * @return $this - */ - public function addSplit($item) { - $this->splits[] = $item; - return $this; - } -} \ No newline at end of file diff --git a/src/Transaction/Base/TransactionSplitsInterface.php b/src/Transaction/Base/TransactionSplitsInterface.php new file mode 100644 index 0000000..da9ae86 --- /dev/null +++ b/src/Transaction/Base/TransactionSplitsInterface.php @@ -0,0 +1,30 @@ +transactionSplits = $transactionSplits; + } + + /** + * @return TransactionSplit[] + */ + public function getTransactionSplits() { + return $this->transactionSplits; + } + + /** + * @param TransactionSplit $transactionSplit + * + * @return void + */ + public function addTransactionSplit($transactionSplit) { + $this->transactionSplits[] = $transactionSplit; + } +} diff --git a/src/Transaction/Capture.php b/src/Transaction/Capture.php index c019638..849f600 100644 --- a/src/Transaction/Capture.php +++ b/src/Transaction/Capture.php @@ -7,16 +7,16 @@ use Ixopay\Client\Transaction\Base\AmountableTrait; use Ixopay\Client\Transaction\Base\ItemsInterface; use Ixopay\Client\Transaction\Base\ItemsTrait; -use Ixopay\Client\Transaction\Base\SplitsInterface; -use Ixopay\Client\Transaction\Base\SplitsTrait; +use Ixopay\Client\Transaction\Base\TransactionSplitsInterface; +use Ixopay\Client\Transaction\Base\TransactionSplitsTrait; /** * Capture: Charge a previously preauthorized transaction. * * @package Ixopay\Client\Transaction */ -class Capture extends AbstractTransactionWithReference implements AmountableInterface, ItemsInterface, SplitsInterface { +class Capture extends AbstractTransactionWithReference implements AmountableInterface, ItemsInterface, TransactionSplitsInterface { use AmountableTrait; use ItemsTrait; - use SplitsTrait; + use TransactionSplitsTrait; } diff --git a/src/Transaction/Debit.php b/src/Transaction/Debit.php index d324dab..0822562 100644 --- a/src/Transaction/Debit.php +++ b/src/Transaction/Debit.php @@ -15,8 +15,8 @@ use Ixopay\Client\Transaction\Base\OffsiteTrait; use Ixopay\Client\Transaction\Base\ScheduleInterface; use Ixopay\Client\Transaction\Base\ScheduleTrait; -use Ixopay\Client\Transaction\Base\SplitsInterface; -use Ixopay\Client\Transaction\Base\SplitsTrait; +use Ixopay\Client\Transaction\Base\TransactionSplitsInterface; +use Ixopay\Client\Transaction\Base\TransactionSplitsTrait; use Ixopay\Client\Transaction\Base\ThreeDSecureInterface; use Ixopay\Client\Transaction\Base\ThreeDSecureTrait; @@ -30,7 +30,7 @@ class Debit extends AbstractTransactionWithReference AmountableInterface, CustomerInterface, ItemsInterface, - SplitsInterface, + TransactionSplitsInterface, OffsiteInterface, ScheduleInterface, ThreeDSecureInterface @@ -40,7 +40,7 @@ class Debit extends AbstractTransactionWithReference use AmountableTrait; use CustomerTrait; use ItemsTrait; - use SplitsTrait; + use TransactionSplitsTrait; use OffsiteTrait; use ScheduleTrait; use ThreeDSecureTrait; diff --git a/src/Transaction/Payout.php b/src/Transaction/Payout.php index 1ee22e2..514fb72 100644 --- a/src/Transaction/Payout.php +++ b/src/Transaction/Payout.php @@ -9,8 +9,8 @@ use Ixopay\Client\Transaction\Base\CustomerTrait; use Ixopay\Client\Transaction\Base\ItemsInterface; use Ixopay\Client\Transaction\Base\ItemsTrait; -use Ixopay\Client\Transaction\Base\SplitsInterface; -use Ixopay\Client\Transaction\Base\SplitsTrait; +use Ixopay\Client\Transaction\Base\TransactionSplitsInterface; +use Ixopay\Client\Transaction\Base\TransactionSplitsTrait; /** * Payout: Payout a certain amount of money to the customer. (Debits the merchant's account, Credits the customer's account) @@ -21,13 +21,13 @@ class Payout extends AbstractTransactionWithReference implements AmountableInterface, CustomerInterface, ItemsInterface, - SplitsInterface + TransactionSplitsInterface { use AmountableTrait; use CustomerTrait; use ItemsTrait; - use SplitsTrait; + use TransactionSplitsTrait; /** @var string */ protected $callbackUrl; diff --git a/src/Transaction/Preauthorize.php b/src/Transaction/Preauthorize.php index 716bab7..e76a3a4 100644 --- a/src/Transaction/Preauthorize.php +++ b/src/Transaction/Preauthorize.php @@ -15,8 +15,8 @@ use Ixopay\Client\Transaction\Base\OffsiteTrait; use Ixopay\Client\Transaction\Base\ScheduleInterface; use Ixopay\Client\Transaction\Base\ScheduleTrait; -use Ixopay\Client\Transaction\Base\SplitsInterface; -use Ixopay\Client\Transaction\Base\SplitsTrait; +use Ixopay\Client\Transaction\Base\TransactionSplitsInterface; +use Ixopay\Client\Transaction\Base\TransactionSplitsTrait; use Ixopay\Client\Transaction\Base\ThreeDSecureInterface; use Ixopay\Client\Transaction\Base\ThreeDSecureTrait; @@ -30,7 +30,7 @@ class Preauthorize extends AbstractTransactionWithReference AmountableInterface, CustomerInterface, ItemsInterface, - SplitsInterface, + TransactionSplitsInterface, OffsiteInterface, ScheduleInterface, ThreeDSecureInterface @@ -40,7 +40,7 @@ class Preauthorize extends AbstractTransactionWithReference use AmountableTrait; use CustomerTrait; use ItemsTrait; - use SplitsTrait; + use TransactionSplitsTrait; use OffsiteTrait; use ScheduleTrait; use ThreeDSecureTrait; diff --git a/src/Transaction/Refund.php b/src/Transaction/Refund.php index 9139f23..bbbf5a3 100644 --- a/src/Transaction/Refund.php +++ b/src/Transaction/Refund.php @@ -7,8 +7,8 @@ use Ixopay\Client\Transaction\Base\AmountableTrait; use Ixopay\Client\Transaction\Base\ItemsInterface; use Ixopay\Client\Transaction\Base\ItemsTrait; -use Ixopay\Client\Transaction\Base\SplitsInterface; -use Ixopay\Client\Transaction\Base\SplitsTrait; +use Ixopay\Client\Transaction\Base\TransactionSplitsInterface; +use Ixopay\Client\Transaction\Base\TransactionSplitsTrait; /** * Refund: Refund money from a previous Debit (or Capture) transaction to the customer. @@ -17,10 +17,10 @@ * * @package Ixopay\Client\Transaction */ -class Refund extends AbstractTransactionWithReference implements AmountableInterface, ItemsInterface, SplitsInterface { +class Refund extends AbstractTransactionWithReference implements AmountableInterface, ItemsInterface, TransactionSplitsInterface { use AmountableTrait; use ItemsTrait; - use SplitsTrait; + use TransactionSplitsTrait; /** @var string */ protected $callbackUrl; From 302a335fed2a20f4e2875fbfa614c899d5ec2d64 Mon Sep 17 00:00:00 2001 From: Sabrina Buchegger Date: Fri, 13 Aug 2021 09:56:02 +0200 Subject: [PATCH 5/7] split: renaming fix --- src/Json/JsonGenerator.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Json/JsonGenerator.php b/src/Json/JsonGenerator.php index e41a018..212beea 100644 --- a/src/Json/JsonGenerator.php +++ b/src/Json/JsonGenerator.php @@ -154,7 +154,7 @@ protected function createDebit($transaction, $language){ 'transactionToken' => $transaction->getTransactionToken(), 'description' => $transaction->getDescription(), 'items' => $this->createItems($transaction->getItems()), - 'splits' => $this->createSplits($transaction->getSplits()), + 'splits' => $this->createSplits($transaction->getTransactionSplits()), 'withRegister' => $transaction->isWithRegister(), 'transactionIndicator' => $transaction->getTransactionIndicator(), 'customer' => $this->createCustomer($transaction->getCustomer()), @@ -194,7 +194,7 @@ protected function createCapture($transaction){ 'amount' => (string)$transaction->getAmount(), 'currency' => $transaction->getCurrency(), 'items' => $this->createItems($transaction->getItems()), - 'splits' => $this->createSplits($transaction->getSplits()), + 'splits' => $this->createSplits($transaction->getTransactionSplits()), ]; return $data; @@ -276,7 +276,7 @@ protected function createRefund($transaction){ 'transactionToken' => $transaction->getTransactionToken(), 'description' => $transaction->getDescription(), 'items' => $this->createItems($transaction->getItems()), - 'splits' => $this->createSplits($transaction->getSplits()), + 'splits' => $this->createSplits($transaction->getTransactionSplits()), ]; return $data; @@ -300,7 +300,7 @@ protected function createPayout($transaction, $language){ 'transactionToken' => $transaction->getTransactionToken(), 'description' => $transaction->getDescription(), 'items' => $this->createItems($transaction->getItems()), - 'splits' => $this->createSplits($transaction->getSplits()), + 'splits' => $this->createSplits($transaction->getTransactionSplits()), 'customer' => $this->createCustomer($transaction->getCustomer()), 'language' => $language, ]; From 4625205b0ac0c82a4beb73ea481c96ae45adb20d Mon Sep 17 00:00:00 2001 From: Sabrina Buchegger Date: Fri, 13 Aug 2021 10:17:43 +0200 Subject: [PATCH 6/7] splits: fix commission fee parsing --- src/Json/JsonParser.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Json/JsonParser.php b/src/Json/JsonParser.php index db60aa3..b8c5b7f 100644 --- a/src/Json/JsonParser.php +++ b/src/Json/JsonParser.php @@ -522,9 +522,11 @@ protected function parseTransactionSplit($data){ $split->setSellerMerchantGuid($this->arrGet($data, 'sellerMerchantGuid')); $split->setSellerMerchantExternalId($this->arrGet($data, 'sellerMerchantExternalId')); - $commissionFee = $data['commissionFee']; - $split->setCommissionFeeAmount($this->arrGet($commissionFee, 'commissionFeeAmount')); - $split->setCommissionFeeCurrency($this->arrGet($commissionFee, 'commissionFeeCurrency')); + if (isset($data['commissionFee'])) { + $commissionFee = $data['commissionFee']; + $split->setCommissionFeeAmount($this->arrGet($commissionFee, 'amount')); + $split->setCommissionFeeCurrency($this->arrGet($commissionFee, 'currency')); + } return $split; } From 97bc148a37982c233a5cd8a5f3877fe758887b8b Mon Sep 17 00:00:00 2001 From: Sabrina Buchegger Date: Tue, 28 Sep 2021 10:14:57 +0200 Subject: [PATCH 7/7] add description to void transactions --- src/Json/JsonGenerator.php | 1 + src/Transaction/VoidTransaction.php | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Json/JsonGenerator.php b/src/Json/JsonGenerator.php index afef7fa..b1af3b6 100644 --- a/src/Json/JsonGenerator.php +++ b/src/Json/JsonGenerator.php @@ -238,6 +238,7 @@ protected function createVoid($transaction){ /** @var VoidTransaction $transaction */ $data = [ 'referenceUuid' => $transaction->getReferenceUuid(), + 'description' => $transaction->getDescription(), ]; return $data; diff --git a/src/Transaction/VoidTransaction.php b/src/Transaction/VoidTransaction.php index db4361b..6614bdc 100644 --- a/src/Transaction/VoidTransaction.php +++ b/src/Transaction/VoidTransaction.php @@ -10,5 +10,20 @@ * @package Ixopay\Client\Transaction */ class VoidTransaction extends AbstractTransactionWithReference { + /** @var string */ + protected $description; -} \ No newline at end of file + /** + * @return string + */ + public function getDescription() { + return $this->description; + } + + /** + * @param string $description + */ + public function setDescription($description) { + $this->description = $description; + } +}