From ec46c397fe2d1b9e2357412e3b8ccc34fe04bf7e Mon Sep 17 00:00:00 2001 From: japatel Date: Tue, 3 Feb 2015 14:28:14 -0600 Subject: [PATCH] Adding Transaction Fee in Sale Object - Updates to #232 --- lib/PayPal/Api/Sale.php | 41 +++++++----- lib/PayPal/Api/TransactionFee.php | 70 -------------------- tests/PayPal/Test/Api/SaleTest.php | 3 +- tests/PayPal/Test/Api/TransactionFeeTest.php | 18 ----- tests/PayPal/Test/Api/TransactionTest.php | 4 +- 5 files changed, 27 insertions(+), 109 deletions(-) delete mode 100644 lib/PayPal/Api/TransactionFee.php delete mode 100644 tests/PayPal/Test/Api/TransactionFeeTest.php diff --git a/lib/PayPal/Api/Sale.php b/lib/PayPal/Api/Sale.php index 9fa5392..b766fe0 100644 --- a/lib/PayPal/Api/Sale.php +++ b/lib/PayPal/Api/Sale.php @@ -2,9 +2,7 @@ namespace PayPal\Api; -use PayPal\Api\Refund; use PayPal\Common\PayPalResourceModel; -use PayPal\Rest\ApiContext; use PayPal\Transport\PayPalRestCall; use PayPal\Validation\ArgumentValidator; @@ -26,25 +24,11 @@ use PayPal\Validation\ArgumentValidator; * @property string protection_eligibility_type * @property string clearing_time * @property string parent_payment - * @property \PayPal\Api\TransactionFee $transactionFee + * @property \PayPal\Api\Currency $transaction_fee * @package PayPal\Api */ class Sale extends PayPalResourceModel { - public function setTransactionFee(\PayPal\Api\TransactionFee $transactionFee) - { - $this->transactionFee = $transactionFee; - return $this; - } - - /** - * @return \PayPal\Api\TransactionFee - */ - public function getTransactionFee() - { - return $this->transactionFee; - } - /** * Identifier of the authorization transaction. * @@ -285,6 +269,29 @@ class Sale extends PayPalResourceModel return $this->protection_eligibility_type; } + /** + * Transaction fee applicable for this payment. + * + * @param Currency $transaction_fee + * @return $this + */ + public function setTransactionFee($transaction_fee) + { + $this->transaction_fee = $transaction_fee; + return $this; + } + + /** + * Transaction fee applicable for this payment. + * + * @return \PayPal\Api\Currency + */ + public function getTransactionFee() + { + return $this->transaction_fee; + } + + /** * Expected clearing time for eCheck Transactions * diff --git a/lib/PayPal/Api/TransactionFee.php b/lib/PayPal/Api/TransactionFee.php deleted file mode 100644 index 6c3583e..0000000 --- a/lib/PayPal/Api/TransactionFee.php +++ /dev/null @@ -1,70 +0,0 @@ -currency = $currency; - return $this; - } - - /** - * 3 letter currency code - * - * @return string - */ - public function getCurrency() - { - return $this->currency; - } - - /** - * Total amount charged from the Payer account (or card) to Payee. In case of a refund, this is the refunded amount to the original Payer from Payee account. - * - * - * @param string|double $value - * - * @return $this - */ - public function setValue($value) - { - NumericValidator::validate($value, "value"); - $value = FormatConverter::formatToPrice($value, $this->getCurrency()); - $this->value = $value; - return $this; - } - - /** - * Value amount charged from the Payer account (or card) to Payee. In case of a refund, this is the refunded amount to the original Payer from Payee account. - * - * @return string - */ - public function getValue() - { - return $this->value; - } -} diff --git a/tests/PayPal/Test/Api/SaleTest.php b/tests/PayPal/Test/Api/SaleTest.php index b4792c5..d1585bf 100644 --- a/tests/PayPal/Test/Api/SaleTest.php +++ b/tests/PayPal/Test/Api/SaleTest.php @@ -1,6 +1,7 @@ setParentPayment(self::$parentPayment); $sale->setState(self::$state); - $this->tFee = new \PayPal\Api\TransactionFee(); + $this->tFee = new Currency(); $this->tFee->setCurrency('AUD'); $this->tFee->setValue('0.10'); diff --git a/tests/PayPal/Test/Api/TransactionFeeTest.php b/tests/PayPal/Test/Api/TransactionFeeTest.php deleted file mode 100644 index ba62189..0000000 --- a/tests/PayPal/Test/Api/TransactionFeeTest.php +++ /dev/null @@ -1,18 +0,0 @@ -setCurrency('AUD'); - $this->assertEquals('AUD', $tfee->getCurrency()); - - $tfee->setValue('0.10'); - $this->assertEquals('0.10', $tfee->getValue()); - } -} diff --git a/tests/PayPal/Test/Api/TransactionTest.php b/tests/PayPal/Test/Api/TransactionTest.php index 3fe00da..66ce086 100644 --- a/tests/PayPal/Test/Api/TransactionTest.php +++ b/tests/PayPal/Test/Api/TransactionTest.php @@ -2,14 +2,12 @@ namespace PayPal\Test\Api; -use PayPal\Api\SubTransaction; - use PayPal\Api\Transaction; -use PayPal\Test\Constants; class TransactionTest extends \PHPUnit_Framework_TestCase { + /** @var Transaction */ private $transaction; public static $description = "desc . . . ";