forked from LiveCarta/PayPal-PHP-SDK
462 lines
12 KiB
PHP
462 lines
12 KiB
PHP
<?php
|
|
|
|
namespace PayPal\Api;
|
|
|
|
use PayPal\Common\PayPalResourceModel;
|
|
use PayPal\Rest\ApiContext;
|
|
use PayPal\Transport\PayPalRestCall;
|
|
use PayPal\Validation\ArgumentValidator;
|
|
|
|
/**
|
|
* Class Authorization
|
|
*
|
|
* An authorization transaction.
|
|
*
|
|
* @package PayPal\Api
|
|
*
|
|
* @property string id
|
|
* @property string create_time
|
|
* @property string update_time
|
|
* @property \PayPal\Api\Amount amount
|
|
* @property string payment_mode
|
|
* @property string state
|
|
* @property string reason_code
|
|
* @property string pending_reason
|
|
* @property string protection_eligibility
|
|
* @property string protection_eligibility_type
|
|
* @property \PayPal\Api\FmfDetails fmf_details
|
|
* @property string parent_payment
|
|
* @property string clearing_time
|
|
* @property string valid_until
|
|
* @property \PayPal\Api\Links links
|
|
*/
|
|
class Authorization extends PayPalResourceModel
|
|
{
|
|
/**
|
|
* Identifier of the authorization transaction.
|
|
*
|
|
* @param string $id
|
|
*
|
|
* @return $this
|
|
*/
|
|
public function setId($id)
|
|
{
|
|
$this->id = $id;
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Identifier of the authorization transaction.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getId()
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
/**
|
|
* Amount being authorized for.
|
|
*
|
|
* @param \PayPal\Api\Amount $amount
|
|
*
|
|
* @return $this
|
|
*/
|
|
public function setAmount($amount)
|
|
{
|
|
$this->amount = $amount;
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Amount being authorized for.
|
|
*
|
|
* @return \PayPal\Api\Amount
|
|
*/
|
|
public function getAmount()
|
|
{
|
|
return $this->amount;
|
|
}
|
|
|
|
/**
|
|
* specifies payment mode of the transaction
|
|
* Valid Values: ["INSTANT_TRANSFER", "MANUAL_BANK_TRANSFER", "DELAYED_TRANSFER", "ECHECK"]
|
|
*
|
|
* @param string $payment_mode
|
|
*
|
|
* @return $this
|
|
*/
|
|
public function setPaymentMode($payment_mode)
|
|
{
|
|
$this->payment_mode = $payment_mode;
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* specifies payment mode of the transaction
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getPaymentMode()
|
|
{
|
|
return $this->payment_mode;
|
|
}
|
|
|
|
/**
|
|
* State of the authorization transaction.
|
|
* Valid Values: ["pending", "authorized", "partially_captured", "captured", "expired", "voided"]
|
|
*
|
|
* @param string $state
|
|
*
|
|
* @return $this
|
|
*/
|
|
public function setState($state)
|
|
{
|
|
$this->state = $state;
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* State of the authorization transaction.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getState()
|
|
{
|
|
return $this->state;
|
|
}
|
|
|
|
/**
|
|
* Reason code for the transaction state being Pending. This field will replace pending_reason field eventually
|
|
* Valid Values: ["AUTHORIZATION"]
|
|
*
|
|
* @param string $reason_code
|
|
*
|
|
* @return $this
|
|
*/
|
|
public function setReasonCode($reason_code)
|
|
{
|
|
$this->reason_code = $reason_code;
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Reason code for the transaction state being Pending. This field will replace pending_reason field eventually
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getReasonCode()
|
|
{
|
|
return $this->reason_code;
|
|
}
|
|
|
|
/**
|
|
* [DEPRECATED] Reason code for the transaction state being Pending.Obsolete. use reason_code field instead.
|
|
* Valid Values: ["AUTHORIZATION"]
|
|
* @deprecated Plese Use setReasonCode instead
|
|
* @param string $pending_reason
|
|
*
|
|
* @return $this
|
|
*/
|
|
public function setPendingReason($pending_reason)
|
|
{
|
|
$this->pending_reason = $pending_reason;
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* [DEPRECATED] Reason code for the transaction state being Pending.Obsolete. use reason_code field instead.
|
|
* @deprecated Plese Use setReasonCode instead
|
|
* @return string
|
|
*/
|
|
public function getPendingReason()
|
|
{
|
|
return $this->pending_reason;
|
|
}
|
|
|
|
/**
|
|
* Protection Eligibility of the Payer
|
|
* Valid Values: ["ELIGIBLE", "PARTIALLY_ELIGIBLE", "INELIGIBLE"]
|
|
*
|
|
* @param string $protection_eligibility
|
|
*
|
|
* @return $this
|
|
*/
|
|
public function setProtectionEligibility($protection_eligibility)
|
|
{
|
|
$this->protection_eligibility = $protection_eligibility;
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Protection Eligibility of the Payer
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getProtectionEligibility()
|
|
{
|
|
return $this->protection_eligibility;
|
|
}
|
|
|
|
/**
|
|
* Protection Eligibility Type of the Payer
|
|
* Valid Values: ["ELIGIBLE", "ITEM_NOT_RECEIVED_ELIGIBLE", "INELIGIBLE", "UNAUTHORIZED_PAYMENT_ELIGIBLE"]
|
|
*
|
|
* @param string $protection_eligibility_type
|
|
*
|
|
* @return $this
|
|
*/
|
|
public function setProtectionEligibilityType($protection_eligibility_type)
|
|
{
|
|
$this->protection_eligibility_type = $protection_eligibility_type;
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Protection Eligibility Type of the Payer
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getProtectionEligibilityType()
|
|
{
|
|
return $this->protection_eligibility_type;
|
|
}
|
|
|
|
/**
|
|
* Fraud Management Filter (FMF) details applied for the payment that could result in accept/deny/pending action.
|
|
*
|
|
* @param \PayPal\Api\FmfDetails $fmf_details
|
|
*
|
|
* @return $this
|
|
*/
|
|
public function setFmfDetails($fmf_details)
|
|
{
|
|
$this->fmf_details = $fmf_details;
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Fraud Management Filter (FMF) details applied for the payment that could result in accept/deny/pending action.
|
|
*
|
|
* @return \PayPal\Api\FmfDetails
|
|
*/
|
|
public function getFmfDetails()
|
|
{
|
|
return $this->fmf_details;
|
|
}
|
|
|
|
/**
|
|
* ID of the Payment resource that this transaction is based on.
|
|
*
|
|
* @param string $parent_payment
|
|
*
|
|
* @return $this
|
|
*/
|
|
public function setParentPayment($parent_payment)
|
|
{
|
|
$this->parent_payment = $parent_payment;
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* ID of the Payment resource that this transaction is based on.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getParentPayment()
|
|
{
|
|
return $this->parent_payment;
|
|
}
|
|
|
|
/**
|
|
* Expected clearing time for eCheck Transactions
|
|
*
|
|
*
|
|
* @param string $clearing_time
|
|
*
|
|
* @return $this
|
|
*/
|
|
public function setClearingTime($clearing_time)
|
|
{
|
|
$this->clearing_time = $clearing_time;
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Expected clearing time for eCheck Transactions
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getClearingTime()
|
|
{
|
|
return $this->clearing_time;
|
|
}
|
|
|
|
/**
|
|
* Date/Time until which funds may be captured against this resource in UTC ISO8601 format.
|
|
*
|
|
* @param string $valid_until
|
|
*
|
|
* @return $this
|
|
*/
|
|
public function setValidUntil($valid_until)
|
|
{
|
|
$this->valid_until = $valid_until;
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Date/Time until which funds may be captured against this resource in UTC ISO8601 format.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getValidUntil()
|
|
{
|
|
return $this->valid_until;
|
|
}
|
|
|
|
/**
|
|
* Time the resource was created in UTC ISO8601 format.
|
|
*
|
|
* @param string $create_time
|
|
*
|
|
* @return $this
|
|
*/
|
|
public function setCreateTime($create_time)
|
|
{
|
|
$this->create_time = $create_time;
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Time the resource was created in UTC ISO8601 format.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getCreateTime()
|
|
{
|
|
return $this->create_time;
|
|
}
|
|
|
|
/**
|
|
* Time the resource was last updated in UTC ISO8601 format.
|
|
*
|
|
* @param string $update_time
|
|
*
|
|
* @return $this
|
|
*/
|
|
public function setUpdateTime($update_time)
|
|
{
|
|
$this->update_time = $update_time;
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Time the resource was last updated in UTC ISO8601 format.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getUpdateTime()
|
|
{
|
|
return $this->update_time;
|
|
}
|
|
|
|
/**
|
|
* Retrieve details about a previously created authorization by passing the authorization_id in the request URI.
|
|
*
|
|
* @param string $authorizationId
|
|
* @param 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 Authorization
|
|
*/
|
|
public static function get($authorizationId, $apiContext = null, $restCall = null)
|
|
{
|
|
ArgumentValidator::validate($authorizationId, 'authorizationId');
|
|
$payLoad = "";
|
|
$json = self::executeCall(
|
|
"/v1/payments/authorization/$authorizationId",
|
|
"GET",
|
|
$payLoad,
|
|
null,
|
|
$apiContext,
|
|
$restCall
|
|
);
|
|
$ret = new Authorization();
|
|
$ret->fromJson($json);
|
|
return $ret;
|
|
}
|
|
|
|
/**
|
|
* Capture and process a previously created authorization by passing the authorization_id in the request URI. To use this request, the original payment call must have the intent set to authorize.
|
|
*
|
|
* @param Capture $capture
|
|
* @param 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 Capture
|
|
*/
|
|
public function capture($capture, $apiContext = null, $restCall = null)
|
|
{
|
|
ArgumentValidator::validate($this->getId(), "Id");
|
|
ArgumentValidator::validate($capture, 'capture');
|
|
$payLoad = $capture->toJSON();
|
|
$json = self::executeCall(
|
|
"/v1/payments/authorization/{$this->getId()}/capture",
|
|
"POST",
|
|
$payLoad,
|
|
null,
|
|
$apiContext,
|
|
$restCall
|
|
);
|
|
$ret = new Capture();
|
|
$ret->fromJson($json);
|
|
return $ret;
|
|
}
|
|
|
|
/**
|
|
* Void (cancel) a previously authorized payment by passing the authorization_id in the request URI. Note that a fully captured authorization cannot be voided.
|
|
*
|
|
* @param 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 Authorization
|
|
*/
|
|
public function void($apiContext = null, $restCall = null)
|
|
{
|
|
ArgumentValidator::validate($this->getId(), "Id");
|
|
$payLoad = "";
|
|
$json = self::executeCall(
|
|
"/v1/payments/authorization/{$this->getId()}/void",
|
|
"POST",
|
|
$payLoad,
|
|
null,
|
|
$apiContext,
|
|
$restCall
|
|
);
|
|
$this->fromJson($json);
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Reauthorize a PayPal account payment by passing the authorization_id in the request URI. You should reauthorize a payment after the initial 3-day honor period to ensure that funds are still available.
|
|
*
|
|
* @param 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 Authorization
|
|
*/
|
|
public function reauthorize($apiContext = null, $restCall = null)
|
|
{
|
|
ArgumentValidator::validate($this->getId(), "Id");
|
|
$payLoad = $this->toJSON();
|
|
$json = self::executeCall(
|
|
"/v1/payments/authorization/{$this->getId()}/reauthorize",
|
|
"POST",
|
|
$payLoad,
|
|
null,
|
|
$apiContext,
|
|
$restCall
|
|
);
|
|
$this->fromJson($json);
|
|
return $this;
|
|
}
|
|
|
|
}
|