Skip to content
This repository has been archived by the owner on Sep 29, 2023. It is now read-only.

Commit

Permalink
Merge branch 'chaitanyakuber-transaction-fee-patch'
Browse files Browse the repository at this point in the history
  • Loading branch information
japatel committed Feb 3, 2015
2 parents 0e9894b + ec46c39 commit 82a0e08
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 61 deletions.
120 changes: 71 additions & 49 deletions lib/PayPal/Api/Sale.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
namespace PayPal\Api;

use PayPal\Common\PayPalResourceModel;
use PayPal\Rest\ApiContext;
use PayPal\Api\Refund;
use PayPal\Transport\PayPalRestCall;
use PayPal\Validation\ArgumentValidator;

Expand All @@ -13,7 +11,6 @@
*
* A sale transaction.
*
* @package PayPal\Api
*
* @property string id
* @property string create_time
Expand All @@ -27,15 +24,17 @@
* @property string protection_eligibility_type
* @property string clearing_time
* @property string parent_payment
* @property \PayPal\Api\Currency $transaction_fee
* @package PayPal\Api
*/
class Sale extends PayPalResourceModel
{
/**
* Identifier of the authorization transaction.
*
*
* @param string $id
*
*
*
* @param string $id
* @return $this
*/
public function setId($id)
Expand All @@ -56,10 +55,10 @@ public function getId()

/**
* Time the resource was created.
*
*
* @param string $create_time
*
*
*
* @param string $create_time
* @return $this
*/
public function setCreateTime($create_time)
Expand All @@ -80,10 +79,10 @@ public function getCreateTime()

/**
* Time the resource was last updated.
*
*
* @param string $update_time
*
*
*
* @param string $update_time
* @return $this
*/
public function setUpdateTime($update_time)
Expand All @@ -104,10 +103,10 @@ public function getUpdateTime()

/**
* Amount being collected.
*
*
* @param \PayPal\Api\Amount $amount
*
*
*
* @param \PayPal\Api\Amount $amount
* @return $this
*/
public function setAmount($amount)
Expand All @@ -128,10 +127,10 @@ public function getAmount()

/**
* specifies payment mode of the transaction
* Valid Values: ["INSTANT_TRANSFER", "MANUAL_BANK_TRANSFER", "DELAYED_TRANSFER", "ECHECK"]
* Valid Values: ["INSTANT_TRANSFER", "MANUAL_BANK_TRANSFER", "DELAYED_TRANSFER", "ECHECK"]
*
*
* @param string $payment_mode
*
* @param string $payment_mode
* @return $this
*/
public function setPaymentMode($payment_mode)
Expand All @@ -152,10 +151,10 @@ public function getPaymentMode()

/**
* Reason of Pending transaction.
*
*
* @param string $pending_reason
*
*
*
* @param string $pending_reason
* @return $this
*/
public function setPendingReason($pending_reason)
Expand All @@ -176,10 +175,10 @@ public function getPendingReason()

/**
* State of the sale transaction.
* Valid Values: ["pending", "completed", "refunded", "partially_refunded"]
* Valid Values: ["pending", "completed", "refunded", "partially_refunded"]
*
*
* @param string $state
*
* @param string $state
* @return $this
*/
public function setState($state)
Expand All @@ -200,10 +199,10 @@ public function getState()

/**
* Reason code for the transaction state being Pending or Reversed.
* Valid Values: ["CHARGEBACK", "GUARANTEE", "BUYER_COMPLAINT", "REFUND", "UNCONFIRMED_SHIPPING_ADDRESS", "ECHECK", "INTERNATIONAL_WITHDRAWAL", "RECEIVING_PREFERENCE_MANDATES_MANUAL_ACTION", "PAYMENT_REVIEW", "REGULATORY_REVIEW", "UNILATERAL", "VERIFICATION_REQUIRED"]
* Valid Values: ["CHARGEBACK", "GUARANTEE", "BUYER_COMPLAINT", "REFUND", "UNCONFIRMED_SHIPPING_ADDRESS", "ECHECK", "INTERNATIONAL_WITHDRAWAL", "RECEIVING_PREFERENCE_MANDATES_MANUAL_ACTION", "PAYMENT_REVIEW", "REGULATORY_REVIEW", "UNILATERAL", "VERIFICATION_REQUIRED"]
*
* @param string $reason_code
*
*
* @param string $reason_code
* @return $this
*/
public function setReasonCode($reason_code)
Expand All @@ -223,11 +222,11 @@ public function getReasonCode()
}

/**
* Protection Eligibility of the Payer
* Valid Values: ["ELIGIBLE", "PARTIALLY_ELIGIBLE", "INELIGIBLE"]
* Protection Eligibility of the Payer
* Valid Values: ["ELIGIBLE", "PARTIALLY_ELIGIBLE", "INELIGIBLE"]
*
*
* @param string $protection_eligibility
*
* @param string $protection_eligibility
* @return $this
*/
public function setProtectionEligibility($protection_eligibility)
Expand All @@ -237,7 +236,7 @@ public function setProtectionEligibility($protection_eligibility)
}

/**
* Protection Eligibility of the Payer
* Protection Eligibility of the Payer
*
* @return string
*/
Expand All @@ -247,11 +246,11 @@ public function getProtectionEligibility()
}

/**
* Protection Eligibility Type of the Payer
* Valid Values: ["ELIGIBLE", "ITEM_NOT_RECEIVED_ELIGIBLE", "INELIGIBLE", "UNAUTHORIZED_PAYMENT_ELIGIBLE"]
* Protection Eligibility Type of the Payer
* Valid Values: ["ELIGIBLE", "ITEM_NOT_RECEIVED_ELIGIBLE", "INELIGIBLE", "UNAUTHORIZED_PAYMENT_ELIGIBLE"]
*
* @param string $protection_eligibility_type
*
*
* @param string $protection_eligibility_type
* @return $this
*/
public function setProtectionEligibilityType($protection_eligibility_type)
Expand All @@ -261,7 +260,7 @@ public function setProtectionEligibilityType($protection_eligibility_type)
}

/**
* Protection Eligibility Type of the Payer
* Protection Eligibility Type of the Payer
*
* @return string
*/
Expand All @@ -270,12 +269,35 @@ public function getProtectionEligibilityType()
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
*
*
* @param string $clearing_time
*
*
*
* @param string $clearing_time
* @return $this
*/
public function setClearingTime($clearing_time)
Expand All @@ -296,10 +318,10 @@ public function getClearingTime()

/**
* ID of the Payment resource that this transaction is based on.
*
*
* @param string $parent_payment
*
*
*
* @param string $parent_payment
* @return $this
*/
public function setParentPayment($parent_payment)
Expand All @@ -321,9 +343,9 @@ public function getParentPayment()
/**
* Obtain the Sale transaction resource for the given identifier.
*
* @param string $saleId
* @param \PayPal\Rest\ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
* @param string $saleId
* @param \PayPal\Rest\ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
* @return Sale
*/
public static function get($saleId, $apiContext = null, $restCall = null)
Expand All @@ -347,9 +369,9 @@ public static function get($saleId, $apiContext = null, $restCall = null)
/**
* Creates (and processes) a new Refund Transaction added as a related resource.
*
* @param Refund $refund
* @param \PayPal\Rest\ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
* @param Refund $refund
* @param \PayPal\Rest\ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
* @return Refund
*/
public function refund($refund, $apiContext = null, $restCall = null)
Expand Down
23 changes: 14 additions & 9 deletions tests/PayPal/Test/Api/SaleTest.php
Original file line number Diff line number Diff line change
@@ -1,40 +1,44 @@
<?php
namespace PayPal\Test\Api;

use PayPal\Api\Refund;
use PayPal\Api\Currency;
use PayPal\Api\Sale;
use PayPal\Test\Constants;
use PayPal\Test\Api\AmountTest;
use PayPal\Test\Api\PaymentTest;
use PayPal\Test\Api\LinksTest;
use PayPal\Exception\PayPalConnectionException;

class SaleTest extends \PHPUnit_Framework_TestCase
{

/** @var Sale */
/**
* @var Sale
*/
private $sale;
private $tFee;

public static $captureId = "CAP-123";
public static $createTime = "2013-02-28T00:00:00Z";
public static $id = "R-5678";
public static $parentPayment = "PAY-123";
public static $state = "Created";

public static function createSale()
private function createSale()
{
$sale = new Sale();
$sale->setAmount(AmountTest::createAmount());
$sale->setCreateTime(self::$createTime);
$sale->setId(self::$id);
$sale->setParentPayment(self::$parentPayment);
$sale->setState(self::$state);

$this->tFee = new Currency();
$this->tFee->setCurrency('AUD');
$this->tFee->setValue('0.10');

$sale->setTransactionFee($this->tFee);
return $sale;
}

public function setup()
{
$this->sale = self::createSale();
$this->sale = $this->createSale();
}

public function testGetterSetter()
Expand All @@ -44,6 +48,7 @@ public function testGetterSetter()
$this->assertEquals(self::$parentPayment, $this->sale->getParentPayment());
$this->assertEquals(self::$state, $this->sale->getState());
$this->assertEquals(AmountTest::$currency, $this->sale->getAmount()->getCurrency());
$this->assertEquals($this->tFee, $this->sale->getTransactionFee());
}

public function testSerializeDeserialize()
Expand Down
4 changes: 1 addition & 3 deletions tests/PayPal/Test/Api/TransactionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 . . . ";
Expand Down

0 comments on commit 82a0e08

Please sign in to comment.