forked from LiveCarta/PayPal-PHP-SDK
Enabling Future Payments
- Added feature to create future payments - Updated Authentication model to retrieve long lived refresh token - Updated Documentation - Updated Sample
This commit is contained in:
48
lib/PayPal/Api/FuturePayment.php
Normal file
48
lib/PayPal/Api/FuturePayment.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace PayPal\Api;
|
||||
|
||||
use PayPal\Common\PPModel;
|
||||
use PayPal\Rest\ApiContext;
|
||||
use PayPal\Transport\PPRestCall;
|
||||
|
||||
/**
|
||||
* Class FuturePayment
|
||||
*
|
||||
* @package PayPal\Api
|
||||
*/
|
||||
class FuturePayment extends Payment
|
||||
{
|
||||
|
||||
/**
|
||||
* Extends the Payment object to create future payments
|
||||
*
|
||||
* @param null $apiContext
|
||||
* @param $correlationId
|
||||
* @return $this
|
||||
*/
|
||||
public function create($apiContext = null, $correlationId = null) {
|
||||
if ($apiContext == null) {
|
||||
$apiContext = new ApiContext(self::$credential);
|
||||
}
|
||||
if (($correlationId == null || trim($correlationId) == "")) {
|
||||
throw new \InvalidArgumentException("correlationId cannot be null or empty");
|
||||
}
|
||||
$payLoad = $this->toJSON();
|
||||
$call = new PPRestCall($apiContext);
|
||||
$json = $call->execute(
|
||||
array('PayPal\Rest\RestHandler'),
|
||||
"/v1/payments/payment",
|
||||
"POST",
|
||||
$payLoad,
|
||||
[
|
||||
'Paypal-Application-Correlation-Id' => $correlationId,
|
||||
'PAYPAL-CLIENT-METADATA-ID' => $correlationId
|
||||
]
|
||||
);
|
||||
$this->fromJson($json);
|
||||
|
||||
return $this;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ class Payment extends PPModel implements IResource
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
private static $credential;
|
||||
protected static $credential;
|
||||
|
||||
/**
|
||||
* Set Credential
|
||||
@@ -467,14 +467,14 @@ class Payment extends PPModel implements IResource
|
||||
$payLoad = "";
|
||||
|
||||
$allowedParams = array(
|
||||
'count' => 1,
|
||||
'start_id' => 1,
|
||||
'count' => 1,
|
||||
'start_id' => 1,
|
||||
'start_index' => 1,
|
||||
'start_time' => 1,
|
||||
'end_time' => 1,
|
||||
'payee_id' => 1,
|
||||
'sort_by' => 1,
|
||||
'sort_order' => 1,
|
||||
'start_time' => 1,
|
||||
'end_time' => 1,
|
||||
'payee_id' => 1,
|
||||
'sort_by' => 1,
|
||||
'sort_order' => 1,
|
||||
);
|
||||
|
||||
if ($apiContext == null) {
|
||||
|
||||
Reference in New Issue
Block a user