Enabled Billing Plans and Agreements APIs

- Added API Classes, Samples, and Tests
- Updated Functional Tests
- Updated Documentation with new SDK Name
- Updated Few Samples to use newer nicer result page
This commit is contained in:
japatel
2014-10-31 10:16:13 -05:00
parent f55fd3d984
commit 4d481ad104
192 changed files with 13310 additions and 1045 deletions

View File

@@ -1,6 +1,6 @@
# REST API SDK for PHP
[![Build Status](https://travis-ci.org/paypal/rest-api-sdk-php.png?branch=master)](https://travis-ci.org/paypal/rest-api-sdk-php) [![Coverage Status](https://coveralls.io/repos/paypal/rest-api-sdk-php/badge.png?branch=master)](https://coveralls.io/r/paypal/rest-api-sdk-php?branch=master) [![Latest Stable Version](https://poser.pugx.org/paypal/rest-api-sdk-php/v/stable.png)](https://packagist.org/packages/paypal/rest-api-sdk-php) [![Total Downloads](https://poser.pugx.org/paypal/rest-api-sdk-php/downloads.png)](https://packagist.org/packages/paypal/rest-api-sdk-php)
[![Build Status](https://travis-ci.org/paypal/PayPal-PHP-SDK.png?branch=master)](https://travis-ci.org/paypal/PayPal-PHP-SDK) [![Coverage Status](https://img.shields.io/coveralls/paypal/PayPal-PHP-SDK.svg)](https://coveralls.io/r/paypal/PayPal-PHP-SDK?branch=master) [![Latest Stable Version](https://poser.pugx.org/paypal/rest-api-sdk-php/v/stable.png)](https://packagist.org/packages/paypal/rest-api-sdk-php) [![Total Downloads](https://poser.pugx.org/paypal/rest-api-sdk-php/downloads.png)](https://packagist.org/packages/paypal/rest-api-sdk-php)
This repository contains PayPal's PHP SDK and samples for REST API.
@@ -27,7 +27,7 @@ Currently, Paypal PHP Rest API SDK is available at [https://packagist.org](https
* Running `composer require paypal/rest-api-sdk-php:*` command on your project root location (where project composer.json is located.)
* Or, manually editing composer.json file `require` field, and adding `"paypal\rest-api-sdk-php" : "*"` inside it.
* Or, manually editing composer.json file `require` field, and adding `"paypal/rest-api-sdk-php" : "*"` inside it.
The resultant sample *composer.json* would look like this:
@@ -49,7 +49,7 @@ The resultant sample *composer.json* would look like this:
If you do not want to use composer, you can grab the SDK zip that contains Paypal PHP Rest API SDK with all its dependencies with it.
#### Steps to Install :
- Download zip archive with desired version from our [Releases](https://github.com/paypal/rest-api-sdk-php/releases). Each release will have a `direct-download-*.zip` that contains PHP Rest API SDK and its dependencies.
- Download zip archive with desired version from our [Releases](https://github.com/paypal/PayPal-PHP-SDK/releases). Each release will have a `direct-download-*.zip` that contains PHP Rest API SDK and its dependencies.
- Unzip and copy vendor directory inside your project, e.g. project root directory.
@@ -134,7 +134,7 @@ We recently introduced a validation to determine if Model Object contains all th
This validation could be configured by updating the configuration settings in your sdk_config.ini file
Please visit our [sample sdk_config.ini](https://github.com/paypal/rest-api-sdk-php/blob/master/sample/sdk_config.ini)
Please visit our [sample sdk_config.ini](https://github.com/paypal/PayPal-PHP-SDK/blob/master/sample/sdk_config.ini)
```
;Validation Configuration
[validation]
@@ -149,12 +149,12 @@ validation.level=strict
The warning message would be logged into your PayPal.log file, for e.g.:
```
PayPal\Validation\ModelAccessorValidator: WARNING: Missing Accessor: PayPal\Api\Payment:setFirstName . Please let us know by creating an issue at https://github.com/paypal/rest-api-sdk-php/issues
PayPal\Validation\ModelAccessorValidator: WARNING: Missing Accessor: PayPal\Api\Payment:setFirstName . Please let us know by creating an issue at https://github.com/paypal/PayPal-PHP-SDK/issues
```
## Contributing
* If you find solution to an [issue/improvements](https://github.com/paypal/rest-api-sdk-php/issues) in sdk that would be helpful to everyone, feel free to send us a pull request.
* If you find solution to an [issue/improvements](https://github.com/paypal/PayPal-PHP-SDK/issues) in sdk that would be helpful to everyone, feel free to send us a pull request.
* The ideal approach to create a fix would be to fork the repository, create a branch in your repository, and make a pull request out of it.
* It is desirable if there is enough comments/documentation and Tests included in the pull request.
* For general idea of contribution, please follow the guidelines mentioned [here](https://guides.github.com/activities/contributing-to-open-source/).
@@ -162,6 +162,5 @@ PayPal\Validation\ModelAccessorValidator: WARNING: Missing Accessor: PayPal\Api\
## More help
* [API Reference](https://developer.paypal.com/webapps/developer/docs/api/)
* [Reporting issues / feature requests] (https://github.com/paypal/rest-api-sdk-php/issues)
* [Reporting issues / feature requests] (https://github.com/paypal/PayPal-PHP-SDK/issues)
* [Pizza App Using Paypal REST API] (https://github.com/paypal/rest-api-sample-app-php)
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/paypal/rest-api-sample-app-php/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

View File

@@ -3,7 +3,6 @@
namespace PayPal\Api;
use PayPal\Common\PPModel;
use PayPal\Rest\ApiContext;
/**
* Class Address
@@ -24,7 +23,6 @@ class Address extends PPModel
{
/**
* Line 1 of the Address (eg. number, street, etc).
*
*
* @param string $line1
*
@@ -48,7 +46,6 @@ class Address extends PPModel
/**
* Optional line 2 of the Address (eg. suite, apt #, etc.).
*
*
* @param string $line2
*
@@ -72,7 +69,6 @@ class Address extends PPModel
/**
* City name.
*
*
* @param string $city
*
@@ -96,7 +92,6 @@ class Address extends PPModel
/**
* 2 letter country code.
*
*
* @param string $country_code
*
@@ -145,7 +140,6 @@ class Address extends PPModel
/**
* Zip code or equivalent is usually required for countries that have them. For list of countries that do not have postal codes please refer to http://en.wikipedia.org/wiki/Postal_code.
*
*
* @param string $postal_code
*
@@ -194,7 +188,6 @@ class Address extends PPModel
/**
* 2 letter code for US states, and the equivalent for other countries.
*
*
* @param string $state
*
@@ -218,7 +211,6 @@ class Address extends PPModel
/**
* Phone number in E.123 format.
*
*
* @param \PayPal\Api\Phone $phone
*

View File

@@ -0,0 +1,832 @@
<?php
namespace PayPal\Api;
use PayPal\Common\ResourceModel;
use PayPal\Validation\ArgumentValidator;
use PayPal\Api\AgreementTransactions;
use PayPal\Rest\ApiContext;
use PayPal\Transport\PPRestCall;
/**
* Class Agreement
*
* A resource representing an agreement.
*
* @package PayPal\Api
*
* @property string id
* @property string state
* @property string name
* @property string description
* @property string start_date
* @property \PayPal\Api\Payer payer
* @property \PayPal\Api\Address shipping_address
* @property \PayPal\Api\MerchantPreferences override_merchant_preferences
* @property \PayPal\Api\OverrideChargeModel[] override_charge_models
* @property \PayPal\Api\Plan plan
* @property string create_time
* @property string update_time
* @property \PayPal\Api\AgreementDetails agreement_details
* @property \PayPal\Api\Links[] links
*/
class Agreement extends ResourceModel
{
/**
* Identifier of the agreement.
*
* @param string $id
*
* @return $this
*/
public function setId($id)
{
$this->id = $id;
return $this;
}
/**
* Identifier of the agreement.
*
* @return string
*/
public function getId()
{
return $this->id;
}
/**
* State of the agreement.
*
* @param string $state
*
* @return $this
*/
public function setState($state)
{
$this->state = $state;
return $this;
}
/**
* State of the agreement.
*
* @return string
*/
public function getState()
{
return $this->state;
}
/**
* Name of the agreement.
*
* @param string $name
*
* @return $this
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Name of the agreement.
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Description of the agreement.
*
* @param string $description
*
* @return $this
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* Description of the agreement.
*
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* Start date of the agreement. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
*
* @param string $start_date
*
* @return $this
*/
public function setStartDate($start_date)
{
$this->start_date = $start_date;
return $this;
}
/**
* Start date of the agreement. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
*
* @return string
*/
public function getStartDate()
{
return $this->start_date;
}
/**
* Start date of the agreement. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
*
* @deprecated Instead use setStartDate
*
* @param string $start_date
* @return $this
*/
public function setStart_date($start_date)
{
$this->start_date = $start_date;
return $this;
}
/**
* Start date of the agreement. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
* @deprecated Instead use getStartDate
*
* @return string
*/
public function getStart_date()
{
return $this->start_date;
}
/**
* Details of the buyer who is enrolling in this agreement. This information is gathered from execution of the approval URL.
*
* @param \PayPal\Api\Payer $payer
*
* @return $this
*/
public function setPayer($payer)
{
$this->payer = $payer;
return $this;
}
/**
* Details of the buyer who is enrolling in this agreement. This information is gathered from execution of the approval URL.
*
* @return \PayPal\Api\Payer
*/
public function getPayer()
{
return $this->payer;
}
/**
* Shipping address object of the agreement, which should be provided if it is different from the default address.
*
* @param \PayPal\Api\Address $shipping_address
*
* @return $this
*/
public function setShippingAddress($shipping_address)
{
$this->shipping_address = $shipping_address;
return $this;
}
/**
* Shipping address object of the agreement, which should be provided if it is different from the default address.
*
* @return \PayPal\Api\Address
*/
public function getShippingAddress()
{
return $this->shipping_address;
}
/**
* Shipping address object of the agreement, which should be provided if it is different from the default address.
*
* @deprecated Instead use setShippingAddress
*
* @param \PayPal\Api\Address $shipping_address
* @return $this
*/
public function setShipping_address($shipping_address)
{
$this->shipping_address = $shipping_address;
return $this;
}
/**
* Shipping address object of the agreement, which should be provided if it is different from the default address.
* @deprecated Instead use getShippingAddress
*
* @return \PayPal\Api\Address
*/
public function getShipping_address()
{
return $this->shipping_address;
}
/**
* Default merchant preferences from the billing plan are used, unless override preferences are provided here.
*
* @param \PayPal\Api\MerchantPreferences $override_merchant_preferences
*
* @return $this
*/
public function setOverrideMerchantPreferences($override_merchant_preferences)
{
$this->override_merchant_preferences = $override_merchant_preferences;
return $this;
}
/**
* Default merchant preferences from the billing plan are used, unless override preferences are provided here.
*
* @return \PayPal\Api\MerchantPreferences
*/
public function getOverrideMerchantPreferences()
{
return $this->override_merchant_preferences;
}
/**
* Default merchant preferences from the billing plan are used, unless override preferences are provided here.
*
* @deprecated Instead use setOverrideMerchantPreferences
*
* @param \PayPal\Api\MerchantPreferences $override_merchant_preferences
* @return $this
*/
public function setOverride_merchant_preferences($override_merchant_preferences)
{
$this->override_merchant_preferences = $override_merchant_preferences;
return $this;
}
/**
* Default merchant preferences from the billing plan are used, unless override preferences are provided here.
* @deprecated Instead use getOverrideMerchantPreferences
*
* @return \PayPal\Api\MerchantPreferences
*/
public function getOverride_merchant_preferences()
{
return $this->override_merchant_preferences;
}
/**
* Array of override_charge_model for this agreement if needed to change the default models from the billing plan.
*
* @param \PayPal\Api\OverrideChargeModel[] $override_charge_models
*
* @return $this
*/
public function setOverrideChargeModels($override_charge_models)
{
$this->override_charge_models = $override_charge_models;
return $this;
}
/**
* Array of override_charge_model for this agreement if needed to change the default models from the billing plan.
*
* @return \PayPal\Api\OverrideChargeModel[]
*/
public function getOverrideChargeModels()
{
return $this->override_charge_models;
}
/**
* Append OverrideChargeModels to the list.
*
* @param \PayPal\Api\OverrideChargeModel $overrideChargeModel
* @return $this
*/
public function addOverrideChargeModel($overrideChargeModel)
{
if (!$this->getOverrideChargeModels()) {
return $this->setOverrideChargeModels(array($overrideChargeModel));
} else {
return $this->setOverrideChargeModels(
array_merge($this->getOverrideChargeModels(), array($overrideChargeModel))
);
}
}
/**
* Remove OverrideChargeModels from the list.
*
* @param \PayPal\Api\OverrideChargeModel $overrideChargeModel
* @return $this
*/
public function removeOverrideChargeModel($overrideChargeModel)
{
return $this->setOverrideChargeModels(
array_diff($this->getOverrideChargeModels(), array($overrideChargeModel))
);
}
/**
* Array of override_charge_model for this agreement if needed to change the default models from the billing plan.
*
* @deprecated Instead use setOverrideChargeModels
*
* @param \PayPal\Api\OverrideChargeModel $override_charge_models
* @return $this
*/
public function setOverride_charge_models($override_charge_models)
{
$this->override_charge_models = $override_charge_models;
return $this;
}
/**
* Array of override_charge_model for this agreement if needed to change the default models from the billing plan.
* @deprecated Instead use getOverrideChargeModels
*
* @return \PayPal\Api\OverrideChargeModel
*/
public function getOverride_charge_models()
{
return $this->override_charge_models;
}
/**
* Plan details for this agreement.
*
* @param \PayPal\Api\Plan $plan
*
* @return $this
*/
public function setPlan($plan)
{
$this->plan = $plan;
return $this;
}
/**
* Plan details for this agreement.
*
* @return \PayPal\Api\Plan
*/
public function getPlan()
{
return $this->plan;
}
/**
* Date and time that this resource was created. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
*
* @param string $create_time
*
* @return $this
*/
public function setCreateTime($create_time)
{
$this->create_time = $create_time;
return $this;
}
/**
* Date and time that this resource was created. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
*
* @return string
*/
public function getCreateTime()
{
return $this->create_time;
}
/**
* Date and time that this resource was created. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
*
* @deprecated Instead use setCreateTime
*
* @param string $create_time
* @return $this
*/
public function setCreate_time($create_time)
{
$this->create_time = $create_time;
return $this;
}
/**
* Date and time that this resource was created. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
* @deprecated Instead use getCreateTime
*
* @return string
*/
public function getCreate_time()
{
return $this->create_time;
}
/**
* Date and time that this resource was updated. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
*
* @param string $update_time
*
* @return $this
*/
public function setUpdateTime($update_time)
{
$this->update_time = $update_time;
return $this;
}
/**
* Date and time that this resource was updated. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
*
* @return string
*/
public function getUpdateTime()
{
return $this->update_time;
}
/**
* Date and time that this resource was updated. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
*
* @deprecated Instead use setUpdateTime
*
* @param string $update_time
* @return $this
*/
public function setUpdate_time($update_time)
{
$this->update_time = $update_time;
return $this;
}
/**
* Date and time that this resource was updated. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
* @deprecated Instead use getUpdateTime
*
* @return string
*/
public function getUpdate_time()
{
return $this->update_time;
}
/**
* Agreement Details
*
* @param \PayPal\Api\AgreementDetails $agreement_details
*
* @return $this
*/
public function setAgreementDetails($agreement_details)
{
$this->{"agreement-details"} = $agreement_details;
return $this;
}
/**
* Agreement Details
*
* @return \PayPal\Api\AgreementDetails
*/
public function getAgreementDetails()
{
return $this->{"agreement-details"};
}
/**
* Agreement Details
*
* @deprecated Instead use setAgreementDetails
*
* @param \PayPal\Api\AgreementDetails $agreement-details
* @return $this
*/
public function setAgreement_details($agreement_details)
{
$this->{"agreement-details"} = $agreement_details;
return $this;
}
/**
* Agreement Details
* @deprecated Instead use getAgreementDetails
*
* @return \PayPal\Api\AgreementDetails
*/
public function getAgreement_details()
{
return $this->{"agreement-details"};
}
/**
* Sets Links
*
* @param \PayPal\Api\Links[] $links
*
* @return $this
*/
public function setLinks($links)
{
$this->links = $links;
return $this;
}
/**
* Gets Links
*
* @return \PayPal\Api\Links[]
*/
public function getLinks()
{
return $this->links;
}
/**
* Append Links to the list.
*
* @param \PayPal\Api\Links $links
* @return $this
*/
public function addLink($links)
{
if (!$this->getLinks()) {
return $this->setLinks(array($links));
} else {
return $this->setLinks(
array_merge($this->getLinks(), array($links))
);
}
}
/**
* Remove Links from the list.
*
* @param \PayPal\Api\Links $links
* @return $this
*/
public function removeLink($links)
{
return $this->setLinks(
array_diff($this->getLinks(), array($links))
);
}
/**
* Create a new billing agreement by passing the details for the agreement, including the name, description, start date, payer, and billing plan in the request JSON.
*
* @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param PPRestCall $restCall is the Rest Call Service that is used to make rest calls
* @return Agreement
*/
public function create($apiContext = null, $restCall = null)
{
$payLoad = $this->toJSON();
$json = self::executeCall(
"/v1/payments/billing-agreements/",
"POST",
$payLoad,
null,
$apiContext,
$restCall
);
$this->fromJson($json);
return $this;
}
/**
* Execute a billing agreement after buyer approval by passing the payment token to the request URI.
*
* @param $paymentToken
* @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param PPRestCall $restCall is the Rest Call Service that is used to make rest calls
* @return Agreement
*/
public function execute($paymentToken, $apiContext = null, $restCall = null)
{
ArgumentValidator::validate($paymentToken, 'paymentToken');
$payLoad = "";
$json = self::executeCall(
"/v1/payments/billing-agreements/$paymentToken/agreement-execute",
"POST",
$payLoad,
null,
$apiContext,
$restCall
);
$this->fromJson($json);
return $this;
}
/**
* Retrieve details for a particular billing agreement by passing the ID of the agreement to the request URI.
*
* @param string $agreementId
* @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param PPRestCall $restCall is the Rest Call Service that is used to make rest calls
* @return Agreement
*/
public static function get($agreementId, $apiContext = null, $restCall = null)
{
ArgumentValidator::validate($agreementId, 'agreementId');
$payLoad = "";
$json = self::executeCall(
"/v1/payments/billing-agreements/$agreementId",
"GET",
$payLoad,
null,
$apiContext,
$restCall
);
$ret = new Agreement();
$ret->fromJson($json);
return $ret;
}
/**
* Update details of a billing agreement, such as the description, shipping address, and start date, by passing the ID of the agreement to the request URI.
*
* @param PatchRequest $patchRequest
* @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param PPRestCall $restCall is the Rest Call Service that is used to make rest calls
* @return bool
*/
public function update($patchRequest, $apiContext = null, $restCall = null)
{
ArgumentValidator::validate($this->getId(), "Id");
ArgumentValidator::validate($patchRequest, 'patchRequest');
$payLoad = $patchRequest->toJSON();
self::executeCall(
"/v1/payments/billing-agreements/{$this->getId()}",
"PATCH",
$payLoad,
null,
$apiContext,
$restCall
);
return true;
}
/**
* Suspend a particular billing agreement by passing the ID of the agreement to the request URI.
*
* @param AgreementStateDescriptor $agreementStateDescriptor
* @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param PPRestCall $restCall is the Rest Call Service that is used to make rest calls
* @return bool
*/
public function suspend($agreementStateDescriptor, $apiContext = null, $restCall = null)
{
ArgumentValidator::validate($this->getId(), "Id");
ArgumentValidator::validate($agreementStateDescriptor, 'agreementStateDescriptor');
$payLoad = $agreementStateDescriptor->toJSON();
self::executeCall(
"/v1/payments/billing-agreements/{$this->getId()}/suspend",
"POST",
$payLoad,
null,
$apiContext,
$restCall
);
return true;
}
/**
* Reactivate a suspended billing agreement by passing the ID of the agreement to the appropriate URI. In addition, pass an agreement_state_descriptor object in the request JSON that includes a note about the reason for changing the state of the agreement and the amount and currency for the agreement.
*
* @param AgreementStateDescriptor $agreementStateDescriptor
* @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param PPRestCall $restCall is the Rest Call Service that is used to make rest calls
* @return bool
*/
public function reActivate($agreementStateDescriptor, $apiContext = null, $restCall = null)
{
ArgumentValidator::validate($this->getId(), "Id");
ArgumentValidator::validate($agreementStateDescriptor, 'agreementStateDescriptor');
$payLoad = $agreementStateDescriptor->toJSON();
self::executeCall(
"/v1/payments/billing-agreements/{$this->getId()}/re-activate",
"POST",
$payLoad,
null,
$apiContext,
$restCall
);
return true;
}
/**
* Cancel a billing agreement by passing the ID of the agreement to the request URI. In addition, pass an agreement_state_descriptor object in the request JSON that includes a note about the reason for changing the state of the agreement and the amount and currency for the agreement.
*
* @param AgreementStateDescriptor $agreementStateDescriptor
* @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param PPRestCall $restCall is the Rest Call Service that is used to make rest calls
* @return bool
*/
public function cancel($agreementStateDescriptor, $apiContext = null, $restCall = null)
{
ArgumentValidator::validate($this->getId(), "Id");
ArgumentValidator::validate($agreementStateDescriptor, 'agreementStateDescriptor');
$payLoad = $agreementStateDescriptor->toJSON();
self::executeCall(
"/v1/payments/billing-agreements/{$this->getId()}/cancel",
"POST",
$payLoad,
null,
$apiContext,
$restCall
);
return true;
}
/**
* Bill an outstanding amount for an agreement by passing the ID of the agreement to the request URI. In addition, pass an agreement_state_descriptor object in the request JSON that includes a note about the reason for changing the state of the agreement and the amount and currency for the agreement.
*
* @param AgreementStateDescriptor $agreementStateDescriptor
* @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param PPRestCall $restCall is the Rest Call Service that is used to make rest calls
* @return bool
*/
public function billBalance($agreementStateDescriptor, $apiContext = null, $restCall = null)
{
ArgumentValidator::validate($this->getId(), "Id");
ArgumentValidator::validate($agreementStateDescriptor, 'agreementStateDescriptor');
$payLoad = $agreementStateDescriptor->toJSON();
self::executeCall(
"/v1/payments/billing-agreements/{$this->getId()}/bill-balance",
"POST",
$payLoad,
null,
$apiContext,
$restCall
);
return true;
}
/**
* Set the balance for an agreement by passing the ID of the agreement to the request URI. In addition, pass a common_currency object in the request JSON that specifies the currency type and value of the balance.
*
* @param Currency $currency
* @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param PPRestCall $restCall is the Rest Call Service that is used to make rest calls
* @return bool
*/
public function setBalance($currency, $apiContext = null, $restCall = null)
{
ArgumentValidator::validate($this->getId(), "Id");
ArgumentValidator::validate($currency, 'currency');
$payLoad = $currency->toJSON();
self::executeCall(
"/v1/payments/billing-agreements/{$this->getId()}/set-balance",
"POST",
$payLoad,
null,
$apiContext,
$restCall
);
return true;
}
/**
* List transactions for a billing agreement by passing the ID of the agreement, as well as the start and end dates of the range of transactions to list, to the request URI.
*
* @param string $agreementId
* @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param PPRestCall $restCall is the Rest Call Service that is used to make rest calls
* @return AgreementTransactions
*/
public static function transactions($agreementId, $apiContext = null, $restCall = null)
{
ArgumentValidator::validate($agreementId, 'agreementId');
$payLoad = "";
$json = self::executeCall(
"/v1/payments/billing-agreements/$agreementId/transactions",
"GET",
$payLoad,
null,
$apiContext,
$restCall
);
$ret = new AgreementTransactions();
$ret->fromJson($json);
return $ret;
}
}

View File

@@ -0,0 +1,409 @@
<?php
namespace PayPal\Api;
use PayPal\Common\PPModel;
/**
* Class AgreementDetails
*
* A resource representing the agreement details.
*
* @package PayPal\Api
*
* @property \PayPal\Api\Currency outstanding_balance
* @property string cycles_remaining
* @property string cycles_completed
* @property string next_billing_date
* @property string last_payment_date
* @property \PayPal\Api\Currency last_payment_amount
* @property string final_payment_date
* @property string failed_payment_count
*/
class AgreementDetails extends PPModel
{
/**
* The outstanding balance for this agreement.
*
* @param \PayPal\Api\Currency $outstanding_balance
*
* @return $this
*/
public function setOutstandingBalance($outstanding_balance)
{
$this->outstanding_balance = $outstanding_balance;
return $this;
}
/**
* The outstanding balance for this agreement.
*
* @return \PayPal\Api\Currency
*/
public function getOutstandingBalance()
{
return $this->outstanding_balance;
}
/**
* The outstanding balance for this agreement.
*
* @deprecated Instead use setOutstandingBalance
*
* @param \PayPal\Api\Currency $outstanding_balance
* @return $this
*/
public function setOutstanding_balance($outstanding_balance)
{
$this->outstanding_balance = $outstanding_balance;
return $this;
}
/**
* The outstanding balance for this agreement.
* @deprecated Instead use getOutstandingBalance
*
* @return \PayPal\Api\Currency
*/
public function getOutstanding_balance()
{
return $this->outstanding_balance;
}
/**
* Number of cycles remaining for this agreement.
*
* @param string $cycles_remaining
*
* @return $this
*/
public function setCyclesRemaining($cycles_remaining)
{
$this->cycles_remaining = $cycles_remaining;
return $this;
}
/**
* Number of cycles remaining for this agreement.
*
* @return string
*/
public function getCyclesRemaining()
{
return $this->cycles_remaining;
}
/**
* Number of cycles remaining for this agreement.
*
* @deprecated Instead use setCyclesRemaining
*
* @param string $cycles_remaining
* @return $this
*/
public function setCycles_remaining($cycles_remaining)
{
$this->cycles_remaining = $cycles_remaining;
return $this;
}
/**
* Number of cycles remaining for this agreement.
* @deprecated Instead use getCyclesRemaining
*
* @return string
*/
public function getCycles_remaining()
{
return $this->cycles_remaining;
}
/**
* Number of cycles completed for this agreement.
*
* @param string $cycles_completed
*
* @return $this
*/
public function setCyclesCompleted($cycles_completed)
{
$this->cycles_completed = $cycles_completed;
return $this;
}
/**
* Number of cycles completed for this agreement.
*
* @return string
*/
public function getCyclesCompleted()
{
return $this->cycles_completed;
}
/**
* Number of cycles completed for this agreement.
*
* @deprecated Instead use setCyclesCompleted
*
* @param string $cycles_completed
* @return $this
*/
public function setCycles_completed($cycles_completed)
{
$this->cycles_completed = $cycles_completed;
return $this;
}
/**
* Number of cycles completed for this agreement.
* @deprecated Instead use getCyclesCompleted
*
* @return string
*/
public function getCycles_completed()
{
return $this->cycles_completed;
}
/**
* The next billing date for this agreement, represented as 2014-02-19T10:00:00Z format.
*
* @param string $next_billing_date
*
* @return $this
*/
public function setNextBillingDate($next_billing_date)
{
$this->next_billing_date = $next_billing_date;
return $this;
}
/**
* The next billing date for this agreement, represented as 2014-02-19T10:00:00Z format.
*
* @return string
*/
public function getNextBillingDate()
{
return $this->next_billing_date;
}
/**
* The next billing date for this agreement, represented as 2014-02-19T10:00:00Z format.
*
* @deprecated Instead use setNextBillingDate
*
* @param string $next_billing_date
* @return $this
*/
public function setNext_billing_date($next_billing_date)
{
$this->next_billing_date = $next_billing_date;
return $this;
}
/**
* The next billing date for this agreement, represented as 2014-02-19T10:00:00Z format.
* @deprecated Instead use getNextBillingDate
*
* @return string
*/
public function getNext_billing_date()
{
return $this->next_billing_date;
}
/**
* Last payment date for this agreement, represented as 2014-06-09T09:42:31Z format.
*
* @param string $last_payment_date
*
* @return $this
*/
public function setLastPaymentDate($last_payment_date)
{
$this->last_payment_date = $last_payment_date;
return $this;
}
/**
* Last payment date for this agreement, represented as 2014-06-09T09:42:31Z format.
*
* @return string
*/
public function getLastPaymentDate()
{
return $this->last_payment_date;
}
/**
* Last payment date for this agreement, represented as 2014-06-09T09:42:31Z format.
*
* @deprecated Instead use setLastPaymentDate
*
* @param string $last_payment_date
* @return $this
*/
public function setLast_payment_date($last_payment_date)
{
$this->last_payment_date = $last_payment_date;
return $this;
}
/**
* Last payment date for this agreement, represented as 2014-06-09T09:42:31Z format.
* @deprecated Instead use getLastPaymentDate
*
* @return string
*/
public function getLast_payment_date()
{
return $this->last_payment_date;
}
/**
* Last payment amount for this agreement.
*
* @param \PayPal\Api\Currency $last_payment_amount
*
* @return $this
*/
public function setLastPaymentAmount($last_payment_amount)
{
$this->last_payment_amount = $last_payment_amount;
return $this;
}
/**
* Last payment amount for this agreement.
*
* @return \PayPal\Api\Currency
*/
public function getLastPaymentAmount()
{
return $this->last_payment_amount;
}
/**
* Last payment amount for this agreement.
*
* @deprecated Instead use setLastPaymentAmount
*
* @param \PayPal\Api\Currency $last_payment_amount
* @return $this
*/
public function setLast_payment_amount($last_payment_amount)
{
$this->last_payment_amount = $last_payment_amount;
return $this;
}
/**
* Last payment amount for this agreement.
* @deprecated Instead use getLastPaymentAmount
*
* @return \PayPal\Api\Currency
*/
public function getLast_payment_amount()
{
return $this->last_payment_amount;
}
/**
* Last payment date for this agreement, represented as 2015-02-19T10:00:00Z format.
*
* @param string $final_payment_date
*
* @return $this
*/
public function setFinalPaymentDate($final_payment_date)
{
$this->final_payment_date = $final_payment_date;
return $this;
}
/**
* Last payment date for this agreement, represented as 2015-02-19T10:00:00Z format.
*
* @return string
*/
public function getFinalPaymentDate()
{
return $this->final_payment_date;
}
/**
* Last payment date for this agreement, represented as 2015-02-19T10:00:00Z format.
*
* @deprecated Instead use setFinalPaymentDate
*
* @param string $final_payment_date
* @return $this
*/
public function setFinal_payment_date($final_payment_date)
{
$this->final_payment_date = $final_payment_date;
return $this;
}
/**
* Last payment date for this agreement, represented as 2015-02-19T10:00:00Z format.
* @deprecated Instead use getFinalPaymentDate
*
* @return string
*/
public function getFinal_payment_date()
{
return $this->final_payment_date;
}
/**
* Total number of failed payments for this agreement.
*
* @param string $failed_payment_count
*
* @return $this
*/
public function setFailedPaymentCount($failed_payment_count)
{
$this->failed_payment_count = $failed_payment_count;
return $this;
}
/**
* Total number of failed payments for this agreement.
*
* @return string
*/
public function getFailedPaymentCount()
{
return $this->failed_payment_count;
}
/**
* Total number of failed payments for this agreement.
*
* @deprecated Instead use setFailedPaymentCount
*
* @param string $failed_payment_count
* @return $this
*/
public function setFailed_payment_count($failed_payment_count)
{
$this->failed_payment_count = $failed_payment_count;
return $this;
}
/**
* Total number of failed payments for this agreement.
* @deprecated Instead use getFailedPaymentCount
*
* @return string
*/
public function getFailed_payment_count()
{
return $this->failed_payment_count;
}
}

View File

@@ -0,0 +1,65 @@
<?php
namespace PayPal\Api;
use PayPal\Common\PPModel;
/**
* Class AgreementStateDescriptor
*
* Description of the current state of the agreement.
*
* @package PayPal\Api
*
* @property string note
* @property \PayPal\Api\Currency amount
*/
class AgreementStateDescriptor extends PPModel
{
/**
* Reason for changing the state of the agreement.
*
* @param string $note
*
* @return $this
*/
public function setNote($note)
{
$this->note = $note;
return $this;
}
/**
* Reason for changing the state of the agreement.
*
* @return string
*/
public function getNote()
{
return $this->note;
}
/**
* The amount and currency of the agreement.
*
* @param \PayPal\Api\Currency $amount
*
* @return $this
*/
public function setAmount($amount)
{
$this->amount = $amount;
return $this;
}
/**
* The amount and currency of the agreement.
*
* @return \PayPal\Api\Currency
*/
public function getAmount()
{
return $this->amount;
}
}

View File

@@ -0,0 +1,457 @@
<?php
namespace PayPal\Api;
use PayPal\Common\PPModel;
/**
* Class AgreementTransaction
*
* A resource representing an agreement_transaction that is returned during a transaction search.
*
* @package PayPal\Api
*
* @property string transaction_id
* @property string status
* @property string transaction_type
* @property \PayPal\Api\Currency amount
* @property \PayPal\Api\Currency fee_amount
* @property \PayPal\Api\Currency net_amount
* @property string payer_email
* @property string payer_name
* @property string time_updated
* @property string time_zone
*/
class AgreementTransaction extends PPModel
{
/**
* Id corresponding to this transaction.
*
* @param string $transaction_id
*
* @return $this
*/
public function setTransactionId($transaction_id)
{
$this->transaction_id = $transaction_id;
return $this;
}
/**
* Id corresponding to this transaction.
*
* @return string
*/
public function getTransactionId()
{
return $this->transaction_id;
}
/**
* Id corresponding to this transaction.
*
* @deprecated Instead use setTransactionId
*
* @param string $transaction_id
* @return $this
*/
public function setTransaction_id($transaction_id)
{
$this->transaction_id = $transaction_id;
return $this;
}
/**
* Id corresponding to this transaction.
* @deprecated Instead use getTransactionId
*
* @return string
*/
public function getTransaction_id()
{
return $this->transaction_id;
}
/**
* State of the subscription at this time.
*
* @param string $status
*
* @return $this
*/
public function setStatus($status)
{
$this->status = $status;
return $this;
}
/**
* State of the subscription at this time.
*
* @return string
*/
public function getStatus()
{
return $this->status;
}
/**
* Type of transaction, usually Recurring Payment.
*
* @param string $transaction_type
*
* @return $this
*/
public function setTransactionType($transaction_type)
{
$this->transaction_type = $transaction_type;
return $this;
}
/**
* Type of transaction, usually Recurring Payment.
*
* @return string
*/
public function getTransactionType()
{
return $this->transaction_type;
}
/**
* Type of transaction, usually Recurring Payment.
*
* @deprecated Instead use setTransactionType
*
* @param string $transaction_type
* @return $this
*/
public function setTransaction_type($transaction_type)
{
$this->transaction_type = $transaction_type;
return $this;
}
/**
* Type of transaction, usually Recurring Payment.
* @deprecated Instead use getTransactionType
*
* @return string
*/
public function getTransaction_type()
{
return $this->transaction_type;
}
/**
* Amount for this transaction.
*
* @param \PayPal\Api\Currency $amount
*
* @return $this
*/
public function setAmount($amount)
{
$this->amount = $amount;
return $this;
}
/**
* Amount for this transaction.
*
* @return \PayPal\Api\Currency
*/
public function getAmount()
{
return $this->amount;
}
/**
* Fee amount for this transaction.
*
* @param \PayPal\Api\Currency $fee_amount
*
* @return $this
*/
public function setFeeAmount($fee_amount)
{
$this->fee_amount = $fee_amount;
return $this;
}
/**
* Fee amount for this transaction.
*
* @return \PayPal\Api\Currency
*/
public function getFeeAmount()
{
return $this->fee_amount;
}
/**
* Fee amount for this transaction.
*
* @deprecated Instead use setFeeAmount
*
* @param \PayPal\Api\Currency $fee_amount
* @return $this
*/
public function setFee_amount($fee_amount)
{
$this->fee_amount = $fee_amount;
return $this;
}
/**
* Fee amount for this transaction.
* @deprecated Instead use getFeeAmount
*
* @return \PayPal\Api\Currency
*/
public function getFee_amount()
{
return $this->fee_amount;
}
/**
* Net amount for this transaction.
*
* @param \PayPal\Api\Currency $net_amount
*
* @return $this
*/
public function setNetAmount($net_amount)
{
$this->net_amount = $net_amount;
return $this;
}
/**
* Net amount for this transaction.
*
* @return \PayPal\Api\Currency
*/
public function getNetAmount()
{
return $this->net_amount;
}
/**
* Net amount for this transaction.
*
* @deprecated Instead use setNetAmount
*
* @param \PayPal\Api\Currency $net_amount
* @return $this
*/
public function setNet_amount($net_amount)
{
$this->net_amount = $net_amount;
return $this;
}
/**
* Net amount for this transaction.
* @deprecated Instead use getNetAmount
*
* @return \PayPal\Api\Currency
*/
public function getNet_amount()
{
return $this->net_amount;
}
/**
* Email id of payer.
*
* @param string $payer_email
*
* @return $this
*/
public function setPayerEmail($payer_email)
{
$this->payer_email = $payer_email;
return $this;
}
/**
* Email id of payer.
*
* @return string
*/
public function getPayerEmail()
{
return $this->payer_email;
}
/**
* Email id of payer.
*
* @deprecated Instead use setPayerEmail
*
* @param string $payer_email
* @return $this
*/
public function setPayer_email($payer_email)
{
$this->payer_email = $payer_email;
return $this;
}
/**
* Email id of payer.
* @deprecated Instead use getPayerEmail
*
* @return string
*/
public function getPayer_email()
{
return $this->payer_email;
}
/**
* Business name of payer.
*
* @param string $payer_name
*
* @return $this
*/
public function setPayerName($payer_name)
{
$this->payer_name = $payer_name;
return $this;
}
/**
* Business name of payer.
*
* @return string
*/
public function getPayerName()
{
return $this->payer_name;
}
/**
* Business name of payer.
*
* @deprecated Instead use setPayerName
*
* @param string $payer_name
* @return $this
*/
public function setPayer_name($payer_name)
{
$this->payer_name = $payer_name;
return $this;
}
/**
* Business name of payer.
* @deprecated Instead use getPayerName
*
* @return string
*/
public function getPayer_name()
{
return $this->payer_name;
}
/**
* Time at which this transaction happened.
*
* @param string $time_updated
*
* @return $this
*/
public function setTimeUpdated($time_updated)
{
$this->time_updated = $time_updated;
return $this;
}
/**
* Time at which this transaction happened.
*
* @return string
*/
public function getTimeUpdated()
{
return $this->time_updated;
}
/**
* Time at which this transaction happened.
*
* @deprecated Instead use setTimeUpdated
*
* @param string $time_updated
* @return $this
*/
public function setTime_updated($time_updated)
{
$this->time_updated = $time_updated;
return $this;
}
/**
* Time at which this transaction happened.
* @deprecated Instead use getTimeUpdated
*
* @return string
*/
public function getTime_updated()
{
return $this->time_updated;
}
/**
* Time zone of time_updated field.
*
* @param string $time_zone
*
* @return $this
*/
public function setTimeZone($time_zone)
{
$this->time_zone = $time_zone;
return $this;
}
/**
* Time zone of time_updated field.
*
* @return string
*/
public function getTimeZone()
{
return $this->time_zone;
}
/**
* Time zone of time_updated field.
*
* @deprecated Instead use setTimeZone
*
* @param string $time_zone
* @return $this
*/
public function setTime_zone($time_zone)
{
$this->time_zone = $time_zone;
return $this;
}
/**
* Time zone of time_updated field.
* @deprecated Instead use getTimeZone
*
* @return string
*/
public function getTime_zone()
{
return $this->time_zone;
}
}

View File

@@ -0,0 +1,96 @@
<?php
namespace PayPal\Api;
use PayPal\Common\PPModel;
/**
* Class AgreementTransactions
*
* A resource representing agreement_transactions that is returned during a transaction search.
*
* @package PayPal\Api
*
* @property \PayPal\Api\AgreementTransaction[] agreement_transaction_list
*/
class AgreementTransactions extends PPModel
{
/**
* Array of agreement_transaction object.
*
* @param \PayPal\Api\AgreementTransaction[] $agreement_transaction_list
*
* @return $this
*/
public function setAgreementTransactionList($agreement_transaction_list)
{
$this->agreement_transaction_list = $agreement_transaction_list;
return $this;
}
/**
* Array of agreement_transaction object.
*
* @return \PayPal\Api\AgreementTransaction[]
*/
public function getAgreementTransactionList()
{
return $this->agreement_transaction_list;
}
/**
* Append AgreementTransactionList to the list.
*
* @param \PayPal\Api\AgreementTransaction $agreementTransaction
* @return $this
*/
public function addAgreementTransactionList($agreementTransaction)
{
if (!$this->getAgreementTransactionList()) {
return $this->setAgreementTransactionList(array($agreementTransaction));
} else {
return $this->setAgreementTransactionList(
array_merge($this->getAgreementTransactionList(), array($agreementTransaction))
);
}
}
/**
* Remove AgreementTransactionList from the list.
*
* @param \PayPal\Api\AgreementTransaction $agreementTransaction
* @return $this
*/
public function removeAgreementTransactionList($agreementTransaction)
{
return $this->setAgreementTransactionList(
array_diff($this->getAgreementTransactionList(), array($agreementTransaction))
);
}
/**
* Array of agreement_transaction object.
*
* @deprecated Instead use setAgreementTransactionList
*
* @param \PayPal\Api\AgreementTransaction $agreement_transaction_list
* @return $this
*/
public function setAgreement_transaction_list($agreement_transaction_list)
{
$this->agreement_transaction_list = $agreement_transaction_list;
return $this;
}
/**
* Array of agreement_transaction object.
* @deprecated Instead use getAgreementTransactionList
*
* @return \PayPal\Api\AgreementTransaction
*/
public function getAgreement_transaction_list()
{
return $this->agreement_transaction_list;
}
}

View File

@@ -2,11 +2,10 @@
namespace PayPal\Api;
use PayPal\Common\PPModel;
use PayPal\Rest\ApiContext;
use PayPal\Rest\IResource;
use PayPal\Transport\PPRestCall;
use PayPal\Common\ResourceModel;
use PayPal\Validation\ArgumentValidator;
use PayPal\Rest\ApiContext;
use PayPal\Transport\PPRestCall;
/**
* Class BankAccount
@@ -38,31 +37,12 @@ use PayPal\Validation\ArgumentValidator;
* @property string create_time
* @property string update_time
* @property string valid_until
* @property \PayPal\Api\Links links
* @property \PayPal\Api\Links[] links
*/
class BankAccount extends PPModel implements IResource
class BankAccount extends ResourceModel
{
/**
* OAuth Credentials to use for this call
*
* @var \PayPal\Auth\OAuthTokenCredential $credential
*/
protected static $credential;
/**
* Sets Credential
*
* @deprecated Pass ApiContext to create/get methods instead
* @param \PayPal\Auth\OAuthTokenCredential $credential
*/
public static function setCredential($credential)
{
self::$credential = $credential;
}
/**
* ID of the bank account being saved for later use.
*
*
* @param string $id
*
@@ -86,7 +66,6 @@ class BankAccount extends PPModel implements IResource
/**
* Account number in either IBAN (max length 34) or BBAN (max length 17) format.
*
*
* @param string $account_number
*
@@ -135,7 +114,7 @@ class BankAccount extends PPModel implements IResource
/**
* Type of the bank account number (International or Basic Bank Account Number). For more information refer to http://en.wikipedia.org/wiki/International_Bank_Account_Number.
* Valid Values: ["BBAN", "IBAN"]
* Valid Values: ["BBAN", "IBAN"]
*
* @param string $account_number_type
*
@@ -184,7 +163,6 @@ class BankAccount extends PPModel implements IResource
/**
* Routing transit number (aka Bank Code) of the bank (typically for domestic use only - for international use, IBAN includes bank code). For more information refer to http://en.wikipedia.org/wiki/Bank_code.
*
*
* @param string $routing_number
*
@@ -233,7 +211,7 @@ class BankAccount extends PPModel implements IResource
/**
* Type of the bank account.
* Valid Values: ["CHECKING", "SAVINGS"]
* Valid Values: ["CHECKING", "SAVINGS"]
*
* @param string $account_type
*
@@ -282,7 +260,6 @@ class BankAccount extends PPModel implements IResource
/**
* A customer designated name.
*
*
* @param string $account_name
*
@@ -331,7 +308,7 @@ class BankAccount extends PPModel implements IResource
/**
* Type of the check when this information was obtained through a check by the facilitator or merchant.
* Valid Values: ["PERSONAL", "COMPANY"]
* Valid Values: ["PERSONAL", "COMPANY"]
*
* @param string $check_type
*
@@ -380,7 +357,7 @@ class BankAccount extends PPModel implements IResource
/**
* How the check was obtained from the customer, if check was the source of the information provided.
* Valid Values: ["CCD", "PPD", "TEL", "POP", "ARC", "RCK", "WEB"]
* Valid Values: ["CCD", "PPD", "TEL", "POP", "ARC", "RCK", "WEB"]
*
* @param string $auth_type
*
@@ -429,7 +406,6 @@ class BankAccount extends PPModel implements IResource
/**
* Time at which the authorization (or check) was captured. Use this field if the user authorization needs to be captured due to any privacy requirements.
*
*
* @param string $auth_capture_timestamp
*
@@ -478,7 +454,6 @@ class BankAccount extends PPModel implements IResource
/**
* Name of the bank.
*
*
* @param string $bank_name
*
@@ -527,7 +502,6 @@ class BankAccount extends PPModel implements IResource
/**
* 2 letter country code of the Bank.
*
*
* @param string $country_code
*
@@ -576,7 +550,6 @@ class BankAccount extends PPModel implements IResource
/**
* Account holder's first name.
*
*
* @param string $first_name
*
@@ -625,7 +598,6 @@ class BankAccount extends PPModel implements IResource
/**
* Account holder's last name.
*
*
* @param string $last_name
*
@@ -674,7 +646,6 @@ class BankAccount extends PPModel implements IResource
/**
* Birth date of the bank account holder.
*
*
* @param string $birth_date
*
@@ -723,7 +694,6 @@ class BankAccount extends PPModel implements IResource
/**
* Billing address.
*
*
* @param \PayPal\Api\Address $billing_address
*
@@ -772,7 +742,7 @@ class BankAccount extends PPModel implements IResource
/**
* State of this funding instrument.
* Valid Values: ["ACTIVE", "INACTIVE", "DELETED"]
* Valid Values: ["ACTIVE", "INACTIVE", "DELETED"]
*
* @param string $state
*
@@ -796,7 +766,7 @@ class BankAccount extends PPModel implements IResource
/**
* Confirmation status of a bank account.
* Valid Values: ["UNCONFIRMED", "CONFIRMED"]
* Valid Values: ["UNCONFIRMED", "CONFIRMED"]
*
* @param string $confirmation_status
*
@@ -845,7 +815,6 @@ class BankAccount extends PPModel implements IResource
/**
* Deprecated - Use external_customer_id instead.
*
*
* @param string $payer_id
*
@@ -894,7 +863,6 @@ class BankAccount extends PPModel implements IResource
/**
* A unique identifier of the customer to whom this bank account belongs to. Generated and provided by the facilitator. This is required when creating or using a stored funding instrument in vault.
*
*
* @param string $external_customer_id
*
@@ -943,7 +911,6 @@ class BankAccount extends PPModel implements IResource
/**
* A unique identifier of the merchant for which this bank account has been stored for. Generated and provided by the facilitator so it can be used to restrict the usage of the bank account to the specific merchnt.
*
*
* @param string $merchant_id
*
@@ -992,7 +959,6 @@ class BankAccount extends PPModel implements IResource
/**
* Time the resource was created.
*
*
* @param string $create_time
*
@@ -1041,7 +1007,6 @@ class BankAccount extends PPModel implements IResource
/**
* Time the resource was last updated.
*
*
* @param string $update_time
*
@@ -1090,7 +1055,6 @@ class BankAccount extends PPModel implements IResource
/**
* Date/Time until this resource can be used to fund a payment.
*
*
* @param string $valid_until
*
@@ -1139,9 +1103,8 @@ class BankAccount extends PPModel implements IResource
/**
* Sets Links
*
*
* @param \PayPal\Api\Links $links
* @param \PayPal\Api\Links[] $links
*
* @return $this
*/
@@ -1161,21 +1124,54 @@ class BankAccount extends PPModel implements IResource
return $this->links;
}
/**
* Append Links to the list.
*
* @param \PayPal\Api\Links $links
* @return $this
*/
public function addLink($links)
{
if (!$this->getLinks()) {
return $this->setLinks(array($links));
} else {
return $this->setLinks(
array_merge($this->getLinks(), array($links))
);
}
}
/**
* Remove Links from the list.
*
* @param \PayPal\Api\Links $links
* @return $this
*/
public function removeLink($links)
{
return $this->setLinks(
array_diff($this->getLinks(), array($links))
);
}
/**
* Creates a new Bank Account Resource.
*
* @param \PayPal\Rest\ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param PPRestCall $restCall is the Rest Call Service that is used to make rest calls
* @return BankAccount
*/
public function create($apiContext = null)
public function create($apiContext = null, $restCall = null)
{
$payLoad = $this->toJSON();
if ($apiContext == null) {
$apiContext = new ApiContext(self::$credential);
}
$call = new PPRestCall($apiContext);
$json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/vault/bank-accounts", "POST", $payLoad);
$json = self::executeCall(
"/v1/vault/bank-accounts",
"POST",
$payLoad,
null,
$apiContext,
$restCall
);
$this->fromJson($json);
return $this;
}
@@ -1184,19 +1180,22 @@ class BankAccount extends PPModel implements IResource
* Obtain the Bank Account resource for the given identifier.
*
* @param string $bankAccountId
* @param \PayPal\Rest\ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param PPRestCall $restCall is the Rest Call Service that is used to make rest calls
* @return BankAccount
*/
public static function get($bankAccountId, $apiContext = null)
public static function get($bankAccountId, $apiContext = null, $restCall = null)
{
ArgumentValidator::validate($bankAccountId, 'bankAccountId');
$payLoad = "";
if ($apiContext == null) {
$apiContext = new ApiContext(self::$credential);
}
$call = new PPRestCall($apiContext);
$json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/vault/bank-accounts/$bankAccountId", "GET", $payLoad);
$json = self::executeCall(
"/v1/vault/bank-accounts/$bankAccountId",
"GET",
$payLoad,
null,
$apiContext,
$restCall
);
$ret = new BankAccount();
$ret->fromJson($json);
return $ret;
@@ -1205,38 +1204,46 @@ class BankAccount extends PPModel implements IResource
/**
* Delete the bank account resource for the given identifier.
*
* @param \PayPal\Rest\ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param PPRestCall $restCall is the Rest Call Service that is used to make rest calls
* @return bool
*/
public function delete($apiContext = null)
public function delete($apiContext = null, $restCall = null)
{
ArgumentValidator::validate($this->getId(), "Id");
$payLoad = "";
if ($apiContext == null) {
$apiContext = new ApiContext(self::$credential);
}
$call = new PPRestCall($apiContext);
$json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/vault/bank-accounts/{$this->getId()}", "DELETE", $payLoad);
self::executeCall(
"/v1/vault/bank-accounts/{$this->getId()}",
"DELETE",
$payLoad,
null,
$apiContext,
$restCall
);
return true;
}
/**
* Update information in a previously saved bank account. Only the modified fields need to be passed in the request.
*
* @param \PayPal\Rest\ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param PatchRequest $patchRequest
* @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param PPRestCall $restCall is the Rest Call Service that is used to make rest calls
* @return BankAccount
*/
public function update($apiContext = null)
public function update($patchRequest, $apiContext = null, $restCall = null)
{
ArgumentValidator::validate($this->getId(), "Id");
$payLoad = "";
if ($apiContext == null) {
$apiContext = new ApiContext(self::$credential);
}
$call = new PPRestCall($apiContext);
$json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/vault/bank-accounts/{$this->getId()}", "PATCH", $payLoad);
ArgumentValidator::validate($patchRequest, 'patchRequest');
$payLoad = $patchRequest->toJSON();
$json = self::executeCall(
"/v1/vault/bank-accounts/{$this->getId()}",
"PATCH",
$payLoad,
null,
$apiContext,
$restCall
);
$this->fromJson($json);
return $this;
}

View File

@@ -3,7 +3,6 @@
namespace PayPal\Api;
use PayPal\Common\PPModel;
use PayPal\Rest\ApiContext;
/**
* Class BankAccountsList
@@ -12,7 +11,7 @@ use PayPal\Rest\ApiContext;
*
* @package PayPal\Api
*
* @property \PayPal\Api\BankAccount bank_accounts
* @property \PayPal\Api\BankAccount[] bank_accounts
* @property int count
* @property string next_id
*/
@@ -20,9 +19,8 @@ class BankAccountsList extends PPModel
{
/**
* A list of bank account resources
*
*
* @param \PayPal\Api\BankAccount $bank_accounts
* @param \PayPal\Api\BankAccount[] $bank_accounts
*
* @return $this
*/
@@ -42,6 +40,36 @@ class BankAccountsList extends PPModel
return $this->{"bank-accounts"};
}
/**
* Append BankAccounts to the list.
*
* @param \PayPal\Api\BankAccount $bankAccount
* @return $this
*/
public function addBankAccount($bankAccount)
{
if (!$this->getBankAccounts()) {
return $this->setBankAccounts(array($bankAccount));
} else {
return $this->setBankAccounts(
array_merge($this->getBankAccounts(), array($bankAccount))
);
}
}
/**
* Remove BankAccounts from the list.
*
* @param \PayPal\Api\BankAccount $bankAccount
* @return $this
*/
public function removeBankAccount($bankAccount)
{
return $this->setBankAccounts(
array_diff($this->getBankAccounts(), array($bankAccount))
);
}
/**
* A list of bank account resources
*
@@ -69,7 +97,6 @@ class BankAccountsList extends PPModel
/**
* Number of items returned in each range of results. Note that the last results range could have fewer items than the requested number of items.
*
*
* @param int $count
*
@@ -93,7 +120,6 @@ class BankAccountsList extends PPModel
/**
* Identifier of the next element to get the next range of results.
*
*
* @param string $next_id
*

View File

@@ -3,7 +3,6 @@
namespace PayPal\Api;
use PayPal\Common\PPModel;
use PayPal\Rest\ApiContext;
/**
* Class BankToken
@@ -20,7 +19,6 @@ class BankToken extends PPModel
{
/**
* ID of a previously saved Bank resource using /vault/bank API.
*
*
* @param string $bank_id
*
@@ -69,7 +67,6 @@ class BankToken extends PPModel
/**
* The unique identifier of the payer used when saving this bank using /vault/bank API.
*
*
* @param string $external_customer_id
*
@@ -118,7 +115,6 @@ class BankToken extends PPModel
/**
* Identifier of the direct debit mandate to validate. Currently supported only for EU bank accounts(SEPA).
*
*
* @param string $mandate_reference_number
*

View File

@@ -0,0 +1,89 @@
<?php
namespace PayPal\Api;
use PayPal\Common\PPModel;
/**
* Class ChargeModel
*
* A resource representing a charge model for a payment definition.
*
* @package PayPal\Api
*
* @property string id
* @property string type
* @property \PayPal\Api\Currency amount
*/
class ChargeModel extends PPModel
{
/**
* Identifier of the charge model. 128 characters max.
*
* @param string $id
*
* @return $this
*/
public function setId($id)
{
$this->id = $id;
return $this;
}
/**
* Identifier of the charge model. 128 characters max.
*
* @return string
*/
public function getId()
{
return $this->id;
}
/**
* Type of charge model. Allowed values: `SHIPPING`, `TAX`.
*
* @param string $type
*
* @return $this
*/
public function setType($type)
{
$this->type = $type;
return $this;
}
/**
* Type of charge model. Allowed values: `SHIPPING`, `TAX`.
*
* @return string
*/
public function getType()
{
return $this->type;
}
/**
* Specific amount for this charge model.
*
* @param \PayPal\Api\Currency $amount
*
* @return $this
*/
public function setAmount($amount)
{
$this->amount = $amount;
return $this;
}
/**
* Specific amount for this charge model.
*
* @return \PayPal\Api\Currency
*/
public function getAmount()
{
return $this->amount;
}
}

View File

@@ -3,7 +3,6 @@
namespace PayPal\Api;
use PayPal\Common\PPModel;
use PayPal\Rest\ApiContext;
/**
* Class Credit
@@ -20,7 +19,6 @@ class Credit extends PPModel
{
/**
* Unique identifier of credit resource.
*
*
* @param string $id
*
@@ -43,8 +41,8 @@ class Credit extends PPModel
}
/**
* specifies type of credit
* Valid Values: ["BILL_ME_LATER", "PAYPAL_EXTRAS_MASTERCARD", "EBAY_MASTERCARD", "PAYPAL_SMART_CONNECT"]
* Specifies the type of credit.
* Valid Values: ["BILL_ME_LATER", "PAYPAL_EXTRAS_MASTERCARD", "EBAY_MASTERCARD", "PAYPAL_SMART_CONNECT"]
*
* @param string $type
*
@@ -57,7 +55,7 @@ class Credit extends PPModel
}
/**
* specifies type of credit
* Specifies the type of credit.
*
* @return string
*/
@@ -67,8 +65,7 @@ class Credit extends PPModel
}
/**
* URI to the associated terms
*
* URI to the associated terms.
*
* @param string $terms
*
@@ -81,7 +78,7 @@ class Credit extends PPModel
}
/**
* URI to the associated terms
* URI to the associated terms.
*
* @return string
*/

View File

@@ -2,11 +2,10 @@
namespace PayPal\Api;
use PayPal\Common\PPModel;
use PayPal\Rest\ApiContext;
use PayPal\Rest\IResource;
use PayPal\Transport\PPRestCall;
use PayPal\Common\ResourceModel;
use PayPal\Validation\ArgumentValidator;
use PayPal\Rest\ApiContext;
use PayPal\Transport\PPRestCall;
/**
* Class CreditCard
@@ -29,31 +28,12 @@ use PayPal\Validation\ArgumentValidator;
* @property string valid_until
* @property string create_time
* @property string update_time
* @property \PayPal\Api\Links links
* @property \PayPal\Api\Links[] links
*/
class CreditCard extends PPModel implements IResource
class CreditCard extends ResourceModel
{
/**
* OAuth Credentials to use for this call
*
* @var \PayPal\Auth\OAuthTokenCredential $credential
*/
protected static $credential;
/**
* Sets Credential
*
* @deprecated Pass ApiContext to create/get methods instead
* @param \PayPal\Auth\OAuthTokenCredential $credential
*/
public static function setCredential($credential)
{
self::$credential = $credential;
}
/**
* ID of the credit card being saved for later use.
*
*
* @param string $id
*
@@ -77,7 +57,6 @@ class CreditCard extends PPModel implements IResource
/**
* Card number.
*
*
* @param string $number
*
@@ -101,7 +80,6 @@ class CreditCard extends PPModel implements IResource
/**
* Type of the Card (eg. Visa, Mastercard, etc.).
*
*
* @param string $type
*
@@ -125,7 +103,6 @@ class CreditCard extends PPModel implements IResource
/**
* 2 digit card expiry month.
*
*
* @param int $expire_month
*
@@ -174,7 +151,6 @@ class CreditCard extends PPModel implements IResource
/**
* 4 digit card expiry year
*
*
* @param int $expire_year
*
@@ -223,7 +199,6 @@ class CreditCard extends PPModel implements IResource
/**
* Card validation code. Only supported when making a Payment but not when saving a credit card for future use.
*
*
* @param int $cvv2
*
@@ -247,7 +222,6 @@ class CreditCard extends PPModel implements IResource
/**
* Card holder's first name.
*
*
* @param string $first_name
*
@@ -296,7 +270,6 @@ class CreditCard extends PPModel implements IResource
/**
* Card holder's last name.
*
*
* @param string $last_name
*
@@ -345,7 +318,6 @@ class CreditCard extends PPModel implements IResource
/**
* Billing Address associated with this card.
*
*
* @param \PayPal\Api\Address $billing_address
*
@@ -394,7 +366,6 @@ class CreditCard extends PPModel implements IResource
/**
* A unique identifier of the customer to whom this bank account belongs to. Generated and provided by the facilitator. This is required when creating or using a stored funding instrument in vault.
*
*
* @param string $external_customer_id
*
@@ -443,7 +414,7 @@ class CreditCard extends PPModel implements IResource
/**
* State of the funding instrument.
* Valid Values: ["expired", "ok"]
* Valid Values: ["expired", "ok"]
*
* @param string $state
*
@@ -467,7 +438,6 @@ class CreditCard extends PPModel implements IResource
/**
* Date/Time until this resource can be used fund a payment.
*
*
* @param string $valid_until
*
@@ -516,7 +486,6 @@ class CreditCard extends PPModel implements IResource
/**
* Time the resource was created in UTC ISO8601 format.
*
*
* @param string $create_time
*
@@ -564,8 +533,7 @@ class CreditCard extends PPModel implements IResource
}
/**
* Time the resource was last updated in UTC ISO8601 format.
*
* Time the resource was created in UTC ISO8601 format.
*
* @param string $update_time
*
@@ -578,7 +546,7 @@ class CreditCard extends PPModel implements IResource
}
/**
* Time the resource was last updated in UTC ISO8601 format.
* Time the resource was created in UTC ISO8601 format.
*
* @return string
*/
@@ -588,7 +556,7 @@ class CreditCard extends PPModel implements IResource
}
/**
* Time the resource was last updated in UTC ISO8601 format.
* Time the resource was created in UTC ISO8601 format.
*
* @deprecated Instead use setUpdateTime
*
@@ -602,7 +570,7 @@ class CreditCard extends PPModel implements IResource
}
/**
* Time the resource was last updated in UTC ISO8601 format.
* Time the resource was created in UTC ISO8601 format.
* @deprecated Instead use getUpdateTime
*
* @return string
@@ -614,9 +582,8 @@ class CreditCard extends PPModel implements IResource
/**
* Sets Links
*
*
* @param \PayPal\Api\Links $links
* @param \PayPal\Api\Links[] $links
*
* @return $this
*/
@@ -636,21 +603,54 @@ class CreditCard extends PPModel implements IResource
return $this->links;
}
/**
* Append Links to the list.
*
* @param \PayPal\Api\Links $links
* @return $this
*/
public function addLink($links)
{
if (!$this->getLinks()) {
return $this->setLinks(array($links));
} else {
return $this->setLinks(
array_merge($this->getLinks(), array($links))
);
}
}
/**
* Remove Links from the list.
*
* @param \PayPal\Api\Links $links
* @return $this
*/
public function removeLink($links)
{
return $this->setLinks(
array_diff($this->getLinks(), array($links))
);
}
/**
* Creates a new Credit Card Resource (aka Tokenize).
*
* @param \PayPal\Rest\ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param PPRestCall $restCall is the Rest Call Service that is used to make rest calls
* @return CreditCard
*/
public function create($apiContext = null)
public function create($apiContext = null, $restCall = null)
{
$payLoad = $this->toJSON();
if ($apiContext == null) {
$apiContext = new ApiContext(self::$credential);
}
$call = new PPRestCall($apiContext);
$json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/vault/credit-card", "POST", $payLoad);
$json = self::executeCall(
"/v1/vault/credit-card",
"POST",
$payLoad,
null,
$apiContext,
$restCall
);
$this->fromJson($json);
return $this;
}
@@ -659,19 +659,22 @@ class CreditCard extends PPModel implements IResource
* Obtain the Credit Card resource for the given identifier.
*
* @param string $creditCardId
* @param \PayPal\Rest\ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param PPRestCall $restCall is the Rest Call Service that is used to make rest calls
* @return CreditCard
*/
public static function get($creditCardId, $apiContext = null)
public static function get($creditCardId, $apiContext = null, $restCall = null)
{
ArgumentValidator::validate($creditCardId, 'creditCardId');
$payLoad = "";
if ($apiContext == null) {
$apiContext = new ApiContext(self::$credential);
}
$call = new PPRestCall($apiContext);
$json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/vault/credit-card/$creditCardId", "GET", $payLoad);
$json = self::executeCall(
"/v1/vault/credit-card/$creditCardId",
"GET",
$payLoad,
null,
$apiContext,
$restCall
);
$ret = new CreditCard();
$ret->fromJson($json);
return $ret;
@@ -680,38 +683,44 @@ class CreditCard extends PPModel implements IResource
/**
* Delete the Credit Card resource for the given identifier.
*
* @param \PayPal\Rest\ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param PPRestCall $restCall is the Rest Call Service that is used to make rest calls
* @return bool
*/
public function delete($apiContext = null)
public function delete($apiContext = null, $restCall = null)
{
ArgumentValidator::validate($this->getId(), "Id");
$payLoad = "";
if ($apiContext == null) {
$apiContext = new ApiContext(self::$credential);
}
$call = new PPRestCall($apiContext);
$json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/vault/credit-card/{$this->getId()}", "DELETE", $payLoad);
self::executeCall(
"/v1/vault/credit-card/{$this->getId()}",
"DELETE",
$payLoad,
null,
$apiContext,
$restCall
);
return true;
}
/**
* Update information in a previously saved card. Only the modified fields need to be passed in the request.
*
* @param \PayPal\Rest\ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param PPRestCall $restCall is the Rest Call Service that is used to make rest calls
* @return CreditCard
*/
public function update($apiContext = null)
public function update($apiContext = null, $restCall = null)
{
ArgumentValidator::validate($this->getId(), "Id");
$payLoad = $this->toJSON();
if ($apiContext == null) {
$apiContext = new ApiContext(self::$credential);
}
$call = new PPRestCall($apiContext);
$json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/vault/credit-card/{$this->getId()}", "PATCH", $payLoad);
$json = self::executeCall(
"/v1/vault/credit-card/{$this->getId()}",
"PATCH",
$payLoad,
null,
$apiContext,
$restCall
);
$this->fromJson($json);
return $this;
}

View File

@@ -3,7 +3,6 @@
namespace PayPal\Api;
use PayPal\Common\PPModel;
use PayPal\Rest\ApiContext;
/**
* Class CreditCardList
@@ -12,7 +11,7 @@ use PayPal\Rest\ApiContext;
*
* @package PayPal\Api
*
* @property \PayPal\Api\CreditCard credit_cards
* @property \PayPal\Api\CreditCard[] credit_cards
* @property int count
* @property string next_id
*/
@@ -20,9 +19,8 @@ class CreditCardList extends PPModel
{
/**
* A list of credit card resources
*
*
* @param \PayPal\Api\CreditCard $credit_cards
* @param \PayPal\Api\CreditCard[] $credit_cards
*
* @return $this
*/
@@ -42,6 +40,36 @@ class CreditCardList extends PPModel
return $this->{"credit-cards"};
}
/**
* Append CreditCards to the list.
*
* @param \PayPal\Api\CreditCard $creditCard
* @return $this
*/
public function addCreditCard($creditCard)
{
if (!$this->getCreditCards()) {
return $this->setCreditCards(array($creditCard));
} else {
return $this->setCreditCards(
array_merge($this->getCreditCards(), array($creditCard))
);
}
}
/**
* Remove CreditCards from the list.
*
* @param \PayPal\Api\CreditCard $creditCard
* @return $this
*/
public function removeCreditCard($creditCard)
{
return $this->setCreditCards(
array_diff($this->getCreditCards(), array($creditCard))
);
}
/**
* A list of credit card resources
*
@@ -69,7 +97,6 @@ class CreditCardList extends PPModel
/**
* Number of items returned in each range of results. Note that the last results range could have fewer items than the requested number of items.
*
*
* @param int $count
*
@@ -93,7 +120,6 @@ class CreditCardList extends PPModel
/**
* Identifier of the next element to get the next range of results.
*
*
* @param string $next_id
*

View File

@@ -3,7 +3,6 @@
namespace PayPal\Api;
use PayPal\Common\PPModel;
use PayPal\Rest\ApiContext;
/**
* Class CreditCardToken
@@ -23,7 +22,6 @@ class CreditCardToken extends PPModel
{
/**
* ID of a previously saved Credit Card resource using /vault/credit-card API.
*
*
* @param string $credit_card_id
*
@@ -72,7 +70,6 @@ class CreditCardToken extends PPModel
/**
* The unique identifier of the payer used when saving this credit card using /vault/credit-card API.
*
*
* @param string $payer_id
*
@@ -121,7 +118,6 @@ class CreditCardToken extends PPModel
/**
* Last 4 digits of the card number from the saved card.
*
*
* @param string $last4
*
@@ -145,7 +141,6 @@ class CreditCardToken extends PPModel
/**
* Type of the Card (eg. visa, mastercard, etc.) from the saved card. Please note that the values are always in lowercase and not meant to be used directly for display.
*
*
* @param string $type
*
@@ -168,8 +163,7 @@ class CreditCardToken extends PPModel
}
/**
* card expiry month from the saved card with value 1 - 12
*
* Expiry month from the saved card, represented as 1 - 12.
*
* @param int $expire_month
*
@@ -182,7 +176,7 @@ class CreditCardToken extends PPModel
}
/**
* card expiry month from the saved card with value 1 - 12
* Expiry month from the saved card, represented as 1 - 12.
*
* @return int
*/
@@ -192,7 +186,7 @@ class CreditCardToken extends PPModel
}
/**
* card expiry month from the saved card with value 1 - 12
* Expiry month from the saved card, represented as 1 - 12.
*
* @deprecated Instead use setExpireMonth
*
@@ -206,7 +200,7 @@ class CreditCardToken extends PPModel
}
/**
* card expiry month from the saved card with value 1 - 12
* Expiry month from the saved card, represented as 1 - 12.
* @deprecated Instead use getExpireMonth
*
* @return int
@@ -217,8 +211,7 @@ class CreditCardToken extends PPModel
}
/**
* 4 digit card expiry year from the saved card
*
* Expiry year from the saved card, represented as YYYY format.
*
* @param int $expire_year
*
@@ -231,7 +224,7 @@ class CreditCardToken extends PPModel
}
/**
* 4 digit card expiry year from the saved card
* Expiry year from the saved card, represented as YYYY format.
*
* @return int
*/
@@ -241,7 +234,7 @@ class CreditCardToken extends PPModel
}
/**
* 4 digit card expiry year from the saved card
* Expiry year from the saved card, represented as YYYY format.
*
* @deprecated Instead use setExpireYear
*
@@ -255,7 +248,7 @@ class CreditCardToken extends PPModel
}
/**
* 4 digit card expiry year from the saved card
* Expiry year from the saved card, represented as YYYY format.
* @deprecated Instead use getExpireYear
*
* @return int

View File

@@ -1,15 +1,27 @@
<?php
namespace PayPal\Api;
use PayPal\Common\PPModel;
use PayPal\Rest\ApiContext;
/**
* Class Currency
*
* Base object for all financial value related fields (balance, payment due, etc.)
*
* @package PayPal\Api
*
* @property string currency
* @property string value
*/
class Currency extends PPModel
{
/**
* 3 letter currency code
* 3 letter currency code as defined by ISO 4217.
*
* @param string $currency
*
* @return $this
*/
public function setCurrency($currency)
{
@@ -18,7 +30,7 @@ class Currency extends PPModel
}
/**
* 3 letter currency code
* 3 letter currency code as defined by ISO 4217.
*
* @return string
*/
@@ -27,11 +39,12 @@ class Currency extends PPModel
return $this->currency;
}
/**
* amount upto 2 decimals represented as string
* amount up to N digit after the decimals separator as defined in ISO 4217 for the appropriate currency code.
*
* @param string $value
*
* @return $this
*/
public function setValue($value)
{
@@ -40,7 +53,7 @@ class Currency extends PPModel
}
/**
* amount upto 2 decimals represented as string
* amount up to N digit after the decimals separator as defined in ISO 4217 for the appropriate currency code.
*
* @return string
*/
@@ -49,5 +62,4 @@ class Currency extends PPModel
return $this->value;
}
}

View File

@@ -3,7 +3,6 @@
namespace PayPal\Api;
use PayPal\Common\PPModel;
use PayPal\Rest\ApiContext;
/**
* Class ExtendedBankAccount
@@ -18,7 +17,6 @@ class ExtendedBankAccount extends BankAccount
{
/**
* Identifier of the direct debit mandate to validate. Currently supported only for EU bank accounts(SEPA).
*
*
* @param string $mandate_reference_number
*

View File

@@ -3,7 +3,6 @@
namespace PayPal\Api;
use PayPal\Common\PPModel;
use PayPal\Rest\ApiContext;
/**
* Class FundingInstrument
@@ -24,7 +23,6 @@ class FundingInstrument extends PPModel
{
/**
* Credit Card information.
*
*
* @param \PayPal\Api\CreditCard $credit_card
*
@@ -73,7 +71,6 @@ class FundingInstrument extends PPModel
/**
* Credit Card information.
*
*
* @param \PayPal\Api\CreditCardToken $credit_card_token
*
@@ -122,7 +119,6 @@ class FundingInstrument extends PPModel
/**
* Payment Card information.
*
*
* @param \PayPal\Api\PaymentCard $payment_card
*
@@ -171,7 +167,6 @@ class FundingInstrument extends PPModel
/**
* Payment card token information.
*
*
* @param \PayPal\Api\PaymentCardToken $payment_card_token
*
@@ -220,7 +215,6 @@ class FundingInstrument extends PPModel
/**
* Bank Account information.
*
*
* @param \PayPal\Api\ExtendedBankAccount $bank_account
*
@@ -269,7 +263,6 @@ class FundingInstrument extends PPModel
/**
* Bank Account information.
*
*
* @param \PayPal\Api\BankToken $bank_account_token
*
@@ -318,7 +311,6 @@ class FundingInstrument extends PPModel
/**
* Credit funding information.
*
*
* @param \PayPal\Api\Credit $credit
*

View File

@@ -3,7 +3,6 @@
namespace PayPal\Api;
use PayPal\Common\PPModel;
use PayPal\Rest\ApiContext;
/**
* Class HyperSchema
@@ -12,7 +11,7 @@ use PayPal\Rest\ApiContext;
*
* @package PayPal\Api
*
* @property \PayPal\Api\Links links
* @property \PayPal\Api\Links[] links
* @property string fragmentResolution
* @property bool readonly
* @property string contentEncoding
@@ -23,9 +22,8 @@ class HyperSchema extends PPModel
{
/**
* Sets Links
*
*
* @param \PayPal\Api\Links $links
* @param \PayPal\Api\Links[] $links
*
* @return $this
*/
@@ -45,9 +43,38 @@ class HyperSchema extends PPModel
return $this->links;
}
/**
* Append Links to the list.
*
* @param \PayPal\Api\Links $links
* @return $this
*/
public function addLink($links)
{
if (!$this->getLinks()) {
return $this->setLinks(array($links));
} else {
return $this->setLinks(
array_merge($this->getLinks(), array($links))
);
}
}
/**
* Remove Links from the list.
*
* @param \PayPal\Api\Links $links
* @return $this
*/
public function removeLink($links)
{
return $this->setLinks(
array_diff($this->getLinks(), array($links))
);
}
/**
* Sets FragmentResolution
*
*
* @param string $fragmentResolution
*
@@ -71,7 +98,6 @@ class HyperSchema extends PPModel
/**
* Sets Readonly
*
*
* @param bool $readonly
*
@@ -95,7 +121,6 @@ class HyperSchema extends PPModel
/**
* Sets ContentEncoding
*
*
* @param string $contentEncoding
*
@@ -119,7 +144,6 @@ class HyperSchema extends PPModel
/**
* Sets PathStart
*
*
* @param string $pathStart
*
@@ -143,7 +167,6 @@ class HyperSchema extends PPModel
/**
* Sets MediaType
*
*
* @param string $mediaType
*

View File

@@ -3,7 +3,6 @@
namespace PayPal\Api;
use PayPal\Common\PPModel;
use PayPal\Rest\ApiContext;
/**
* Class Links
@@ -23,7 +22,6 @@ class Links extends PPModel
{
/**
* Sets Href
*
*
* @param string $href
*
@@ -47,7 +45,6 @@ class Links extends PPModel
/**
* Sets Rel
*
*
* @param string $rel
*
@@ -71,7 +68,6 @@ class Links extends PPModel
/**
* Sets TargetSchema
*
*
* @param \PayPal\Api\HyperSchema $targetSchema
*
@@ -95,7 +91,6 @@ class Links extends PPModel
/**
* Sets Method
*
*
* @param string $method
*
@@ -119,7 +114,6 @@ class Links extends PPModel
/**
* Sets Enctype
*
*
* @param string $enctype
*
@@ -143,7 +137,6 @@ class Links extends PPModel
/**
* Sets Schema
*
*
* @param \PayPal\Api\HyperSchema $schema
*

View File

@@ -0,0 +1,486 @@
<?php
namespace PayPal\Api;
use PayPal\Common\PPModel;
use PayPal\Validation\UrlValidator;
/**
* Class MerchantPreferences
*
* Resource representing merchant preferences like max failed attempts, set up fee and others for a plan.
*
* @package PayPal\Api
*
* @property string id
* @property \PayPal\Api\Currency setup_fee
* @property string cancel_url
* @property string return_url
* @property string notify_url
* @property string max_fail_attempts
* @property string auto_bill_amount
* @property string initial_fail_amount_action
* @property string accepted_payment_type
* @property string char_set
*/
class MerchantPreferences extends PPModel
{
/**
* Identifier of the merchant_preferences. 128 characters max.
*
* @param string $id
*
* @return $this
*/
public function setId($id)
{
$this->id = $id;
return $this;
}
/**
* Identifier of the merchant_preferences. 128 characters max.
*
* @return string
*/
public function getId()
{
return $this->id;
}
/**
* Setup fee amount. Default is 0.
*
* @param \PayPal\Api\Currency $setup_fee
*
* @return $this
*/
public function setSetupFee($setup_fee)
{
$this->setup_fee = $setup_fee;
return $this;
}
/**
* Setup fee amount. Default is 0.
*
* @return \PayPal\Api\Currency
*/
public function getSetupFee()
{
return $this->setup_fee;
}
/**
* Setup fee amount. Default is 0.
*
* @deprecated Instead use setSetupFee
*
* @param \PayPal\Api\Currency $setup_fee
* @return $this
*/
public function setSetup_fee($setup_fee)
{
$this->setup_fee = $setup_fee;
return $this;
}
/**
* Setup fee amount. Default is 0.
* @deprecated Instead use getSetupFee
*
* @return \PayPal\Api\Currency
*/
public function getSetup_fee()
{
return $this->setup_fee;
}
/**
* Redirect URL on cancellation of agreement request. 1000 characters max.
*
* @param string $cancel_url
* @throws \InvalidArgumentException
* @return $this
*/
public function setCancelUrl($cancel_url)
{
UrlValidator::validate($cancel_url, "CancelUrl");
$this->cancel_url = $cancel_url;
return $this;
}
/**
* Redirect URL on cancellation of agreement request. 1000 characters max.
*
* @return string
*/
public function getCancelUrl()
{
return $this->cancel_url;
}
/**
* Redirect URL on cancellation of agreement request. 1000 characters max.
*
* @deprecated Instead use setCancelUrl
*
* @param string $cancel_url
* @return $this
*/
public function setCancel_url($cancel_url)
{
$this->cancel_url = $cancel_url;
return $this;
}
/**
* Redirect URL on cancellation of agreement request. 1000 characters max.
* @deprecated Instead use getCancelUrl
*
* @return string
*/
public function getCancel_url()
{
return $this->cancel_url;
}
/**
* Redirect URL on creation of agreement request. 1000 characters max.
*
* @param string $return_url
* @throws \InvalidArgumentException
* @return $this
*/
public function setReturnUrl($return_url)
{
UrlValidator::validate($return_url, "ReturnUrl");
$this->return_url = $return_url;
return $this;
}
/**
* Redirect URL on creation of agreement request. 1000 characters max.
*
* @return string
*/
public function getReturnUrl()
{
return $this->return_url;
}
/**
* Redirect URL on creation of agreement request. 1000 characters max.
*
* @deprecated Instead use setReturnUrl
*
* @param string $return_url
* @return $this
*/
public function setReturn_url($return_url)
{
$this->return_url = $return_url;
return $this;
}
/**
* Redirect URL on creation of agreement request. 1000 characters max.
* @deprecated Instead use getReturnUrl
*
* @return string
*/
public function getReturn_url()
{
return $this->return_url;
}
/**
* Notify URL on agreement creation. 1000 characters max.
*
* @param string $notify_url
* @throws \InvalidArgumentException
* @return $this
*/
public function setNotifyUrl($notify_url)
{
UrlValidator::validate($notify_url, "NotifyUrl");
$this->notify_url = $notify_url;
return $this;
}
/**
* Notify URL on agreement creation. 1000 characters max.
*
* @return string
*/
public function getNotifyUrl()
{
return $this->notify_url;
}
/**
* Notify URL on agreement creation. 1000 characters max.
*
* @deprecated Instead use setNotifyUrl
*
* @param string $notify_url
* @return $this
*/
public function setNotify_url($notify_url)
{
$this->notify_url = $notify_url;
return $this;
}
/**
* Notify URL on agreement creation. 1000 characters max.
* @deprecated Instead use getNotifyUrl
*
* @return string
*/
public function getNotify_url()
{
return $this->notify_url;
}
/**
* Total number of failed attempts allowed. Default is 0, representing an infinite number of failed attempts.
*
* @param string $max_fail_attempts
*
* @return $this
*/
public function setMaxFailAttempts($max_fail_attempts)
{
$this->max_fail_attempts = $max_fail_attempts;
return $this;
}
/**
* Total number of failed attempts allowed. Default is 0, representing an infinite number of failed attempts.
*
* @return string
*/
public function getMaxFailAttempts()
{
return $this->max_fail_attempts;
}
/**
* Total number of failed attempts allowed. Default is 0, representing an infinite number of failed attempts.
*
* @deprecated Instead use setMaxFailAttempts
*
* @param string $max_fail_attempts
* @return $this
*/
public function setMax_fail_attempts($max_fail_attempts)
{
$this->max_fail_attempts = $max_fail_attempts;
return $this;
}
/**
* Total number of failed attempts allowed. Default is 0, representing an infinite number of failed attempts.
* @deprecated Instead use getMaxFailAttempts
*
* @return string
*/
public function getMax_fail_attempts()
{
return $this->max_fail_attempts;
}
/**
* Allow auto billing for the outstanding amount of the agreement in the next cycle. Allowed values: `YES`, `NO`. Default is `NO`.
*
* @param string $auto_bill_amount
*
* @return $this
*/
public function setAutoBillAmount($auto_bill_amount)
{
$this->auto_bill_amount = $auto_bill_amount;
return $this;
}
/**
* Allow auto billing for the outstanding amount of the agreement in the next cycle. Allowed values: `YES`, `NO`. Default is `NO`.
*
* @return string
*/
public function getAutoBillAmount()
{
return $this->auto_bill_amount;
}
/**
* Allow auto billing for the outstanding amount of the agreement in the next cycle. Allowed values: `YES`, `NO`. Default is `NO`.
*
* @deprecated Instead use setAutoBillAmount
*
* @param string $auto_bill_amount
* @return $this
*/
public function setAuto_bill_amount($auto_bill_amount)
{
$this->auto_bill_amount = $auto_bill_amount;
return $this;
}
/**
* Allow auto billing for the outstanding amount of the agreement in the next cycle. Allowed values: `YES`, `NO`. Default is `NO`.
* @deprecated Instead use getAutoBillAmount
*
* @return string
*/
public function getAuto_bill_amount()
{
return $this->auto_bill_amount;
}
/**
* Action to take if a failure occurs during initial payment. Allowed values: `CONTINUE`, `CANCEL`. Default is continue.
*
* @param string $initial_fail_amount_action
*
* @return $this
*/
public function setInitialFailAmountAction($initial_fail_amount_action)
{
$this->initial_fail_amount_action = $initial_fail_amount_action;
return $this;
}
/**
* Action to take if a failure occurs during initial payment. Allowed values: `CONTINUE`, `CANCEL`. Default is continue.
*
* @return string
*/
public function getInitialFailAmountAction()
{
return $this->initial_fail_amount_action;
}
/**
* Action to take if a failure occurs during initial payment. Allowed values: `CONTINUE`, `CANCEL`. Default is continue.
*
* @deprecated Instead use setInitialFailAmountAction
*
* @param string $initial_fail_amount_action
* @return $this
*/
public function setInitial_fail_amount_action($initial_fail_amount_action)
{
$this->initial_fail_amount_action = $initial_fail_amount_action;
return $this;
}
/**
* Action to take if a failure occurs during initial payment. Allowed values: `CONTINUE`, `CANCEL`. Default is continue.
* @deprecated Instead use getInitialFailAmountAction
*
* @return string
*/
public function getInitial_fail_amount_action()
{
return $this->initial_fail_amount_action;
}
/**
* Payment types that are accepted for this plan.
*
* @param string $accepted_payment_type
*
* @return $this
*/
public function setAcceptedPaymentType($accepted_payment_type)
{
$this->accepted_payment_type = $accepted_payment_type;
return $this;
}
/**
* Payment types that are accepted for this plan.
*
* @return string
*/
public function getAcceptedPaymentType()
{
return $this->accepted_payment_type;
}
/**
* Payment types that are accepted for this plan.
*
* @deprecated Instead use setAcceptedPaymentType
*
* @param string $accepted_payment_type
* @return $this
*/
public function setAccepted_payment_type($accepted_payment_type)
{
$this->accepted_payment_type = $accepted_payment_type;
return $this;
}
/**
* Payment types that are accepted for this plan.
* @deprecated Instead use getAcceptedPaymentType
*
* @return string
*/
public function getAccepted_payment_type()
{
return $this->accepted_payment_type;
}
/**
* char_set for this plan.
*
* @param string $char_set
*
* @return $this
*/
public function setCharSet($char_set)
{
$this->char_set = $char_set;
return $this;
}
/**
* char_set for this plan.
*
* @return string
*/
public function getCharSet()
{
return $this->char_set;
}
/**
* char_set for this plan.
*
* @deprecated Instead use setCharSet
*
* @param string $char_set
* @return $this
*/
public function setChar_set($char_set)
{
$this->char_set = $char_set;
return $this;
}
/**
* char_set for this plan.
* @deprecated Instead use getCharSet
*
* @return string
*/
public function getChar_set()
{
return $this->char_set;
}
}

View File

@@ -0,0 +1,90 @@
<?php
namespace PayPal\Api;
use PayPal\Common\PPModel;
/**
* Class OverrideChargeModel
*
* A resource representing an override_charge_model to be used during creation of the agreement.
*
* @package PayPal\Api
*
* @property string charge_id
* @property \PayPal\Api\Currency amount
*/
class OverrideChargeModel extends PPModel
{
/**
* ID of charge model.
*
* @param string $charge_id
*
* @return $this
*/
public function setChargeId($charge_id)
{
$this->charge_id = $charge_id;
return $this;
}
/**
* ID of charge model.
*
* @return string
*/
public function getChargeId()
{
return $this->charge_id;
}
/**
* ID of charge model.
*
* @deprecated Instead use setChargeId
*
* @param string $charge_id
* @return $this
*/
public function setCharge_id($charge_id)
{
$this->charge_id = $charge_id;
return $this;
}
/**
* ID of charge model.
* @deprecated Instead use getChargeId
*
* @return string
*/
public function getCharge_id()
{
return $this->charge_id;
}
/**
* Updated Amount to be associated with this charge model.
*
* @param \PayPal\Api\Currency $amount
*
* @return $this
*/
public function setAmount($amount)
{
$this->amount = $amount;
return $this;
}
/**
* Updated Amount to be associated with this charge model.
*
* @return \PayPal\Api\Currency
*/
public function getAmount()
{
return $this->amount;
}
}

View File

@@ -20,7 +20,7 @@ class Patch extends PPModel
{
/**
* The operation to perform.
* Valid Values: ["add", "remove", "replace", "move", "copy", "test"]
* Valid Values: ["add", "remove", "replace", "move", "copy", "test"]
*
* @param string $op
*
@@ -44,7 +44,6 @@ class Patch extends PPModel
/**
* String containing a JSON-Pointer value that references a location within the target document where the operation is performed.
*
*
* @param string $path
*
@@ -68,7 +67,6 @@ class Patch extends PPModel
/**
* New value to apply based on the operation. op=remove does not require value.
*
*
* @param mixed $value
*
@@ -92,7 +90,6 @@ class Patch extends PPModel
/**
* A string containing a JSON Pointer value that references the location in the target document from which to move the value. Required for use where op=move.
*
*
* @param string $from
*

View File

@@ -0,0 +1,86 @@
<?php
namespace PayPal\Api;
use PayPal\Common\PPModel;
/**
* Class PatchRequest
*
* Request object used for a JSON Patch.
*
* @package PayPal\Api
*
* @property \PayPal\Api\Patch[] patches
*/
class PatchRequest extends PPModel
{
/**
* Placeholder for holding array of patch objects
*
* @param \PayPal\Api\Patch[] $patches
*
* @return $this
*/
public function setPatches($patches)
{
$this->patches = $patches;
return $this;
}
/**
* Placeholder for holding array of patch objects
*
* @return \PayPal\Api\Patch[]
*/
public function getPatches()
{
return $this->patches;
}
/**
* Append Patches to the list.
*
* @param \PayPal\Api\Patch $patch
* @return $this
*/
public function addPatch($patch)
{
if (!$this->getPatches()) {
return $this->setPatches(array($patch));
} else {
return $this->setPatches(
array_merge($this->getPatches(), array($patch))
);
}
}
/**
* Remove Patches from the list.
*
* @param \PayPal\Api\Patch $patch
* @return $this
*/
public function removePatch($patch)
{
return $this->setPatches(
array_diff($this->getPatches(), array($patch))
);
}
/**
* As PatchRequest holds the array of Patch object, we would override the json conversion to return
* a json representation of array of Patch objects.
*
* @param int $options
* @return mixed|string
*/
public function toJSON($options = 0)
{
$json = array();
foreach ($this->getPatches() as $patch) {
$json[] = $patch->toArray();
}
return json_encode($json, $options);
}
}

View File

@@ -3,7 +3,6 @@
namespace PayPal\Api;
use PayPal\Common\PPModel;
use PayPal\Rest\ApiContext;
/**
* Class Payer
@@ -14,15 +13,15 @@ use PayPal\Rest\ApiContext;
*
* @property string payment_method
* @property string status
* @property \PayPal\Api\FundingInstrument funding_instruments
* @property \PayPal\Api\FundingInstrument[] funding_instruments
* @property string funding_option_id
* @property \PayPal\Api\PayerInfo payer_info
*/
class Payer extends PPModel
{
/**
* Payment method being used - PayPal Wallet payment, Bank Direct Debit or Direct Credit card.
* Valid Values: ["credit_card", "bank", "paypal"]
* Payment method being used - PayPal Wallet payment, Bank Direct Debit, or Direct Credit card.
* Valid Values: ["credit_card", "bank", "paypal"]
*
* @param string $payment_method
*
@@ -35,7 +34,7 @@ class Payer extends PPModel
}
/**
* Payment method being used - PayPal Wallet payment, Bank Direct Debit or Direct Credit card.
* Payment method being used - PayPal Wallet payment, Bank Direct Debit, or Direct Credit card.
*
* @return string
*/
@@ -45,7 +44,7 @@ class Payer extends PPModel
}
/**
* Payment method being used - PayPal Wallet payment, Bank Direct Debit or Direct Credit card.
* Payment method being used - PayPal Wallet payment, Bank Direct Debit, or Direct Credit card.
*
* @deprecated Instead use setPaymentMethod
*
@@ -59,7 +58,7 @@ class Payer extends PPModel
}
/**
* Payment method being used - PayPal Wallet payment, Bank Direct Debit or Direct Credit card.
* Payment method being used - PayPal Wallet payment, Bank Direct Debit, or Direct Credit card.
* @deprecated Instead use getPaymentMethod
*
* @return string
@@ -71,7 +70,7 @@ class Payer extends PPModel
/**
* Status of Payer PayPal Account.
* Valid Values: ["VERIFIED", "UNVERIFIED"]
* Valid Values: ["VERIFIED", "UNVERIFIED"]
*
* @param string $status
*
@@ -94,10 +93,9 @@ class Payer extends PPModel
}
/**
* List of funding instruments from where the funds of the current payment come from. Typically a credit card.
*
* List of funding instruments from which the funds of the current payment come. Typically a credit card.
*
* @param \PayPal\Api\FundingInstrument $funding_instruments
* @param \PayPal\Api\FundingInstrument[] $funding_instruments
*
* @return $this
*/
@@ -108,7 +106,7 @@ class Payer extends PPModel
}
/**
* List of funding instruments from where the funds of the current payment come from. Typically a credit card.
* List of funding instruments from which the funds of the current payment come. Typically a credit card.
*
* @return \PayPal\Api\FundingInstrument[]
*/
@@ -118,7 +116,37 @@ class Payer extends PPModel
}
/**
* List of funding instruments from where the funds of the current payment come from. Typically a credit card.
* Append FundingInstruments to the list.
*
* @param \PayPal\Api\FundingInstrument $fundingInstrument
* @return $this
*/
public function addFundingInstrument($fundingInstrument)
{
if (!$this->getFundingInstruments()) {
return $this->setFundingInstruments(array($fundingInstrument));
} else {
return $this->setFundingInstruments(
array_merge($this->getFundingInstruments(), array($fundingInstrument))
);
}
}
/**
* Remove FundingInstruments from the list.
*
* @param \PayPal\Api\FundingInstrument $fundingInstrument
* @return $this
*/
public function removeFundingInstrument($fundingInstrument)
{
return $this->setFundingInstruments(
array_diff($this->getFundingInstruments(), array($fundingInstrument))
);
}
/**
* List of funding instruments from which the funds of the current payment come. Typically a credit card.
*
* @deprecated Instead use setFundingInstruments
*
@@ -132,7 +160,7 @@ class Payer extends PPModel
}
/**
* List of funding instruments from where the funds of the current payment come from. Typically a credit card.
* List of funding instruments from which the funds of the current payment come. Typically a credit card.
* @deprecated Instead use getFundingInstruments
*
* @return \PayPal\Api\FundingInstrument
@@ -143,8 +171,7 @@ class Payer extends PPModel
}
/**
* Id of user selected funding option for the payment. 'OneOf' funding_instruments or funding_option_id to be present
*
* Id of user selected funding option for the payment. 'OneOf' funding_instruments or funding_option_id to be present.
*
* @param string $funding_option_id
*
@@ -157,7 +184,7 @@ class Payer extends PPModel
}
/**
* Id of user selected funding option for the payment. 'OneOf' funding_instruments or funding_option_id to be present
* Id of user selected funding option for the payment. 'OneOf' funding_instruments or funding_option_id to be present.
*
* @return string
*/
@@ -167,7 +194,7 @@ class Payer extends PPModel
}
/**
* Id of user selected funding option for the payment. 'OneOf' funding_instruments or funding_option_id to be present
* Id of user selected funding option for the payment. 'OneOf' funding_instruments or funding_option_id to be present.
*
* @deprecated Instead use setFundingOptionId
*
@@ -181,7 +208,7 @@ class Payer extends PPModel
}
/**
* Id of user selected funding option for the payment. 'OneOf' funding_instruments or funding_option_id to be present
* Id of user selected funding option for the payment. 'OneOf' funding_instruments or funding_option_id to be present.
* @deprecated Instead use getFundingOptionId
*
* @return string
@@ -193,7 +220,6 @@ class Payer extends PPModel
/**
* Information related to the Payer.
*
*
* @param \PayPal\Api\PayerInfo $payer_info
*

View File

@@ -3,12 +3,11 @@
namespace PayPal\Api;
use PayPal\Common\PPModel;
use PayPal\Rest\ApiContext;
/**
* Class PayerInfo
*
* A resource representing a information about Payer.
* A resource representing information about a Payer.
*
* @package PayPal\Api
*
@@ -30,7 +29,6 @@ class PayerInfo extends PPModel
{
/**
* Email address representing the Payer.
*
*
* @param string $email
*
@@ -54,7 +52,6 @@ class PayerInfo extends PPModel
/**
* External Remember Me id representing the Payer
*
*
* @param string $external_remember_me_id
*
@@ -103,7 +100,6 @@ class PayerInfo extends PPModel
/**
* Account Number representing the Payer
*
*
* @param string $buyer_account_number
*
@@ -152,7 +148,6 @@ class PayerInfo extends PPModel
/**
* First Name of the Payer.
*
*
* @param string $first_name
*
@@ -201,7 +196,6 @@ class PayerInfo extends PPModel
/**
* Last Name of the Payer.
*
*
* @param string $last_name
*
@@ -250,7 +244,6 @@ class PayerInfo extends PPModel
/**
* PayPal assigned Payer ID.
*
*
* @param string $payer_id
*
@@ -299,7 +292,6 @@ class PayerInfo extends PPModel
/**
* Phone number representing the Payer.
*
*
* @param string $phone
*
@@ -323,7 +315,7 @@ class PayerInfo extends PPModel
/**
* Phone type
* Valid Values: ["HOME", "WORK", "MOBILE", "OTHER"]
* Valid Values: ["HOME", "WORK", "MOBILE", "OTHER"]
*
* @param string $phone_type
*
@@ -372,7 +364,6 @@ class PayerInfo extends PPModel
/**
* Birth date of the Payer in ISO8601 format (YYYY-MM-DD).
*
*
* @param string $birth_date
*
@@ -421,7 +412,6 @@ class PayerInfo extends PPModel
/**
* Payer's tax ID.
*
*
* @param string $tax_id
*
@@ -470,7 +460,7 @@ class PayerInfo extends PPModel
/**
* Payer's tax ID type.
* Valid Values: ["BR_CPF", "BR_CNPJ"]
* Valid Values: ["BR_CPF", "BR_CNPJ"]
*
* @param string $tax_id_type
*
@@ -519,7 +509,6 @@ class PayerInfo extends PPModel
/**
* Billing address of the Payer.
*
*
* @param \PayPal\Api\Address $billing_address
*
@@ -568,7 +557,6 @@ class PayerInfo extends PPModel
/**
* Obsolete. Use shipping address present in purchase unit.
*
*
* @param \PayPal\Api\ShippingAddress $shipping_address
*

View File

@@ -3,6 +3,7 @@
namespace PayPal\Api;
use PayPal\Common\PPModel;
use PayPal\Common\ResourceModel;
use PayPal\Rest\ApiContext;
use PayPal\Rest\IResource;
use PayPal\Api\PaymentHistory;
@@ -28,7 +29,7 @@ use PayPal\Validation\ArgumentValidator;
* @property \PayPal\Api\Links links
* @property string experience_profile_id
*/
class Payment extends PPModel implements IResource
class Payment extends ResourceModel
{
/**
* OAuth Credentials to use for this call
@@ -392,17 +393,21 @@ class Payment extends PPModel implements IResource
* Creates (and processes) a new Payment Resource.
*
* @param \PayPal\Rest\ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param PPRestCall $restCall is the Rest Call Service that is used to make rest calls
* @return Payment
*/
public function create($apiContext = null)
public function create($apiContext = null, $restCall = null)
{
$payLoad = $this->toJSON();
if ($apiContext == null) {
$apiContext = new ApiContext(self::$credential);
}
$call = new PPRestCall($apiContext);
$json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/payments/payment", "POST", $payLoad);
$json = self::executeCall(
"/v1/payments/payment",
"POST",
$payLoad,
null,
$apiContext,
$restCall
);
$this->fromJson($json);
return $this;
}
@@ -412,18 +417,22 @@ class Payment extends PPModel implements IResource
*
* @param string $paymentId
* @param \PayPal\Rest\ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param PPRestCall $restCall is the Rest Call Service that is used to make rest calls
* @return Payment
*/
public static function get($paymentId, $apiContext = null)
public static function get($paymentId, $apiContext = null, $restCall = null)
{
ArgumentValidator::validate($paymentId, 'paymentId');
$payLoad = "";
if ($apiContext == null) {
$apiContext = new ApiContext(self::$credential);
}
$call = new PPRestCall($apiContext);
$json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/payments/payment/$paymentId", "GET", $payLoad);
$json = self::executeCall(
"/v1/payments/payment/$paymentId",
"GET",
$payLoad,
null,
$apiContext,
$restCall
);
$ret = new Payment();
$ret->fromJson($json);
return $ret;
@@ -434,19 +443,23 @@ class Payment extends PPModel implements IResource
*
* @param PaymentExecution $paymentExecution
* @param \PayPal\Rest\ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param PPRestCall $restCall is the Rest Call Service that is used to make rest calls
* @return Payment
*/
public function execute($paymentExecution, $apiContext = null)
public function execute($paymentExecution, $apiContext = null, $restCall = null)
{
ArgumentValidator::validate($this->getId(), "Id");
ArgumentValidator::validate($paymentExecution, 'paymentExecution');
$payLoad = $paymentExecution->toJSON();
if ($apiContext == null) {
$apiContext = new ApiContext(self::$credential);
}
$call = new PPRestCall($apiContext);
$json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/payments/payment/{$this->getId()}/execute", "POST", $payLoad);
$json = self::executeCall(
"/v1/payments/payment/{$this->getId()}/execute",
"POST",
$payLoad,
null,
$apiContext,
$restCall
);
$this->fromJson($json);
return $this;
}
@@ -456,9 +469,10 @@ class Payment extends PPModel implements IResource
*
* @param array $params
* @param \PayPal\Rest\ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param PPRestCall $restCall is the Rest Call Service that is used to make rest calls
* @return PaymentHistory
*/
public static function all($params, $apiContext = null)
public static function all($params, $apiContext = null, $restCall = null)
{
ArgumentValidator::validate($params, 'params');
@@ -473,11 +487,14 @@ class Payment extends PPModel implements IResource
'sort_by' => 1,
'sort_order' => 1,
);
if ($apiContext == null) {
$apiContext = new ApiContext(self::$credential);
}
$call = new PPRestCall($apiContext);
$json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/payments/payment?" . http_build_query(array_intersect_key($params, $allowedParams)), "GET", $payLoad);
$json = self::executeCall(
"/v1/payments/payment?" . http_build_query(array_intersect_key($params, $allowedParams)),
"GET",
$payLoad,
null,
$apiContext,
$restCall
);
$ret = new PaymentHistory();
$ret->fromJson($json);
return $ret;

View File

@@ -3,7 +3,6 @@
namespace PayPal\Api;
use PayPal\Common\PPModel;
use PayPal\Rest\ApiContext;
/**
* Class PaymentCard
@@ -26,13 +25,12 @@ use PayPal\Rest\ApiContext;
* @property string external_customer_id
* @property string status
* @property string valid_until
* @property \PayPal\Api\Links links
* @property \PayPal\Api\Links[] links
*/
class PaymentCard extends PPModel
{
/**
* ID of the credit card being saved for later use.
*
*
* @param string $id
*
@@ -56,7 +54,6 @@ class PaymentCard extends PPModel
/**
* Card number.
*
*
* @param string $number
*
@@ -80,7 +77,7 @@ class PaymentCard extends PPModel
/**
* Type of the Card.
* Valid Values: ["VISA", "AMEX", "SOLO", "JCB", "STAR", "DELTA", "DISCOVER", "SWITCH", "MAESTRO", "CB_NATIONALE", "CONFINOGA", "COFIDIS", "ELECTRON", "CETELEM", "CHINA_UNION_PAY", "MASTERCARD"]
* Valid Values: ["VISA", "AMEX", "SOLO", "JCB", "STAR", "DELTA", "DISCOVER", "SWITCH", "MAESTRO", "CB_NATIONALE", "CONFINOGA", "COFIDIS", "ELECTRON", "CETELEM", "CHINA_UNION_PAY", "MASTERCARD"]
*
* @param string $type
*
@@ -104,7 +101,6 @@ class PaymentCard extends PPModel
/**
* 2 digit card expiry month.
*
*
* @param int $expire_month
*
@@ -152,8 +148,7 @@ class PaymentCard extends PPModel
}
/**
* 4 digit card expiry year
*
* 4 digit card expiry year.
*
* @param int $expire_year
*
@@ -166,7 +161,7 @@ class PaymentCard extends PPModel
}
/**
* 4 digit card expiry year
* 4 digit card expiry year.
*
* @return int
*/
@@ -176,7 +171,7 @@ class PaymentCard extends PPModel
}
/**
* 4 digit card expiry year
* 4 digit card expiry year.
*
* @deprecated Instead use setExpireYear
*
@@ -190,7 +185,7 @@ class PaymentCard extends PPModel
}
/**
* 4 digit card expiry year
* 4 digit card expiry year.
* @deprecated Instead use getExpireYear
*
* @return int
@@ -202,7 +197,6 @@ class PaymentCard extends PPModel
/**
* 2 digit card start month.
*
*
* @param int $start_month
*
@@ -251,7 +245,6 @@ class PaymentCard extends PPModel
/**
* 4 digit card start year.
*
*
* @param int $start_year
*
@@ -299,8 +292,7 @@ class PaymentCard extends PPModel
}
/**
* Card validation code. Only supported when making a Payment but not when saving a payment card for future use.
*
* Card validation code. Only supported when making a Payment, but not when saving a payment card for future use.
*
* @param int $cvv2
*
@@ -313,7 +305,7 @@ class PaymentCard extends PPModel
}
/**
* Card validation code. Only supported when making a Payment but not when saving a payment card for future use.
* Card validation code. Only supported when making a Payment, but not when saving a payment card for future use.
*
* @return int
*/
@@ -324,7 +316,6 @@ class PaymentCard extends PPModel
/**
* Card holder's first name.
*
*
* @param string $first_name
*
@@ -373,7 +364,6 @@ class PaymentCard extends PPModel
/**
* Card holder's last name.
*
*
* @param string $last_name
*
@@ -422,7 +412,6 @@ class PaymentCard extends PPModel
/**
* Billing Address associated with this card.
*
*
* @param \PayPal\Api\Address $billing_address
*
@@ -470,8 +459,7 @@ class PaymentCard extends PPModel
}
/**
* A unique identifier of the customer to whom this card account belongs to. Generated and provided by the facilitator. This is required when creating or using a stored funding instrument in vault.
*
* A unique identifier of the customer to whom this card account belongs. Generated and provided by the facilitator. This is required when creating or using a stored funding instrument in vault.
*
* @param string $external_customer_id
*
@@ -484,7 +472,7 @@ class PaymentCard extends PPModel
}
/**
* A unique identifier of the customer to whom this card account belongs to. Generated and provided by the facilitator. This is required when creating or using a stored funding instrument in vault.
* A unique identifier of the customer to whom this card account belongs. Generated and provided by the facilitator. This is required when creating or using a stored funding instrument in vault.
*
* @return string
*/
@@ -494,7 +482,7 @@ class PaymentCard extends PPModel
}
/**
* A unique identifier of the customer to whom this card account belongs to. Generated and provided by the facilitator. This is required when creating or using a stored funding instrument in vault.
* A unique identifier of the customer to whom this card account belongs. Generated and provided by the facilitator. This is required when creating or using a stored funding instrument in vault.
*
* @deprecated Instead use setExternalCustomerId
*
@@ -508,7 +496,7 @@ class PaymentCard extends PPModel
}
/**
* A unique identifier of the customer to whom this card account belongs to. Generated and provided by the facilitator. This is required when creating or using a stored funding instrument in vault.
* A unique identifier of the customer to whom this card account belongs. Generated and provided by the facilitator. This is required when creating or using a stored funding instrument in vault.
* @deprecated Instead use getExternalCustomerId
*
* @return string
@@ -520,7 +508,7 @@ class PaymentCard extends PPModel
/**
* State of the funding instrument.
* Valid Values: ["EXPIRED", "ACTIVE"]
* Valid Values: ["EXPIRED", "ACTIVE"]
*
* @param string $status
*
@@ -543,8 +531,7 @@ class PaymentCard extends PPModel
}
/**
* Date/Time until this resource can be used fund a payment.
*
* Date/Time until this resource can be used to fund a payment.
*
* @param string $valid_until
*
@@ -557,7 +544,7 @@ class PaymentCard extends PPModel
}
/**
* Date/Time until this resource can be used fund a payment.
* Date/Time until this resource can be used to fund a payment.
*
* @return string
*/
@@ -567,7 +554,7 @@ class PaymentCard extends PPModel
}
/**
* Date/Time until this resource can be used fund a payment.
* Date/Time until this resource can be used to fund a payment.
*
* @deprecated Instead use setValidUntil
*
@@ -581,7 +568,7 @@ class PaymentCard extends PPModel
}
/**
* Date/Time until this resource can be used fund a payment.
* Date/Time until this resource can be used to fund a payment.
* @deprecated Instead use getValidUntil
*
* @return string
@@ -593,9 +580,8 @@ class PaymentCard extends PPModel
/**
* Sets Links
*
*
* @param \PayPal\Api\Links $links
* @param \PayPal\Api\Links[] $links
*
* @return $this
*/
@@ -615,4 +601,34 @@ class PaymentCard extends PPModel
return $this->links;
}
/**
* Append Links to the list.
*
* @param \PayPal\Api\Links $links
* @return $this
*/
public function addLink($links)
{
if (!$this->getLinks()) {
return $this->setLinks(array($links));
} else {
return $this->setLinks(
array_merge($this->getLinks(), array($links))
);
}
}
/**
* Remove Links from the list.
*
* @param \PayPal\Api\Links $links
* @return $this
*/
public function removeLink($links)
{
return $this->setLinks(
array_diff($this->getLinks(), array($links))
);
}
}

View File

@@ -3,7 +3,6 @@
namespace PayPal\Api;
use PayPal\Common\PPModel;
use PayPal\Rest\ApiContext;
/**
* Class PaymentCardToken
@@ -23,7 +22,6 @@ class PaymentCardToken extends PPModel
{
/**
* ID of a previously saved Payment Card resource.
*
*
* @param string $payment_card_id
*
@@ -72,7 +70,6 @@ class PaymentCardToken extends PPModel
/**
* The unique identifier of the payer used when saving this payment card.
*
*
* @param string $external_customer_id
*
@@ -121,7 +118,6 @@ class PaymentCardToken extends PPModel
/**
* Last 4 digits of the card number from the saved card.
*
*
* @param string $last4
*
@@ -145,7 +141,7 @@ class PaymentCardToken extends PPModel
/**
* Type of the Card.
* Valid Values: ["VISA", "AMEX", "SOLO", "JCB", "STAR", "DELTA", "DISCOVER", "SWITCH", "MAESTRO", "CB_NATIONALE", "CONFINOGA", "COFIDIS", "ELECTRON", "CETELEM", "CHINA_UNION_PAY", "MASTERCARD"]
* Valid Values: ["VISA", "AMEX", "SOLO", "JCB", "STAR", "DELTA", "DISCOVER", "SWITCH", "MAESTRO", "CB_NATIONALE", "CONFINOGA", "COFIDIS", "ELECTRON", "CETELEM", "CHINA_UNION_PAY", "MASTERCARD"]
*
* @param string $type
*
@@ -168,8 +164,7 @@ class PaymentCardToken extends PPModel
}
/**
* card expiry month from the saved card with value 1 - 12
*
* Expiry month from the saved card with value 1 - 12.
*
* @param int $expire_month
*
@@ -182,7 +177,7 @@ class PaymentCardToken extends PPModel
}
/**
* card expiry month from the saved card with value 1 - 12
* Expiry month from the saved card with value 1 - 12.
*
* @return int
*/
@@ -192,7 +187,7 @@ class PaymentCardToken extends PPModel
}
/**
* card expiry month from the saved card with value 1 - 12
* Expiry month from the saved card with value 1 - 12.
*
* @deprecated Instead use setExpireMonth
*
@@ -206,7 +201,7 @@ class PaymentCardToken extends PPModel
}
/**
* card expiry month from the saved card with value 1 - 12
* Expiry month from the saved card with value 1 - 12.
* @deprecated Instead use getExpireMonth
*
* @return int
@@ -217,8 +212,7 @@ class PaymentCardToken extends PPModel
}
/**
* 4 digit card expiry year from the saved card
*
* Four digit expiry year from the saved card, represented as YYYY format.
*
* @param int $expire_year
*
@@ -231,7 +225,7 @@ class PaymentCardToken extends PPModel
}
/**
* 4 digit card expiry year from the saved card
* Four digit expiry year from the saved card, represented as YYYY format.
*
* @return int
*/
@@ -241,7 +235,7 @@ class PaymentCardToken extends PPModel
}
/**
* 4 digit card expiry year from the saved card
* Four digit expiry year from the saved card, represented as YYYY format.
*
* @deprecated Instead use setExpireYear
*
@@ -255,7 +249,7 @@ class PaymentCardToken extends PPModel
}
/**
* 4 digit card expiry year from the saved card
* Four digit expiry year from the saved card, represented as YYYY format.
* @deprecated Instead use getExpireYear
*
* @return int

View File

@@ -0,0 +1,289 @@
<?php
namespace PayPal\Api;
use PayPal\Common\PPModel;
/**
* Class PaymentDefinition
*
* Resource representing payment definition scheduling information.
*
* @package PayPal\Api
*
* @property string id
* @property string name
* @property string type
* @property string frequency_interval
* @property string frequency
* @property string cycles
* @property \PayPal\Api\Currency amount
* @property \PayPal\Api\ChargeModel[] charge_models
*/
class PaymentDefinition extends PPModel
{
/**
* Identifier of the payment_definition. 128 characters max.
*
* @param string $id
*
* @return $this
*/
public function setId($id)
{
$this->id = $id;
return $this;
}
/**
* Identifier of the payment_definition. 128 characters max.
*
* @return string
*/
public function getId()
{
return $this->id;
}
/**
* Name of the payment definition. 128 characters max.
*
* @param string $name
*
* @return $this
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Name of the payment definition. 128 characters max.
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Type of the payment definition. Allowed values: `TRIAL`, `REGULAR`.
*
* @param string $type
*
* @return $this
*/
public function setType($type)
{
$this->type = $type;
return $this;
}
/**
* Type of the payment definition. Allowed values: `TRIAL`, `REGULAR`.
*
* @return string
*/
public function getType()
{
return $this->type;
}
/**
* How frequently the customer should be charged.
*
* @param string $frequency_interval
*
* @return $this
*/
public function setFrequencyInterval($frequency_interval)
{
$this->frequency_interval = $frequency_interval;
return $this;
}
/**
* How frequently the customer should be charged.
*
* @return string
*/
public function getFrequencyInterval()
{
return $this->frequency_interval;
}
/**
* How frequently the customer should be charged.
*
* @deprecated Instead use setFrequencyInterval
*
* @param string $frequency_interval
* @return $this
*/
public function setFrequency_interval($frequency_interval)
{
$this->frequency_interval = $frequency_interval;
return $this;
}
/**
* How frequently the customer should be charged.
* @deprecated Instead use getFrequencyInterval
*
* @return string
*/
public function getFrequency_interval()
{
return $this->frequency_interval;
}
/**
* Frequency of the payment definition offered. Allowed values: `WEEK`, `DAY`, `YEAR`, `MONTH`.
*
* @param string $frequency
*
* @return $this
*/
public function setFrequency($frequency)
{
$this->frequency = $frequency;
return $this;
}
/**
* Frequency of the payment definition offered. Allowed values: `WEEK`, `DAY`, `YEAR`, `MONTH`.
*
* @return string
*/
public function getFrequency()
{
return $this->frequency;
}
/**
* Number of cycles in this payment definition.
*
* @param string $cycles
*
* @return $this
*/
public function setCycles($cycles)
{
$this->cycles = $cycles;
return $this;
}
/**
* Number of cycles in this payment definition.
*
* @return string
*/
public function getCycles()
{
return $this->cycles;
}
/**
* Amount that will be charged at the end of each cycle for this payment definition.
*
* @param \PayPal\Api\Currency $amount
*
* @return $this
*/
public function setAmount($amount)
{
$this->amount = $amount;
return $this;
}
/**
* Amount that will be charged at the end of each cycle for this payment definition.
*
* @return \PayPal\Api\Currency
*/
public function getAmount()
{
return $this->amount;
}
/**
* Array of charge_models for this payment definition.
*
* @param \PayPal\Api\ChargeModel[] $charge_models
*
* @return $this
*/
public function setChargeModels($charge_models)
{
$this->charge_models = $charge_models;
return $this;
}
/**
* Array of charge_models for this payment definition.
*
* @return \PayPal\Api\ChargeModel[]
*/
public function getChargeModels()
{
return $this->charge_models;
}
/**
* Append ChargeModels to the list.
*
* @param \PayPal\Api\ChargeModel $chargeModel
* @return $this
*/
public function addChargeModel($chargeModel)
{
if (!$this->getChargeModels()) {
return $this->setChargeModels(array($chargeModel));
} else {
return $this->setChargeModels(
array_merge($this->getChargeModels(), array($chargeModel))
);
}
}
/**
* Remove ChargeModels from the list.
*
* @param \PayPal\Api\ChargeModel $chargeModel
* @return $this
*/
public function removeChargeModel($chargeModel)
{
return $this->setChargeModels(
array_diff($this->getChargeModels(), array($chargeModel))
);
}
/**
* Array of charge_models for this payment definition.
*
* @deprecated Instead use setChargeModels
*
* @param \PayPal\Api\ChargeModel $charge_models
* @return $this
*/
public function setCharge_models($charge_models)
{
$this->charge_models = $charge_models;
return $this;
}
/**
* Array of charge_models for this payment definition.
* @deprecated Instead use getChargeModels
*
* @return \PayPal\Api\ChargeModel
*/
public function getCharge_models()
{
return $this->charge_models;
}
}

577
lib/PayPal/Api/Plan.php Normal file
View File

@@ -0,0 +1,577 @@
<?php
namespace PayPal\Api;
use PayPal\Common\ResourceModel;
use PayPal\Validation\ArgumentValidator;
use PayPal\Api\PlanList;
use PayPal\Rest\ApiContext;
use PayPal\Transport\PPRestCall;
/**
* Class Plan
*
* Billing plan resource that will be used to create a billing agreement.
*
* @package PayPal\Api
*
* @property string id
* @property string name
* @property string description
* @property string type
* @property string state
* @property string create_time
* @property string update_time
* @property \PayPal\Api\PaymentDefinition[] payment_definitions
* @property \PayPal\Api\Terms[] terms
* @property \PayPal\Api\MerchantPreferences merchant_preferences
* @property \PayPal\Api\Links[] links
*/
class Plan extends ResourceModel
{
/**
* Identifier of the billing plan. 128 characters max.
*
* @param string $id
*
* @return $this
*/
public function setId($id)
{
$this->id = $id;
return $this;
}
/**
* Identifier of the billing plan. 128 characters max.
*
* @return string
*/
public function getId()
{
return $this->id;
}
/**
* Name of the billing plan. 128 characters max.
*
* @param string $name
*
* @return $this
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Name of the billing plan. 128 characters max.
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Description of the billing plan. 128 characters max.
*
* @param string $description
*
* @return $this
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* Description of the billing plan. 128 characters max.
*
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* Type of the billing plan. Allowed values: `FIXED`, `INFINITE`.
*
* @param string $type
*
* @return $this
*/
public function setType($type)
{
$this->type = $type;
return $this;
}
/**
* Type of the billing plan. Allowed values: `FIXED`, `INFINITE`.
*
* @return string
*/
public function getType()
{
return $this->type;
}
/**
* Status of the billing plan. Allowed values: `CREATED`, `ACTIVE`, `INACTIVE`, and `DELETED`.
*
* @param string $state
*
* @return $this
*/
public function setState($state)
{
$this->state = $state;
return $this;
}
/**
* Status of the billing plan. Allowed values: `CREATED`, `ACTIVE`, `INACTIVE`, and `DELETED`.
*
* @return string
*/
public function getState()
{
return $this->state;
}
/**
* Time when the billing plan was created. Format YYYY-MM-DDTimeTimezone, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
*
* @param string $create_time
*
* @return $this
*/
public function setCreateTime($create_time)
{
$this->create_time = $create_time;
return $this;
}
/**
* Time when the billing plan was created. Format YYYY-MM-DDTimeTimezone, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
*
* @return string
*/
public function getCreateTime()
{
return $this->create_time;
}
/**
* Time when the billing plan was created. Format YYYY-MM-DDTimeTimezone, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
*
* @deprecated Instead use setCreateTime
*
* @param string $create_time
* @return $this
*/
public function setCreate_time($create_time)
{
$this->create_time = $create_time;
return $this;
}
/**
* Time when the billing plan was created. Format YYYY-MM-DDTimeTimezone, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
* @deprecated Instead use getCreateTime
*
* @return string
*/
public function getCreate_time()
{
return $this->create_time;
}
/**
* Time when this billing plan was updated. Format YYYY-MM-DDTimeTimezone, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
*
* @param string $update_time
*
* @return $this
*/
public function setUpdateTime($update_time)
{
$this->update_time = $update_time;
return $this;
}
/**
* Time when this billing plan was updated. Format YYYY-MM-DDTimeTimezone, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
*
* @return string
*/
public function getUpdateTime()
{
return $this->update_time;
}
/**
* Time when this billing plan was updated. Format YYYY-MM-DDTimeTimezone, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
*
* @deprecated Instead use setUpdateTime
*
* @param string $update_time
* @return $this
*/
public function setUpdate_time($update_time)
{
$this->update_time = $update_time;
return $this;
}
/**
* Time when this billing plan was updated. Format YYYY-MM-DDTimeTimezone, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
* @deprecated Instead use getUpdateTime
*
* @return string
*/
public function getUpdate_time()
{
return $this->update_time;
}
/**
* Array of payment definitions for this billing plan.
*
* @param \PayPal\Api\PaymentDefinition[] $payment_definitions
*
* @return $this
*/
public function setPaymentDefinitions($payment_definitions)
{
$this->payment_definitions = $payment_definitions;
return $this;
}
/**
* Array of payment definitions for this billing plan.
*
* @return \PayPal\Api\PaymentDefinition[]
*/
public function getPaymentDefinitions()
{
return $this->payment_definitions;
}
/**
* Append PaymentDefinitions to the list.
*
* @param \PayPal\Api\PaymentDefinition $paymentDefinition
* @return $this
*/
public function addPaymentDefinition($paymentDefinition)
{
if (!$this->getPaymentDefinitions()) {
return $this->setPaymentDefinitions(array($paymentDefinition));
} else {
return $this->setPaymentDefinitions(
array_merge($this->getPaymentDefinitions(), array($paymentDefinition))
);
}
}
/**
* Remove PaymentDefinitions from the list.
*
* @param \PayPal\Api\PaymentDefinition $paymentDefinition
* @return $this
*/
public function removePaymentDefinition($paymentDefinition)
{
return $this->setPaymentDefinitions(
array_diff($this->getPaymentDefinitions(), array($paymentDefinition))
);
}
/**
* Array of payment definitions for this billing plan.
*
* @deprecated Instead use setPaymentDefinitions
*
* @param \PayPal\Api\PaymentDefinition $payment_definitions
* @return $this
*/
public function setPayment_definitions($payment_definitions)
{
$this->payment_definitions = $payment_definitions;
return $this;
}
/**
* Array of payment definitions for this billing plan.
* @deprecated Instead use getPaymentDefinitions
*
* @return \PayPal\Api\PaymentDefinition
*/
public function getPayment_definitions()
{
return $this->payment_definitions;
}
/**
* Array of terms for this billing plan.
*
* @param \PayPal\Api\Terms[] $terms
*
* @return $this
*/
public function setTerms($terms)
{
$this->terms = $terms;
return $this;
}
/**
* Array of terms for this billing plan.
*
* @return \PayPal\Api\Terms[]
*/
public function getTerms()
{
return $this->terms;
}
/**
* Append Terms to the list.
*
* @param \PayPal\Api\Terms $terms
* @return $this
*/
public function addTerm($terms)
{
if (!$this->getTerms()) {
return $this->setTerms(array($terms));
} else {
return $this->setTerms(
array_merge($this->getTerms(), array($terms))
);
}
}
/**
* Remove Terms from the list.
*
* @param \PayPal\Api\Terms $terms
* @return $this
*/
public function removeTerm($terms)
{
return $this->setTerms(
array_diff($this->getTerms(), array($terms))
);
}
/**
* Specific preferences such as: set up fee, max fail attempts, autobill amount, and others that are configured for this billing plan.
*
* @param \PayPal\Api\MerchantPreferences $merchant_preferences
*
* @return $this
*/
public function setMerchantPreferences($merchant_preferences)
{
$this->merchant_preferences = $merchant_preferences;
return $this;
}
/**
* Specific preferences such as: set up fee, max fail attempts, autobill amount, and others that are configured for this billing plan.
*
* @return \PayPal\Api\MerchantPreferences
*/
public function getMerchantPreferences()
{
return $this->merchant_preferences;
}
/**
* Specific preferences such as: set up fee, max fail attempts, autobill amount, and others that are configured for this billing plan.
*
* @deprecated Instead use setMerchantPreferences
*
* @param \PayPal\Api\MerchantPreferences $merchant_preferences
* @return $this
*/
public function setMerchant_preferences($merchant_preferences)
{
$this->merchant_preferences = $merchant_preferences;
return $this;
}
/**
* Specific preferences such as: set up fee, max fail attempts, autobill amount, and others that are configured for this billing plan.
* @deprecated Instead use getMerchantPreferences
*
* @return \PayPal\Api\MerchantPreferences
*/
public function getMerchant_preferences()
{
return $this->merchant_preferences;
}
/**
* Sets Links
*
* @param \PayPal\Api\Links[] $links
*
* @return $this
*/
public function setLinks($links)
{
$this->links = $links;
return $this;
}
/**
* Gets Links
*
* @return \PayPal\Api\Links[]
*/
public function getLinks()
{
return $this->links;
}
/**
* Append Links to the list.
*
* @param \PayPal\Api\Links $links
* @return $this
*/
public function addLink($links)
{
if (!$this->getLinks()) {
return $this->setLinks(array($links));
} else {
return $this->setLinks(
array_merge($this->getLinks(), array($links))
);
}
}
/**
* Remove Links from the list.
*
* @param \PayPal\Api\Links $links
* @return $this
*/
public function removeLink($links)
{
return $this->setLinks(
array_diff($this->getLinks(), array($links))
);
}
/**
* Retrieve the details for a particular billing plan by passing the billing plan ID to the request URI.
*
* @param string $planId
* @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param PPRestCall $restCall is the Rest Call Service that is used to make rest calls
* @return Plan
*/
public static function get($planId, $apiContext = null, $restCall = null)
{
ArgumentValidator::validate($planId, 'planId');
$payLoad = "";
$json = self::executeCall(
"/v1/payments/billing-plans/$planId",
"GET",
$payLoad,
null,
$apiContext,
$restCall
);
$ret = new Plan();
$ret->fromJson($json);
return $ret;
}
/**
* Create a new billing plan by passing the details for the plan, including the plan name, description, and type, to the request URI.
*
* @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param PPRestCall $restCall is the Rest Call Service that is used to make rest calls
* @return Plan
*/
public function create($apiContext = null, $restCall = null)
{
$payLoad = $this->toJSON();
$json = self::executeCall(
"/v1/payments/billing-plans/",
"POST",
$payLoad,
null,
$apiContext,
$restCall
);
$this->fromJson($json);
return $this;
}
/**
* Replace specific fields within a billing plan by passing the ID of the billing plan to the request URI. In addition, pass a patch object in the request JSON that specifies the operation to perform, field to update, and new value for each update.
*
* @param PatchRequest $patchRequest
* @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param PPRestCall $restCall is the Rest Call Service that is used to make rest calls
* @return bool
*/
public function update($patchRequest, $apiContext = null, $restCall = null)
{
ArgumentValidator::validate($this->getId(), "Id");
ArgumentValidator::validate($patchRequest, 'patchRequest');
$payLoad = $patchRequest->toJSON();
self::executeCall(
"/v1/payments/billing-plans/{$this->getId()}",
"PATCH",
$payLoad,
null,
$apiContext,
$restCall
);
return true;
}
/**
* List billing plans according to optional query string parameters specified.
*
* @param array $params
* @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param PPRestCall $restCall is the Rest Call Service that is used to make rest calls
* @return PlanList
*/
public static function all($params, $apiContext = null, $restCall = null)
{
ArgumentValidator::validate($params, 'params');
$payLoad = "";
$allowedParams = array(
'page_size' => 1,
'status' => 1,
'page' => 1,
'total_required' => 1
);
$json = self::executeCall(
"/v1/payments/billing-plans/" . "?" . http_build_query(array_intersect_key($params, $allowedParams)),
"GET",
$payLoad,
null,
$apiContext,
$restCall
);
$ret = new PlanList();
$ret->fromJson($json);
return $ret;
}
}

223
lib/PayPal/Api/PlanList.php Normal file
View File

@@ -0,0 +1,223 @@
<?php
namespace PayPal\Api;
use PayPal\Common\PPModel;
/**
* Class PlanList
*
* Resource representing a list of billing plans with basic information and get link.
*
* @package PayPal\Api
*
* @property \PayPal\Api\Plan[] plans
* @property string total_items
* @property string total_pages
* @property \PayPal\Api\Links[] links
*/
class PlanList extends PPModel
{
/**
* Array of billing plans.
*
* @param \PayPal\Api\Plan[] $plans
*
* @return $this
*/
public function setPlans($plans)
{
$this->plans = $plans;
return $this;
}
/**
* Array of billing plans.
*
* @return \PayPal\Api\Plan[]
*/
public function getPlans()
{
return $this->plans;
}
/**
* Append Plans to the list.
*
* @param \PayPal\Api\Plan $plan
* @return $this
*/
public function addPlan($plan)
{
if (!$this->getPlans()) {
return $this->setPlans(array($plan));
} else {
return $this->setPlans(
array_merge($this->getPlans(), array($plan))
);
}
}
/**
* Remove Plans from the list.
*
* @param \PayPal\Api\Plan $plan
* @return $this
*/
public function removePlan($plan)
{
return $this->setPlans(
array_diff($this->getPlans(), array($plan))
);
}
/**
* Total number of items.
*
* @param string $total_items
*
* @return $this
*/
public function setTotalItems($total_items)
{
$this->total_items = $total_items;
return $this;
}
/**
* Total number of items.
*
* @return string
*/
public function getTotalItems()
{
return $this->total_items;
}
/**
* Total number of items.
*
* @deprecated Instead use setTotalItems
*
* @param string $total_items
* @return $this
*/
public function setTotal_items($total_items)
{
$this->total_items = $total_items;
return $this;
}
/**
* Total number of items.
* @deprecated Instead use getTotalItems
*
* @return string
*/
public function getTotal_items()
{
return $this->total_items;
}
/**
* Total number of pages.
*
* @param string $total_pages
*
* @return $this
*/
public function setTotalPages($total_pages)
{
$this->total_pages = $total_pages;
return $this;
}
/**
* Total number of pages.
*
* @return string
*/
public function getTotalPages()
{
return $this->total_pages;
}
/**
* Total number of pages.
*
* @deprecated Instead use setTotalPages
*
* @param string $total_pages
* @return $this
*/
public function setTotal_pages($total_pages)
{
$this->total_pages = $total_pages;
return $this;
}
/**
* Total number of pages.
* @deprecated Instead use getTotalPages
*
* @return string
*/
public function getTotal_pages()
{
return $this->total_pages;
}
/**
* Sets Links
*
* @param \PayPal\Api\Links[] $links
*
* @return $this
*/
public function setLinks($links)
{
$this->links = $links;
return $this;
}
/**
* Gets Links
*
* @return \PayPal\Api\Links[]
*/
public function getLinks()
{
return $this->links;
}
/**
* Append Links to the list.
*
* @param \PayPal\Api\Links $links
* @return $this
*/
public function addLink($links)
{
if (!$this->getLinks()) {
return $this->setLinks(array($links));
} else {
return $this->setLinks(
array_merge($this->getLinks(), array($links))
);
}
}
/**
* Remove Links from the list.
*
* @param \PayPal\Api\Links $links
* @return $this
*/
public function removeLink($links)
{
return $this->setLinks(
array_diff($this->getLinks(), array($links))
);
}
}

View File

@@ -2,9 +2,8 @@
namespace PayPal\Api;
use PayPal\Common\PPModel;
use PayPal\Common\ResourceModel;
use PayPal\Rest\ApiContext;
use PayPal\Rest\IResource;
use PayPal\Api\Refund;
use PayPal\Transport\PPRestCall;
use PayPal\Validation\ArgumentValidator;
@@ -30,7 +29,7 @@ use PayPal\Validation\ArgumentValidator;
* @property string parent_payment
* @property \PayPal\Api\Links links
*/
class Sale extends PPModel implements IResource
class Sale extends ResourceModel
{
/**
* OAuth Credentials to use for this call
@@ -592,18 +591,22 @@ class Sale extends PPModel implements IResource
*
* @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 PPRestCall $restCall is the Rest Call Service that is used to make rest calls
* @return Sale
*/
public static function get($saleId, $apiContext = null)
public static function get($saleId, $apiContext = null, $restCall = null)
{
ArgumentValidator::validate($saleId, 'saleId');
$payLoad = "";
if ($apiContext == null) {
$apiContext = new ApiContext(self::$credential);
}
$call = new PPRestCall($apiContext);
$json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/payments/sale/$saleId", "GET", $payLoad);
$json = self::executeCall(
"/v1/payments/sale/$saleId",
"GET",
$payLoad,
null,
$apiContext,
$restCall
);
$ret = new Sale();
$ret->fromJson($json);
return $ret;
@@ -614,19 +617,23 @@ class Sale extends PPModel implements IResource
*
* @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 PPRestCall $restCall is the Rest Call Service that is used to make rest calls
* @return Refund
*/
public function refund($refund, $apiContext = null)
public function refund($refund, $apiContext = null, $restCall = null)
{
ArgumentValidator::validate($this->getId(), "Id");
ArgumentValidator::validate($refund, 'refund');
$payLoad = $refund->toJSON();
if ($apiContext == null) {
$apiContext = new ApiContext(self::$credential);
}
$call = new PPRestCall($apiContext);
$json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/payments/sale/{$this->getId()}/refund", "POST", $payLoad);
$json = self::executeCall(
"/v1/payments/sale/{$this->getId()}/refund",
"POST",
$payLoad,
null,
$apiContext,
$restCall
);
$ret = new Refund();
$ret->fromJson($json);
return $ret;

View File

@@ -3,7 +3,6 @@
namespace PayPal\Api;
use PayPal\Common\PPModel;
use PayPal\Rest\ApiContext;
/**
* Class ShippingAddress
@@ -20,7 +19,6 @@ class ShippingAddress extends Address
{
/**
* Address ID assigned in PayPal system.
*
*
* @param string $id
*
@@ -44,7 +42,6 @@ class ShippingAddress extends Address
/**
* Name of the recipient at this address.
*
*
* @param string $recipient_name
*
@@ -93,7 +90,6 @@ class ShippingAddress extends Address
/**
* Default shipping address of the Payer.
*
*
* @param bool $default_address
*

236
lib/PayPal/Api/Terms.php Normal file
View File

@@ -0,0 +1,236 @@
<?php
namespace PayPal\Api;
use PayPal\Common\PPModel;
/**
* Class Terms
*
* Resource representing terms used by the plan.
*
* @package PayPal\Api
*
* @property string id
* @property string type
* @property \PayPal\Api\Currency max_billing_amount
* @property string occurrences
* @property \PayPal\Api\Currency amount_range
* @property string buyer_editable
*/
class Terms extends PPModel
{
/**
* Identifier of the terms. 128 characters max.
*
* @param string $id
*
* @return $this
*/
public function setId($id)
{
$this->id = $id;
return $this;
}
/**
* Identifier of the terms. 128 characters max.
*
* @return string
*/
public function getId()
{
return $this->id;
}
/**
* Term type. Allowed values: `MONTHLY`, `WEEKLY`, `YEARLY`.
*
* @param string $type
*
* @return $this
*/
public function setType($type)
{
$this->type = $type;
return $this;
}
/**
* Term type. Allowed values: `MONTHLY`, `WEEKLY`, `YEARLY`.
*
* @return string
*/
public function getType()
{
return $this->type;
}
/**
* Max Amount associated with this term.
*
* @param \PayPal\Api\Currency $max_billing_amount
*
* @return $this
*/
public function setMaxBillingAmount($max_billing_amount)
{
$this->max_billing_amount = $max_billing_amount;
return $this;
}
/**
* Max Amount associated with this term.
*
* @return \PayPal\Api\Currency
*/
public function getMaxBillingAmount()
{
return $this->max_billing_amount;
}
/**
* Max Amount associated with this term.
*
* @deprecated Instead use setMaxBillingAmount
*
* @param \PayPal\Api\Currency $max_billing_amount
* @return $this
*/
public function setMax_billing_amount($max_billing_amount)
{
$this->max_billing_amount = $max_billing_amount;
return $this;
}
/**
* Max Amount associated with this term.
* @deprecated Instead use getMaxBillingAmount
*
* @return \PayPal\Api\Currency
*/
public function getMax_billing_amount()
{
return $this->max_billing_amount;
}
/**
* How many times money can be pulled during this term.
*
* @param string $occurrences
*
* @return $this
*/
public function setOccurrences($occurrences)
{
$this->occurrences = $occurrences;
return $this;
}
/**
* How many times money can be pulled during this term.
*
* @return string
*/
public function getOccurrences()
{
return $this->occurrences;
}
/**
* Amount_range associated with this term.
*
* @param \PayPal\Api\Currency $amount_range
*
* @return $this
*/
public function setAmountRange($amount_range)
{
$this->amount_range = $amount_range;
return $this;
}
/**
* Amount_range associated with this term.
*
* @return \PayPal\Api\Currency
*/
public function getAmountRange()
{
return $this->amount_range;
}
/**
* Amount_range associated with this term.
*
* @deprecated Instead use setAmountRange
*
* @param \PayPal\Api\Currency $amount_range
* @return $this
*/
public function setAmount_range($amount_range)
{
$this->amount_range = $amount_range;
return $this;
}
/**
* Amount_range associated with this term.
* @deprecated Instead use getAmountRange
*
* @return \PayPal\Api\Currency
*/
public function getAmount_range()
{
return $this->amount_range;
}
/**
* Buyer's ability to edit the amount in this term.
*
* @param string $buyer_editable
*
* @return $this
*/
public function setBuyerEditable($buyer_editable)
{
$this->buyer_editable = $buyer_editable;
return $this;
}
/**
* Buyer's ability to edit the amount in this term.
*
* @return string
*/
public function getBuyerEditable()
{
return $this->buyer_editable;
}
/**
* Buyer's ability to edit the amount in this term.
*
* @deprecated Instead use setBuyerEditable
*
* @param string $buyer_editable
* @return $this
*/
public function setBuyer_editable($buyer_editable)
{
$this->buyer_editable = $buyer_editable;
return $this;
}
/**
* Buyer's ability to edit the amount in this term.
* @deprecated Instead use getBuyerEditable
*
* @return string
*/
public function getBuyer_editable()
{
return $this->buyer_editable;
}
}

View File

@@ -173,7 +173,7 @@ class PPModel
$this->assignValue($k, $arr);
}
} else {
$this->$k = $v;
$this->assignValue($k, $v);
}
}
return $this;

View File

@@ -41,7 +41,9 @@ class PPConfigManager
$configFile = implode(DIRECTORY_SEPARATOR,
array(dirname(__FILE__), "..", "config", "sdk_config.ini"));
}
$this->addConfigFromIni($configFile);
if (file_exists($configFile)) {
$this->addConfigFromIni($configFile);
}
}
/**
@@ -65,7 +67,7 @@ class PPConfigManager
*/
public function addConfigFromIni($fileName)
{
if ($configs = @parse_ini_file($fileName)) {
if ($configs = parse_ini_file($fileName)) {
$this->addConfigs($configs);
}
return $this;

View File

@@ -11,8 +11,8 @@ namespace PayPal\Core;
class PPConstants
{
const SDK_NAME = 'rest-api-sdk-php';
const SDK_VERSION = '0.11.0';
const SDK_NAME = 'PayPal-PHP-SDK';
const SDK_VERSION = '0.14.0';
const REST_SANDBOX_ENDPOINT = "https://api.sandbox.paypal.com/";
const OPENID_REDIRECT_SANDBOX_URL = "https://www.sandbox.paypal.com/webapps/auth/protocol/openidconnect";

View File

@@ -144,7 +144,7 @@ class PPCredentialManager
*/
public function getCredentialObject($userId = null)
{
if ($userId == null) {
if ($userId == null && array_key_exists($this->defaultAccountName, $this->credentialHashmap)) {
$credObj = $this->credentialHashmap[$this->defaultAccountName];
} else if (array_key_exists($userId, $this->credentialHashmap)) {
$credObj = $this->credentialHashmap[$userId];

View File

@@ -107,7 +107,7 @@ class PPHttpConnection
$this->logger->fine($header);
}
$this->logger->fine("Payload : " . $data . "\n");
$this->logger->fine(($data && $data != '' ? "Payload : " . $data : "No Request Payload") . "\n");
//Execute Curl Request
$result = curl_exec($ch);
@@ -144,6 +144,8 @@ class PPHttpConnection
}
//Close the curl request
curl_close($ch);
$this->logger->fine(($result && $result != '' ? "Response : " . $result : "No Response Body") . "\n\n");
//More Exceptions based on HttpStatus Code
if (in_array($httpStatus, self::$retryCodes)) {
$ex = new PPConnectionException(
@@ -151,7 +153,6 @@ class PPHttpConnection
"Got Http response code $httpStatus when accessing {$this->httpConfig->getUrl()}. " .
"Retried $retries times."
);
$this->logger->fine("Response : " . $result . "\n\n");
$ex->setData($result);
throw $ex;
} else if ($httpStatus < 200 || $httpStatus >= 300) {
@@ -160,12 +161,10 @@ class PPHttpConnection
"Got Http response code $httpStatus when accessing {$this->httpConfig->getUrl()}.",
$httpStatus
);
$this->logger->fine("Response : " . $result . "\n\n");
$ex->setData($result);
throw $ex;
}
$this->logger->fine("Response : " . $result . "\n\n");
//Return result object
return $result;

View File

@@ -29,9 +29,9 @@ class ArgumentValidator
) {
//Throw an Exception for string or array
throw new \InvalidArgumentException("$argumentName cannot be null or empty");
} elseif ($argument == null) {
} elseif ($argument === null) {
//Generic Exception
throw new \InvalidArgumentException("$argumentName cannot be null");
}
}
}
}

View File

@@ -1,5 +1,9 @@
PayPal PHP SDK release notes
============================
v0.14.0
----
* Enabled Billing Plans and Agreements APIs
* Renamed SDK name to PayPal-PHP-SDK
v0.13.2
----

View File

@@ -3,12 +3,12 @@ Rest API Samples
This sample project is a simple web app that you can explore to understand what the payment APIs can do for you.
To try out the sample, run `composer update --no-dev` from the rest-api-sdk-php folder and you are all set.
To try out the sample, run `composer update --no-dev` from the PayPal-PHP-SDK folder and you are all set.
The sample comes pre-configured with a test account but in case you need to try them against your account, you must
* Obtain your client id and client secret from the developer portal
* Update the sdk_config.ini file with your new client id and secret.
* Update the bootstrap.php file with your new client id and secret.
If you are looking for a full fledged application that uses the new RESTful APIs, check out the Pizza store sample app at https://github.com/paypal/rest-api-sample-app-php

View File

@@ -0,0 +1,111 @@
<?php
// # Create Billing Agreement with Credit Card as Payment Source
//
// This sample code demonstrate how you can create a billing agreement, as documented here at:
// https://developer.paypal.com/webapps/developer/docs/api/#create-an-agreement
// API used: /v1/payments/billing-agreements
// Retrieving the Plan from the Create Update Sample. This would be used to
// define Plan information to create an agreement. Make sure the plan you are using is in active state.
/** @var Plan $createdPlan */
$createdPlan = require 'UpdatePlan.php';
use PayPal\Api\Agreement;
use PayPal\Api\Plan;
use PayPal\Api\Payer;
use PayPal\Api\ShippingAddress;
use PayPal\Api\PayerInfo;
use PayPal\Api\CreditCard;
use PayPal\Api\FundingInstrument;
/* Create a new instance of Agreement object
{
"name": "DPRP",
"description": "Payment with credit Card ",
"start_date": "2015-06-17T9:45:04Z",
"plan": {
"id": "P-1WJ68935LL406420PUTENA2I"
},
"shipping_address": {
"line1": "111 First Street",
"city": "Saratoga",
"state": "CA",
"postal_code": "95070",
"country_code": "US"
},
"payer": {
"payment_method": "credit_card",
"payer_info": {
"email": "jaypatel512-facilitator@hotmail.com"
},
"funding_instruments": [
{
"credit_card": {
"type": "visa",
"number": "4417119669820331",
"expire_month": "12",
"expire_year": "2017",
"cvv2": "128"
}
}
]
}
}*/
$agreement = new Agreement();
$agreement->setName('DPRP')
->setDescription('Payment with credit Card')
->setStartDate('2015-06-17T9:45:04Z');
// Add Plan ID
// Please note that the plan Id should be only set in this case.
$plan = new Plan();
$plan->setId($createdPlan->getId());
$agreement->setPlan($plan);
// Add Payer
$payer = new Payer();
$payer->setPaymentMethod('credit_card')
->setPayerInfo(new PayerInfo(['email' => 'jaypatel512-facilitator@hotmail.com']));
// Add Credit Card to Funding Instruments
$creditCard = new CreditCard();
$creditCard->setType('visa')
->setNumber('4417119669820331')
->setExpireMonth('12')
->setExpireYear('2017')
->setCvv2('128');
$fundingInstrument = new FundingInstrument();
$fundingInstrument->setCreditCard($creditCard);
$payer->setFundingInstruments(array($fundingInstrument));
//Add Payer to Agreement
$agreement->setPayer($payer);
// Add Shipping Address
$shippingAddress = new ShippingAddress();
$shippingAddress->setLine1('111 First Street')
->setCity('Saratoga')
->setState('CA')
->setPostalCode('95070')
->setCountryCode('US');
$agreement->setShippingAddress($shippingAddress);
// For Sample Purposes Only.
$request = clone $agreement;
// ### Create Agreement
try {
// Please note that as the agreement has not yet activated, we wont be receiving the ID just yet.
$agreement = $agreement->create($apiContext);
} catch (PayPal\Exception\PPConnectionException $ex) {
echo "Exception: " . $ex->getMessage() . PHP_EOL;
var_dump($ex->getData());
exit(1);
}
ResultPrinter::printResult("Created Billing Agreement.", "Agreement", $agreement->getId(), $request, $agreement);
return $agreement;

View File

@@ -0,0 +1,91 @@
<?php
// # Create Billing Agreement with PayPal as Payment Source
//
// This sample code demonstrate how you can create a billing agreement, as documented here at:
// https://developer.paypal.com/webapps/developer/docs/api/#create-an-agreement
// API used: /v1/payments/billing-agreements
// Retrieving the Plan from the Create Update Sample. This would be used to
// define Plan information to create an agreement. Make sure the plan you are using is in active state.
/** @var Plan $createdPlan */
$createdPlan = require 'UpdatePlan.php';
use PayPal\Api\Agreement;
use PayPal\Api\Plan;
use PayPal\Api\Payer;
use PayPal\Api\ShippingAddress;
/* Create a new instance of Agreement object
{
"name": "Base Agreement",
"description": "Basic agreement",
"start_date": "2015-06-17T9:45:04Z",
"plan": {
"id": "P-1WJ68935LL406420PUTENA2I"
},
"payer": {
"payment_method": "paypal"
},
"shipping_address": {
"line1": "111 First Street",
"city": "Saratoga",
"state": "CA",
"postal_code": "95070",
"country_code": "US"
}
}*/
$agreement = new Agreement();
$agreement->setName('Base Agreement')
->setDescription('Basic Agreement')
->setStartDate('2015-06-17T9:45:04Z');
// Add Plan ID
// Please note that the plan Id should be only set in this case.
$plan = new Plan();
$plan->setId($createdPlan->getId());
$agreement->setPlan($plan);
// Add Payer
$payer = new Payer();
$payer->setPaymentMethod('paypal');
$agreement->setPayer($payer);
// Add Shipping Address
$shippingAddress = new ShippingAddress();
$shippingAddress->setLine1('111 First Street')
->setCity('Saratoga')
->setState('CA')
->setPostalCode('95070')
->setCountryCode('US');
$agreement->setShippingAddress($shippingAddress);
// For Sample Purposes Only.
$request = clone $agreement;
// ### Create Agreement
try {
// Please note that as the agreement has not yet activated, we wont be receiving the ID just yet.
$agreement = $agreement->create($apiContext);
// ### Get redirect url
// The API response provides the url that you must redirect
// the buyer to. Retrieve the url from the $agreement->getLinks()
// method
foreach ($agreement->getLinks() as $link) {
if ($link->getRel() == 'approval_url') {
$approvalUrl = $link->getHref();
break;
}
}
} catch (PayPal\Exception\PPConnectionException $ex) {
echo "Exception: " . $ex->getMessage() . PHP_EOL;
var_dump($ex->getData());
exit(1);
}
ResultPrinter::printResult("Created Billing Agreement. Please visit the URL to Approve.", "Agreement", "<a href='$approvalUrl' >$approvalUrl</a>", $request, $agreement);
return $agreement;

View File

@@ -0,0 +1,72 @@
<?php
// # Create Plan Sample
//
// This sample code demonstrate how you can create a billing plan, as documented here at:
// https://developer.paypal.com/webapps/developer/docs/api/#create-a-plan
// API used: /v1/payments/billing-plans
require __DIR__ . '/../bootstrap.php';
use PayPal\Api\Plan;
use PayPal\Api\PaymentDefinition;
use PayPal\Api\MerchantPreferences;
use PayPal\Api\Currency;
use PayPal\Api\ChargeModel;
// Create a new instance of Plan object
$plan = new Plan();
// # Basic Information
// Fill up the basic information that is required for the plan
$plan->setName('T-Shirt of the Month Club Plan')
->setDescription('Template creation.')
->setType('fixed');
// # Payment definitions for this billing plan.
$paymentDefinition = new PaymentDefinition();
// The possible values for such setters are mentioned in the setter method documentation.
// Just open the class file. e.g. lib/PayPal/Api/PaymentDefinition.php and look for setFrequency method.
// You should be able to see the acceptable values in the comments.
$paymentDefinition->setName('Regular Payments')
->setType('REGULAR')
->setFrequency('Month')
->setFrequencyInterval("2")
->setCycles("12")
->setAmount(new Currency(['value' => '100', 'currency' => 'USD']));
// Charge Models
$chargeModel = new ChargeModel();
$chargeModel->setType('SHIPPING')
->setAmount(new Currency(['value' => '10', 'currency' => 'USD']));
$paymentDefinition->setChargeModels(array($chargeModel));
$merchantPreferences = new MerchantPreferences();
$baseUrl = getBaseUrl();
$merchantPreferences->setReturnUrl("$baseUrl/ExecuteAgreement.php?success=true")
->setCancelUrl("$baseUrl/ExecuteAgreement.php?success=false")
->setAutoBillAmount("YES")
->setInitialFailAmountAction("CONTINUE")
->setMaxFailAttempts("0")
->setSetupFee(new Currency(['value' => '1', 'currency' => 'USD']));
$plan->setPaymentDefinitions(array($paymentDefinition));
$plan->setMerchantPreferences($merchantPreferences);
// For Sample Purposes Only.
$request = clone $plan;
// ### Create Plan
try {
$output = $plan->create($apiContext);
} catch (PayPal\Exception\PPConnectionException $ex) {
echo "Exception: " . $ex->getMessage() . PHP_EOL;
var_dump($ex->getData());
exit(1);
}
ResultPrinter::printResult("Created Plan", "Plan", $output->getId(), $request, $output);
return $output;

View File

@@ -0,0 +1,22 @@
<?php
require __DIR__ . '/../bootstrap.php';
session_start();
if (isset($_GET['success']) && $_GET['success'] == 'true') {
$token = $_GET['token'];
$agreement = new \PayPal\Api\Agreement();
try {
$agreement->execute($token, $apiContext);
} catch (PayPal\Exception\PPConnectionException $ex) {
echo "Exception: " . $ex->getMessage() . PHP_EOL;
var_dump($ex->getData());
exit(1);
}
ResultPrinter::printResult("Executed an Agreement", "Agreement", $agreement->getId(), $_GET['token'], $agreement);
} else {
ResultPrinter::printResult("User Cancelled the Approval", null);
}

View File

@@ -0,0 +1,25 @@
<?php
// # Get Billing Agreement Sample
//
// This sample code demonstrate how you can get a billing agreement, as documented here at:
// https://developer.paypal.com/webapps/developer/docs/api/#retrieve-an-agreement
// API used: /v1/payments/billing-agreements/<Agreement-Id>
// Retrieving the Agreement object from Create Agreement From Credit Card Sample
/** @var Agreement $createdAgreement */
$createdAgreement = require 'CreateBillingAgreementWithCreditCard.php';
use PayPal\Api\Agreement;
try {
$agreement = Agreement::get($createdAgreement->getId(), $apiContext);
} catch (PayPal\Exception\PPConnectionException $ex) {
echo "Exception: " . $ex->getMessage() . PHP_EOL;
var_dump($ex->getData());
exit(1);
}
ResultPrinter::printResult("Retrieved an Agreement", "Agreement", $agreement->getId(), $createdAgreement->getId(), $agreement);
return $agreement;

View File

@@ -0,0 +1,25 @@
<?php
// # Get Plan Sample
//
// This sample code demonstrate how you can get a billing plan, as documented here at:
// https://developer.paypal.com/webapps/developer/docs/api/#retrieve-a-plan
// API used: /v1/payments/billing-plans
// Retrieving the Plan object from Create Plan Sample
/** @var Plan $createdPlan */
$createdPlan = require 'CreatePlan.php';
use PayPal\Api\Plan;
try {
$plan = Plan::get($createdPlan->getId(), $apiContext);
} catch (PayPal\Exception\PPConnectionException $ex) {
echo "Exception: " . $ex->getMessage() . PHP_EOL;
var_dump($ex->getData());
exit(1);
}
ResultPrinter::printResult("Retrieved a Plan", "Plan", $plan->getId(), null, $plan);
return $plan;

View File

@@ -0,0 +1,30 @@
<?php
// # Get List of Plan Sample
//
// This sample code demonstrate how you can get a list of billing plan, as documented here at:
// https://developer.paypal.com/webapps/developer/docs/api/#list-plans
// API used: /v1/payments/billing-plans
// Retrieving the Plan object from Create Plan Sample to demonstrate the List
/** @var Plan $createdPlan */
$createdPlan = require 'CreatePlan.php';
use PayPal\Api\Plan;
try {
// Get the list of all plans
// You can modify different params to change the return list.
// The explanation about each pagination information could be found here
// at https://developer.paypal.com/webapps/developer/docs/api/#list-plans
$params = array('page_size' => '2');
$planList = Plan::all($params, $apiContext);
} catch (PayPal\Exception\PPConnectionException $ex) {
echo "Exception: " . $ex->getMessage() . PHP_EOL;
var_dump($ex->getData());
exit(1);
}
ResultPrinter::printResult("List of Plans", "Plan", null, $params, $planList);
return $planList;

View File

@@ -0,0 +1,35 @@
<?php
// # Reactivate an agreement
//
// This sample code demonstrate how you can reactivate a billing agreement, as documented here at:
// https://developer.paypal.com/webapps/developer/docs/api/#suspend-an-agreement
// API used: /v1/payments/billing-agreements/<Agreement-Id>/suspend
// Retrieving the Agreement object from Suspend Agreement Sample to demonstrate the List
/** @var Agreement $suspendedAgreement */
$suspendedAgreement = require 'SuspendBillingAgreement.php';
use PayPal\Api\Agreement;
use PayPal\Api\AgreementStateDescriptor;
//Create an Agreement State Descriptor, explaining the reason to suspend.
$agreementStateDescriptor = new AgreementStateDescriptor();
$agreementStateDescriptor->setNote("Reactivating the agreement");
try {
$suspendedAgreement->reActivate($agreementStateDescriptor, $apiContext);
// Lets get the updated Agreement Object
$agreement = Agreement::get($suspendedAgreement->getId(), $apiContext);
} catch (PayPal\Exception\PPConnectionException $ex) {
echo "Exception: " . $ex->getMessage() . PHP_EOL;
var_dump($ex->getData());
exit(1);
}
ResultPrinter::printResult("Reactivate the Agreement", "Agreement", $agreement->getId(), $suspendedAgreement, $agreement);
return $agreement;

View File

@@ -0,0 +1,35 @@
<?php
// # Suspend an agreement
//
// This sample code demonstrate how you can suspend a billing agreement, as documented here at:
// https://developer.paypal.com/webapps/developer/docs/api/#suspend-an-agreement
// API used: /v1/payments/billing-agreements/<Agreement-Id>/suspend
// Retrieving the Agreement object from Create Agreement Sample to demonstrate the List
/** @var Agreement $createdAgreement */
$createdAgreement = require 'CreateBillingAgreementWithCreditCard.php';
use PayPal\Api\Agreement;
use PayPal\Api\AgreementStateDescriptor;
//Create an Agreement State Descriptor, explaining the reason to suspend.
$agreementStateDescriptor = new AgreementStateDescriptor();
$agreementStateDescriptor->setNote("Suspending the agreement");
try {
$createdAgreement->suspend($agreementStateDescriptor, $apiContext);
// Lets get the updated Agreement Object
$agreement = Agreement::get($createdAgreement->getId(), $apiContext);
} catch (PayPal\Exception\PPConnectionException $ex) {
echo "Exception: " . $ex->getMessage() . PHP_EOL;
var_dump($ex->getData());
exit(1);
}
ResultPrinter::printResult("Suspended the Agreement", "Agreement", $agreement->getId(), $agreementStateDescriptor, $agreement);
return $agreement;

View File

@@ -0,0 +1,47 @@
<?php
// # Update an agreement
//
// This sample code demonstrate how you can update a billing agreement, as documented here at:
// https://developer.paypal.com/webapps/developer/docs/api/#update-an-agreement
// API used: /v1/payments/billing-agreements/<Agreement-Id>
// Retrieving the Agreement object from Create Agreement Sample to demonstrate the List
/** @var Agreement $createdAgreement */
$createdAgreement = require 'CreateBillingAgreementWithCreditCard.php';
use PayPal\Api\Agreement;
use PayPal\Api\PatchRequest;
use PayPal\Api\Patch;
$patch = new Patch();
$patch->setOp('replace')
->setPath('/')
->setValue(json_decode('{
"description": "New Description",
"shipping_address": {
"line1": "2065 Hamilton Ave",
"city": "San Jose",
"state": "CA",
"postal_code": "95125",
"country_code": "US"
}
}'));
$patchRequest = new PatchRequest();
$patchRequest->addPatch($patch);
try {
$createdAgreement->update($patchRequest, $apiContext);
// Lets get the updated Agreement Object
$agreement = Agreement::get($createdAgreement->getId(), $apiContext);
} catch (PayPal\Exception\PPConnectionException $ex) {
echo "Exception: " . $ex->getMessage() . PHP_EOL;
var_dump($ex->getData());
exit(1);
}
ResultPrinter::printResult("Updated the Agreement with new Description and Updated Shipping Address", "Agreement", $agreement->getId(), $patchRequest, $agreement);
return $agreement;

View File

@@ -0,0 +1,45 @@
<?php
// # Update a plan
//
// This sample code demonstrate how you can update a billing plan, as documented here at:
// https://developer.paypal.com/webapps/developer/docs/api/#update-a-plan
// API used: /v1/payments/billing-plans/<Plan-Id>
// ### Making Plan Active
// This example demonstrate how you could activate the Plan.
// Retrieving the Plan object from Create Plan Sample to demonstrate the List
/** @var Plan $createdPlan */
$createdPlan = require 'CreatePlan.php';
use PayPal\Api\Plan;
use PayPal\Api\PatchRequest;
use PayPal\Api\Patch;
use PayPal\Common\PPModel;
try {
$patch = new Patch();
$value = new PPModel('{
"state":"ACTIVE"
}');
$patch->setOp('replace')
->setPath('/')
->setValue($value);
$patchRequest = new PatchRequest();
$patchRequest->addPatch($patch);
$createdPlan->update($patchRequest, $apiContext);
$plan = Plan::get($createdPlan->getId(), $apiContext);
} catch (PayPal\Exception\PPConnectionException $ex) {
echo "Exception: " . $ex->getMessage() . PHP_EOL;
var_dump($ex->getData());
exit(1);
}
ResultPrinter::printResult("Updated the Plan to Active State", "Plan", $plan->getId(), $patchRequest, $plan);
return $plan;

View File

@@ -12,25 +12,80 @@ use PayPal\Api\Payment;
use PayPal\Api\Transaction;
use PayPal\Api\FundingInstrument;
/**
* Helper Class for Printing Results
*
* Class ResultPrinter
*/
class ResultPrinter {
function print_result($title, $objectName, $objectId = null, $output = null)
{
echo "<h3>$title</h3>";
private static $printResultCounter = 0;
if ($objectId) {
echo "<div> Created " . ($objectName ? $objectName : "Object") . " with ID: $objectId</div>";
public static function printResult($title, $objectName, $objectId = null, $request = null, $response = null)
{
if (self::$printResultCounter == 0) {
include "header.html";
echo '<br />
<div class="row"><div class="col-md-2 pull-left"><a href="../index.html"><h4>&#10094;&#10094; Back to Samples</h4></a><br /><br /></div>
<div class="col-md-1 pull-right"><img src="../images/pp_v_rgb.png" height="70" /></div> </div><div class="clearfix visible-xs-block"></div>';
echo '<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">';
}
self::$printResultCounter++;
echo '
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="heading-'.self::$printResultCounter.'">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#step-'. self::$printResultCounter .'" aria-expanded="false" aria-controls="step-'.self::$printResultCounter.'">
'. self::$printResultCounter .'. '. $title .'</a>
</h4>
</div>
<div id="step-'.self::$printResultCounter.'" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading-'. self::$printResultCounter . '">
<div class="panel-body">
';
if ($objectId) {
echo '<div>' . ($objectName ? $objectName : "Object") . " with ID: $objectId </div>";
}
echo '<div class="row hidden-xs hidden-sm hidden-md"><div class="col-md-6"><h4>Request Object</h4>';
self::printObject($request);
echo '</div><div class="col-md-6"><h4>Response Object</h4>';
self::printObject($response);
echo '</div></div>';
echo '<div class="hidden-lg"><ul class="nav nav-tabs" role="tablist">
<li role="presentation" ><a href="#step-'.self::$printResultCounter .'-request" role="tab" data-toggle="tab">Request</a></li>
<li role="presentation" class="active"><a href="#step-'.self::$printResultCounter .'-response" role="tab" data-toggle="tab">Response</a></li>
</ul>
<div class="tab-content">
<div role="tabpanel" class="tab-pane" id="step-'.self::$printResultCounter .'-request"><h4>Request Object</h4>';
self::printObject($request) ;
echo '</div><div role="tabpanel" class="tab-pane active" id="step-'.self::$printResultCounter .'-response"><h4>Response Object</h4>';
self::printObject($response);
echo '</div></div></div></div>
</div>
</div>';
flush();
}
if ($output) {
if (is_a($output, 'PayPal\Common\PPModel')) {
/** @var $output \PayPal\Common\PPModel */
echo "<pre>" . $output->toJSON(128) . "</pre>";
} elseif (is_string($output)) {
echo "<pre>$output</pre>";
protected static function printObject($object)
{
if ($object) {
if (is_a($object, 'PayPal\Common\PPModel')) {
/** @var $object \PayPal\Common\PPModel */
echo '<pre class="prettyprint">' . $object->toJSON(128) . "</pre>";
} elseif (is_string($object)) {
echo "<pre>$object</pre>";
} else {
echo "<pre>";
print_r($object);
echo "</pre>";
}
} else {
echo "<span>No Data</span>";
}
}
echo "<hr />";
}
/**

View File

@@ -6,6 +6,393 @@ f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3
tableOfContents = [
{
"type": "folder",
"data": {
"path": "billing",
"title": "billing"
},
"depth": 1,
"children": [
{
"type": "file",
"data": {
"language": {
"nameMatchers": [{}, ".fbp"],
"pygmentsLexer": "php",
"singleLineComment": ["//"],
"ignorePrefix": "}",
"foldPrefix": "^",
"name": "PHP"
},
"sourcePath": "/Users/japatel/Documents/workspace/Server-SDK/rest-api-sdk-php/sample/billing/CreateBillingAgreementWithCreditCard.php",
"projectPath": "billing/CreateBillingAgreementWithCreditCard.php",
"targetPath": "billing/CreateBillingAgreementWithCreditCard",
"pageTitle": "billing/CreateBillingAgreementWithCreditCard",
"title": "CreateBillingAgreementWithCreditCard"
},
"depth": 2,
"outline": [
{
"type": "heading",
"data": {
"level": 1,
"title": "Create Billing Agreement with Credit Card as Payment Source",
"slug": "create-billing-agreement-with-credit-card-as-payment-source"
},
"depth": 1,
"children": [
{
"type": "heading",
"data": {
"level": 3,
"title": "Create Agreement",
"slug": "create-agreement"
},
"depth": 3
}
]
}
]
}, {
"type": "file",
"data": {
"language": {
"nameMatchers": [{}, ".fbp"],
"pygmentsLexer": "php",
"singleLineComment": ["//"],
"ignorePrefix": "}",
"foldPrefix": "^",
"name": "PHP"
},
"sourcePath": "/Users/japatel/Documents/workspace/Server-SDK/rest-api-sdk-php/sample/billing/CreateBillingAgreementWithPayPal.php",
"projectPath": "billing/CreateBillingAgreementWithPayPal.php",
"targetPath": "billing/CreateBillingAgreementWithPayPal",
"pageTitle": "billing/CreateBillingAgreementWithPayPal",
"title": "CreateBillingAgreementWithPayPal"
},
"depth": 2,
"outline": [
{
"type": "heading",
"data": {
"level": 1,
"title": "Create Billing Agreement with PayPal as Payment Source",
"slug": "create-billing-agreement-with-paypal-as-payment-source"
},
"depth": 1,
"children": [
{
"type": "heading",
"data": {
"level": 3,
"title": "Create Agreement",
"slug": "create-agreement"
},
"depth": 3
}, {
"type": "heading",
"data": {
"level": 3,
"title": "Get redirect url",
"slug": "get-redirect-url"
},
"depth": 3
}
]
}
]
}, {
"type": "file",
"data": {
"language": {
"nameMatchers": [{}, ".fbp"],
"pygmentsLexer": "php",
"singleLineComment": ["//"],
"ignorePrefix": "}",
"foldPrefix": "^",
"name": "PHP"
},
"sourcePath": "/Users/japatel/Documents/workspace/Server-SDK/rest-api-sdk-php/sample/billing/CreatePlan.php",
"projectPath": "billing/CreatePlan.php",
"targetPath": "billing/CreatePlan",
"pageTitle": "billing/CreatePlan",
"title": "CreatePlan"
},
"depth": 2,
"outline": [
{
"type": "heading",
"data": {
"level": 1,
"title": "Create Plan Sample",
"slug": "create-plan-sample"
},
"depth": 1
}, {
"type": "heading",
"data": {
"level": 1,
"title": "Basic Information",
"slug": "basic-information"
},
"depth": 1
}, {
"type": "heading",
"data": {
"level": 1,
"title": "Payment definitions for this billing plan.",
"slug": "payment-definitions-for-this-billing-plan"
},
"depth": 1,
"children": [
{
"type": "heading",
"data": {
"level": 3,
"title": "Create Plan",
"slug": "create-plan"
},
"depth": 3
}
]
}
]
}, {
"type": "file",
"data": {
"language": {
"nameMatchers": [{}, ".fbp"],
"pygmentsLexer": "php",
"singleLineComment": ["//"],
"ignorePrefix": "}",
"foldPrefix": "^",
"name": "PHP"
},
"sourcePath": "/Users/japatel/Documents/workspace/Server-SDK/rest-api-sdk-php/sample/billing/ExecuteAgreement.php",
"projectPath": "billing/ExecuteAgreement.php",
"targetPath": "billing/ExecuteAgreement",
"pageTitle": "billing/ExecuteAgreement",
"title": "ExecuteAgreement"
},
"depth": 2,
"outline": []
}, {
"type": "file",
"data": {
"language": {
"nameMatchers": [{}, ".fbp"],
"pygmentsLexer": "php",
"singleLineComment": ["//"],
"ignorePrefix": "}",
"foldPrefix": "^",
"name": "PHP"
},
"sourcePath": "/Users/japatel/Documents/workspace/Server-SDK/rest-api-sdk-php/sample/billing/GetBillingAgreement.php",
"projectPath": "billing/GetBillingAgreement.php",
"targetPath": "billing/GetBillingAgreement",
"pageTitle": "billing/GetBillingAgreement",
"title": "GetBillingAgreement"
},
"depth": 2,
"outline": [
{
"type": "heading",
"data": {
"level": 1,
"title": "Get Billing Agreement Sample",
"slug": "get-billing-agreement-sample"
},
"depth": 1
}
]
}, {
"type": "file",
"data": {
"language": {
"nameMatchers": [{}, ".fbp"],
"pygmentsLexer": "php",
"singleLineComment": ["//"],
"ignorePrefix": "}",
"foldPrefix": "^",
"name": "PHP"
},
"sourcePath": "/Users/japatel/Documents/workspace/Server-SDK/rest-api-sdk-php/sample/billing/GetPlan.php",
"projectPath": "billing/GetPlan.php",
"targetPath": "billing/GetPlan",
"pageTitle": "billing/GetPlan",
"title": "GetPlan"
},
"depth": 2,
"outline": [
{
"type": "heading",
"data": {
"level": 1,
"title": "Get Plan Sample",
"slug": "get-plan-sample"
},
"depth": 1
}
]
}, {
"type": "file",
"data": {
"language": {
"nameMatchers": [{}, ".fbp"],
"pygmentsLexer": "php",
"singleLineComment": ["//"],
"ignorePrefix": "}",
"foldPrefix": "^",
"name": "PHP"
},
"sourcePath": "/Users/japatel/Documents/workspace/Server-SDK/rest-api-sdk-php/sample/billing/ListPlans.php",
"projectPath": "billing/ListPlans.php",
"targetPath": "billing/ListPlans",
"pageTitle": "billing/ListPlans",
"title": "ListPlans"
},
"depth": 2,
"outline": [
{
"type": "heading",
"data": {
"level": 1,
"title": "Get List of Plan Sample",
"slug": "get-list-of-plan-sample"
},
"depth": 1
}
]
}, {
"type": "file",
"data": {
"language": {
"nameMatchers": [{}, ".fbp"],
"pygmentsLexer": "php",
"singleLineComment": ["//"],
"ignorePrefix": "}",
"foldPrefix": "^",
"name": "PHP"
},
"sourcePath": "/Users/japatel/Documents/workspace/Server-SDK/rest-api-sdk-php/sample/billing/ReactivateBillingAgreement.php",
"projectPath": "billing/ReactivateBillingAgreement.php",
"targetPath": "billing/ReactivateBillingAgreement",
"pageTitle": "billing/ReactivateBillingAgreement",
"title": "ReactivateBillingAgreement"
},
"depth": 2,
"outline": [
{
"type": "heading",
"data": {
"level": 1,
"title": "Reactivate an agreement",
"slug": "reactivate-an-agreement"
},
"depth": 1
}
]
}, {
"type": "file",
"data": {
"language": {
"nameMatchers": [{}, ".fbp"],
"pygmentsLexer": "php",
"singleLineComment": ["//"],
"ignorePrefix": "}",
"foldPrefix": "^",
"name": "PHP"
},
"sourcePath": "/Users/japatel/Documents/workspace/Server-SDK/rest-api-sdk-php/sample/billing/SuspendBillingAgreement.php",
"projectPath": "billing/SuspendBillingAgreement.php",
"targetPath": "billing/SuspendBillingAgreement",
"pageTitle": "billing/SuspendBillingAgreement",
"title": "SuspendBillingAgreement"
},
"depth": 2,
"outline": [
{
"type": "heading",
"data": {
"level": 1,
"title": "Suspend an agreement",
"slug": "suspend-an-agreement"
},
"depth": 1
}
]
}, {
"type": "file",
"data": {
"language": {
"nameMatchers": [{}, ".fbp"],
"pygmentsLexer": "php",
"singleLineComment": ["//"],
"ignorePrefix": "}",
"foldPrefix": "^",
"name": "PHP"
},
"sourcePath": "/Users/japatel/Documents/workspace/Server-SDK/rest-api-sdk-php/sample/billing/UpdateBillingAgreement.php",
"projectPath": "billing/UpdateBillingAgreement.php",
"targetPath": "billing/UpdateBillingAgreement",
"pageTitle": "billing/UpdateBillingAgreement",
"title": "UpdateBillingAgreement"
},
"depth": 2,
"outline": [
{
"type": "heading",
"data": {
"level": 1,
"title": "Update an agreement",
"slug": "update-an-agreement"
},
"depth": 1
}
]
}, {
"type": "file",
"data": {
"language": {
"nameMatchers": [{}, ".fbp"],
"pygmentsLexer": "php",
"singleLineComment": ["//"],
"ignorePrefix": "}",
"foldPrefix": "^",
"name": "PHP"
},
"sourcePath": "/Users/japatel/Documents/workspace/Server-SDK/rest-api-sdk-php/sample/billing/UpdatePlan.php",
"projectPath": "billing/UpdatePlan.php",
"targetPath": "billing/UpdatePlan",
"pageTitle": "billing/UpdatePlan",
"title": "UpdatePlan"
},
"depth": 2,
"outline": [
{
"type": "heading",
"data": {
"level": 1,
"title": "Update a plan",
"slug": "update-a-plan"
},
"depth": 1,
"children": [
{
"type": "heading",
"data": {
"level": 3,
"title": "Making Plan Active",
"slug": "making-plan-active"
},
"depth": 3
}
]
}
]
}
]
}, {
"type": "folder",
"data": {
"path": "invoice",

View File

@@ -0,0 +1,85 @@
<!DOCTYPE html><html lang="en"><head><title>billing/CreateBillingAgreementWithCreditCard</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content="../"><meta name="groc-document-path" content="billing/CreateBillingAgreementWithCreditCard"><meta name="groc-project-path" content="billing/CreateBillingAgreementWithCreditCard.php"><link rel="stylesheet" type="text/css" media="all" href="../assets/style.css"><script type="text/javascript" src="../assets/behavior.js"></script><body><div id="meta"><div class="file-path">billing/CreateBillingAgreementWithCreditCard.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor">&lt;?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="create-billing-agreement-with-credit-card-as-payment-source">Create Billing Agreement with Credit Card as Payment Source</h1>
<p>This sample code demonstrate how you can create a billing agreement, as documented here at:
<a href="https://developer.paypal.com/webapps/developer/docs/api/#create-an-agreement">https://developer.paypal.com/webapps/developer/docs/api/#create-an-agreement</a>
API used: /v1/payments/billing-agreements</p></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Retrieving the Plan from the Create Update Sample. This would be used to
define Plan information to create an agreement. Make sure the plan you are using is in active state.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> Plan $createdPlan */</span>
<span class="hljs-variable">$createdPlan</span> = <span class="hljs-keyword">require</span> <span class="hljs-string">'UpdatePlan.php'</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Agreement</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Plan</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Payer</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">ShippingAddress</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">PayerInfo</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">CreditCard</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">FundingInstrument</span>;
<span class="hljs-comment">/* Create a new instance of Agreement object
{
"name": "DPRP",
"description": "Payment with credit Card ",
"start_date": "2015-06-17T9:45:04Z",
"plan": {
"id": "P-1WJ68935LL406420PUTENA2I"
},
"shipping_address": {
"line1": "111 First Street",
"city": "Saratoga",
"state": "CA",
"postal_code": "95070",
"country_code": "US"
},
"payer": {
"payment_method": "credit_card",
"payer_info": {
"email": "jaypatel512-facilitator@hotmail.com"
},
"funding_instruments": [
{
"credit_card": {
"type": "visa",
"number": "4417119669820331",
"expire_month": "12",
"expire_year": "2017",
"cvv2": "128"
}
}
]
}
}*/</span>
<span class="hljs-variable">$agreement</span> = <span class="hljs-keyword">new</span> Agreement();
<span class="hljs-variable">$agreement</span>-&gt;setName(<span class="hljs-string">'DPRP'</span>)
-&gt;setDescription(<span class="hljs-string">'Payment with credit Card'</span>)
-&gt;setStartDate(<span class="hljs-string">'2015-06-17T9:45:04Z'</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Add Plan ID
Please note that the plan Id should be only set in this case.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$plan</span> = <span class="hljs-keyword">new</span> Plan();
<span class="hljs-variable">$plan</span>-&gt;setId(<span class="hljs-variable">$createdPlan</span>-&gt;getId());
<span class="hljs-variable">$agreement</span>-&gt;setPlan(<span class="hljs-variable">$plan</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Add Payer</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$payer</span> = <span class="hljs-keyword">new</span> Payer();
<span class="hljs-variable">$payer</span>-&gt;setPaymentMethod(<span class="hljs-string">'credit_card'</span>)
-&gt;setPayerInfo(<span class="hljs-keyword">new</span> PayerInfo([<span class="hljs-string">'email'</span> =&gt; <span class="hljs-string">'jaypatel512-facilitator@hotmail.com'</span>]));</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Add Credit Card to Funding Instruments</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$creditCard</span> = <span class="hljs-keyword">new</span> CreditCard();
<span class="hljs-variable">$creditCard</span>-&gt;setType(<span class="hljs-string">'visa'</span>)
-&gt;setNumber(<span class="hljs-string">'4417119669820331'</span>)
-&gt;setExpireMonth(<span class="hljs-string">'12'</span>)
-&gt;setExpireYear(<span class="hljs-string">'2017'</span>)
-&gt;setCvv2(<span class="hljs-string">'128'</span>);
<span class="hljs-variable">$fundingInstrument</span> = <span class="hljs-keyword">new</span> FundingInstrument();
<span class="hljs-variable">$fundingInstrument</span>-&gt;setCreditCard(<span class="hljs-variable">$creditCard</span>);
<span class="hljs-variable">$payer</span>-&gt;setFundingInstruments(<span class="hljs-keyword">array</span>(<span class="hljs-variable">$fundingInstrument</span>));
<span class="hljs-comment">//Add Payer to Agreement</span>
<span class="hljs-variable">$agreement</span>-&gt;setPayer(<span class="hljs-variable">$payer</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Add Shipping Address</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$shippingAddress</span> = <span class="hljs-keyword">new</span> ShippingAddress();
<span class="hljs-variable">$shippingAddress</span>-&gt;setLine1(<span class="hljs-string">'111 First Street'</span>)
-&gt;setCity(<span class="hljs-string">'Saratoga'</span>)
-&gt;setState(<span class="hljs-string">'CA'</span>)
-&gt;setPostalCode(<span class="hljs-string">'95070'</span>)
-&gt;setCountryCode(<span class="hljs-string">'US'</span>);
<span class="hljs-variable">$agreement</span>-&gt;setShippingAddress(<span class="hljs-variable">$shippingAddress</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>For Sample Purposes Only.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$request</span> = <span class="hljs-keyword">clone</span> <span class="hljs-variable">$agreement</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="create-agreement">Create Agreement</h3></div></div></div><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Please note that as the agreement has not yet activated, we wont be receiving the ID just yet.</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$agreement</span> = <span class="hljs-variable">$agreement</span>-&gt;create(<span class="hljs-variable">$apiContext</span>);
} <span class="hljs-keyword">catch</span> (PayPal\<span class="hljs-keyword">Exception</span>\PPConnectionException <span class="hljs-variable">$ex</span>) {
<span class="hljs-keyword">echo</span> <span class="hljs-string">"Exception: "</span> . <span class="hljs-variable">$ex</span>-&gt;getMessage() . PHP_EOL;
var_dump(<span class="hljs-variable">$ex</span>-&gt;getData());
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
}
ResultPrinter::printResult(<span class="hljs-string">"Created Billing Agreement."</span>, <span class="hljs-string">"Agreement"</span>, <span class="hljs-variable">$agreement</span>-&gt;getId(), <span class="hljs-variable">$request</span>, <span class="hljs-variable">$agreement</span>);
<span class="hljs-keyword">return</span> <span class="hljs-variable">$agreement</span>;</div></div></div></div></body></html>

View File

@@ -0,0 +1,65 @@
<!DOCTYPE html><html lang="en"><head><title>billing/CreateBillingAgreementWithPayPal</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content="../"><meta name="groc-document-path" content="billing/CreateBillingAgreementWithPayPal"><meta name="groc-project-path" content="billing/CreateBillingAgreementWithPayPal.php"><link rel="stylesheet" type="text/css" media="all" href="../assets/style.css"><script type="text/javascript" src="../assets/behavior.js"></script><body><div id="meta"><div class="file-path">billing/CreateBillingAgreementWithPayPal.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor">&lt;?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="create-billing-agreement-with-paypal-as-payment-source">Create Billing Agreement with PayPal as Payment Source</h1>
<p>This sample code demonstrate how you can create a billing agreement, as documented here at:
<a href="https://developer.paypal.com/webapps/developer/docs/api/#create-an-agreement">https://developer.paypal.com/webapps/developer/docs/api/#create-an-agreement</a>
API used: /v1/payments/billing-agreements</p></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Retrieving the Plan from the Create Update Sample. This would be used to
define Plan information to create an agreement. Make sure the plan you are using is in active state.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> Plan $createdPlan */</span>
<span class="hljs-variable">$createdPlan</span> = <span class="hljs-keyword">require</span> <span class="hljs-string">'UpdatePlan.php'</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Agreement</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Plan</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Payer</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">ShippingAddress</span>;
<span class="hljs-comment">/* Create a new instance of Agreement object
{
"name": "Base Agreement",
"description": "Basic agreement",
"start_date": "2015-06-17T9:45:04Z",
"plan": {
"id": "P-1WJ68935LL406420PUTENA2I"
},
"payer": {
"payment_method": "paypal"
},
"shipping_address": {
"line1": "111 First Street",
"city": "Saratoga",
"state": "CA",
"postal_code": "95070",
"country_code": "US"
}
}*/</span>
<span class="hljs-variable">$agreement</span> = <span class="hljs-keyword">new</span> Agreement();
<span class="hljs-variable">$agreement</span>-&gt;setName(<span class="hljs-string">'Base Agreement'</span>)
-&gt;setDescription(<span class="hljs-string">'Basic Agreement'</span>)
-&gt;setStartDate(<span class="hljs-string">'2015-06-17T9:45:04Z'</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Add Plan ID
Please note that the plan Id should be only set in this case.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$plan</span> = <span class="hljs-keyword">new</span> Plan();
<span class="hljs-variable">$plan</span>-&gt;setId(<span class="hljs-variable">$createdPlan</span>-&gt;getId());
<span class="hljs-variable">$agreement</span>-&gt;setPlan(<span class="hljs-variable">$plan</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Add Payer</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$payer</span> = <span class="hljs-keyword">new</span> Payer();
<span class="hljs-variable">$payer</span>-&gt;setPaymentMethod(<span class="hljs-string">'paypal'</span>);
<span class="hljs-variable">$agreement</span>-&gt;setPayer(<span class="hljs-variable">$payer</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Add Shipping Address</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$shippingAddress</span> = <span class="hljs-keyword">new</span> ShippingAddress();
<span class="hljs-variable">$shippingAddress</span>-&gt;setLine1(<span class="hljs-string">'111 First Street'</span>)
-&gt;setCity(<span class="hljs-string">'Saratoga'</span>)
-&gt;setState(<span class="hljs-string">'CA'</span>)
-&gt;setPostalCode(<span class="hljs-string">'95070'</span>)
-&gt;setCountryCode(<span class="hljs-string">'US'</span>);
<span class="hljs-variable">$agreement</span>-&gt;setShippingAddress(<span class="hljs-variable">$shippingAddress</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>For Sample Purposes Only.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$request</span> = <span class="hljs-keyword">clone</span> <span class="hljs-variable">$agreement</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="create-agreement">Create Agreement</h3></div></div></div><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Please note that as the agreement has not yet activated, we wont be receiving the ID just yet.</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$agreement</span> = <span class="hljs-variable">$agreement</span>-&gt;create(<span class="hljs-variable">$apiContext</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="get-redirect-url">Get redirect url</h3>
<p>The API response provides the url that you must redirect
the buyer to. Retrieve the url from the $agreement-&gt;getLinks()
method</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-keyword">foreach</span> (<span class="hljs-variable">$agreement</span>-&gt;getLinks() <span class="hljs-keyword">as</span> <span class="hljs-variable">$link</span>) {
<span class="hljs-keyword">if</span> (<span class="hljs-variable">$link</span>-&gt;getRel() == <span class="hljs-string">'approval_url'</span>) {
<span class="hljs-variable">$approvalUrl</span> = <span class="hljs-variable">$link</span>-&gt;getHref();
<span class="hljs-keyword">break</span>;
}
}
} <span class="hljs-keyword">catch</span> (PayPal\<span class="hljs-keyword">Exception</span>\PPConnectionException <span class="hljs-variable">$ex</span>) {
<span class="hljs-keyword">echo</span> <span class="hljs-string">"Exception: "</span> . <span class="hljs-variable">$ex</span>-&gt;getMessage() . PHP_EOL;
var_dump(<span class="hljs-variable">$ex</span>-&gt;getData());
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
}
ResultPrinter::printResult(<span class="hljs-string">"Created Billing Agreement. Please visit the URL to Approve."</span>, <span class="hljs-string">"Agreement"</span>, <span class="hljs-string">"&lt;a href='$approvalUrl' &gt;$approvalUrl&lt;/a&gt;"</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$agreement</span>);
<span class="hljs-keyword">return</span> <span class="hljs-variable">$agreement</span>;</div></div></div></div></body></html>

View File

@@ -0,0 +1,46 @@
<!DOCTYPE html><html lang="en"><head><title>billing/CreatePlan</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content="../"><meta name="groc-document-path" content="billing/CreatePlan"><meta name="groc-project-path" content="billing/CreatePlan.php"><link rel="stylesheet" type="text/css" media="all" href="../assets/style.css"><script type="text/javascript" src="../assets/behavior.js"></script><body><div id="meta"><div class="file-path">billing/CreatePlan.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor">&lt;?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="create-plan-sample">Create Plan Sample</h1>
<p>This sample code demonstrate how you can create a billing plan, as documented here at:
<a href="https://developer.paypal.com/webapps/developer/docs/api/#create-a-plan">https://developer.paypal.com/webapps/developer/docs/api/#create-a-plan</a>
API used: /v1/payments/billing-plans</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">require</span> <span class="hljs-keyword">__DIR__</span> . <span class="hljs-string">'/../bootstrap.php'</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Plan</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">PaymentDefinition</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">MerchantPreferences</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Currency</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">ChargeModel</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Create a new instance of Plan object</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$plan</span> = <span class="hljs-keyword">new</span> Plan();</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="basic-information">Basic Information</h1>
<p>Fill up the basic information that is required for the plan</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$plan</span>-&gt;setName(<span class="hljs-string">'T-Shirt of the Month Club Plan'</span>)
-&gt;setDescription(<span class="hljs-string">'Template creation.'</span>)
-&gt;setType(<span class="hljs-string">'fixed'</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="payment-definitions-for-this-billing-plan">Payment definitions for this billing plan.</h1></div></div></div><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-variable">$paymentDefinition</span> = <span class="hljs-keyword">new</span> PaymentDefinition();</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>The possible values for such setters are mentioned in the setter method documentation.
Just open the class file. e.g. lib/PayPal/Api/PaymentDefinition.php and look for setFrequency method.
You should be able to see the acceptable values in the comments.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$paymentDefinition</span>-&gt;setName(<span class="hljs-string">'Regular Payments'</span>)
-&gt;setType(<span class="hljs-string">'REGULAR'</span>)
-&gt;setFrequency(<span class="hljs-string">'Month'</span>)
-&gt;setFrequencyInterval(<span class="hljs-string">"2"</span>)
-&gt;setCycles(<span class="hljs-string">"12"</span>)
-&gt;setAmount(<span class="hljs-keyword">new</span> Currency([<span class="hljs-string">'value'</span> =&gt; <span class="hljs-string">'100'</span>, <span class="hljs-string">'currency'</span> =&gt; <span class="hljs-string">'USD'</span>]));</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Charge Models</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$chargeModel</span> = <span class="hljs-keyword">new</span> ChargeModel();
<span class="hljs-variable">$chargeModel</span>-&gt;setType(<span class="hljs-string">'SHIPPING'</span>)
-&gt;setAmount(<span class="hljs-keyword">new</span> Currency([<span class="hljs-string">'value'</span> =&gt; <span class="hljs-string">'10'</span>, <span class="hljs-string">'currency'</span> =&gt; <span class="hljs-string">'USD'</span>]));
<span class="hljs-variable">$paymentDefinition</span>-&gt;setChargeModels(<span class="hljs-keyword">array</span>(<span class="hljs-variable">$chargeModel</span>));
<span class="hljs-variable">$merchantPreferences</span> = <span class="hljs-keyword">new</span> MerchantPreferences();
<span class="hljs-variable">$baseUrl</span> = getBaseUrl();
<span class="hljs-variable">$merchantPreferences</span>-&gt;setReturnUrl(<span class="hljs-string">"$baseUrl/ExecuteAgreement.php?success=true"</span>)
-&gt;setCancelUrl(<span class="hljs-string">"$baseUrl/ExecuteAgreement.php?success=false"</span>)
-&gt;setAutoBillAmount(<span class="hljs-string">"YES"</span>)
-&gt;setInitialFailAmountAction(<span class="hljs-string">"CONTINUE"</span>)
-&gt;setMaxFailAttempts(<span class="hljs-string">"0"</span>)
-&gt;setSetupFee(<span class="hljs-keyword">new</span> Currency([<span class="hljs-string">'value'</span> =&gt; <span class="hljs-string">'1'</span>, <span class="hljs-string">'currency'</span> =&gt; <span class="hljs-string">'USD'</span>]));
<span class="hljs-variable">$plan</span>-&gt;setPaymentDefinitions(<span class="hljs-keyword">array</span>(<span class="hljs-variable">$paymentDefinition</span>));
<span class="hljs-variable">$plan</span>-&gt;setMerchantPreferences(<span class="hljs-variable">$merchantPreferences</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>For Sample Purposes Only.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$request</span> = <span class="hljs-keyword">clone</span> <span class="hljs-variable">$plan</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="create-plan">Create Plan</h3></div></div></div><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
<span class="hljs-variable">$output</span> = <span class="hljs-variable">$plan</span>-&gt;create(<span class="hljs-variable">$apiContext</span>);
} <span class="hljs-keyword">catch</span> (PayPal\<span class="hljs-keyword">Exception</span>\PPConnectionException <span class="hljs-variable">$ex</span>) {
<span class="hljs-keyword">echo</span> <span class="hljs-string">"Exception: "</span> . <span class="hljs-variable">$ex</span>-&gt;getMessage() . PHP_EOL;
var_dump(<span class="hljs-variable">$ex</span>-&gt;getData());
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
}
ResultPrinter::printResult(<span class="hljs-string">"Created Plan"</span>, <span class="hljs-string">"Plan"</span>, <span class="hljs-variable">$output</span>-&gt;getId(), <span class="hljs-variable">$request</span>, <span class="hljs-variable">$output</span>);
<span class="hljs-keyword">return</span> <span class="hljs-variable">$output</span>;</div></div></div></div></body></html>

View File

@@ -0,0 +1,22 @@
<!DOCTYPE html><html lang="en"><head><title>billing/ExecuteAgreement</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content="../"><meta name="groc-document-path" content="billing/ExecuteAgreement"><meta name="groc-project-path" content="billing/ExecuteAgreement.php"><link rel="stylesheet" type="text/css" media="all" href="../assets/style.css"><script type="text/javascript" src="../assets/behavior.js"></script><body><div id="meta"><div class="file-path">billing/ExecuteAgreement.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor">&lt;?php</span>
<span class="hljs-keyword">require</span> <span class="hljs-keyword">__DIR__</span> . <span class="hljs-string">'/../bootstrap.php'</span>;
session_start();
<span class="hljs-keyword">if</span> (<span class="hljs-keyword">isset</span>(<span class="hljs-variable">$_GET</span>[<span class="hljs-string">'success'</span>]) &amp;&amp; <span class="hljs-variable">$_GET</span>[<span class="hljs-string">'success'</span>] == <span class="hljs-string">'true'</span>) {
<span class="hljs-variable">$token</span> = <span class="hljs-variable">$_GET</span>[<span class="hljs-string">'token'</span>];
<span class="hljs-variable">$agreement</span> = <span class="hljs-keyword">new</span> \PayPal\Api\Agreement();
<span class="hljs-keyword">try</span> {
<span class="hljs-variable">$agreement</span>-&gt;execute(<span class="hljs-variable">$token</span>, <span class="hljs-variable">$apiContext</span>);
} <span class="hljs-keyword">catch</span> (PayPal\<span class="hljs-keyword">Exception</span>\PPConnectionException <span class="hljs-variable">$ex</span>) {
<span class="hljs-keyword">echo</span> <span class="hljs-string">"Exception: "</span> . <span class="hljs-variable">$ex</span>-&gt;getMessage() . PHP_EOL;
var_dump(<span class="hljs-variable">$ex</span>-&gt;getData());
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
}
ResultPrinter::printResult(<span class="hljs-string">"Executed an Agreement"</span>, <span class="hljs-string">"Agreement"</span>, <span class="hljs-variable">$agreement</span>-&gt;getId(), <span class="hljs-variable">$_GET</span>[<span class="hljs-string">'token'</span>], <span class="hljs-variable">$agreement</span>);
} <span class="hljs-keyword">else</span> {
ResultPrinter::printResult(<span class="hljs-string">"User Cancelled the Approval"</span>, <span class="hljs-keyword">null</span>);
}</div></div></div></div></body></html>

View File

@@ -0,0 +1,19 @@
<!DOCTYPE html><html lang="en"><head><title>billing/GetBillingAgreement</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content="../"><meta name="groc-document-path" content="billing/GetBillingAgreement"><meta name="groc-project-path" content="billing/GetBillingAgreement.php"><link rel="stylesheet" type="text/css" media="all" href="../assets/style.css"><script type="text/javascript" src="../assets/behavior.js"></script><body><div id="meta"><div class="file-path">billing/GetBillingAgreement.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor">&lt;?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="get-billing-agreement-sample">Get Billing Agreement Sample</h1>
<p>This sample code demonstrate how you can get a billing agreement, as documented here at:
<a href="https://developer.paypal.com/webapps/developer/docs/api/#retrieve-an-agreement">https://developer.paypal.com/webapps/developer/docs/api/#retrieve-an-agreement</a>
API used: /v1/payments/billing-agreements/<Agreement-Id></p></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Retrieving the Agreement object from Create Agreement From Credit Card Sample</p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> Agreement $createdAgreement */</span>
<span class="hljs-variable">$createdAgreement</span> = <span class="hljs-keyword">require</span> <span class="hljs-string">'CreateBillingAgreementWithCreditCard.php'</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Agreement</span>;
<span class="hljs-keyword">try</span> {
<span class="hljs-variable">$agreement</span> = Agreement::get(<span class="hljs-variable">$createdAgreement</span>-&gt;getId(), <span class="hljs-variable">$apiContext</span>);
} <span class="hljs-keyword">catch</span> (PayPal\<span class="hljs-keyword">Exception</span>\PPConnectionException <span class="hljs-variable">$ex</span>) {
<span class="hljs-keyword">echo</span> <span class="hljs-string">"Exception: "</span> . <span class="hljs-variable">$ex</span>-&gt;getMessage() . PHP_EOL;
var_dump(<span class="hljs-variable">$ex</span>-&gt;getData());
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
}
ResultPrinter::printResult(<span class="hljs-string">"Retrieved an Agreement"</span>, <span class="hljs-string">"Agreement"</span>, <span class="hljs-variable">$agreement</span>-&gt;getId(), <span class="hljs-variable">$createdAgreement</span>-&gt;getId(), <span class="hljs-variable">$agreement</span>);
<span class="hljs-keyword">return</span> <span class="hljs-variable">$agreement</span>;</div></div></div></div></body></html>

View File

@@ -0,0 +1,19 @@
<!DOCTYPE html><html lang="en"><head><title>billing/GetPlan</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content="../"><meta name="groc-document-path" content="billing/GetPlan"><meta name="groc-project-path" content="billing/GetPlan.php"><link rel="stylesheet" type="text/css" media="all" href="../assets/style.css"><script type="text/javascript" src="../assets/behavior.js"></script><body><div id="meta"><div class="file-path">billing/GetPlan.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor">&lt;?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="get-plan-sample">Get Plan Sample</h1>
<p>This sample code demonstrate how you can get a billing plan, as documented here at:
<a href="https://developer.paypal.com/webapps/developer/docs/api/#retrieve-a-plan">https://developer.paypal.com/webapps/developer/docs/api/#retrieve-a-plan</a>
API used: /v1/payments/billing-plans</p></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Retrieving the Plan object from Create Plan Sample</p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> Plan $createdPlan */</span>
<span class="hljs-variable">$createdPlan</span> = <span class="hljs-keyword">require</span> <span class="hljs-string">'CreatePlan.php'</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Plan</span>;
<span class="hljs-keyword">try</span> {
<span class="hljs-variable">$plan</span> = Plan::get(<span class="hljs-variable">$createdPlan</span>-&gt;getId(), <span class="hljs-variable">$apiContext</span>);
} <span class="hljs-keyword">catch</span> (PayPal\<span class="hljs-keyword">Exception</span>\PPConnectionException <span class="hljs-variable">$ex</span>) {
<span class="hljs-keyword">echo</span> <span class="hljs-string">"Exception: "</span> . <span class="hljs-variable">$ex</span>-&gt;getMessage() . PHP_EOL;
var_dump(<span class="hljs-variable">$ex</span>-&gt;getData());
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
}
ResultPrinter::printResult(<span class="hljs-string">"Retrieved a Plan"</span>, <span class="hljs-string">"Plan"</span>, <span class="hljs-variable">$plan</span>-&gt;getId(), <span class="hljs-keyword">null</span>, <span class="hljs-variable">$plan</span>);
<span class="hljs-keyword">return</span> <span class="hljs-variable">$plan</span>;</div></div></div></div></body></html>

View File

@@ -0,0 +1,22 @@
<!DOCTYPE html><html lang="en"><head><title>billing/ListPlans</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content="../"><meta name="groc-document-path" content="billing/ListPlans"><meta name="groc-project-path" content="billing/ListPlans.php"><link rel="stylesheet" type="text/css" media="all" href="../assets/style.css"><script type="text/javascript" src="../assets/behavior.js"></script><body><div id="meta"><div class="file-path">billing/ListPlans.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor">&lt;?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="get-list-of-plan-sample">Get List of Plan Sample</h1>
<p>This sample code demonstrate how you can get a list of billing plan, as documented here at:
<a href="https://developer.paypal.com/webapps/developer/docs/api/#list-plans">https://developer.paypal.com/webapps/developer/docs/api/#list-plans</a>
API used: /v1/payments/billing-plans</p></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Retrieving the Plan object from Create Plan Sample to demonstrate the List</p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> Plan $createdPlan */</span>
<span class="hljs-variable">$createdPlan</span> = <span class="hljs-keyword">require</span> <span class="hljs-string">'CreatePlan.php'</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Plan</span>;
<span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Get the list of all plans
You can modify different params to change the return list.
The explanation about each pagination information could be found here
at <a href="https://developer.paypal.com/webapps/developer/docs/api/#list-plans">https://developer.paypal.com/webapps/developer/docs/api/#list-plans</a></p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$params</span> = <span class="hljs-keyword">array</span>(<span class="hljs-string">'page_size'</span> =&gt; <span class="hljs-string">'2'</span>);
<span class="hljs-variable">$planList</span> = Plan::all(<span class="hljs-variable">$params</span>, <span class="hljs-variable">$apiContext</span>);
} <span class="hljs-keyword">catch</span> (PayPal\<span class="hljs-keyword">Exception</span>\PPConnectionException <span class="hljs-variable">$ex</span>) {
<span class="hljs-keyword">echo</span> <span class="hljs-string">"Exception: "</span> . <span class="hljs-variable">$ex</span>-&gt;getMessage() . PHP_EOL;
var_dump(<span class="hljs-variable">$ex</span>-&gt;getData());
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
}
ResultPrinter::printResult(<span class="hljs-string">"List of Plans"</span>, <span class="hljs-string">"Plan"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$params</span>, <span class="hljs-variable">$planList</span>);
<span class="hljs-keyword">return</span> <span class="hljs-variable">$planList</span>;</div></div></div></div></body></html>

View File

@@ -0,0 +1,26 @@
<!DOCTYPE html><html lang="en"><head><title>billing/ReactivateBillingAgreement</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content="../"><meta name="groc-document-path" content="billing/ReactivateBillingAgreement"><meta name="groc-project-path" content="billing/ReactivateBillingAgreement.php"><link rel="stylesheet" type="text/css" media="all" href="../assets/style.css"><script type="text/javascript" src="../assets/behavior.js"></script><body><div id="meta"><div class="file-path">billing/ReactivateBillingAgreement.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor">&lt;?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="reactivate-an-agreement">Reactivate an agreement</h1>
<p>This sample code demonstrate how you can reactivate a billing agreement, as documented here at:
<a href="https://developer.paypal.com/webapps/developer/docs/api/#suspend-an-agreement">https://developer.paypal.com/webapps/developer/docs/api/#suspend-an-agreement</a>
API used: /v1/payments/billing-agreements/<Agreement-Id>/suspend</p></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Retrieving the Agreement object from Suspend Agreement Sample to demonstrate the List</p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> Agreement $suspendedAgreement */</span>
<span class="hljs-variable">$suspendedAgreement</span> = <span class="hljs-keyword">require</span> <span class="hljs-string">'SuspendBillingAgreement.php'</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Agreement</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">AgreementStateDescriptor</span>;
<span class="hljs-comment">//Create an Agreement State Descriptor, explaining the reason to suspend.</span>
<span class="hljs-variable">$agreementStateDescriptor</span> = <span class="hljs-keyword">new</span> AgreementStateDescriptor();
<span class="hljs-variable">$agreementStateDescriptor</span>-&gt;setNote(<span class="hljs-string">"Reactivating the agreement"</span>);
<span class="hljs-keyword">try</span> {
<span class="hljs-variable">$suspendedAgreement</span>-&gt;reActivate(<span class="hljs-variable">$agreementStateDescriptor</span>, <span class="hljs-variable">$apiContext</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Lets get the updated Agreement Object</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$agreement</span> = Agreement::get(<span class="hljs-variable">$suspendedAgreement</span>-&gt;getId(), <span class="hljs-variable">$apiContext</span>);
} <span class="hljs-keyword">catch</span> (PayPal\<span class="hljs-keyword">Exception</span>\PPConnectionException <span class="hljs-variable">$ex</span>) {
<span class="hljs-keyword">echo</span> <span class="hljs-string">"Exception: "</span> . <span class="hljs-variable">$ex</span>-&gt;getMessage() . PHP_EOL;
var_dump(<span class="hljs-variable">$ex</span>-&gt;getData());
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
}
ResultPrinter::printResult(<span class="hljs-string">"Reactivate the Agreement"</span>, <span class="hljs-string">"Agreement"</span>, <span class="hljs-variable">$agreement</span>-&gt;getId(), <span class="hljs-variable">$suspendedAgreement</span>, <span class="hljs-variable">$agreement</span>);
<span class="hljs-keyword">return</span> <span class="hljs-variable">$agreement</span>;</div></div></div></div></body></html>

View File

@@ -0,0 +1,26 @@
<!DOCTYPE html><html lang="en"><head><title>billing/SuspendBillingAgreement</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content="../"><meta name="groc-document-path" content="billing/SuspendBillingAgreement"><meta name="groc-project-path" content="billing/SuspendBillingAgreement.php"><link rel="stylesheet" type="text/css" media="all" href="../assets/style.css"><script type="text/javascript" src="../assets/behavior.js"></script><body><div id="meta"><div class="file-path">billing/SuspendBillingAgreement.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor">&lt;?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="suspend-an-agreement">Suspend an agreement</h1>
<p>This sample code demonstrate how you can suspend a billing agreement, as documented here at:
<a href="https://developer.paypal.com/webapps/developer/docs/api/#suspend-an-agreement">https://developer.paypal.com/webapps/developer/docs/api/#suspend-an-agreement</a>
API used: /v1/payments/billing-agreements/<Agreement-Id>/suspend</p></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Retrieving the Agreement object from Create Agreement Sample to demonstrate the List</p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> Agreement $createdAgreement */</span>
<span class="hljs-variable">$createdAgreement</span> = <span class="hljs-keyword">require</span> <span class="hljs-string">'CreateBillingAgreementWithCreditCard.php'</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Agreement</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">AgreementStateDescriptor</span>;
<span class="hljs-comment">//Create an Agreement State Descriptor, explaining the reason to suspend.</span>
<span class="hljs-variable">$agreementStateDescriptor</span> = <span class="hljs-keyword">new</span> AgreementStateDescriptor();
<span class="hljs-variable">$agreementStateDescriptor</span>-&gt;setNote(<span class="hljs-string">"Suspending the agreement"</span>);
<span class="hljs-keyword">try</span> {
<span class="hljs-variable">$createdAgreement</span>-&gt;suspend(<span class="hljs-variable">$agreementStateDescriptor</span>, <span class="hljs-variable">$apiContext</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Lets get the updated Agreement Object</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$agreement</span> = Agreement::get(<span class="hljs-variable">$createdAgreement</span>-&gt;getId(), <span class="hljs-variable">$apiContext</span>);
} <span class="hljs-keyword">catch</span> (PayPal\<span class="hljs-keyword">Exception</span>\PPConnectionException <span class="hljs-variable">$ex</span>) {
<span class="hljs-keyword">echo</span> <span class="hljs-string">"Exception: "</span> . <span class="hljs-variable">$ex</span>-&gt;getMessage() . PHP_EOL;
var_dump(<span class="hljs-variable">$ex</span>-&gt;getData());
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
}
ResultPrinter::printResult(<span class="hljs-string">"Suspended the Agreement"</span>, <span class="hljs-string">"Agreement"</span>, <span class="hljs-variable">$agreement</span>-&gt;getId(), <span class="hljs-variable">$agreementStateDescriptor</span>, <span class="hljs-variable">$agreement</span>);
<span class="hljs-keyword">return</span> <span class="hljs-variable">$agreement</span>;</div></div></div></div></body></html>

View File

@@ -0,0 +1,38 @@
<!DOCTYPE html><html lang="en"><head><title>billing/UpdateBillingAgreement</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content="../"><meta name="groc-document-path" content="billing/UpdateBillingAgreement"><meta name="groc-project-path" content="billing/UpdateBillingAgreement.php"><link rel="stylesheet" type="text/css" media="all" href="../assets/style.css"><script type="text/javascript" src="../assets/behavior.js"></script><body><div id="meta"><div class="file-path">billing/UpdateBillingAgreement.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor">&lt;?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="update-an-agreement">Update an agreement</h1>
<p>This sample code demonstrate how you can update a billing agreement, as documented here at:
<a href="https://developer.paypal.com/webapps/developer/docs/api/#update-an-agreement">https://developer.paypal.com/webapps/developer/docs/api/#update-an-agreement</a>
API used: /v1/payments/billing-agreements/<Agreement-Id></p></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Retrieving the Agreement object from Create Agreement Sample to demonstrate the List</p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> Agreement $createdAgreement */</span>
<span class="hljs-variable">$createdAgreement</span> = <span class="hljs-keyword">require</span> <span class="hljs-string">'CreateBillingAgreementWithCreditCard.php'</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Agreement</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">PatchRequest</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Patch</span>;
<span class="hljs-variable">$patch</span> = <span class="hljs-keyword">new</span> Patch();
<span class="hljs-variable">$patch</span>-&gt;setOp(<span class="hljs-string">'replace'</span>)
-&gt;setPath(<span class="hljs-string">'/'</span>)
-&gt;setValue(json_decode(<span class="hljs-string">'{
"description": "New Description",
"shipping_address": {
"line1": "2065 Hamilton Ave",
"city": "San Jose",
"state": "CA",
"postal_code": "95125",
"country_code": "US"
}
}'</span>));
<span class="hljs-variable">$patchRequest</span> = <span class="hljs-keyword">new</span> PatchRequest();
<span class="hljs-variable">$patchRequest</span>-&gt;addPatch(<span class="hljs-variable">$patch</span>);
<span class="hljs-keyword">try</span> {
<span class="hljs-variable">$createdAgreement</span>-&gt;update(<span class="hljs-variable">$patchRequest</span>, <span class="hljs-variable">$apiContext</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Lets get the updated Agreement Object</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$agreement</span> = Agreement::get(<span class="hljs-variable">$createdAgreement</span>-&gt;getId(), <span class="hljs-variable">$apiContext</span>);
} <span class="hljs-keyword">catch</span> (PayPal\<span class="hljs-keyword">Exception</span>\PPConnectionException <span class="hljs-variable">$ex</span>) {
<span class="hljs-keyword">echo</span> <span class="hljs-string">"Exception: "</span> . <span class="hljs-variable">$ex</span>-&gt;getMessage() . PHP_EOL;
var_dump(<span class="hljs-variable">$ex</span>-&gt;getData());
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
}
ResultPrinter::printResult(<span class="hljs-string">"Updated the Agreement with new Description and Updated Shipping Address"</span>, <span class="hljs-string">"Agreement"</span>, <span class="hljs-variable">$agreement</span>-&gt;getId(), <span class="hljs-variable">$patchRequest</span>, <span class="hljs-variable">$agreement</span>);
<span class="hljs-keyword">return</span> <span class="hljs-variable">$agreement</span>;</div></div></div></div></body></html>

View File

@@ -0,0 +1,37 @@
<!DOCTYPE html><html lang="en"><head><title>billing/UpdatePlan</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content="../"><meta name="groc-document-path" content="billing/UpdatePlan"><meta name="groc-project-path" content="billing/UpdatePlan.php"><link rel="stylesheet" type="text/css" media="all" href="../assets/style.css"><script type="text/javascript" src="../assets/behavior.js"></script><body><div id="meta"><div class="file-path">billing/UpdatePlan.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor">&lt;?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="update-a-plan">Update a plan</h1>
<p>This sample code demonstrate how you can update a billing plan, as documented here at:
<a href="https://developer.paypal.com/webapps/developer/docs/api/#update-a-plan">https://developer.paypal.com/webapps/developer/docs/api/#update-a-plan</a>
API used: /v1/payments/billing-plans/<Plan-Id></p></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="making-plan-active">Making Plan Active</h3>
<p>This example demonstrate how you could activate the Plan.</p></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Retrieving the Plan object from Create Plan Sample to demonstrate the List</p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> Plan $createdPlan */</span>
<span class="hljs-variable">$createdPlan</span> = <span class="hljs-keyword">require</span> <span class="hljs-string">'CreatePlan.php'</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Plan</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">PatchRequest</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Patch</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Common</span>\<span class="hljs-title">PPModel</span>;
<span class="hljs-keyword">try</span> {
<span class="hljs-variable">$patch</span> = <span class="hljs-keyword">new</span> Patch();
<span class="hljs-variable">$value</span> = <span class="hljs-keyword">new</span> PPModel(<span class="hljs-string">'{
"state":"ACTIVE"
}'</span>);
<span class="hljs-variable">$patch</span>-&gt;setOp(<span class="hljs-string">'replace'</span>)
-&gt;setPath(<span class="hljs-string">'/'</span>)
-&gt;setValue(<span class="hljs-variable">$value</span>);
<span class="hljs-variable">$patchRequest</span> = <span class="hljs-keyword">new</span> PatchRequest();
<span class="hljs-variable">$patchRequest</span>-&gt;addPatch(<span class="hljs-variable">$patch</span>);
<span class="hljs-variable">$createdPlan</span>-&gt;update(<span class="hljs-variable">$patchRequest</span>, <span class="hljs-variable">$apiContext</span>);
<span class="hljs-variable">$plan</span> = Plan::get(<span class="hljs-variable">$createdPlan</span>-&gt;getId(), <span class="hljs-variable">$apiContext</span>);
} <span class="hljs-keyword">catch</span> (PayPal\<span class="hljs-keyword">Exception</span>\PPConnectionException <span class="hljs-variable">$ex</span>) {
<span class="hljs-keyword">echo</span> <span class="hljs-string">"Exception: "</span> . <span class="hljs-variable">$ex</span>-&gt;getMessage() . PHP_EOL;
var_dump(<span class="hljs-variable">$ex</span>-&gt;getData());
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
}
ResultPrinter::printResult(<span class="hljs-string">"Updated the Plan to Active State"</span>, <span class="hljs-string">"Plan"</span>, <span class="hljs-variable">$plan</span>-&gt;getId(), <span class="hljs-variable">$patchRequest</span>, <span class="hljs-variable">$plan</span>);
<span class="hljs-keyword">return</span> <span class="hljs-variable">$plan</span>;</div></div></div></div></body></html>

View File

@@ -30,15 +30,4 @@ notification object
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
}
<span class="hljs-preprocessor">?&gt;</span>
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Cancel Invoice&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div&gt;Cancel Invoice:&lt;/div&gt;
&lt;pre&gt;<span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$invoice</span>-&gt;toJSON(128); <span class="hljs-preprocessor">?&gt;</span>&lt;/pre&gt;
&lt;a href=<span class="hljs-string">'../index.html'</span>&gt;Back&lt;/a&gt;
&lt;/body&gt;
&lt;/html&gt;</div></div></div></div></body></html>
ResultPrinter::printResult(<span class="hljs-string">"Cancel Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>-&gt;getId(), <span class="hljs-variable">$notify</span>, <span class="hljs-keyword">null</span>);</div></div></div></div></body></html>

View File

@@ -69,7 +69,7 @@ detailed breakdown of invoice</p></div></div><div class="code"><div class="wrapp
-&gt;setCity(<span class="hljs-string">"Portland"</span>)
-&gt;setState(<span class="hljs-string">"OR"</span>)
-&gt;setPostalCode(<span class="hljs-string">"97217"</span>)
-&gt;setCountryCode(<span class="hljs-string">"US"</span>);
-&gt;setCountryCode(<span class="hljs-string">"US"</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>For Sample Purposes Only.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$request</span> = <span class="hljs-keyword">clone</span> <span class="hljs-variable">$invoice</span>;
<span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="create-invoice">Create Invoice</h3>
<p>Create an invoice by calling the invoice-&gt;create() method
@@ -79,17 +79,5 @@ with a valid ApiContext (See bootstrap.php for more on <code>ApiContext</code>)<
var_dump(<span class="hljs-variable">$ex</span>-&gt;getData());
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
}
<span class="hljs-preprocessor">?&gt;</span>
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Invoice Creation&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div&gt;
Created Invoice:
<span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$invoice</span>-&gt;getId(); <span class="hljs-preprocessor">?&gt;</span>
&lt;/div&gt;
&lt;pre&gt;<span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$invoice</span>-&gt;toJSON(128); <span class="hljs-preprocessor">?&gt;</span>&lt;/pre&gt;
&lt;a href=<span class="hljs-string">'../index.html'</span>&gt;Back&lt;/a&gt;
&lt;/body&gt;
&lt;/html&gt;</div></div></div></div></body></html>
ResultPrinter::printResult(<span class="hljs-string">"Invoice Creation"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>-&gt;getId(), <span class="hljs-variable">$request</span>, <span class="hljs-variable">$invoice</span>);</div></div></div></div></body></html>

View File

@@ -15,14 +15,5 @@ Invoice ID
var_dump(<span class="hljs-variable">$ex</span>-&gt;getData());
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
}
<span class="hljs-preprocessor">?&gt;</span>
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Lookup invoice details&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div&gt;Retrieving Invoice: <span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$invoiceId</span>;<span class="hljs-preprocessor">?&gt;</span>&lt;/div&gt;
&lt;pre&gt;<span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$invoice</span>-&gt;toJSON(128); <span class="hljs-preprocessor">?&gt;</span>&lt;/pre&gt;
&lt;a href=<span class="hljs-string">'../index.html'</span>&gt;Back&lt;/a&gt;
&lt;/body&gt;
&lt;/html&gt;</div></div></div></div></body></html>
ResultPrinter::printResult(<span class="hljs-string">"Get Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>-&gt;getId(), <span class="hljs-variable">$invoiceId</span>, <span class="hljs-variable">$invoice</span>);</div></div></div></div></body></html>

View File

@@ -13,14 +13,4 @@ Refer the method doc for valid values for keys
var_dump(<span class="hljs-variable">$ex</span>-&gt;getData());
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
}
<span class="hljs-preprocessor">?&gt;</span>
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Lookup invoice history&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div&gt;Got invoices &lt;/div&gt;
&lt;pre&gt;<span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$invoices</span>-&gt;toJSON(128); <span class="hljs-preprocessor">?&gt;</span>&lt;/pre&gt;
&lt;a href=<span class="hljs-string">'../index.html'</span>&gt;Back&lt;/a&gt;
&lt;/body&gt;
&lt;/html&gt;</div></div></div></div></body></html>
ResultPrinter::printResult(<span class="hljs-string">"Lookup Invoice History"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$invoices</span>);</div></div></div></div></body></html>

View File

@@ -29,15 +29,4 @@ notification object
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
}
<span class="hljs-preprocessor">?&gt;</span>
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Remind Invoice&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div&gt;Remind Invoice:&lt;/div&gt;
&lt;pre&gt;<span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$invoice</span>-&gt;toJSON(128); <span class="hljs-preprocessor">?&gt;</span>&lt;/pre&gt;
&lt;a href=<span class="hljs-string">'../index.html'</span>&gt;Back&lt;/a&gt;
&lt;/body&gt;
&lt;/html&gt;</div></div></div></div></body></html>
ResultPrinter::printResult(<span class="hljs-string">"Remind Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$notify</span>, <span class="hljs-keyword">null</span>);</div></div></div></div></body></html>

View File

@@ -18,14 +18,4 @@ with a valid ApiContext (See bootstrap.php for more on <code>ApiContext</code>)<
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
}
<span class="hljs-preprocessor">?&gt;</span>
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Send Invoice&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div&gt;Send Invoice:&lt;/div&gt;
&lt;pre&gt;<span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$invoice</span>-&gt;toJSON(128); <span class="hljs-preprocessor">?&gt;</span>&lt;/pre&gt;
&lt;a href=<span class="hljs-string">'../index.html'</span>&gt;Back&lt;/a&gt;
&lt;/body&gt;
&lt;/html&gt;</div></div></div></div></body></html>
ResultPrinter::printResult(<span class="hljs-string">"Send Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>-&gt;getId(), <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>);</div></div></div></div></body></html>

View File

@@ -12,4 +12,4 @@
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
}
print_result(<span class="hljs-string">"Obtained Access Token From Refresh Token"</span>, <span class="hljs-string">"Access Token"</span>, <span class="hljs-variable">$tokenInfo</span>-&gt;getAccessToken(), <span class="hljs-variable">$tokenInfo</span>);</div></div></div></div></body></html>
ResultPrinter::printResult(<span class="hljs-string">"Obtained Access Token From Refresh Token"</span>, <span class="hljs-string">"Access Token"</span>, <span class="hljs-variable">$tokenInfo</span>-&gt;getAccessToken(), <span class="hljs-keyword">null</span>, <span class="hljs-variable">$tokenInfo</span>);</div></div></div></div></body></html>

View File

@@ -22,4 +22,4 @@ to retreive the information. The short lived access token can be retrieved using
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
}
print_result(<span class="hljs-string">"User Information"</span>, <span class="hljs-string">"User Info"</span>, <span class="hljs-variable">$userInfo</span>-&gt;getUserId(), <span class="hljs-variable">$userInfo</span>-&gt;toJSON(128));</div></div></div></div></body></html>
ResultPrinter::printResult(<span class="hljs-string">"User Information"</span>, <span class="hljs-string">"User Info"</span>, <span class="hljs-variable">$userInfo</span>-&gt;getUserId(), <span class="hljs-variable">$params</span>, <span class="hljs-variable">$userInfo</span>);</div></div></div></div></body></html>

View File

@@ -15,4 +15,4 @@
<span class="hljs-variable">$apiContext</span>
);
print_result(<span class="hljs-string">"Generated the User Consent URL"</span>, <span class="hljs-string">"URL"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-string">'&lt;a href="'</span>. <span class="hljs-variable">$redirectUrl</span> . <span class="hljs-string">'" &gt;Click Here to Obtain User Consent&lt;/a&gt;'</span>);</div></div></div></div></body></html>
ResultPrinter::printResult(<span class="hljs-string">"Generated the User Consent URL"</span>, <span class="hljs-string">"URL"</span>, <span class="hljs-string">'&lt;a href="'</span>. <span class="hljs-variable">$redirectUrl</span> . <span class="hljs-string">'" &gt;Click Here to Obtain User Consent&lt;/a&gt;'</span>, <span class="hljs-variable">$baseUrl</span>, <span class="hljs-variable">$redirectUrl</span>);</div></div></div></div></body></html>

View File

@@ -18,6 +18,6 @@ The user would then able to retrieve the access token by getting the code, which
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
}
print_result(<span class="hljs-string">"Obtained Access Token"</span>, <span class="hljs-string">"Access Token"</span>, <span class="hljs-variable">$accessToken</span>-&gt;getAccessToken(), <span class="hljs-variable">$accessToken</span>);
ResultPrinter::printResult(<span class="hljs-string">"Obtained Access Token"</span>, <span class="hljs-string">"Access Token"</span>, <span class="hljs-variable">$accessToken</span>-&gt;getAccessToken(), <span class="hljs-variable">$_GET</span>[<span class="hljs-string">'code'</span>], <span class="hljs-variable">$accessToken</span>);
}</div></div></div></div></body></html>

File diff suppressed because one or more lines are too long

View File

@@ -17,4 +17,4 @@ that contains the web profile ID.</p></div></div><div class="code"><div class="w
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
}
print_result(<span class="hljs-string">"Deleted Web Profile"</span>, <span class="hljs-string">"Web Profile"</span>, <span class="hljs-variable">$createProfileResponse</span>-&gt;getId());</div></div></div></div></body></html>
ResultPrinter::printResult(<span class="hljs-string">"Deleted Web Profile"</span>, <span class="hljs-string">"Web Profile"</span>, <span class="hljs-variable">$createProfileResponse</span>-&gt;getId(), <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>);</div></div></div></div></body></html>

View File

@@ -16,6 +16,6 @@ that contains the web profile ID.</p></div></div><div class="code"><div class="w
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
}
print_result(<span class="hljs-string">"Get Web Profile"</span>, <span class="hljs-string">"Web Profile"</span>, <span class="hljs-variable">$webProfile</span>-&gt;getId(), <span class="hljs-variable">$webProfile</span>);
ResultPrinter::printResult(<span class="hljs-string">"Get Web Profile"</span>, <span class="hljs-string">"Web Profile"</span>, <span class="hljs-variable">$webProfile</span>-&gt;getId(), <span class="hljs-keyword">null</span>, <span class="hljs-variable">$webProfile</span>);
<span class="hljs-keyword">return</span> <span class="hljs-variable">$webProfile</span>;</div></div></div></div></body></html>

View File

@@ -15,9 +15,9 @@ static <code>get_list</code> method on the WebProfile class.
}
<span class="hljs-variable">$result</span> = <span class="hljs-string">''</span>;
<span class="hljs-keyword">foreach</span> (<span class="hljs-variable">$list</span> <span class="hljs-keyword">as</span> <span class="hljs-variable">$object</span>) {
<span class="hljs-variable">$result</span> .= <span class="hljs-variable">$object</span>-&gt;toJSON(128) . PHP_EOL;
<span class="hljs-variable">$result</span> .= <span class="hljs-variable">$object</span>-&gt;toJSON(<span class="hljs-number">128</span>) . PHP_EOL;
}
print_result(<span class="hljs-string">"Get List of All Web Profiles"</span>, <span class="hljs-string">"Web Profiles"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$result</span>);
ResultPrinter::printResult(<span class="hljs-string">"Get List of All Web Profiles"</span>, <span class="hljs-string">"Web Profiles"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$result</span>);
<span class="hljs-keyword">return</span> <span class="hljs-variable">$list</span>;</div></div></div></div></body></html>
<span class="hljs-keyword">return</span> <span class="hljs-variable">$list</span>;</div></div></div></div></body></html>

View File

@@ -26,4 +26,4 @@ as shown below</p></div></div><div class="code"><div class="wrapper"><span class
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
}
print_result(<span class="hljs-string">"Partially Updated Web Profile"</span>, <span class="hljs-string">"Web Profile"</span>, <span class="hljs-variable">$webProfile</span>-&gt;getId(), <span class="hljs-variable">$webProfile</span>);</div></div></div></div></body></html>
ResultPrinter::printResult(<span class="hljs-string">"Partially Updated Web Profile"</span>, <span class="hljs-string">"Web Profile"</span>, <span class="hljs-variable">$webProfile</span>-&gt;getId(), <span class="hljs-variable">$patches</span>, <span class="hljs-variable">$webProfile</span>);</div></div></div></div></body></html>

View File

@@ -16,4 +16,4 @@ object</p></div></div><div class="code"><div class="wrapper"> <span class
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
}
print_result(<span class="hljs-string">"Updated Web Profile"</span>, <span class="hljs-string">"Web Profile"</span>, <span class="hljs-variable">$updatedWebProfile</span>-&gt;getId(), <span class="hljs-variable">$updatedWebProfile</span>);</div></div></div></div></body></html>
ResultPrinter::printResult(<span class="hljs-string">"Updated Web Profile"</span>, <span class="hljs-string">"Web Profile"</span>, <span class="hljs-variable">$updatedWebProfile</span>-&gt;getId(), <span class="hljs-variable">$webProfile</span>, <span class="hljs-variable">$updatedWebProfile</span>);</div></div></div></div></body></html>

View File

@@ -33,7 +33,7 @@ createAuthorization defined in common.php</p></div></div><div class="code"><div
Captured payment <span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$getCapture</span>-&gt;getParentPayment(); <span class="hljs-preprocessor">?&gt;</span>. Capture Id:
<span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$getCapture</span>-&gt;getId();<span class="hljs-preprocessor">?&gt;</span>
&lt;/div&gt;
&lt;pre&gt;<span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$getCapture</span>-&gt;toJSON(128);<span class="hljs-preprocessor">?&gt;</span>&lt;/pre&gt;
&lt;pre&gt;<span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$getCapture</span>-&gt;toJSON(<span class="hljs-number">128</span>);<span class="hljs-preprocessor">?&gt;</span>&lt;/pre&gt;
&lt;a href=<span class="hljs-string">'../index.html'</span>&gt;Back&lt;/a&gt;
&lt;/body&gt;
&lt;/html&gt;</div></div></div></div></body></html>
&lt;/html&gt;</div></div></div></div></body></html>

View File

@@ -61,7 +61,7 @@ Please note that currently future payments works only with PayPal as a funding i
Created payment:
<span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$payment</span>-&gt;getId();<span class="hljs-preprocessor">?&gt;</span>
&lt;/div&gt;
&lt;pre&gt;<span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$payment</span>-&gt;toJSON(128);<span class="hljs-preprocessor">?&gt;</span>&lt;/pre&gt;
&lt;pre&gt;<span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$payment</span>-&gt;toJSON(<span class="hljs-number">128</span>);<span class="hljs-preprocessor">?&gt;</span>&lt;/pre&gt;
&lt;a href=<span class="hljs-string">'../index.html'</span>&gt;Back&lt;/a&gt;
&lt;/body&gt;
&lt;/html&gt;</div></div></div></div></body></html>
&lt;/html&gt;</div></div></div></div></body></html>

View File

@@ -91,7 +91,7 @@ The return object contains the state.</p></div></div><div class="code"><div clas
Created payment:
<span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$payment</span>-&gt;getId();<span class="hljs-preprocessor">?&gt;</span>
&lt;/div&gt;
&lt;pre&gt;<span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$payment</span>-&gt;toJSON(128);<span class="hljs-preprocessor">?&gt;</span>&lt;/pre&gt;
&lt;pre&gt;<span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$payment</span>-&gt;toJSON(<span class="hljs-number">128</span>);<span class="hljs-preprocessor">?&gt;</span>&lt;/pre&gt;
&lt;a href=<span class="hljs-string">'../index.html'</span>&gt;Back&lt;/a&gt;
&lt;/body&gt;
&lt;/html&gt;</div></div></div></div></body></html>
&lt;/html&gt;</div></div></div></div></body></html>

View File

@@ -9,8 +9,7 @@ API used: /v1/payments/payment</p></div></div><div class="code"><div class="wrap
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Payer</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Payment</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">RedirectUrls</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Transaction</span>;
session_start();</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="payer">Payer</h3>
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Transaction</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="payer">Payer</h3>
<p>A resource representing a Payer that funds a payment
For paypal account payments, set payment method
to &#39;paypal&#39;.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$payer</span> = <span class="hljs-keyword">new</span> Payer();
@@ -77,14 +76,7 @@ method</p></div></div><div class="code"><div class="wrapper"><span class="hljs-k
<span class="hljs-variable">$redirectUrl</span> = <span class="hljs-variable">$link</span>-&gt;getHref();
<span class="hljs-keyword">break</span>;
}
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="redirect-buyer-to-paypal-website">Redirect buyer to PayPal website</h3>
<p>Save the payment id so that you can &#39;complete&#39; the payment
once the buyer approves the payment and is redirected
back to your website.
It is not a great idea to store the payment id
in the session. In a real world app, you may want to
store the payment id in a database.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$_SESSION</span>[<span class="hljs-string">'paymentId'</span>] = <span class="hljs-variable">$payment</span>-&gt;getId();
<span class="hljs-keyword">if</span>(<span class="hljs-keyword">isset</span>(<span class="hljs-variable">$redirectUrl</span>)) {
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="redirect-buyer-to-paypal-website">Redirect buyer to PayPal website</h3></div></div></div><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-keyword">if</span>(<span class="hljs-keyword">isset</span>(<span class="hljs-variable">$redirectUrl</span>)) {
header(<span class="hljs-string">"Location: $redirectUrl"</span>);
<span class="hljs-keyword">exit</span>;
}</div></div></div></div></body></html>

View File

@@ -80,7 +80,7 @@ The return object contains the state.</p></div></div><div class="code"><div clas
Created payment:
<span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$payment</span>-&gt;getId();<span class="hljs-preprocessor">?&gt;</span>
&lt;/div&gt;
&lt;pre&gt;<span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$payment</span>-&gt;toJSON(128);<span class="hljs-preprocessor">?&gt;</span>&lt;/pre&gt;
&lt;pre&gt;<span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$payment</span>-&gt;toJSON(<span class="hljs-number">128</span>);<span class="hljs-preprocessor">?&gt;</span>&lt;/pre&gt;
&lt;a href=<span class="hljs-string">'../index.html'</span>&gt;Back&lt;/a&gt;
&lt;/body&gt;
&lt;/html&gt;</div></div></div></div></body></html>
&lt;/html&gt;</div></div></div></div></body></html>

View File

@@ -8,26 +8,24 @@ API used: POST &#39;/v1/payments/payment/<payment-id>/execute&#39;.</p></div></d
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">ExecutePayment</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Payment</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">PaymentExecution</span>;
session_start();
<span class="hljs-keyword">if</span>(<span class="hljs-keyword">isset</span>(<span class="hljs-variable">$_GET</span>[<span class="hljs-string">'success'</span>]) &amp;&amp; <span class="hljs-variable">$_GET</span>[<span class="hljs-string">'success'</span>] == <span class="hljs-string">'true'</span>) {
</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Get the payment Object by passing paymentId
<span class="hljs-keyword">if</span> (<span class="hljs-keyword">isset</span>(<span class="hljs-variable">$_GET</span>[<span class="hljs-string">'success'</span>]) &amp;&amp; <span class="hljs-variable">$_GET</span>[<span class="hljs-string">'success'</span>] == <span class="hljs-string">'true'</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Get the payment Object by passing paymentId
payment id was previously stored in session in
CreatePaymentUsingPayPal.php</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$paymentId</span> = <span class="hljs-variable">$_SESSION</span>[<span class="hljs-string">'paymentId'</span>];
<span class="hljs-variable">$payment</span> = Payment::get(<span class="hljs-variable">$paymentId</span>, <span class="hljs-variable">$apiContext</span>);
</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>PaymentExecution object includes information necessary
to execute a PayPal account payment.
CreatePaymentUsingPayPal.php</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$paymentId</span> = <span class="hljs-variable">$_GET</span>[<span class="hljs-string">'paymentId'</span>];
<span class="hljs-variable">$payment</span> = Payment::get(<span class="hljs-variable">$paymentId</span>, <span class="hljs-variable">$apiContext</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>PaymentExecution object includes information necessary
to execute a PayPal account payment.
The payer_id is added to the request query parameters
when the user is redirected from paypal back to your site</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$execution</span> = <span class="hljs-keyword">new</span> PaymentExecution();
<span class="hljs-variable">$execution</span>-&gt;setPayerId(<span class="hljs-variable">$_GET</span>[<span class="hljs-string">'PayerID'</span>]);
<span class="hljs-comment">//Execute the payment</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$result</span> = <span class="hljs-variable">$payment</span>-&gt;execute(<span class="hljs-variable">$execution</span>, <span class="hljs-variable">$apiContext</span>);
when the user is redirected from paypal back to your site</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$execution</span> = <span class="hljs-keyword">new</span> PaymentExecution();
<span class="hljs-variable">$execution</span>-&gt;setPayerId(<span class="hljs-variable">$_GET</span>[<span class="hljs-string">'PayerID'</span>]);
<span class="hljs-comment">//Execute the payment</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$result</span> = <span class="hljs-variable">$payment</span>-&gt;execute(<span class="hljs-variable">$execution</span>, <span class="hljs-variable">$apiContext</span>);
<span class="hljs-keyword">echo</span> <span class="hljs-string">"&lt;html&gt;&lt;body&gt;&lt;pre&gt;"</span>;
<span class="hljs-keyword">echo</span> <span class="hljs-variable">$result</span>-&gt;toJSON(128);
<span class="hljs-keyword">echo</span> <span class="hljs-string">"&lt;/pre&gt;&lt;a href='../index.html'&gt;Back&lt;/a&gt;&lt;/body&gt;&lt;/html&gt;"</span>;
<span class="hljs-keyword">echo</span> <span class="hljs-variable">$result</span>-&gt;toJSON(<span class="hljs-number">128</span>);
<span class="hljs-keyword">echo</span> <span class="hljs-string">"&lt;/pre&gt;&lt;a href='../index.html'&gt;Back&lt;/a&gt;&lt;/body&gt;&lt;/html&gt;"</span>;
} <span class="hljs-keyword">else</span> {
<span class="hljs-keyword">echo</span> <span class="hljs-string">"&lt;html&gt;&lt;body&gt;&lt;h1&gt;"</span>;
<span class="hljs-keyword">echo</span> <span class="hljs-string">"User cancelled payment."</span>;
<span class="hljs-keyword">echo</span> <span class="hljs-string">"User cancelled payment."</span>;
<span class="hljs-keyword">echo</span> <span class="hljs-string">"&lt;/h1&gt;&lt;a href='../index.html'&gt;Back&lt;/a&gt;&lt;/body&gt;&lt;/html&gt;"</span>;
}</div></div></div></div></body></html>
}</div></div></div></div></body></html>

View File

@@ -25,7 +25,7 @@ createAuthorization is defined in common.php</p></div></div><div class="code"><d
Retrieved Authorization:
<span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$authorization</span>-&gt;getId();<span class="hljs-preprocessor">?&gt;</span>
&lt;/div&gt;
&lt;pre&gt;<span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$authorization</span>-&gt;toJSON(128);<span class="hljs-preprocessor">?&gt;</span>&lt;/pre&gt;
&lt;pre&gt;<span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$authorization</span>-&gt;toJSON(<span class="hljs-number">128</span>);<span class="hljs-preprocessor">?&gt;</span>&lt;/pre&gt;
&lt;a href=<span class="hljs-string">'../index.html'</span>&gt;Back&lt;/a&gt;
&lt;/body&gt;
&lt;/html&gt;</div></div></div></div></body></html>
&lt;/html&gt;</div></div></div></div></body></html>

View File

@@ -41,7 +41,7 @@ with a valid ApiContext (See bootstrap.php for more on <code>ApiContext</code>)<
Capture Id:
<span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$capture</span>-&gt;getId();<span class="hljs-preprocessor">?&gt;</span>
&lt;/div&gt;
&lt;pre&gt;<span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$capture</span>-&gt;toJSON(128);<span class="hljs-preprocessor">?&gt;</span>&lt;/pre&gt;
&lt;pre&gt;<span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$capture</span>-&gt;toJSON(<span class="hljs-number">128</span>);<span class="hljs-preprocessor">?&gt;</span>&lt;/pre&gt;
&lt;a href=<span class="hljs-string">'../index.html'</span>&gt;Back&lt;/a&gt;
&lt;/body&gt;
&lt;/html&gt;</div></div></div></div></body></html>
&lt;/html&gt;</div></div></div></div></body></html>

View File

@@ -27,7 +27,7 @@ Payment ID
&lt;/head&gt;
&lt;body&gt;
&lt;div&gt;Retrieving Payment ID: <span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$paymentId</span>;<span class="hljs-preprocessor">?&gt;</span>&lt;/div&gt;
&lt;pre&gt;<span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$payment</span>-&gt;toJSON(128);<span class="hljs-preprocessor">?&gt;</span>&lt;/pre&gt;
&lt;pre&gt;<span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$payment</span>-&gt;toJSON(<span class="hljs-number">128</span>);<span class="hljs-preprocessor">?&gt;</span>&lt;/pre&gt;
&lt;a href=<span class="hljs-string">'../index.html'</span>&gt;Back&lt;/a&gt;
&lt;/body&gt;
&lt;/html&gt;</div></div></div></div></body></html>
&lt;/html&gt;</div></div></div></div></body></html>

View File

@@ -26,7 +26,7 @@ Refer the method doc for valid values for keys
&lt;/head&gt;
&lt;body&gt;
&lt;div&gt;Got <span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$payments</span>-&gt;getCount(); <span class="hljs-preprocessor">?&gt;</span> matching payments &lt;/div&gt;
&lt;pre&gt;<span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$payments</span>-&gt;toJSON(128);<span class="hljs-preprocessor">?&gt;</span>&lt;/pre&gt;
&lt;pre&gt;<span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$payments</span>-&gt;toJSON(<span class="hljs-number">128</span>);<span class="hljs-preprocessor">?&gt;</span>&lt;/pre&gt;
&lt;a href=<span class="hljs-string">'../index.html'</span>&gt;Back&lt;/a&gt;
&lt;/body&gt;
&lt;/html&gt;</div></div></div></div></body></html>
&lt;/html&gt;</div></div></div></div></body></html>

View File

@@ -30,8 +30,8 @@ has expired.</p></div></div><div class="code"><div class="wrapper"><span class="
<span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$reauthorization</span>-&gt;getId();<span class="hljs-preprocessor">?&gt;</span>
&lt;/div&gt;
&lt;pre&gt;
<span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$reauthorization</span>-&gt;toJSON(128);<span class="hljs-preprocessor">?&gt;</span>
<span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$reauthorization</span>-&gt;toJSON(<span class="hljs-number">128</span>);<span class="hljs-preprocessor">?&gt;</span>
&lt;/pre&gt;
&lt;a href=<span class="hljs-string">'../index.html'</span>&gt;Back&lt;/a&gt;
&lt;/body&gt;
&lt;/html&gt;</div></div></div></div></body></html>
&lt;/html&gt;</div></div></div></div></body></html>

View File

@@ -46,7 +46,7 @@ PayPal-Request-Id (idempotency) header for this resource</p></div></div><div cla
&lt;/head&gt;
&lt;body&gt;
&lt;div&gt;Refund Capture:&lt;/div&gt;
&lt;pre&gt;<span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$captureRefund</span>-&gt;toJSON(128);<span class="hljs-preprocessor">?&gt;</span>&lt;/pre&gt;
&lt;pre&gt;<span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$captureRefund</span>-&gt;toJSON(<span class="hljs-number">128</span>);<span class="hljs-preprocessor">?&gt;</span>&lt;/pre&gt;
&lt;a href=<span class="hljs-string">'../index.html'</span>&gt;Back&lt;/a&gt;
&lt;/body&gt;
&lt;/html&gt;</div></div></div></div></body></html>
&lt;/html&gt;</div></div></div></div></body></html>

View File

@@ -22,7 +22,7 @@ createAuthorization is defined in common.php</p></div></div><div class="code"><d
&lt;div&gt;
Voided authorization
&lt;/div&gt;
&lt;pre&gt;<span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$voidedAuth</span>-&gt;toJSON(128);<span class="hljs-preprocessor">?&gt;</span>&lt;/pre&gt;
&lt;pre&gt;<span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$voidedAuth</span>-&gt;toJSON(<span class="hljs-number">128</span>);<span class="hljs-preprocessor">?&gt;</span>&lt;/pre&gt;
&lt;a href=<span class="hljs-string">'../index.html'</span>&gt;Back&lt;/a&gt;
&lt;/body&gt;
&lt;/html&gt;</div></div></div></div></body></html>
&lt;/html&gt;</div></div></div></div></body></html>

View File

@@ -22,7 +22,7 @@ transaction from your payment resource.</p></div></div><div class="code"><div cl
&lt;/head&gt;
&lt;body&gt;
&lt;div&gt;Retrieving sale id: <span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$saleId</span>;<span class="hljs-preprocessor">?&gt;</span>&lt;/div&gt;
&lt;pre&gt;<span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$sale</span>-&gt;toJSON(128)<span class="hljs-preprocessor">?&gt;</span>&lt;/pre&gt;
&lt;pre&gt;<span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$sale</span>-&gt;toJSON(<span class="hljs-number">128</span>)<span class="hljs-preprocessor">?&gt;</span>&lt;/pre&gt;
&lt;a href=<span class="hljs-string">'../index.html'</span>&gt;Back&lt;/a&gt;
&lt;/body&gt;
&lt;/html&gt;</div></div></div></div></body></html>
&lt;/html&gt;</div></div></div></div></body></html>

View File

@@ -32,7 +32,7 @@ given sale transaction id.</p></div></div><div class="code"><div class="wrapper"
&lt;/head&gt;
&lt;body&gt;
&lt;div&gt;Refunding sale id: <span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$saleId</span>;<span class="hljs-preprocessor">?&gt;</span>&lt;/div&gt;
&lt;pre&gt;<span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$sale</span>-&gt;toJSON(128);<span class="hljs-preprocessor">?&gt;</span>&lt;/pre&gt;
&lt;pre&gt;<span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$sale</span>-&gt;toJSON(<span class="hljs-number">128</span>);<span class="hljs-preprocessor">?&gt;</span>&lt;/pre&gt;
&lt;a href=<span class="hljs-string">'../index.html'</span>&gt;Back&lt;/a&gt;
&lt;/body&gt;
&lt;/html&gt;</div></div></div></div></body></html>
&lt;/html&gt;</div></div></div></div></body></html>

View File

@@ -31,7 +31,7 @@ in future payments.
&lt;/head&gt;
&lt;body&gt;
&lt;div&gt;Saved a <span class="hljs-keyword">new</span> credit card with id: <span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$card</span>-&gt;getId();<span class="hljs-preprocessor">?&gt;</span>&lt;/div&gt;
&lt;pre&gt;<span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$card</span>-&gt;toJSON(128);<span class="hljs-preprocessor">?&gt;</span>&lt;/pre&gt;
&lt;pre&gt;<span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$card</span>-&gt;toJSON(<span class="hljs-number">128</span>);<span class="hljs-preprocessor">?&gt;</span>&lt;/pre&gt;
&lt;a href=<span class="hljs-string">'../index.html'</span>&gt;Back&lt;/a&gt;
&lt;/body&gt;
&lt;/html&gt;</div></div></div></div></body></html>
&lt;/html&gt;</div></div></div></div></body></html>

View File

@@ -21,7 +21,7 @@ card operation. Use $card-&gt;getId()</p></div></div><div class="code"><div clas
&lt;/head&gt;
&lt;body&gt;
&lt;div&gt;Retrieving saved credit card: <span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$cardId</span>;<span class="hljs-preprocessor">?&gt;</span>&lt;/div&gt;
&lt;pre&gt;<span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$card</span>-&gt;toJSON(128);<span class="hljs-preprocessor">?&gt;</span>&lt;/pre&gt;
&lt;pre&gt;<span class="hljs-preprocessor">&lt;?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$card</span>-&gt;toJSON(<span class="hljs-number">128</span>);<span class="hljs-preprocessor">?&gt;</span>&lt;/pre&gt;
&lt;a href=<span class="hljs-string">'../index.html'</span>&gt;Back&lt;/a&gt;
&lt;/body&gt;
&lt;/html&gt;</div></div></div></div></body></html>
&lt;/html&gt;</div></div></div></div></body></html>

Some files were not shown because too many files have changed in this diff Show More