Adding Transaction Fee in Sale Object

- Updates to #232
This commit is contained in:
japatel
2015-02-03 14:28:14 -06:00
parent 7b811ffafe
commit ec46c397fe
5 changed files with 27 additions and 109 deletions

View File

@@ -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
*

View File

@@ -1,70 +0,0 @@
<?php
namespace PayPal\Api;
use PayPal\Common\PayPalModel;
use PayPal\Converter\FormatConverter;
use PayPal\Validation\NumericValidator;
/**
* Class TranactionFee
*
* Let's you specify details of the transaction fee.
*
* @package PayPal\Api
*
* @property string currency
* @property string value
*/
class TransactionFee extends PayPalModel
{
/**
* 3 letter currency code
*
*
* @param string $currency
*
* @return $this
*/
public function setCurrency($currency)
{
$this->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;
}
}

View File

@@ -1,6 +1,7 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Api\Currency;
use PayPal\Api\Sale;
use PayPal\Test\Api\AmountTest;
@@ -27,7 +28,7 @@ class SaleTest extends \PHPUnit_Framework_TestCase
$sale->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');

View File

@@ -1,18 +0,0 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Api\TransactionFee;
class TransactionFeeTest extends \PHPUnit_Framework_TestCase
{
public function testGetterSetter()
{
$tfee = new TransactionFee();
$tfee->setCurrency('AUD');
$this->assertEquals('AUD', $tfee->getCurrency());
$tfee->setValue('0.10');
$this->assertEquals('0.10', $tfee->getValue());
}
}

View File

@@ -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 . . . ";