Removing Dependency from SDK Core Project

- Copied files required for Rest API SDK
- Removed PPApiContext and directly connected APIContext with PPConfigManager
- Removed duplicate data storage of configuration and credentials.
- Code Style Fixes
- Remove build.xml file as it is not required anymore
- Updated the samples
- Updated the documentations
This commit is contained in:
japatel
2014-10-06 11:16:47 -05:00
parent bb7654b0b8
commit 49b80f76af
150 changed files with 10975 additions and 6525 deletions

View File

@@ -128,5 +128,5 @@ There are two kinds of tests that we include in our sdk package. Unit tests, and
* [API Reference](https://developer.paypal.com/webapps/developer/docs/api/)
* [Reporting issues / feature requests] (https://github.com/paypal/rest-api-sdk-php/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

@@ -1,67 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="paypal-rest-sdk-php" basedir="." default="all">
<property name="basedir" value="." />
<property name="release.dir" value="${basedir}/release" />
<property name="output.dir" value="${basedir}/build" />
<property name="phplint.out" value="${output.dir}/phplint.txt" />
<property name="phploc.out" value="${output.dir}/phploc.xml" />
<property name="coverage.dir" value="${output.dir}/coverage" />
<property name="coverage.out" value="${coverage.dir}/junit.xml" />
<property name="clover.out" value="${coverage.dir}/clover.xml" />
<property name="test.dir" value="${output.dir}/test" />
<fileset id="src.files" dir="${basedir}/lib" includes="**/*.php" />
<target name="composer-init" description="Downloads composer.phar if not available locally">
<if>
<available file="composer.phar" />
<then>
<echo>Composer is installed</echo>
</then>
<else>
<echo message="Installing composer" />
<exec command="curl -s http://getcomposer.org/installer | php" />
<exec command="php composer.phar install --dev" />
</else>
</if>
</target>
<target name="phplint">
<delete file="${phplint.out}"/>
<apply executable="php" failonerror="true" output="${phplint.out}" append="true">
<arg value="-l" />
<fileset refid="src.files" />
</apply>
</target>
<target name="phploc">
<exec command="phploc --log-xml ${phploc.out} ." dir="${basedir}/lib" />
</target>
<target name="coverage">
<mkdir dir="${output.dir}/coverage"/>
<exec command="phpunit --coverage-html=${coverage.dir} --coverage-clover=${clover.out} --log-junit=${coverage.out} --exclude-group=PayPal\\Api\\*" />
</target>
<target name="clean" description="Deletes build artifacts">
<delete dir="${output.dir}"/>
<mkdir dir="${output.dir}"/>
</target>
<target name="test" description="Runs test cases">
<exec command="phpunit --testdox-html=${test.dir}/testdox.html --log-junit=${test.dir}/junit.xml"/>
</target>
<!-- Requires phing -->
<target name="convert-test-report" >
<mkdir dir="build/test/report"/>
<phpunitreport infile="${coverage.out}"
format="frames"
todir="build/test/report" />
</target>
<target name="build" depends="test" description="Builds SDK" />
<target name="report" depends="phplint, coverage, phploc" description="Runs code checks and coverage reports" />
<target name="all" depends="clean, test, build, report" description="Do everything" />
</project>

View File

@@ -14,8 +14,7 @@
"require": {
"php": ">=5.3.0",
"ext-curl": "*",
"ext-json": "*",
"paypal/sdk-core-php": "2.5.*"
"ext-json": "*"
},
"require-dev": {
"phpunit/phpunit": "3.7.*"

View File

@@ -4,221 +4,248 @@ namespace PayPal\Api;
use PayPal\Common\PPModel;
use PayPal\Rest\ApiContext;
class BillingInfo extends PPModel {
/**
* Email address of the invoice recipient. 260 characters max.
*
* @param string $email
*/
public function setEmail($email) {
$this->email = $email;
return $this;
}
class BillingInfo extends PPModel
{
/**
* Email address of the invoice recipient. 260 characters max.
*
* @param string $email
*/
public function setEmail($email)
{
$this->email = $email;
return $this;
}
/**
* Email address of the invoice recipient. 260 characters max.
*
* @return string
*/
public function getEmail() {
return $this->email;
}
/**
* Email address of the invoice recipient. 260 characters max.
*
* @return string
*/
public function getEmail()
{
return $this->email;
}
/**
* First name of the invoice recipient. 30 characters max.
*
* @param string $first_name
*/
public function setFirstName($first_name) {
$this->first_name = $first_name;
return $this;
}
/**
* First name of the invoice recipient. 30 characters max.
*
* @param string $first_name
*/
public function setFirstName($first_name)
{
$this->first_name = $first_name;
return $this;
}
/**
* First name of the invoice recipient. 30 characters max.
*
* @return string
*/
public function getFirstName() {
return $this->first_name;
}
/**
* First name of the invoice recipient. 30 characters max.
*
* @return string
*/
public function getFirstName()
{
return $this->first_name;
}
/**
* First name of the invoice recipient. 30 characters max.
*
* @param string $first_name
* @deprecated. Instead use setFirstName
*/
public function setFirst_name($first_name) {
$this->first_name = $first_name;
return $this;
}
/**
* First name of the invoice recipient. 30 characters max.
*
* @return string
* @deprecated. Instead use getFirstName
*/
public function getFirst_name() {
return $this->first_name;
}
/**
* First name of the invoice recipient. 30 characters max.
*
* @param string $first_name
* @deprecated. Instead use setFirstName
*/
public function setFirst_name($first_name)
{
$this->first_name = $first_name;
return $this;
}
/**
* Last name of the invoice recipient. 30 characters max.
*
* @param string $last_name
*/
public function setLastName($last_name) {
$this->last_name = $last_name;
return $this;
}
/**
* First name of the invoice recipient. 30 characters max.
*
* @return string
* @deprecated. Instead use getFirstName
*/
public function getFirst_name()
{
return $this->first_name;
}
/**
* Last name of the invoice recipient. 30 characters max.
*
* @return string
*/
public function getLastName() {
return $this->last_name;
}
/**
* Last name of the invoice recipient. 30 characters max.
*
* @param string $last_name
*/
public function setLastName($last_name)
{
$this->last_name = $last_name;
return $this;
}
/**
* Last name of the invoice recipient. 30 characters max.
*
* @param string $last_name
* @deprecated. Instead use setLastName
*/
public function setLast_name($last_name) {
$this->last_name = $last_name;
return $this;
}
/**
* Last name of the invoice recipient. 30 characters max.
*
* @return string
* @deprecated. Instead use getLastName
*/
public function getLast_name() {
return $this->last_name;
}
/**
* Last name of the invoice recipient. 30 characters max.
*
* @return string
*/
public function getLastName()
{
return $this->last_name;
}
/**
* Company business name of the invoice recipient. 100 characters max.
*
* @param string $business_name
*/
public function setBusinessName($business_name) {
$this->business_name = $business_name;
return $this;
}
/**
* Last name of the invoice recipient. 30 characters max.
*
* @param string $last_name
* @deprecated. Instead use setLastName
*/
public function setLast_name($last_name)
{
$this->last_name = $last_name;
return $this;
}
/**
* Company business name of the invoice recipient. 100 characters max.
*
* @return string
*/
public function getBusinessName() {
return $this->business_name;
}
/**
* Last name of the invoice recipient. 30 characters max.
*
* @return string
* @deprecated. Instead use getLastName
*/
public function getLast_name()
{
return $this->last_name;
}
/**
* Company business name of the invoice recipient. 100 characters max.
*
* @param string $business_name
* @deprecated. Instead use setBusinessName
*/
public function setBusiness_name($business_name) {
$this->business_name = $business_name;
return $this;
}
/**
* Company business name of the invoice recipient. 100 characters max.
*
* @return string
* @deprecated. Instead use getBusinessName
*/
public function getBusiness_name() {
return $this->business_name;
}
/**
* Company business name of the invoice recipient. 100 characters max.
*
* @param string $business_name
*/
public function setBusinessName($business_name)
{
$this->business_name = $business_name;
return $this;
}
/**
* Address of the invoice recipient.
*
* @param PayPal\Api\Address $address
*/
public function setAddress($address) {
$this->address = $address;
return $this;
}
/**
* Company business name of the invoice recipient. 100 characters max.
*
* @return string
*/
public function getBusinessName()
{
return $this->business_name;
}
/**
* Address of the invoice recipient.
*
* @return PayPal\Api\Address
*/
public function getAddress() {
return $this->address;
}
/**
* Company business name of the invoice recipient. 100 characters max.
*
* @param string $business_name
* @deprecated. Instead use setBusinessName
*/
public function setBusiness_name($business_name)
{
$this->business_name = $business_name;
return $this;
}
/**
* Company business name of the invoice recipient. 100 characters max.
*
* @return string
* @deprecated. Instead use getBusinessName
*/
public function getBusiness_name()
{
return $this->business_name;
}
/**
* Address of the invoice recipient.
*
* @param PayPal\Api\Address $address
*/
public function setAddress($address)
{
$this->address = $address;
return $this;
}
/**
* Address of the invoice recipient.
*
* @return PayPal\Api\Address
*/
public function getAddress()
{
return $this->address;
}
/**
* Language of the email sent to the payer. Will only be used if payer doesn't have a PayPal account.
*
* @param string $language
*/
public function setLanguage($language) {
$this->language = $language;
return $this;
}
/**
* Language of the email sent to the payer. Will only be used if payer doesn't have a PayPal account.
*
* @param string $language
*/
public function setLanguage($language)
{
$this->language = $language;
return $this;
}
/**
* Language of the email sent to the payer. Will only be used if payer doesn't have a PayPal account.
*
* @return string
*/
public function getLanguage() {
return $this->language;
}
/**
* Language of the email sent to the payer. Will only be used if payer doesn't have a PayPal account.
*
* @return string
*/
public function getLanguage()
{
return $this->language;
}
/**
* Option to display additional information such as business hours. 40 characters max.
*
* @param string $additional_info
*/
public function setAdditionalInfo($additional_info) {
$this->additional_info = $additional_info;
return $this;
}
/**
* Option to display additional information such as business hours. 40 characters max.
*
* @param string $additional_info
*/
public function setAdditionalInfo($additional_info)
{
$this->additional_info = $additional_info;
return $this;
}
/**
* Option to display additional information such as business hours. 40 characters max.
*
* @return string
*/
public function getAdditionalInfo() {
return $this->additional_info;
}
/**
* Option to display additional information such as business hours. 40 characters max.
*
* @return string
*/
public function getAdditionalInfo()
{
return $this->additional_info;
}
/**
* Option to display additional information such as business hours. 40 characters max.
*
* @param string $additional_info
* @deprecated. Instead use setAdditionalInfo
*/
public function setAdditional_info($additional_info) {
$this->additional_info = $additional_info;
return $this;
}
/**
* Option to display additional information such as business hours. 40 characters max.
*
* @return string
* @deprecated. Instead use getAdditionalInfo
*/
public function getAdditional_info() {
return $this->additional_info;
}
/**
* Option to display additional information such as business hours. 40 characters max.
*
* @param string $additional_info
* @deprecated. Instead use setAdditionalInfo
*/
public function setAdditional_info($additional_info)
{
$this->additional_info = $additional_info;
return $this;
}
/**
* Option to display additional information such as business hours. 40 characters max.
*
* @return string
* @deprecated. Instead use getAdditionalInfo
*/
public function getAdditional_info()
{
return $this->additional_info;
}
}

View File

@@ -4,123 +4,138 @@ namespace PayPal\Api;
use PayPal\Common\PPModel;
use PayPal\Rest\ApiContext;
class CancelNotification extends PPModel {
/**
* Subject of the notification.
*
* @param string $subject
*/
public function setSubject($subject) {
$this->subject = $subject;
return $this;
}
class CancelNotification extends PPModel
{
/**
* Subject of the notification.
*
* @param string $subject
*/
public function setSubject($subject)
{
$this->subject = $subject;
return $this;
}
/**
* Subject of the notification.
*
* @return string
*/
public function getSubject() {
return $this->subject;
}
/**
* Subject of the notification.
*
* @return string
*/
public function getSubject()
{
return $this->subject;
}
/**
* Note to the payer.
*
* @param string $note
*/
public function setNote($note) {
$this->note = $note;
return $this;
}
/**
* Note to the payer.
*
* @param string $note
*/
public function setNote($note)
{
$this->note = $note;
return $this;
}
/**
* Note to the payer.
*
* @return string
*/
public function getNote() {
return $this->note;
}
/**
* Note to the payer.
*
* @return string
*/
public function getNote()
{
return $this->note;
}
/**
* A flag indicating whether a copy of the email has to be sent to the merchant.
*
* @param boolean $send_to_merchant
*/
public function setSendToMerchant($send_to_merchant) {
$this->send_to_merchant = $send_to_merchant;
return $this;
}
/**
* A flag indicating whether a copy of the email has to be sent to the merchant.
*
* @param boolean $send_to_merchant
*/
public function setSendToMerchant($send_to_merchant)
{
$this->send_to_merchant = $send_to_merchant;
return $this;
}
/**
* A flag indicating whether a copy of the email has to be sent to the merchant.
*
* @return boolean
*/
public function getSendToMerchant() {
return $this->send_to_merchant;
}
/**
* A flag indicating whether a copy of the email has to be sent to the merchant.
*
* @return boolean
*/
public function getSendToMerchant()
{
return $this->send_to_merchant;
}
/**
* A flag indicating whether a copy of the email has to be sent to the merchant.
*
* @param boolean $send_to_merchant
* @deprecated. Instead use setSendToMerchant
*/
public function setSend_to_merchant($send_to_merchant) {
$this->send_to_merchant = $send_to_merchant;
return $this;
}
/**
* A flag indicating whether a copy of the email has to be sent to the merchant.
*
* @return boolean
* @deprecated. Instead use getSendToMerchant
*/
public function getSend_to_merchant() {
return $this->send_to_merchant;
}
/**
* A flag indicating whether a copy of the email has to be sent to the merchant.
*
* @param boolean $send_to_merchant
* @deprecated. Instead use setSendToMerchant
*/
public function setSend_to_merchant($send_to_merchant)
{
$this->send_to_merchant = $send_to_merchant;
return $this;
}
/**
* A flag indicating whether a copy of the email has to be sent to the payer.
*
* @param boolean $send_to_payer
*/
public function setSendToPayer($send_to_payer) {
$this->send_to_payer = $send_to_payer;
return $this;
}
/**
* A flag indicating whether a copy of the email has to be sent to the merchant.
*
* @return boolean
* @deprecated. Instead use getSendToMerchant
*/
public function getSend_to_merchant()
{
return $this->send_to_merchant;
}
/**
* A flag indicating whether a copy of the email has to be sent to the payer.
*
* @return boolean
*/
public function getSendToPayer() {
return $this->send_to_payer;
}
/**
* A flag indicating whether a copy of the email has to be sent to the payer.
*
* @param boolean $send_to_payer
*/
public function setSendToPayer($send_to_payer)
{
$this->send_to_payer = $send_to_payer;
return $this;
}
/**
* A flag indicating whether a copy of the email has to be sent to the payer.
*
* @param boolean $send_to_payer
* @deprecated. Instead use setSendToPayer
*/
public function setSend_to_payer($send_to_payer) {
$this->send_to_payer = $send_to_payer;
return $this;
}
/**
* A flag indicating whether a copy of the email has to be sent to the payer.
*
* @return boolean
* @deprecated. Instead use getSendToPayer
*/
public function getSend_to_payer() {
return $this->send_to_payer;
}
/**
* A flag indicating whether a copy of the email has to be sent to the payer.
*
* @return boolean
*/
public function getSendToPayer()
{
return $this->send_to_payer;
}
/**
* A flag indicating whether a copy of the email has to be sent to the payer.
*
* @param boolean $send_to_payer
* @deprecated. Instead use setSendToPayer
*/
public function setSend_to_payer($send_to_payer)
{
$this->send_to_payer = $send_to_payer;
return $this;
}
/**
* A flag indicating whether a copy of the email has to be sent to the payer.
*
* @return boolean
* @deprecated. Instead use getSendToPayer
*/
public function getSend_to_payer()
{
return $this->send_to_payer;
}
}

View File

@@ -4,45 +4,50 @@ namespace PayPal\Api;
use PayPal\Common\PPModel;
use PayPal\Rest\ApiContext;
class Cost extends PPModel {
/**
* Cost in percent. Range of 0 to 100.
*
* @param PayPal\Api\number $percent
*/
public function setPercent($percent) {
$this->percent = $percent;
return $this;
}
class Cost extends PPModel
{
/**
* Cost in percent. Range of 0 to 100.
*
* @param PayPal\Api\number $percent
*/
public function setPercent($percent)
{
$this->percent = $percent;
return $this;
}
/**
* Cost in percent. Range of 0 to 100.
*
* @return PayPal\Api\number
*/
public function getPercent() {
return $this->percent;
}
/**
* Cost in percent. Range of 0 to 100.
*
* @return PayPal\Api\number
*/
public function getPercent()
{
return $this->percent;
}
/**
* Cost in amount. Range of 0 to 999999.99.
*
* @param PayPal\Api\Currency $amount
*/
public function setAmount($amount) {
$this->amount = $amount;
return $this;
}
/**
* Cost in amount. Range of 0 to 999999.99.
*
* @param PayPal\Api\Currency $amount
*/
public function setAmount($amount)
{
$this->amount = $amount;
return $this;
}
/**
* Cost in amount. Range of 0 to 999999.99.
*
* @return PayPal\Api\Currency
*/
public function getAmount() {
return $this->amount;
}
/**
* Cost in amount. Range of 0 to 999999.99.
*
* @return PayPal\Api\Currency
*/
public function getAmount()
{
return $this->amount;
}
}

View File

@@ -4,45 +4,50 @@ namespace PayPal\Api;
use PayPal\Common\PPModel;
use PayPal\Rest\ApiContext;
class Currency extends PPModel {
/**
* 3 letter currency code
*
* @param string $currency
*/
public function setCurrency($currency) {
$this->currency = $currency;
return $this;
}
class Currency extends PPModel
{
/**
* 3 letter currency code
*
* @param string $currency
*/
public function setCurrency($currency)
{
$this->currency = $currency;
return $this;
}
/**
* 3 letter currency code
*
* @return string
*/
public function getCurrency() {
return $this->currency;
}
/**
* 3 letter currency code
*
* @return string
*/
public function getCurrency()
{
return $this->currency;
}
/**
* amount upto 2 decimals represented as string
*
* @param string $value
*/
public function setValue($value) {
$this->value = $value;
return $this;
}
/**
* amount upto 2 decimals represented as string
*
* @param string $value
*/
public function setValue($value)
{
$this->value = $value;
return $this;
}
/**
* amount upto 2 decimals represented as string
*
* @return string
*/
public function getValue() {
return $this->value;
}
/**
* amount upto 2 decimals represented as string
*
* @return string
*/
public function getValue()
{
return $this->value;
}
}

View File

@@ -4,45 +4,50 @@ namespace PayPal\Api;
use PayPal\Common\PPModel;
use PayPal\Rest\ApiContext;
class CustomAmount extends PPModel {
/**
* Custom amount label. 25 characters max.
*
* @param string $label
*/
public function setLabel($label) {
$this->label = $label;
return $this;
}
class CustomAmount extends PPModel
{
/**
* Custom amount label. 25 characters max.
*
* @param string $label
*/
public function setLabel($label)
{
$this->label = $label;
return $this;
}
/**
* Custom amount label. 25 characters max.
*
* @return string
*/
public function getLabel() {
return $this->label;
}
/**
* Custom amount label. 25 characters max.
*
* @return string
*/
public function getLabel()
{
return $this->label;
}
/**
* Custom amount value. Range of 0 to 999999.99.
*
* @param PayPal\Api\Currency $amount
*/
public function setAmount($amount) {
$this->amount = $amount;
return $this;
}
/**
* Custom amount value. Range of 0 to 999999.99.
*
* @param PayPal\Api\Currency $amount
*/
public function setAmount($amount)
{
$this->amount = $amount;
return $this;
}
/**
* Custom amount value. Range of 0 to 999999.99.
*
* @return PayPal\Api\Currency
*/
public function getAmount() {
return $this->amount;
}
/**
* Custom amount value. Range of 0 to 999999.99.
*
* @return PayPal\Api\Currency
*/
public function getAmount()
{
return $this->amount;
}
}

View File

@@ -4,143 +4,160 @@ namespace PayPal\Api;
use PayPal\Common\PPModel;
use PayPal\Rest\ApiContext;
class Error extends PPModel {
/**
* Human readable, unique name of the error.
*
* @param string $name
*/
public function setName($name) {
$this->name = $name;
return $this;
}
class Error extends PPModel
{
/**
* Human readable, unique name of the error.
*
* @param string $name
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Human readable, unique name of the error.
*
* @return string
*/
public function getName() {
return $this->name;
}
/**
* Human readable, unique name of the error.
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* PayPal internal identifier used for correlation purposes.
*
* @param string $debug_id
*/
public function setDebugId($debug_id) {
$this->debug_id = $debug_id;
return $this;
}
/**
* PayPal internal identifier used for correlation purposes.
*
* @param string $debug_id
*/
public function setDebugId($debug_id)
{
$this->debug_id = $debug_id;
return $this;
}
/**
* PayPal internal identifier used for correlation purposes.
*
* @return string
*/
public function getDebugId() {
return $this->debug_id;
}
/**
* PayPal internal identifier used for correlation purposes.
*
* @return string
*/
public function getDebugId()
{
return $this->debug_id;
}
/**
* PayPal internal identifier used for correlation purposes.
*
* @param string $debug_id
* @deprecated. Instead use setDebugId
*/
public function setDebug_id($debug_id) {
$this->debug_id = $debug_id;
return $this;
}
/**
* PayPal internal identifier used for correlation purposes.
*
* @return string
* @deprecated. Instead use getDebugId
*/
public function getDebug_id() {
return $this->debug_id;
}
/**
* PayPal internal identifier used for correlation purposes.
*
* @param string $debug_id
* @deprecated. Instead use setDebugId
*/
public function setDebug_id($debug_id)
{
$this->debug_id = $debug_id;
return $this;
}
/**
* Message describing the error.
*
* @param string $message
*/
public function setMessage($message) {
$this->message = $message;
return $this;
}
/**
* PayPal internal identifier used for correlation purposes.
*
* @return string
* @deprecated. Instead use getDebugId
*/
public function getDebug_id()
{
return $this->debug_id;
}
/**
* Message describing the error.
*
* @return string
*/
public function getMessage() {
return $this->message;
}
/**
* Message describing the error.
*
* @param string $message
*/
public function setMessage($message)
{
$this->message = $message;
return $this;
}
/**
* Message describing the error.
*
* @return string
*/
public function getMessage()
{
return $this->message;
}
/**
* URI for detailed information related to this error for the developer.
*
* @param string $information_link
*/
public function setInformationLink($information_link) {
$this->information_link = $information_link;
return $this;
}
/**
* URI for detailed information related to this error for the developer.
*
* @param string $information_link
*/
public function setInformationLink($information_link)
{
$this->information_link = $information_link;
return $this;
}
/**
* URI for detailed information related to this error for the developer.
*
* @return string
*/
public function getInformationLink() {
return $this->information_link;
}
/**
* URI for detailed information related to this error for the developer.
*
* @return string
*/
public function getInformationLink()
{
return $this->information_link;
}
/**
* URI for detailed information related to this error for the developer.
*
* @param string $information_link
* @deprecated. Instead use setInformationLink
*/
public function setInformation_link($information_link) {
$this->information_link = $information_link;
return $this;
}
/**
* URI for detailed information related to this error for the developer.
*
* @return string
* @deprecated. Instead use getInformationLink
*/
public function getInformation_link() {
return $this->information_link;
}
/**
* URI for detailed information related to this error for the developer.
*
* @param string $information_link
* @deprecated. Instead use setInformationLink
*/
public function setInformation_link($information_link)
{
$this->information_link = $information_link;
return $this;
}
/**
* Additional details of the error
*
* @param PayPal\Api\ErrorDetails $details
*/
public function setDetails($details) {
$this->details = $details;
return $this;
}
/**
* URI for detailed information related to this error for the developer.
*
* @return string
* @deprecated. Instead use getInformationLink
*/
public function getInformation_link()
{
return $this->information_link;
}
/**
* Additional details of the error
*
* @return PayPal\Api\ErrorDetails
*/
public function getDetails() {
return $this->details;
}
/**
* Additional details of the error
*
* @param PayPal\Api\ErrorDetails $details
*/
public function setDetails($details)
{
$this->details = $details;
return $this;
}
/**
* Additional details of the error
*
* @return PayPal\Api\ErrorDetails
*/
public function getDetails()
{
return $this->details;
}
}

View File

@@ -4,45 +4,50 @@ namespace PayPal\Api;
use PayPal\Common\PPModel;
use PayPal\Rest\ApiContext;
class ErrorDetails extends PPModel {
/**
* Name of the field that caused the error.
*
* @param string $field
*/
public function setField($field) {
$this->field = $field;
return $this;
}
class ErrorDetails extends PPModel
{
/**
* Name of the field that caused the error.
*
* @param string $field
*/
public function setField($field)
{
$this->field = $field;
return $this;
}
/**
* Name of the field that caused the error.
*
* @return string
*/
public function getField() {
return $this->field;
}
/**
* Name of the field that caused the error.
*
* @return string
*/
public function getField()
{
return $this->field;
}
/**
* Reason for the error.
*
* @param string $issue
*/
public function setIssue($issue) {
$this->issue = $issue;
return $this;
}
/**
* Reason for the error.
*
* @param string $issue
*/
public function setIssue($issue)
{
$this->issue = $issue;
return $this;
}
/**
* Reason for the error.
*
* @return string
*/
public function getIssue() {
return $this->issue;
}
/**
* Reason for the error.
*
* @return string
*/
public function getIssue()
{
return $this->issue;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -4,164 +4,182 @@ namespace PayPal\Api;
use PayPal\Common\PPModel;
use PayPal\Rest\ApiContext;
class InvoiceItem extends PPModel {
/**
* Name of the item. 60 characters max.
*
* @param string $name
*/
public function setName($name) {
$this->name = $name;
return $this;
}
class InvoiceItem extends PPModel
{
/**
* Name of the item. 60 characters max.
*
* @param string $name
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Name of the item. 60 characters max.
*
* @return string
*/
public function getName() {
return $this->name;
}
/**
* Name of the item. 60 characters max.
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Description of the item. 1000 characters max.
*
* @param string $description
*/
public function setDescription($description) {
$this->description = $description;
return $this;
}
/**
* Description of the item. 1000 characters max.
*
* @param string $description
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* Description of the item. 1000 characters max.
*
* @return string
*/
public function getDescription() {
return $this->description;
}
/**
* Description of the item. 1000 characters max.
*
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* Quantity of the item. Range of 0 to 9999.999.
*
* @param PayPal\Api\number $quantity
*/
public function setQuantity($quantity) {
$this->quantity = $quantity;
return $this;
}
/**
* Quantity of the item. Range of 0 to 9999.999.
*
* @param PayPal\Api\number $quantity
*/
public function setQuantity($quantity)
{
$this->quantity = $quantity;
return $this;
}
/**
* Quantity of the item. Range of 0 to 9999.999.
*
* @return PayPal\Api\number
*/
public function getQuantity() {
return $this->quantity;
}
/**
* Quantity of the item. Range of 0 to 9999.999.
*
* @return PayPal\Api\number
*/
public function getQuantity()
{
return $this->quantity;
}
/**
* Unit price of the item. Range of -999999.99 to 999999.99.
*
* @param PayPal\Api\Currency $unit_price
*/
public function setUnitPrice($unit_price) {
$this->unit_price = $unit_price;
return $this;
}
/**
* Unit price of the item. Range of -999999.99 to 999999.99.
*
* @param PayPal\Api\Currency $unit_price
*/
public function setUnitPrice($unit_price)
{
$this->unit_price = $unit_price;
return $this;
}
/**
* Unit price of the item. Range of -999999.99 to 999999.99.
*
* @return PayPal\Api\Currency
*/
public function getUnitPrice() {
return $this->unit_price;
}
/**
* Unit price of the item. Range of -999999.99 to 999999.99.
*
* @return PayPal\Api\Currency
*/
public function getUnitPrice()
{
return $this->unit_price;
}
/**
* Unit price of the item. Range of -999999.99 to 999999.99.
*
* @param PayPal\Api\Currency $unit_price
* @deprecated. Instead use setUnitPrice
*/
public function setUnit_price($unit_price) {
$this->unit_price = $unit_price;
return $this;
}
/**
* Unit price of the item. Range of -999999.99 to 999999.99.
*
* @return PayPal\Api\Currency
* @deprecated. Instead use getUnitPrice
*/
public function getUnit_price() {
return $this->unit_price;
}
/**
* Unit price of the item. Range of -999999.99 to 999999.99.
*
* @param PayPal\Api\Currency $unit_price
* @deprecated. Instead use setUnitPrice
*/
public function setUnit_price($unit_price)
{
$this->unit_price = $unit_price;
return $this;
}
/**
* Tax associated with the item.
*
* @param PayPal\Api\Tax $tax
*/
public function setTax($tax) {
$this->tax = $tax;
return $this;
}
/**
* Unit price of the item. Range of -999999.99 to 999999.99.
*
* @return PayPal\Api\Currency
* @deprecated. Instead use getUnitPrice
*/
public function getUnit_price()
{
return $this->unit_price;
}
/**
* Tax associated with the item.
*
* @return PayPal\Api\Tax
*/
public function getTax() {
return $this->tax;
}
/**
* Tax associated with the item.
*
* @param PayPal\Api\Tax $tax
*/
public function setTax($tax)
{
$this->tax = $tax;
return $this;
}
/**
* Tax associated with the item.
*
* @return PayPal\Api\Tax
*/
public function getTax()
{
return $this->tax;
}
/**
* Date on which the item or service was provided. Date format: yyyy-MM-dd z. For example, 2014-02-27 PST.
*
* @param string $date
*/
public function setDate($date) {
$this->date = $date;
return $this;
}
/**
* Date on which the item or service was provided. Date format: yyyy-MM-dd z. For example, 2014-02-27 PST.
*
* @param string $date
*/
public function setDate($date)
{
$this->date = $date;
return $this;
}
/**
* Date on which the item or service was provided. Date format: yyyy-MM-dd z. For example, 2014-02-27 PST.
*
* @return string
*/
public function getDate() {
return $this->date;
}
/**
* Date on which the item or service was provided. Date format: yyyy-MM-dd z. For example, 2014-02-27 PST.
*
* @return string
*/
public function getDate()
{
return $this->date;
}
/**
* Item discount in percent or amount.
*
* @param PayPal\Api\Cost $discount
*/
public function setDiscount($discount) {
$this->discount = $discount;
return $this;
}
/**
* Item discount in percent or amount.
*
* @param PayPal\Api\Cost $discount
*/
public function setDiscount($discount)
{
$this->discount = $discount;
return $this;
}
/**
* Item discount in percent or amount.
*
* @return PayPal\Api\Cost
*/
public function getDiscount() {
return $this->discount;
}
/**
* Item discount in percent or amount.
*
* @return PayPal\Api\Cost
*/
public function getDiscount()
{
return $this->discount;
}
}

View File

@@ -4,64 +4,72 @@ namespace PayPal\Api;
use PayPal\Common\PPModel;
use PayPal\Rest\ApiContext;
class Invoices extends PPModel {
/**
*
*
* @param integer $total_count
*/
public function setTotalCount($total_count) {
$this->total_count = $total_count;
return $this;
}
class Invoices extends PPModel
{
/**
*
*
* @param integer $total_count
*/
public function setTotalCount($total_count)
{
$this->total_count = $total_count;
return $this;
}
/**
*
*
* @return integer
*/
public function getTotalCount() {
return $this->total_count;
}
/**
*
*
* @return integer
*/
public function getTotalCount()
{
return $this->total_count;
}
/**
*
*
* @param integer $total_count
* @deprecated. Instead use setTotalCount
*/
public function setTotal_count($total_count) {
$this->total_count = $total_count;
return $this;
}
/**
*
*
* @return integer
* @deprecated. Instead use getTotalCount
*/
public function getTotal_count() {
return $this->total_count;
}
/**
*
*
* @param integer $total_count
* @deprecated. Instead use setTotalCount
*/
public function setTotal_count($total_count)
{
$this->total_count = $total_count;
return $this;
}
/**
* List of invoices belonging to a merchant.
*
* @param PayPal\Api\Invoice $invoices
*/
public function setInvoices($invoices) {
$this->invoices = $invoices;
return $this;
}
/**
*
*
* @return integer
* @deprecated. Instead use getTotalCount
*/
public function getTotal_count()
{
return $this->total_count;
}
/**
* List of invoices belonging to a merchant.
*
* @return PayPal\Api\Invoice
*/
public function getInvoices() {
return $this->invoices;
}
/**
* List of invoices belonging to a merchant.
*
* @param PayPal\Api\Invoice $invoices
*/
public function setInvoices($invoices)
{
$this->invoices = $invoices;
return $this;
}
/**
* List of invoices belonging to a merchant.
*
* @return PayPal\Api\Invoice
*/
public function getInvoices()
{
return $this->invoices;
}
}

View File

@@ -4,356 +4,402 @@ namespace PayPal\Api;
use PayPal\Common\PPModel;
use PayPal\Rest\ApiContext;
class InvoicingMetaData extends PPModel {
/**
* Date when the resource was created.
*
* @param string $created_date
*/
public function setCreatedDate($created_date) {
$this->created_date = $created_date;
return $this;
}
class InvoicingMetaData extends PPModel
{
/**
* Date when the resource was created.
*
* @param string $created_date
*/
public function setCreatedDate($created_date)
{
$this->created_date = $created_date;
return $this;
}
/**
* Date when the resource was created.
*
* @return string
*/
public function getCreatedDate() {
return $this->created_date;
}
/**
* Date when the resource was created.
*
* @return string
*/
public function getCreatedDate()
{
return $this->created_date;
}
/**
* Date when the resource was created.
*
* @param string $created_date
* @deprecated. Instead use setCreatedDate
*/
public function setCreated_date($created_date) {
$this->created_date = $created_date;
return $this;
}
/**
* Date when the resource was created.
*
* @return string
* @deprecated. Instead use getCreatedDate
*/
public function getCreated_date() {
return $this->created_date;
}
/**
* Date when the resource was created.
*
* @param string $created_date
* @deprecated. Instead use setCreatedDate
*/
public function setCreated_date($created_date)
{
$this->created_date = $created_date;
return $this;
}
/**
* Email address of the account that created the resource.
*
* @param string $created_by
*/
public function setCreatedBy($created_by) {
$this->created_by = $created_by;
return $this;
}
/**
* Date when the resource was created.
*
* @return string
* @deprecated. Instead use getCreatedDate
*/
public function getCreated_date()
{
return $this->created_date;
}
/**
* Email address of the account that created the resource.
*
* @return string
*/
public function getCreatedBy() {
return $this->created_by;
}
/**
* Email address of the account that created the resource.
*
* @param string $created_by
*/
public function setCreatedBy($created_by)
{
$this->created_by = $created_by;
return $this;
}
/**
* Email address of the account that created the resource.
*
* @param string $created_by
* @deprecated. Instead use setCreatedBy
*/
public function setCreated_by($created_by) {
$this->created_by = $created_by;
return $this;
}
/**
* Email address of the account that created the resource.
*
* @return string
* @deprecated. Instead use getCreatedBy
*/
public function getCreated_by() {
return $this->created_by;
}
/**
* Email address of the account that created the resource.
*
* @return string
*/
public function getCreatedBy()
{
return $this->created_by;
}
/**
* Date when the resource was cancelled.
*
* @param string $cancelled_date
*/
public function setCancelledDate($cancelled_date) {
$this->cancelled_date = $cancelled_date;
return $this;
}
/**
* Email address of the account that created the resource.
*
* @param string $created_by
* @deprecated. Instead use setCreatedBy
*/
public function setCreated_by($created_by)
{
$this->created_by = $created_by;
return $this;
}
/**
* Date when the resource was cancelled.
*
* @return string
*/
public function getCancelledDate() {
return $this->cancelled_date;
}
/**
* Email address of the account that created the resource.
*
* @return string
* @deprecated. Instead use getCreatedBy
*/
public function getCreated_by()
{
return $this->created_by;
}
/**
* Date when the resource was cancelled.
*
* @param string $cancelled_date
* @deprecated. Instead use setCancelledDate
*/
public function setCancelled_date($cancelled_date) {
$this->cancelled_date = $cancelled_date;
return $this;
}
/**
* Date when the resource was cancelled.
*
* @return string
* @deprecated. Instead use getCancelledDate
*/
public function getCancelled_date() {
return $this->cancelled_date;
}
/**
* Date when the resource was cancelled.
*
* @param string $cancelled_date
*/
public function setCancelledDate($cancelled_date)
{
$this->cancelled_date = $cancelled_date;
return $this;
}
/**
* Actor who cancelled the resource.
*
* @param string $cancelled_by
*/
public function setCancelledBy($cancelled_by) {
$this->cancelled_by = $cancelled_by;
return $this;
}
/**
* Date when the resource was cancelled.
*
* @return string
*/
public function getCancelledDate()
{
return $this->cancelled_date;
}
/**
* Actor who cancelled the resource.
*
* @return string
*/
public function getCancelledBy() {
return $this->cancelled_by;
}
/**
* Date when the resource was cancelled.
*
* @param string $cancelled_date
* @deprecated. Instead use setCancelledDate
*/
public function setCancelled_date($cancelled_date)
{
$this->cancelled_date = $cancelled_date;
return $this;
}
/**
* Actor who cancelled the resource.
*
* @param string $cancelled_by
* @deprecated. Instead use setCancelledBy
*/
public function setCancelled_by($cancelled_by) {
$this->cancelled_by = $cancelled_by;
return $this;
}
/**
* Actor who cancelled the resource.
*
* @return string
* @deprecated. Instead use getCancelledBy
*/
public function getCancelled_by() {
return $this->cancelled_by;
}
/**
* Date when the resource was cancelled.
*
* @return string
* @deprecated. Instead use getCancelledDate
*/
public function getCancelled_date()
{
return $this->cancelled_date;
}
/**
* Date when the resource was last edited.
*
* @param string $last_updated_date
*/
public function setLastUpdatedDate($last_updated_date) {
$this->last_updated_date = $last_updated_date;
return $this;
}
/**
* Actor who cancelled the resource.
*
* @param string $cancelled_by
*/
public function setCancelledBy($cancelled_by)
{
$this->cancelled_by = $cancelled_by;
return $this;
}
/**
* Date when the resource was last edited.
*
* @return string
*/
public function getLastUpdatedDate() {
return $this->last_updated_date;
}
/**
* Actor who cancelled the resource.
*
* @return string
*/
public function getCancelledBy()
{
return $this->cancelled_by;
}
/**
* Date when the resource was last edited.
*
* @param string $last_updated_date
* @deprecated. Instead use setLastUpdatedDate
*/
public function setLast_updated_date($last_updated_date) {
$this->last_updated_date = $last_updated_date;
return $this;
}
/**
* Date when the resource was last edited.
*
* @return string
* @deprecated. Instead use getLastUpdatedDate
*/
public function getLast_updated_date() {
return $this->last_updated_date;
}
/**
* Actor who cancelled the resource.
*
* @param string $cancelled_by
* @deprecated. Instead use setCancelledBy
*/
public function setCancelled_by($cancelled_by)
{
$this->cancelled_by = $cancelled_by;
return $this;
}
/**
* Email address of the account that last edited the resource.
*
* @param string $last_updated_by
*/
public function setLastUpdatedBy($last_updated_by) {
$this->last_updated_by = $last_updated_by;
return $this;
}
/**
* Actor who cancelled the resource.
*
* @return string
* @deprecated. Instead use getCancelledBy
*/
public function getCancelled_by()
{
return $this->cancelled_by;
}
/**
* Email address of the account that last edited the resource.
*
* @return string
*/
public function getLastUpdatedBy() {
return $this->last_updated_by;
}
/**
* Date when the resource was last edited.
*
* @param string $last_updated_date
*/
public function setLastUpdatedDate($last_updated_date)
{
$this->last_updated_date = $last_updated_date;
return $this;
}
/**
* Email address of the account that last edited the resource.
*
* @param string $last_updated_by
* @deprecated. Instead use setLastUpdatedBy
*/
public function setLast_updated_by($last_updated_by) {
$this->last_updated_by = $last_updated_by;
return $this;
}
/**
* Email address of the account that last edited the resource.
*
* @return string
* @deprecated. Instead use getLastUpdatedBy
*/
public function getLast_updated_by() {
return $this->last_updated_by;
}
/**
* Date when the resource was last edited.
*
* @return string
*/
public function getLastUpdatedDate()
{
return $this->last_updated_date;
}
/**
* Date when the resource was first sent.
*
* @param string $first_sent_date
*/
public function setFirstSentDate($first_sent_date) {
$this->first_sent_date = $first_sent_date;
return $this;
}
/**
* Date when the resource was last edited.
*
* @param string $last_updated_date
* @deprecated. Instead use setLastUpdatedDate
*/
public function setLast_updated_date($last_updated_date)
{
$this->last_updated_date = $last_updated_date;
return $this;
}
/**
* Date when the resource was first sent.
*
* @return string
*/
public function getFirstSentDate() {
return $this->first_sent_date;
}
/**
* Date when the resource was last edited.
*
* @return string
* @deprecated. Instead use getLastUpdatedDate
*/
public function getLast_updated_date()
{
return $this->last_updated_date;
}
/**
* Date when the resource was first sent.
*
* @param string $first_sent_date
* @deprecated. Instead use setFirstSentDate
*/
public function setFirst_sent_date($first_sent_date) {
$this->first_sent_date = $first_sent_date;
return $this;
}
/**
* Date when the resource was first sent.
*
* @return string
* @deprecated. Instead use getFirstSentDate
*/
public function getFirst_sent_date() {
return $this->first_sent_date;
}
/**
* Email address of the account that last edited the resource.
*
* @param string $last_updated_by
*/
public function setLastUpdatedBy($last_updated_by)
{
$this->last_updated_by = $last_updated_by;
return $this;
}
/**
* Date when the resource was last sent.
*
* @param string $last_sent_date
*/
public function setLastSentDate($last_sent_date) {
$this->last_sent_date = $last_sent_date;
return $this;
}
/**
* Email address of the account that last edited the resource.
*
* @return string
*/
public function getLastUpdatedBy()
{
return $this->last_updated_by;
}
/**
* Date when the resource was last sent.
*
* @return string
*/
public function getLastSentDate() {
return $this->last_sent_date;
}
/**
* Email address of the account that last edited the resource.
*
* @param string $last_updated_by
* @deprecated. Instead use setLastUpdatedBy
*/
public function setLast_updated_by($last_updated_by)
{
$this->last_updated_by = $last_updated_by;
return $this;
}
/**
* Date when the resource was last sent.
*
* @param string $last_sent_date
* @deprecated. Instead use setLastSentDate
*/
public function setLast_sent_date($last_sent_date) {
$this->last_sent_date = $last_sent_date;
return $this;
}
/**
* Date when the resource was last sent.
*
* @return string
* @deprecated. Instead use getLastSentDate
*/
public function getLast_sent_date() {
return $this->last_sent_date;
}
/**
* Email address of the account that last edited the resource.
*
* @return string
* @deprecated. Instead use getLastUpdatedBy
*/
public function getLast_updated_by()
{
return $this->last_updated_by;
}
/**
* Email address of the account that last sent the resource.
*
* @param string $last_sent_by
*/
public function setLastSentBy($last_sent_by) {
$this->last_sent_by = $last_sent_by;
return $this;
}
/**
* Date when the resource was first sent.
*
* @param string $first_sent_date
*/
public function setFirstSentDate($first_sent_date)
{
$this->first_sent_date = $first_sent_date;
return $this;
}
/**
* Email address of the account that last sent the resource.
*
* @return string
*/
public function getLastSentBy() {
return $this->last_sent_by;
}
/**
* Date when the resource was first sent.
*
* @return string
*/
public function getFirstSentDate()
{
return $this->first_sent_date;
}
/**
* Email address of the account that last sent the resource.
*
* @param string $last_sent_by
* @deprecated. Instead use setLastSentBy
*/
public function setLast_sent_by($last_sent_by) {
$this->last_sent_by = $last_sent_by;
return $this;
}
/**
* Email address of the account that last sent the resource.
*
* @return string
* @deprecated. Instead use getLastSentBy
*/
public function getLast_sent_by() {
return $this->last_sent_by;
}
/**
* Date when the resource was first sent.
*
* @param string $first_sent_date
* @deprecated. Instead use setFirstSentDate
*/
public function setFirst_sent_date($first_sent_date)
{
$this->first_sent_date = $first_sent_date;
return $this;
}
/**
* Date when the resource was first sent.
*
* @return string
* @deprecated. Instead use getFirstSentDate
*/
public function getFirst_sent_date()
{
return $this->first_sent_date;
}
/**
* Date when the resource was last sent.
*
* @param string $last_sent_date
*/
public function setLastSentDate($last_sent_date)
{
$this->last_sent_date = $last_sent_date;
return $this;
}
/**
* Date when the resource was last sent.
*
* @return string
*/
public function getLastSentDate()
{
return $this->last_sent_date;
}
/**
* Date when the resource was last sent.
*
* @param string $last_sent_date
* @deprecated. Instead use setLastSentDate
*/
public function setLast_sent_date($last_sent_date)
{
$this->last_sent_date = $last_sent_date;
return $this;
}
/**
* Date when the resource was last sent.
*
* @return string
* @deprecated. Instead use getLastSentDate
*/
public function getLast_sent_date()
{
return $this->last_sent_date;
}
/**
* Email address of the account that last sent the resource.
*
* @param string $last_sent_by
*/
public function setLastSentBy($last_sent_by)
{
$this->last_sent_by = $last_sent_by;
return $this;
}
/**
* Email address of the account that last sent the resource.
*
* @return string
*/
public function getLastSentBy()
{
return $this->last_sent_by;
}
/**
* Email address of the account that last sent the resource.
*
* @param string $last_sent_by
* @deprecated. Instead use setLastSentBy
*/
public function setLast_sent_by($last_sent_by)
{
$this->last_sent_by = $last_sent_by;
return $this;
}
/**
* Email address of the account that last sent the resource.
*
* @return string
* @deprecated. Instead use getLastSentBy
*/
public function getLast_sent_by()
{
return $this->last_sent_by;
}
}

View File

@@ -4,84 +4,94 @@ namespace PayPal\Api;
use PayPal\Common\PPModel;
use PayPal\Rest\ApiContext;
class InvoicingNotification extends PPModel {
/**
* Subject of the notification.
*
* @param string $subject
*/
public function setSubject($subject) {
$this->subject = $subject;
return $this;
}
class InvoicingNotification extends PPModel
{
/**
* Subject of the notification.
*
* @param string $subject
*/
public function setSubject($subject)
{
$this->subject = $subject;
return $this;
}
/**
* Subject of the notification.
*
* @return string
*/
public function getSubject() {
return $this->subject;
}
/**
* Subject of the notification.
*
* @return string
*/
public function getSubject()
{
return $this->subject;
}
/**
* Note to the payer.
*
* @param string $note
*/
public function setNote($note) {
$this->note = $note;
return $this;
}
/**
* Note to the payer.
*
* @param string $note
*/
public function setNote($note)
{
$this->note = $note;
return $this;
}
/**
* Note to the payer.
*
* @return string
*/
public function getNote() {
return $this->note;
}
/**
* Note to the payer.
*
* @return string
*/
public function getNote()
{
return $this->note;
}
/**
* A flag indicating whether a copy of the email has to be sent to the merchant.
*
* @param boolean $send_to_merchant
*/
public function setSendToMerchant($send_to_merchant) {
$this->send_to_merchant = $send_to_merchant;
return $this;
}
/**
* A flag indicating whether a copy of the email has to be sent to the merchant.
*
* @param boolean $send_to_merchant
*/
public function setSendToMerchant($send_to_merchant)
{
$this->send_to_merchant = $send_to_merchant;
return $this;
}
/**
* A flag indicating whether a copy of the email has to be sent to the merchant.
*
* @return boolean
*/
public function getSendToMerchant() {
return $this->send_to_merchant;
}
/**
* A flag indicating whether a copy of the email has to be sent to the merchant.
*
* @return boolean
*/
public function getSendToMerchant()
{
return $this->send_to_merchant;
}
/**
* A flag indicating whether a copy of the email has to be sent to the merchant.
*
* @param boolean $send_to_merchant
* @deprecated. Instead use setSendToMerchant
*/
public function setSend_to_merchant($send_to_merchant) {
$this->send_to_merchant = $send_to_merchant;
return $this;
}
/**
* A flag indicating whether a copy of the email has to be sent to the merchant.
*
* @return boolean
* @deprecated. Instead use getSendToMerchant
*/
public function getSend_to_merchant() {
return $this->send_to_merchant;
}
/**
* A flag indicating whether a copy of the email has to be sent to the merchant.
*
* @param boolean $send_to_merchant
* @deprecated. Instead use setSendToMerchant
*/
public function setSend_to_merchant($send_to_merchant)
{
$this->send_to_merchant = $send_to_merchant;
return $this;
}
/**
* A flag indicating whether a copy of the email has to be sent to the merchant.
*
* @return boolean
* @deprecated. Instead use getSendToMerchant
*/
public function getSend_to_merchant()
{
return $this->send_to_merchant;
}
}

View File

@@ -4,163 +4,182 @@ namespace PayPal\Api;
use PayPal\Common\PPModel;
use PayPal\Rest\ApiContext;
class InvoicingPaymentDetail extends PPModel {
/**
* PayPal payment detail indicating whether payment was made in an invoicing flow via PayPal or externally. In the case of the mark-as-paid API, payment type is EXTERNAL and this is what is now supported. The PAYPAL value is provided for backward compatibility.
*
* @param string $type
*/
public function setType($type) {
$this->type = $type;
return $this;
}
class InvoicingPaymentDetail extends PPModel
{
/**
* PayPal payment detail indicating whether payment was made in an invoicing flow via PayPal or externally. In the case of the mark-as-paid API, payment type is EXTERNAL and this is what is now supported. The PAYPAL value is provided for backward compatibility.
*
* @param string $type
*/
public function setType($type)
{
$this->type = $type;
return $this;
}
/**
* PayPal payment detail indicating whether payment was made in an invoicing flow via PayPal or externally. In the case of the mark-as-paid API, payment type is EXTERNAL and this is what is now supported. The PAYPAL value is provided for backward compatibility.
*
* @return string
*/
public function getType() {
return $this->type;
}
/**
* PayPal payment detail indicating whether payment was made in an invoicing flow via PayPal or externally. In the case of the mark-as-paid API, payment type is EXTERNAL and this is what is now supported. The PAYPAL value is provided for backward compatibility.
*
* @return string
*/
public function getType()
{
return $this->type;
}
/**
* PayPal payment transaction id. Mandatory field in case the type value is PAYPAL.
*
* @param string $transaction_id
*/
public function setTransactionId($transaction_id) {
$this->transaction_id = $transaction_id;
return $this;
}
/**
* PayPal payment transaction id. Mandatory field in case the type value is PAYPAL.
*
* @param string $transaction_id
*/
public function setTransactionId($transaction_id)
{
$this->transaction_id = $transaction_id;
return $this;
}
/**
* PayPal payment transaction id. Mandatory field in case the type value is PAYPAL.
*
* @return string
*/
public function getTransactionId() {
return $this->transaction_id;
}
/**
* PayPal payment transaction id. Mandatory field in case the type value is PAYPAL.
*
* @return string
*/
public function getTransactionId()
{
return $this->transaction_id;
}
/**
* PayPal payment transaction id. Mandatory field in case the type value is PAYPAL.
*
* @param string $transaction_id
* @deprecated. Instead use setTransactionId
*/
public function setTransaction_id($transaction_id) {
$this->transaction_id = $transaction_id;
return $this;
}
/**
* PayPal payment transaction id. Mandatory field in case the type value is PAYPAL.
*
* @return string
* @deprecated. Instead use getTransactionId
*/
public function getTransaction_id() {
return $this->transaction_id;
}
/**
* PayPal payment transaction id. Mandatory field in case the type value is PAYPAL.
*
* @param string $transaction_id
* @deprecated. Instead use setTransactionId
*/
public function setTransaction_id($transaction_id)
{
$this->transaction_id = $transaction_id;
return $this;
}
/**
* Type of the transaction.
*
* @param string $transaction_type
*/
public function setTransactionType($transaction_type) {
$this->transaction_type = $transaction_type;
return $this;
}
/**
* PayPal payment transaction id. Mandatory field in case the type value is PAYPAL.
*
* @return string
* @deprecated. Instead use getTransactionId
*/
public function getTransaction_id()
{
return $this->transaction_id;
}
/**
* Type of the transaction.
*
* @return string
*/
public function getTransactionType() {
return $this->transaction_type;
}
/**
* Type of the transaction.
*
* @param string $transaction_type
*/
public function setTransactionType($transaction_type)
{
$this->transaction_type = $transaction_type;
return $this;
}
/**
* Type of the transaction.
*
* @param string $transaction_type
* @deprecated. Instead use setTransactionType
*/
public function setTransaction_type($transaction_type) {
$this->transaction_type = $transaction_type;
return $this;
}
/**
* Type of the transaction.
*
* @return string
* @deprecated. Instead use getTransactionType
*/
public function getTransaction_type() {
return $this->transaction_type;
}
/**
* Type of the transaction.
*
* @return string
*/
public function getTransactionType()
{
return $this->transaction_type;
}
/**
* Date when the invoice was paid. Date format: yyyy-MM-dd z. For example, 2014-02-27 PST.
*
* @param string $date
*/
public function setDate($date) {
$this->date = $date;
return $this;
}
/**
* Type of the transaction.
*
* @param string $transaction_type
* @deprecated. Instead use setTransactionType
*/
public function setTransaction_type($transaction_type)
{
$this->transaction_type = $transaction_type;
return $this;
}
/**
* Date when the invoice was paid. Date format: yyyy-MM-dd z. For example, 2014-02-27 PST.
*
* @return string
*/
public function getDate() {
return $this->date;
}
/**
* Type of the transaction.
*
* @return string
* @deprecated. Instead use getTransactionType
*/
public function getTransaction_type()
{
return $this->transaction_type;
}
/**
* Date when the invoice was paid. Date format: yyyy-MM-dd z. For example, 2014-02-27 PST.
*
* @param string $date
*/
public function setDate($date)
{
$this->date = $date;
return $this;
}
/**
* Date when the invoice was paid. Date format: yyyy-MM-dd z. For example, 2014-02-27 PST.
*
* @return string
*/
public function getDate()
{
return $this->date;
}
/**
* Payment mode or method. This field is mandatory if the value of the type field is OTHER.
*
* @param string $method
*/
public function setMethod($method) {
$this->method = $method;
return $this;
}
/**
* Payment mode or method. This field is mandatory if the value of the type field is OTHER.
*
* @param string $method
*/
public function setMethod($method)
{
$this->method = $method;
return $this;
}
/**
* Payment mode or method. This field is mandatory if the value of the type field is OTHER.
*
* @return string
*/
public function getMethod() {
return $this->method;
}
/**
* Payment mode or method. This field is mandatory if the value of the type field is OTHER.
*
* @return string
*/
public function getMethod()
{
return $this->method;
}
/**
* Optional note associated with the payment.
*
* @param string $note
*/
public function setNote($note) {
$this->note = $note;
return $this;
}
/**
* Optional note associated with the payment.
*
* @param string $note
*/
public function setNote($note)
{
$this->note = $note;
return $this;
}
/**
* Optional note associated with the payment.
*
* @return string
*/
public function getNote() {
return $this->note;
}
/**
* Optional note associated with the payment.
*
* @return string
*/
public function getNote()
{
return $this->note;
}
}

View File

@@ -4,65 +4,72 @@ namespace PayPal\Api;
use PayPal\Common\PPModel;
use PayPal\Rest\ApiContext;
class InvoicingRefundDetail extends PPModel {
/**
* PayPal refund type indicating whether refund was done in invoicing flow via PayPal or externally. In the case of the mark-as-refunded API, refund type is EXTERNAL and this is what is now supported. The PAYPAL value is provided for backward compatibility.
*
* @param string $type
*/
public function setType($type) {
$this->type = $type;
return $this;
}
class InvoicingRefundDetail extends PPModel
{
/**
* PayPal refund type indicating whether refund was done in invoicing flow via PayPal or externally. In the case of the mark-as-refunded API, refund type is EXTERNAL and this is what is now supported. The PAYPAL value is provided for backward compatibility.
*
* @param string $type
*/
public function setType($type)
{
$this->type = $type;
return $this;
}
/**
* PayPal refund type indicating whether refund was done in invoicing flow via PayPal or externally. In the case of the mark-as-refunded API, refund type is EXTERNAL and this is what is now supported. The PAYPAL value is provided for backward compatibility.
*
* @return string
*/
public function getType() {
return $this->type;
}
/**
* PayPal refund type indicating whether refund was done in invoicing flow via PayPal or externally. In the case of the mark-as-refunded API, refund type is EXTERNAL and this is what is now supported. The PAYPAL value is provided for backward compatibility.
*
* @return string
*/
public function getType()
{
return $this->type;
}
/**
* Date when the invoice was marked as refunded. If no date is specified, the current date and time is used as the default. In addition, the date must be after the invoice payment date.
*
* @param string $date
*/
public function setDate($date) {
$this->date = $date;
return $this;
}
/**
* Date when the invoice was marked as refunded. If no date is specified, the current date and time is used as the default. In addition, the date must be after the invoice payment date.
*
* @param string $date
*/
public function setDate($date)
{
$this->date = $date;
return $this;
}
/**
* Date when the invoice was marked as refunded. If no date is specified, the current date and time is used as the default. In addition, the date must be after the invoice payment date.
*
* @return string
*/
public function getDate() {
return $this->date;
}
/**
* Date when the invoice was marked as refunded. If no date is specified, the current date and time is used as the default. In addition, the date must be after the invoice payment date.
*
* @return string
*/
public function getDate()
{
return $this->date;
}
/**
* Optional note associated with the refund.
*
* @param string $note
*/
public function setNote($note) {
$this->note = $note;
return $this;
}
/**
* Optional note associated with the refund.
*
* @param string $note
*/
public function setNote($note)
{
$this->note = $note;
return $this;
}
/**
* Optional note associated with the refund.
*
* @return string
*/
public function getNote() {
return $this->note;
}
/**
* Optional note associated with the refund.
*
* @return string
*/
public function getNote()
{
return $this->note;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -156,7 +156,8 @@ class Item extends PPModel
*
* @return $this
*/
public function setDescription($description) {
public function setDescription($description)
{
$this->description = $description;
return $this;
@@ -168,7 +169,8 @@ class Item extends PPModel
*
* @return string
*/
public function getDescription() {
public function getDescription()
{
return $this->description;
}
@@ -180,7 +182,8 @@ class Item extends PPModel
*
* @return $this
*/
public function setTax($tax) {
public function setTax($tax)
{
$this->tax = $tax;
return $this;
@@ -192,7 +195,8 @@ class Item extends PPModel
*
* @return string
*/
public function getTax() {
public function getTax()
{
return $this->tax;
}
}

View File

@@ -17,14 +17,16 @@ class ItemList extends PPModel
/**
* Construct an empty list.
*/
function __construct() {
function __construct()
{
$this->items = array();
}
/**
/**
* Is this list empty?
*/
public function isEmpty() {
public function isEmpty()
{
return empty($this->items);
}
@@ -67,26 +69,30 @@ class ItemList extends PPModel
return $this;
}
/**
* Append an item to the list.
* @return PayPal\Api\Item
*/
public function addItem($item) {
return $this->setItems(
array_merge($this->items, array($item))
);
}
/**
* Append an item to the list.
*
* @return PayPal\Api\Item
*/
public function addItem($item)
{
return $this->setItems(
array_merge($this->items, array($item))
);
}
/**
* Remove an item from the list.
* Items are compared using === comparision (PHP.net)
* @return PayPal\Api\Item
*/
public function removeItem($item) {
return $this->setItems(
array_diff($this->items, array($item))
);
}
/**
* Remove an item from the list.
* Items are compared using === comparision (PHP.net)
*
* @return PayPal\Api\Item
*/
public function removeItem($item)
{
return $this->setItems(
array_diff($this->items, array($item))
);
}
/**
* Get Shipping Address

View File

@@ -4,300 +4,336 @@ namespace PayPal\Api;
use PayPal\Common\PPModel;
use PayPal\Rest\ApiContext;
class MerchantInfo extends PPModel {
/**
* Email address of the merchant. 260 characters max.
*
* @param string $email
*/
public function setEmail($email) {
$this->email = $email;
return $this;
}
class MerchantInfo extends PPModel
{
/**
* Email address of the merchant. 260 characters max.
*
* @param string $email
*/
public function setEmail($email)
{
$this->email = $email;
return $this;
}
/**
* Email address of the merchant. 260 characters max.
*
* @return string
*/
public function getEmail() {
return $this->email;
}
/**
* Email address of the merchant. 260 characters max.
*
* @return string
*/
public function getEmail()
{
return $this->email;
}
/**
* First name of the merchant. 30 characters max.
*
* @param string $first_name
*/
public function setFirstName($first_name) {
$this->first_name = $first_name;
return $this;
}
/**
* First name of the merchant. 30 characters max.
*
* @param string $first_name
*/
public function setFirstName($first_name)
{
$this->first_name = $first_name;
return $this;
}
/**
* First name of the merchant. 30 characters max.
*
* @return string
*/
public function getFirstName() {
return $this->first_name;
}
/**
* First name of the merchant. 30 characters max.
*
* @return string
*/
public function getFirstName()
{
return $this->first_name;
}
/**
* First name of the merchant. 30 characters max.
*
* @param string $first_name
* @deprecated. Instead use setFirstName
*/
public function setFirst_name($first_name) {
$this->first_name = $first_name;
return $this;
}
/**
* First name of the merchant. 30 characters max.
*
* @return string
* @deprecated. Instead use getFirstName
*/
public function getFirst_name() {
return $this->first_name;
}
/**
* First name of the merchant. 30 characters max.
*
* @param string $first_name
* @deprecated. Instead use setFirstName
*/
public function setFirst_name($first_name)
{
$this->first_name = $first_name;
return $this;
}
/**
* Last name of the merchant. 30 characters max.
*
* @param string $last_name
*/
public function setLastName($last_name) {
$this->last_name = $last_name;
return $this;
}
/**
* First name of the merchant. 30 characters max.
*
* @return string
* @deprecated. Instead use getFirstName
*/
public function getFirst_name()
{
return $this->first_name;
}
/**
* Last name of the merchant. 30 characters max.
*
* @return string
*/
public function getLastName() {
return $this->last_name;
}
/**
* Last name of the merchant. 30 characters max.
*
* @param string $last_name
*/
public function setLastName($last_name)
{
$this->last_name = $last_name;
return $this;
}
/**
* Last name of the merchant. 30 characters max.
*
* @param string $last_name
* @deprecated. Instead use setLastName
*/
public function setLast_name($last_name) {
$this->last_name = $last_name;
return $this;
}
/**
* Last name of the merchant. 30 characters max.
*
* @return string
* @deprecated. Instead use getLastName
*/
public function getLast_name() {
return $this->last_name;
}
/**
* Last name of the merchant. 30 characters max.
*
* @return string
*/
public function getLastName()
{
return $this->last_name;
}
/**
* Address of the merchant.
*
* @param PayPal\Api\Address $address
*/
public function setAddress($address) {
$this->address = $address;
return $this;
}
/**
* Last name of the merchant. 30 characters max.
*
* @param string $last_name
* @deprecated. Instead use setLastName
*/
public function setLast_name($last_name)
{
$this->last_name = $last_name;
return $this;
}
/**
* Address of the merchant.
*
* @return PayPal\Api\Address
*/
public function getAddress() {
return $this->address;
}
/**
* Last name of the merchant. 30 characters max.
*
* @return string
* @deprecated. Instead use getLastName
*/
public function getLast_name()
{
return $this->last_name;
}
/**
* Address of the merchant.
*
* @param PayPal\Api\Address $address
*/
public function setAddress($address)
{
$this->address = $address;
return $this;
}
/**
* Address of the merchant.
*
* @return PayPal\Api\Address
*/
public function getAddress()
{
return $this->address;
}
/**
* Company business name of the merchant. 100 characters max.
*
* @param string $business_name
*/
public function setBusinessName($business_name) {
$this->business_name = $business_name;
return $this;
}
/**
* Company business name of the merchant. 100 characters max.
*
* @param string $business_name
*/
public function setBusinessName($business_name)
{
$this->business_name = $business_name;
return $this;
}
/**
* Company business name of the merchant. 100 characters max.
*
* @return string
*/
public function getBusinessName() {
return $this->business_name;
}
/**
* Company business name of the merchant. 100 characters max.
*
* @return string
*/
public function getBusinessName()
{
return $this->business_name;
}
/**
* Company business name of the merchant. 100 characters max.
*
* @param string $business_name
* @deprecated. Instead use setBusinessName
*/
public function setBusiness_name($business_name) {
$this->business_name = $business_name;
return $this;
}
/**
* Company business name of the merchant. 100 characters max.
*
* @return string
* @deprecated. Instead use getBusinessName
*/
public function getBusiness_name() {
return $this->business_name;
}
/**
* Company business name of the merchant. 100 characters max.
*
* @param string $business_name
* @deprecated. Instead use setBusinessName
*/
public function setBusiness_name($business_name)
{
$this->business_name = $business_name;
return $this;
}
/**
* Phone number of the merchant.
*
* @param PayPal\Api\Phone $phone
*/
public function setPhone($phone) {
$this->phone = $phone;
return $this;
}
/**
* Company business name of the merchant. 100 characters max.
*
* @return string
* @deprecated. Instead use getBusinessName
*/
public function getBusiness_name()
{
return $this->business_name;
}
/**
* Phone number of the merchant.
*
* @return PayPal\Api\Phone
*/
public function getPhone() {
return $this->phone;
}
/**
* Phone number of the merchant.
*
* @param PayPal\Api\Phone $phone
*/
public function setPhone($phone)
{
$this->phone = $phone;
return $this;
}
/**
* Phone number of the merchant.
*
* @return PayPal\Api\Phone
*/
public function getPhone()
{
return $this->phone;
}
/**
* Fax number of the merchant.
*
* @param PayPal\Api\Phone $fax
*/
public function setFax($fax) {
$this->fax = $fax;
return $this;
}
/**
* Fax number of the merchant.
*
* @param PayPal\Api\Phone $fax
*/
public function setFax($fax)
{
$this->fax = $fax;
return $this;
}
/**
* Fax number of the merchant.
*
* @return PayPal\Api\Phone
*/
public function getFax() {
return $this->fax;
}
/**
* Fax number of the merchant.
*
* @return PayPal\Api\Phone
*/
public function getFax()
{
return $this->fax;
}
/**
* Website of the merchant. 2048 characters max.
*
* @param string $website
*/
public function setWebsite($website) {
$this->website = $website;
return $this;
}
/**
* Website of the merchant. 2048 characters max.
*
* @param string $website
*/
public function setWebsite($website)
{
$this->website = $website;
return $this;
}
/**
* Website of the merchant. 2048 characters max.
*
* @return string
*/
public function getWebsite() {
return $this->website;
}
/**
* Website of the merchant. 2048 characters max.
*
* @return string
*/
public function getWebsite()
{
return $this->website;
}
/**
* Tax ID of the merchant. 100 characters max.
*
* @param string $tax_id
*/
public function setTaxId($tax_id) {
$this->tax_id = $tax_id;
return $this;
}
/**
* Tax ID of the merchant. 100 characters max.
*
* @param string $tax_id
*/
public function setTaxId($tax_id)
{
$this->tax_id = $tax_id;
return $this;
}
/**
* Tax ID of the merchant. 100 characters max.
*
* @return string
*/
public function getTaxId() {
return $this->tax_id;
}
/**
* Tax ID of the merchant. 100 characters max.
*
* @return string
*/
public function getTaxId()
{
return $this->tax_id;
}
/**
* Tax ID of the merchant. 100 characters max.
*
* @param string $tax_id
* @deprecated. Instead use setTaxId
*/
public function setTax_id($tax_id) {
$this->tax_id = $tax_id;
return $this;
}
/**
* Tax ID of the merchant. 100 characters max.
*
* @return string
* @deprecated. Instead use getTaxId
*/
public function getTax_id() {
return $this->tax_id;
}
/**
* Tax ID of the merchant. 100 characters max.
*
* @param string $tax_id
* @deprecated. Instead use setTaxId
*/
public function setTax_id($tax_id)
{
$this->tax_id = $tax_id;
return $this;
}
/**
* Option to display additional information such as business hours. 40 characters max.
*
* @param string $additional_info
*/
public function setAdditionalInfo($additional_info) {
$this->additional_info = $additional_info;
return $this;
}
/**
* Tax ID of the merchant. 100 characters max.
*
* @return string
* @deprecated. Instead use getTaxId
*/
public function getTax_id()
{
return $this->tax_id;
}
/**
* Option to display additional information such as business hours. 40 characters max.
*
* @return string
*/
public function getAdditionalInfo() {
return $this->additional_info;
}
/**
* Option to display additional information such as business hours. 40 characters max.
*
* @param string $additional_info
*/
public function setAdditionalInfo($additional_info)
{
$this->additional_info = $additional_info;
return $this;
}
/**
* Option to display additional information such as business hours. 40 characters max.
*
* @param string $additional_info
* @deprecated. Instead use setAdditionalInfo
*/
public function setAdditional_info($additional_info) {
$this->additional_info = $additional_info;
return $this;
}
/**
* Option to display additional information such as business hours. 40 characters max.
*
* @return string
* @deprecated. Instead use getAdditionalInfo
*/
public function getAdditional_info() {
return $this->additional_info;
}
/**
* Option to display additional information such as business hours. 40 characters max.
*
* @return string
*/
public function getAdditionalInfo()
{
return $this->additional_info;
}
/**
* Option to display additional information such as business hours. 40 characters max.
*
* @param string $additional_info
* @deprecated. Instead use setAdditionalInfo
*/
public function setAdditional_info($additional_info)
{
$this->additional_info = $additional_info;
return $this;
}
/**
* Option to display additional information such as business hours. 40 characters max.
*
* @return string
* @deprecated. Instead use getAdditionalInfo
*/
public function getAdditional_info()
{
return $this->additional_info;
}
}

View File

@@ -4,356 +4,402 @@ namespace PayPal\Api;
use PayPal\Common\PPModel;
use PayPal\Rest\ApiContext;
class Metadata extends PPModel {
/**
* Date when the resource was created.
*
* @param string $created_date
*/
public function setCreatedDate($created_date) {
$this->created_date = $created_date;
return $this;
}
class Metadata extends PPModel
{
/**
* Date when the resource was created.
*
* @param string $created_date
*/
public function setCreatedDate($created_date)
{
$this->created_date = $created_date;
return $this;
}
/**
* Date when the resource was created.
*
* @return string
*/
public function getCreatedDate() {
return $this->created_date;
}
/**
* Date when the resource was created.
*
* @return string
*/
public function getCreatedDate()
{
return $this->created_date;
}
/**
* Date when the resource was created.
*
* @param string $created_date
* @deprecated. Instead use setCreatedDate
*/
public function setCreated_date($created_date) {
$this->created_date = $created_date;
return $this;
}
/**
* Date when the resource was created.
*
* @return string
* @deprecated. Instead use getCreatedDate
*/
public function getCreated_date() {
return $this->created_date;
}
/**
* Date when the resource was created.
*
* @param string $created_date
* @deprecated. Instead use setCreatedDate
*/
public function setCreated_date($created_date)
{
$this->created_date = $created_date;
return $this;
}
/**
* Email address of the account that created the resource.
*
* @param string $created_by
*/
public function setCreatedBy($created_by) {
$this->created_by = $created_by;
return $this;
}
/**
* Date when the resource was created.
*
* @return string
* @deprecated. Instead use getCreatedDate
*/
public function getCreated_date()
{
return $this->created_date;
}
/**
* Email address of the account that created the resource.
*
* @return string
*/
public function getCreatedBy() {
return $this->created_by;
}
/**
* Email address of the account that created the resource.
*
* @param string $created_by
*/
public function setCreatedBy($created_by)
{
$this->created_by = $created_by;
return $this;
}
/**
* Email address of the account that created the resource.
*
* @param string $created_by
* @deprecated. Instead use setCreatedBy
*/
public function setCreated_by($created_by) {
$this->created_by = $created_by;
return $this;
}
/**
* Email address of the account that created the resource.
*
* @return string
* @deprecated. Instead use getCreatedBy
*/
public function getCreated_by() {
return $this->created_by;
}
/**
* Email address of the account that created the resource.
*
* @return string
*/
public function getCreatedBy()
{
return $this->created_by;
}
/**
* Date when the resource was cancelled.
*
* @param string $cancelled_date
*/
public function setCancelledDate($cancelled_date) {
$this->cancelled_date = $cancelled_date;
return $this;
}
/**
* Email address of the account that created the resource.
*
* @param string $created_by
* @deprecated. Instead use setCreatedBy
*/
public function setCreated_by($created_by)
{
$this->created_by = $created_by;
return $this;
}
/**
* Date when the resource was cancelled.
*
* @return string
*/
public function getCancelledDate() {
return $this->cancelled_date;
}
/**
* Email address of the account that created the resource.
*
* @return string
* @deprecated. Instead use getCreatedBy
*/
public function getCreated_by()
{
return $this->created_by;
}
/**
* Date when the resource was cancelled.
*
* @param string $cancelled_date
* @deprecated. Instead use setCancelledDate
*/
public function setCancelled_date($cancelled_date) {
$this->cancelled_date = $cancelled_date;
return $this;
}
/**
* Date when the resource was cancelled.
*
* @return string
* @deprecated. Instead use getCancelledDate
*/
public function getCancelled_date() {
return $this->cancelled_date;
}
/**
* Date when the resource was cancelled.
*
* @param string $cancelled_date
*/
public function setCancelledDate($cancelled_date)
{
$this->cancelled_date = $cancelled_date;
return $this;
}
/**
* Actor who cancelled the resource.
*
* @param string $cancelled_by
*/
public function setCancelledBy($cancelled_by) {
$this->cancelled_by = $cancelled_by;
return $this;
}
/**
* Date when the resource was cancelled.
*
* @return string
*/
public function getCancelledDate()
{
return $this->cancelled_date;
}
/**
* Actor who cancelled the resource.
*
* @return string
*/
public function getCancelledBy() {
return $this->cancelled_by;
}
/**
* Date when the resource was cancelled.
*
* @param string $cancelled_date
* @deprecated. Instead use setCancelledDate
*/
public function setCancelled_date($cancelled_date)
{
$this->cancelled_date = $cancelled_date;
return $this;
}
/**
* Actor who cancelled the resource.
*
* @param string $cancelled_by
* @deprecated. Instead use setCancelledBy
*/
public function setCancelled_by($cancelled_by) {
$this->cancelled_by = $cancelled_by;
return $this;
}
/**
* Actor who cancelled the resource.
*
* @return string
* @deprecated. Instead use getCancelledBy
*/
public function getCancelled_by() {
return $this->cancelled_by;
}
/**
* Date when the resource was cancelled.
*
* @return string
* @deprecated. Instead use getCancelledDate
*/
public function getCancelled_date()
{
return $this->cancelled_date;
}
/**
* Date when the resource was last edited.
*
* @param string $last_updated_date
*/
public function setLastUpdatedDate($last_updated_date) {
$this->last_updated_date = $last_updated_date;
return $this;
}
/**
* Actor who cancelled the resource.
*
* @param string $cancelled_by
*/
public function setCancelledBy($cancelled_by)
{
$this->cancelled_by = $cancelled_by;
return $this;
}
/**
* Date when the resource was last edited.
*
* @return string
*/
public function getLastUpdatedDate() {
return $this->last_updated_date;
}
/**
* Actor who cancelled the resource.
*
* @return string
*/
public function getCancelledBy()
{
return $this->cancelled_by;
}
/**
* Date when the resource was last edited.
*
* @param string $last_updated_date
* @deprecated. Instead use setLastUpdatedDate
*/
public function setLast_updated_date($last_updated_date) {
$this->last_updated_date = $last_updated_date;
return $this;
}
/**
* Date when the resource was last edited.
*
* @return string
* @deprecated. Instead use getLastUpdatedDate
*/
public function getLast_updated_date() {
return $this->last_updated_date;
}
/**
* Actor who cancelled the resource.
*
* @param string $cancelled_by
* @deprecated. Instead use setCancelledBy
*/
public function setCancelled_by($cancelled_by)
{
$this->cancelled_by = $cancelled_by;
return $this;
}
/**
* Email address of the account that last edited the resource.
*
* @param string $last_updated_by
*/
public function setLastUpdatedBy($last_updated_by) {
$this->last_updated_by = $last_updated_by;
return $this;
}
/**
* Actor who cancelled the resource.
*
* @return string
* @deprecated. Instead use getCancelledBy
*/
public function getCancelled_by()
{
return $this->cancelled_by;
}
/**
* Email address of the account that last edited the resource.
*
* @return string
*/
public function getLastUpdatedBy() {
return $this->last_updated_by;
}
/**
* Date when the resource was last edited.
*
* @param string $last_updated_date
*/
public function setLastUpdatedDate($last_updated_date)
{
$this->last_updated_date = $last_updated_date;
return $this;
}
/**
* Email address of the account that last edited the resource.
*
* @param string $last_updated_by
* @deprecated. Instead use setLastUpdatedBy
*/
public function setLast_updated_by($last_updated_by) {
$this->last_updated_by = $last_updated_by;
return $this;
}
/**
* Email address of the account that last edited the resource.
*
* @return string
* @deprecated. Instead use getLastUpdatedBy
*/
public function getLast_updated_by() {
return $this->last_updated_by;
}
/**
* Date when the resource was last edited.
*
* @return string
*/
public function getLastUpdatedDate()
{
return $this->last_updated_date;
}
/**
* Date when the resource was first sent.
*
* @param string $first_sent_date
*/
public function setFirstSentDate($first_sent_date) {
$this->first_sent_date = $first_sent_date;
return $this;
}
/**
* Date when the resource was last edited.
*
* @param string $last_updated_date
* @deprecated. Instead use setLastUpdatedDate
*/
public function setLast_updated_date($last_updated_date)
{
$this->last_updated_date = $last_updated_date;
return $this;
}
/**
* Date when the resource was first sent.
*
* @return string
*/
public function getFirstSentDate() {
return $this->first_sent_date;
}
/**
* Date when the resource was last edited.
*
* @return string
* @deprecated. Instead use getLastUpdatedDate
*/
public function getLast_updated_date()
{
return $this->last_updated_date;
}
/**
* Date when the resource was first sent.
*
* @param string $first_sent_date
* @deprecated. Instead use setFirstSentDate
*/
public function setFirst_sent_date($first_sent_date) {
$this->first_sent_date = $first_sent_date;
return $this;
}
/**
* Date when the resource was first sent.
*
* @return string
* @deprecated. Instead use getFirstSentDate
*/
public function getFirst_sent_date() {
return $this->first_sent_date;
}
/**
* Email address of the account that last edited the resource.
*
* @param string $last_updated_by
*/
public function setLastUpdatedBy($last_updated_by)
{
$this->last_updated_by = $last_updated_by;
return $this;
}
/**
* Date when the resource was last sent.
*
* @param string $last_sent_date
*/
public function setLastSentDate($last_sent_date) {
$this->last_sent_date = $last_sent_date;
return $this;
}
/**
* Email address of the account that last edited the resource.
*
* @return string
*/
public function getLastUpdatedBy()
{
return $this->last_updated_by;
}
/**
* Date when the resource was last sent.
*
* @return string
*/
public function getLastSentDate() {
return $this->last_sent_date;
}
/**
* Email address of the account that last edited the resource.
*
* @param string $last_updated_by
* @deprecated. Instead use setLastUpdatedBy
*/
public function setLast_updated_by($last_updated_by)
{
$this->last_updated_by = $last_updated_by;
return $this;
}
/**
* Date when the resource was last sent.
*
* @param string $last_sent_date
* @deprecated. Instead use setLastSentDate
*/
public function setLast_sent_date($last_sent_date) {
$this->last_sent_date = $last_sent_date;
return $this;
}
/**
* Date when the resource was last sent.
*
* @return string
* @deprecated. Instead use getLastSentDate
*/
public function getLast_sent_date() {
return $this->last_sent_date;
}
/**
* Email address of the account that last edited the resource.
*
* @return string
* @deprecated. Instead use getLastUpdatedBy
*/
public function getLast_updated_by()
{
return $this->last_updated_by;
}
/**
* Email address of the account that last sent the resource.
*
* @param string $last_sent_by
*/
public function setLastSentBy($last_sent_by) {
$this->last_sent_by = $last_sent_by;
return $this;
}
/**
* Date when the resource was first sent.
*
* @param string $first_sent_date
*/
public function setFirstSentDate($first_sent_date)
{
$this->first_sent_date = $first_sent_date;
return $this;
}
/**
* Email address of the account that last sent the resource.
*
* @return string
*/
public function getLastSentBy() {
return $this->last_sent_by;
}
/**
* Date when the resource was first sent.
*
* @return string
*/
public function getFirstSentDate()
{
return $this->first_sent_date;
}
/**
* Email address of the account that last sent the resource.
*
* @param string $last_sent_by
* @deprecated. Instead use setLastSentBy
*/
public function setLast_sent_by($last_sent_by) {
$this->last_sent_by = $last_sent_by;
return $this;
}
/**
* Email address of the account that last sent the resource.
*
* @return string
* @deprecated. Instead use getLastSentBy
*/
public function getLast_sent_by() {
return $this->last_sent_by;
}
/**
* Date when the resource was first sent.
*
* @param string $first_sent_date
* @deprecated. Instead use setFirstSentDate
*/
public function setFirst_sent_date($first_sent_date)
{
$this->first_sent_date = $first_sent_date;
return $this;
}
/**
* Date when the resource was first sent.
*
* @return string
* @deprecated. Instead use getFirstSentDate
*/
public function getFirst_sent_date()
{
return $this->first_sent_date;
}
/**
* Date when the resource was last sent.
*
* @param string $last_sent_date
*/
public function setLastSentDate($last_sent_date)
{
$this->last_sent_date = $last_sent_date;
return $this;
}
/**
* Date when the resource was last sent.
*
* @return string
*/
public function getLastSentDate()
{
return $this->last_sent_date;
}
/**
* Date when the resource was last sent.
*
* @param string $last_sent_date
* @deprecated. Instead use setLastSentDate
*/
public function setLast_sent_date($last_sent_date)
{
$this->last_sent_date = $last_sent_date;
return $this;
}
/**
* Date when the resource was last sent.
*
* @return string
* @deprecated. Instead use getLastSentDate
*/
public function getLast_sent_date()
{
return $this->last_sent_date;
}
/**
* Email address of the account that last sent the resource.
*
* @param string $last_sent_by
*/
public function setLastSentBy($last_sent_by)
{
$this->last_sent_by = $last_sent_by;
return $this;
}
/**
* Email address of the account that last sent the resource.
*
* @return string
*/
public function getLastSentBy()
{
return $this->last_sent_by;
}
/**
* Email address of the account that last sent the resource.
*
* @param string $last_sent_by
* @deprecated. Instead use setLastSentBy
*/
public function setLast_sent_by($last_sent_by)
{
$this->last_sent_by = $last_sent_by;
return $this;
}
/**
* Email address of the account that last sent the resource.
*
* @return string
* @deprecated. Instead use getLastSentBy
*/
public function getLast_sent_by()
{
return $this->last_sent_by;
}
}

View File

@@ -4,84 +4,94 @@ namespace PayPal\Api;
use PayPal\Common\PPModel;
use PayPal\Rest\ApiContext;
class Notification extends PPModel {
/**
* Subject of the notification.
*
* @param string $subject
*/
public function setSubject($subject) {
$this->subject = $subject;
return $this;
}
class Notification extends PPModel
{
/**
* Subject of the notification.
*
* @param string $subject
*/
public function setSubject($subject)
{
$this->subject = $subject;
return $this;
}
/**
* Subject of the notification.
*
* @return string
*/
public function getSubject() {
return $this->subject;
}
/**
* Subject of the notification.
*
* @return string
*/
public function getSubject()
{
return $this->subject;
}
/**
* Note to the payer.
*
* @param string $note
*/
public function setNote($note) {
$this->note = $note;
return $this;
}
/**
* Note to the payer.
*
* @param string $note
*/
public function setNote($note)
{
$this->note = $note;
return $this;
}
/**
* Note to the payer.
*
* @return string
*/
public function getNote() {
return $this->note;
}
/**
* Note to the payer.
*
* @return string
*/
public function getNote()
{
return $this->note;
}
/**
* A flag indicating whether a copy of the email has to be sent to the merchant.
*
* @param boolean $send_to_merchant
*/
public function setSendToMerchant($send_to_merchant) {
$this->send_to_merchant = $send_to_merchant;
return $this;
}
/**
* A flag indicating whether a copy of the email has to be sent to the merchant.
*
* @param boolean $send_to_merchant
*/
public function setSendToMerchant($send_to_merchant)
{
$this->send_to_merchant = $send_to_merchant;
return $this;
}
/**
* A flag indicating whether a copy of the email has to be sent to the merchant.
*
* @return boolean
*/
public function getSendToMerchant() {
return $this->send_to_merchant;
}
/**
* A flag indicating whether a copy of the email has to be sent to the merchant.
*
* @return boolean
*/
public function getSendToMerchant()
{
return $this->send_to_merchant;
}
/**
* A flag indicating whether a copy of the email has to be sent to the merchant.
*
* @param boolean $send_to_merchant
* @deprecated. Instead use setSendToMerchant
*/
public function setSend_to_merchant($send_to_merchant) {
$this->send_to_merchant = $send_to_merchant;
return $this;
}
/**
* A flag indicating whether a copy of the email has to be sent to the merchant.
*
* @return boolean
* @deprecated. Instead use getSendToMerchant
*/
public function getSend_to_merchant() {
return $this->send_to_merchant;
}
/**
* A flag indicating whether a copy of the email has to be sent to the merchant.
*
* @param boolean $send_to_merchant
* @deprecated. Instead use setSendToMerchant
*/
public function setSend_to_merchant($send_to_merchant)
{
$this->send_to_merchant = $send_to_merchant;
return $this;
}
/**
* A flag indicating whether a copy of the email has to be sent to the merchant.
*
* @return boolean
* @deprecated. Instead use getSendToMerchant
*/
public function getSend_to_merchant()
{
return $this->send_to_merchant;
}
}

View File

@@ -7,7 +7,7 @@ use PayPal\Rest\ApiContext;
/**
* Class Order
*
*
* @property string id
* @property string createTime
* @property string updateTime
@@ -21,9 +21,9 @@ class Order extends PPModel
{
/**
* Set the identifier of the order transaction.
*
*
* @param string $id
*
*
* @return $this
*/
public function setId($id)
@@ -35,7 +35,7 @@ class Order extends PPModel
/**
* Get the identifier of the order transaction.
*
*
* @return string
*/
public function getId()
@@ -45,9 +45,9 @@ class Order extends PPModel
/**
* Set the time the resource was created.
*
*
* @param string $create_time
*
*
* @return $this
*/
public function setCreateTime($create_time)
@@ -59,7 +59,7 @@ class Order extends PPModel
/**
* Get the time the resource was created.
*
*
* @return string
*/
public function getCreateTime()
@@ -69,9 +69,9 @@ class Order extends PPModel
/**
* Set the time the resource was last updated.
*
*
* @param string $update_time
*
*
* @return $this
*/
public function setUpdateTime($update_time)
@@ -83,7 +83,7 @@ class Order extends PPModel
/**
* Get the time the resource was last updated.
*
*
* @return string
*/
public function getUpdateTime()
@@ -93,11 +93,11 @@ class Order extends PPModel
/**
* Set the state of the order transaction.
*
*
* Allowed values are: `PENDING`, `COMPLETED`, `REFUNDED` or `PARTIALLY_REFUNDED`.
*
*
* @param string $state
*
*
* @return $this
*/
public function setState($state)
@@ -109,9 +109,9 @@ class Order extends PPModel
/**
* Get the state of the order transaction.
*
*
* Allowed values are: `PENDING`, `COMPLETED`, `REFUNDED` or `PARTIALLY_REFUNDED`.
*
*
* @return string
*/
public function getState()
@@ -121,9 +121,9 @@ class Order extends PPModel
/**
* Set the amount being collected.
*
*
* @param \PayPal\Api\Amount $amount
*
*
* @return $this
*/
public function setAmount($amount)
@@ -135,7 +135,7 @@ class Order extends PPModel
/**
* Get the amount being collected.
*
*
* @return \PayPal\Api\Amount
*/
public function getAmount()
@@ -145,9 +145,9 @@ class Order extends PPModel
/**
* Set ID of the payment resource on which this transaction is based.
*
*
* @param string $parent_payment
*
*
* @return $this
*/
public function setParentPayment($parent_payment)
@@ -159,7 +159,7 @@ class Order extends PPModel
/**
* Get ID of the payment resource on which this transaction is based.
*
*
* @return string
*/
public function getParentPayment()
@@ -169,9 +169,9 @@ class Order extends PPModel
/**
* Set Links
*
*
* @param \PayPal\Api\Links $links
*
*
* @return $this
*/
public function setLinks($links)
@@ -183,7 +183,7 @@ class Order extends PPModel
/**
* Get Links
*
*
* @return \PayPal\Api\Links
*/
public function getLinks()
@@ -193,16 +193,16 @@ class Order extends PPModel
/**
* Reason code for the transaction state being Pending or Reversed. Assigned in response.
*
*
* Allowed values: `CHARGEBACK`, `GUARANTEE`, `BUYER_COMPLAINT`, `REFUND`,
* `UNCONFIRMED_SHIPPING_ADDRESS`,
* `ECHECK`, `INTERNATIONAL_WITHDRAWAL`,
* `RECEIVING_PREFERENCE_MANDATES_MANUAL_ACTION`, `PAYMENT_REVIEW`,
* `REGULATORY_REVIEW`, `UNILATERAL`, or `VERIFICATION_REQUIRED`
* (`ORDER` can also be set in the response).
*
*
* @param string $reason_code
*
*
* @return $this
*/
public function setReasonCode($reason_code)
@@ -214,14 +214,14 @@ class Order extends PPModel
/**
* Reason code for the transaction state being Pending or Reversed. Assigned in response.
*
*
* Allowed values: `CHARGEBACK`, `GUARANTEE`, `BUYER_COMPLAINT`, `REFUND`,
* `UNCONFIRMED_SHIPPING_ADDRESS`,
* `ECHECK`, `INTERNATIONAL_WITHDRAWAL`,
* `RECEIVING_PREFERENCE_MANDATES_MANUAL_ACTION`, `PAYMENT_REVIEW`,
* `REGULATORY_REVIEW`, `UNILATERAL`, or `VERIFICATION_REQUIRED`
* (`ORDER` can also be set in the response).
*
*
* @return string
*/
public function getReasonCode()

View File

@@ -279,7 +279,7 @@ class PayerInfo extends PPModel
return $this;
}
/**
* Get Shipping Address
* Shipping address of the Payer from their PayPal Account

View File

@@ -4,163 +4,182 @@ namespace PayPal\Api;
use PayPal\Common\PPModel;
use PayPal\Rest\ApiContext;
class PaymentDetail extends PPModel {
/**
* PayPal payment detail indicating whether payment was made in an invoicing flow via PayPal or externally. In the case of the mark-as-paid API, payment type is EXTERNAL and this is what is now supported. The PAYPAL value is provided for backward compatibility.
*
* @param string $type
*/
public function setType($type) {
$this->type = $type;
return $this;
}
class PaymentDetail extends PPModel
{
/**
* PayPal payment detail indicating whether payment was made in an invoicing flow via PayPal or externally. In the case of the mark-as-paid API, payment type is EXTERNAL and this is what is now supported. The PAYPAL value is provided for backward compatibility.
*
* @param string $type
*/
public function setType($type)
{
$this->type = $type;
return $this;
}
/**
* PayPal payment detail indicating whether payment was made in an invoicing flow via PayPal or externally. In the case of the mark-as-paid API, payment type is EXTERNAL and this is what is now supported. The PAYPAL value is provided for backward compatibility.
*
* @return string
*/
public function getType() {
return $this->type;
}
/**
* PayPal payment detail indicating whether payment was made in an invoicing flow via PayPal or externally. In the case of the mark-as-paid API, payment type is EXTERNAL and this is what is now supported. The PAYPAL value is provided for backward compatibility.
*
* @return string
*/
public function getType()
{
return $this->type;
}
/**
* PayPal payment transaction id. Mandatory field in case the type value is PAYPAL.
*
* @param string $transaction_id
*/
public function setTransactionId($transaction_id) {
$this->transaction_id = $transaction_id;
return $this;
}
/**
* PayPal payment transaction id. Mandatory field in case the type value is PAYPAL.
*
* @param string $transaction_id
*/
public function setTransactionId($transaction_id)
{
$this->transaction_id = $transaction_id;
return $this;
}
/**
* PayPal payment transaction id. Mandatory field in case the type value is PAYPAL.
*
* @return string
*/
public function getTransactionId() {
return $this->transaction_id;
}
/**
* PayPal payment transaction id. Mandatory field in case the type value is PAYPAL.
*
* @return string
*/
public function getTransactionId()
{
return $this->transaction_id;
}
/**
* PayPal payment transaction id. Mandatory field in case the type value is PAYPAL.
*
* @param string $transaction_id
* @deprecated. Instead use setTransactionId
*/
public function setTransaction_id($transaction_id) {
$this->transaction_id = $transaction_id;
return $this;
}
/**
* PayPal payment transaction id. Mandatory field in case the type value is PAYPAL.
*
* @return string
* @deprecated. Instead use getTransactionId
*/
public function getTransaction_id() {
return $this->transaction_id;
}
/**
* PayPal payment transaction id. Mandatory field in case the type value is PAYPAL.
*
* @param string $transaction_id
* @deprecated. Instead use setTransactionId
*/
public function setTransaction_id($transaction_id)
{
$this->transaction_id = $transaction_id;
return $this;
}
/**
* Type of the transaction.
*
* @param string $transaction_type
*/
public function setTransactionType($transaction_type) {
$this->transaction_type = $transaction_type;
return $this;
}
/**
* PayPal payment transaction id. Mandatory field in case the type value is PAYPAL.
*
* @return string
* @deprecated. Instead use getTransactionId
*/
public function getTransaction_id()
{
return $this->transaction_id;
}
/**
* Type of the transaction.
*
* @return string
*/
public function getTransactionType() {
return $this->transaction_type;
}
/**
* Type of the transaction.
*
* @param string $transaction_type
*/
public function setTransactionType($transaction_type)
{
$this->transaction_type = $transaction_type;
return $this;
}
/**
* Type of the transaction.
*
* @param string $transaction_type
* @deprecated. Instead use setTransactionType
*/
public function setTransaction_type($transaction_type) {
$this->transaction_type = $transaction_type;
return $this;
}
/**
* Type of the transaction.
*
* @return string
* @deprecated. Instead use getTransactionType
*/
public function getTransaction_type() {
return $this->transaction_type;
}
/**
* Type of the transaction.
*
* @return string
*/
public function getTransactionType()
{
return $this->transaction_type;
}
/**
* Date when the invoice was paid. Date format: yyyy-MM-dd z. For example, 2014-02-27 PST.
*
* @param string $date
*/
public function setDate($date) {
$this->date = $date;
return $this;
}
/**
* Type of the transaction.
*
* @param string $transaction_type
* @deprecated. Instead use setTransactionType
*/
public function setTransaction_type($transaction_type)
{
$this->transaction_type = $transaction_type;
return $this;
}
/**
* Date when the invoice was paid. Date format: yyyy-MM-dd z. For example, 2014-02-27 PST.
*
* @return string
*/
public function getDate() {
return $this->date;
}
/**
* Type of the transaction.
*
* @return string
* @deprecated. Instead use getTransactionType
*/
public function getTransaction_type()
{
return $this->transaction_type;
}
/**
* Date when the invoice was paid. Date format: yyyy-MM-dd z. For example, 2014-02-27 PST.
*
* @param string $date
*/
public function setDate($date)
{
$this->date = $date;
return $this;
}
/**
* Date when the invoice was paid. Date format: yyyy-MM-dd z. For example, 2014-02-27 PST.
*
* @return string
*/
public function getDate()
{
return $this->date;
}
/**
* Payment mode or method. This field is mandatory if the value of the type field is OTHER.
*
* @param string $method
*/
public function setMethod($method) {
$this->method = $method;
return $this;
}
/**
* Payment mode or method. This field is mandatory if the value of the type field is OTHER.
*
* @param string $method
*/
public function setMethod($method)
{
$this->method = $method;
return $this;
}
/**
* Payment mode or method. This field is mandatory if the value of the type field is OTHER.
*
* @return string
*/
public function getMethod() {
return $this->method;
}
/**
* Payment mode or method. This field is mandatory if the value of the type field is OTHER.
*
* @return string
*/
public function getMethod()
{
return $this->method;
}
/**
* Optional note associated with the payment.
*
* @param string $note
*/
public function setNote($note) {
$this->note = $note;
return $this;
}
/**
* Optional note associated with the payment.
*
* @param string $note
*/
public function setNote($note)
{
$this->note = $note;
return $this;
}
/**
* Optional note associated with the payment.
*
* @return string
*/
public function getNote() {
return $this->note;
}
/**
* Optional note associated with the payment.
*
* @return string
*/
public function getNote()
{
return $this->note;
}
}

View File

@@ -108,7 +108,7 @@ class PaymentHistory extends PPModel
return $this;
}
/**
* Get Next ID
* Identifier of the next element to get the next range of results

View File

@@ -4,83 +4,94 @@ namespace PayPal\Api;
use PayPal\Common\PPModel;
use PayPal\Rest\ApiContext;
class PaymentTerm extends PPModel {
/**
* Terms by which the invoice payment is due.
*
* @param string $term_type
*/
public function setTermType($term_type) {
$this->term_type = $term_type;
return $this;
}
class PaymentTerm extends PPModel
{
/**
* Terms by which the invoice payment is due.
*
* @param string $term_type
*/
public function setTermType($term_type)
{
$this->term_type = $term_type;
return $this;
}
/**
* Terms by which the invoice payment is due.
*
* @return string
*/
public function getTermType() {
return $this->term_type;
}
/**
* Terms by which the invoice payment is due.
*
* @return string
*/
public function getTermType()
{
return $this->term_type;
}
/**
* Terms by which the invoice payment is due.
*
* @param string $term_type
* @deprecated. Instead use setTermType
*/
public function setTerm_type($term_type) {
$this->term_type = $term_type;
return $this;
}
/**
* Terms by which the invoice payment is due.
*
* @return string
* @deprecated. Instead use getTermType
*/
public function getTerm_type() {
return $this->term_type;
}
/**
* Terms by which the invoice payment is due.
*
* @param string $term_type
* @deprecated. Instead use setTermType
*/
public function setTerm_type($term_type)
{
$this->term_type = $term_type;
return $this;
}
/**
* Date on which invoice payment is due. It must be always a future date. Date format: yyyy-MM-dd z. For example, 2014-02-27 PST
*
* @param string $due_date
*/
public function setDueDate($due_date) {
$this->due_date = $due_date;
return $this;
}
/**
* Terms by which the invoice payment is due.
*
* @return string
* @deprecated. Instead use getTermType
*/
public function getTerm_type()
{
return $this->term_type;
}
/**
* Date on which invoice payment is due. It must be always a future date. Date format: yyyy-MM-dd z. For example, 2014-02-27 PST
*
* @return string
*/
public function getDueDate() {
return $this->due_date;
}
/**
* Date on which invoice payment is due. It must be always a future date. Date format: yyyy-MM-dd z. For example, 2014-02-27 PST
*
* @param string $due_date
*/
public function setDueDate($due_date)
{
$this->due_date = $due_date;
return $this;
}
/**
* Date on which invoice payment is due. It must be always a future date. Date format: yyyy-MM-dd z. For example, 2014-02-27 PST
*
* @param string $due_date
* @deprecated. Instead use setDueDate
*/
public function setDue_date($due_date) {
$this->due_date = $due_date;
return $this;
}
/**
* Date on which invoice payment is due. It must be always a future date. Date format: yyyy-MM-dd z. For example, 2014-02-27 PST
*
* @return string
* @deprecated. Instead use getDueDate
*/
public function getDue_date() {
return $this->due_date;
}
/**
* Date on which invoice payment is due. It must be always a future date. Date format: yyyy-MM-dd z. For example, 2014-02-27 PST
*
* @return string
*/
public function getDueDate()
{
return $this->due_date;
}
/**
* Date on which invoice payment is due. It must be always a future date. Date format: yyyy-MM-dd z. For example, 2014-02-27 PST
*
* @param string $due_date
* @deprecated. Instead use setDueDate
*/
public function setDue_date($due_date)
{
$this->due_date = $due_date;
return $this;
}
/**
* Date on which invoice payment is due. It must be always a future date. Date format: yyyy-MM-dd z. For example, 2014-02-27 PST
*
* @return string
* @deprecated. Instead use getDueDate
*/
public function getDue_date()
{
return $this->due_date;
}
}

View File

@@ -4,83 +4,94 @@ namespace PayPal\Api;
use PayPal\Common\PPModel;
use PayPal\Rest\ApiContext;
class Phone extends PPModel {
/**
* Country code (in E.164 format). Assume length is n.
*
* @param string $country_code
*/
public function setCountryCode($country_code) {
$this->country_code = $country_code;
return $this;
}
class Phone extends PPModel
{
/**
* Country code (in E.164 format). Assume length is n.
*
* @param string $country_code
*/
public function setCountryCode($country_code)
{
$this->country_code = $country_code;
return $this;
}
/**
* Country code (in E.164 format). Assume length is n.
*
* @return string
*/
public function getCountryCode() {
return $this->country_code;
}
/**
* Country code (in E.164 format). Assume length is n.
*
* @return string
*/
public function getCountryCode()
{
return $this->country_code;
}
/**
* Country code (in E.164 format). Assume length is n.
*
* @param string $country_code
* @deprecated. Instead use setCountryCode
*/
public function setCountry_code($country_code) {
$this->country_code = $country_code;
return $this;
}
/**
* Country code (in E.164 format). Assume length is n.
*
* @return string
* @deprecated. Instead use getCountryCode
*/
public function getCountry_code() {
return $this->country_code;
}
/**
* Country code (in E.164 format). Assume length is n.
*
* @param string $country_code
* @deprecated. Instead use setCountryCode
*/
public function setCountry_code($country_code)
{
$this->country_code = $country_code;
return $this;
}
/**
* In-country phone number (in E.164 format). Maximum (15 - n) digits.
*
* @param string $national_number
*/
public function setNationalNumber($national_number) {
$this->national_number = $national_number;
return $this;
}
/**
* Country code (in E.164 format). Assume length is n.
*
* @return string
* @deprecated. Instead use getCountryCode
*/
public function getCountry_code()
{
return $this->country_code;
}
/**
* In-country phone number (in E.164 format). Maximum (15 - n) digits.
*
* @return string
*/
public function getNationalNumber() {
return $this->national_number;
}
/**
* In-country phone number (in E.164 format). Maximum (15 - n) digits.
*
* @param string $national_number
*/
public function setNationalNumber($national_number)
{
$this->national_number = $national_number;
return $this;
}
/**
* In-country phone number (in E.164 format). Maximum (15 - n) digits.
*
* @param string $national_number
* @deprecated. Instead use setNationalNumber
*/
public function setNational_number($national_number) {
$this->national_number = $national_number;
return $this;
}
/**
* In-country phone number (in E.164 format). Maximum (15 - n) digits.
*
* @return string
* @deprecated. Instead use getNationalNumber
*/
public function getNational_number() {
return $this->national_number;
}
/**
* In-country phone number (in E.164 format). Maximum (15 - n) digits.
*
* @return string
*/
public function getNationalNumber()
{
return $this->national_number;
}
/**
* In-country phone number (in E.164 format). Maximum (15 - n) digits.
*
* @param string $national_number
* @deprecated. Instead use setNationalNumber
*/
public function setNational_number($national_number)
{
$this->national_number = $national_number;
return $this;
}
/**
* In-country phone number (in E.164 format). Maximum (15 - n) digits.
*
* @return string
* @deprecated. Instead use getNationalNumber
*/
public function getNational_number()
{
return $this->national_number;
}
}

View File

@@ -23,8 +23,7 @@ class RedirectUrls extends PPModel
*/
public function setReturnUrl($return_url)
{
if(filter_var($return_url, FILTER_VALIDATE_URL) === false)
{
if (filter_var($return_url, FILTER_VALIDATE_URL) === false) {
throw new \InvalidArgumentException("Return URL is not a fully qualified URL");
}
@@ -84,8 +83,7 @@ class RedirectUrls extends PPModel
*/
public function setCancelUrl($cancel_url)
{
if(filter_var($cancel_url, FILTER_VALIDATE_URL) === false)
{
if (filter_var($cancel_url, FILTER_VALIDATE_URL) === false) {
throw new \InvalidArgumentException("Cancel URL is not a fully qualified URL");
}
$this->cancel_url = $cancel_url;
@@ -120,7 +118,7 @@ class RedirectUrls extends PPModel
return $this;
}
/**
* Get Cancel URL
* Url where the payer would be redirected to after canceling the payment

View File

@@ -4,65 +4,72 @@ namespace PayPal\Api;
use PayPal\Common\PPModel;
use PayPal\Rest\ApiContext;
class RefundDetail extends PPModel {
/**
* PayPal refund type indicating whether refund was done in invoicing flow via PayPal or externally. In the case of the mark-as-refunded API, refund type is EXTERNAL and this is what is now supported. The PAYPAL value is provided for backward compatibility.
*
* @param string $type
*/
public function setType($type) {
$this->type = $type;
return $this;
}
class RefundDetail extends PPModel
{
/**
* PayPal refund type indicating whether refund was done in invoicing flow via PayPal or externally. In the case of the mark-as-refunded API, refund type is EXTERNAL and this is what is now supported. The PAYPAL value is provided for backward compatibility.
*
* @param string $type
*/
public function setType($type)
{
$this->type = $type;
return $this;
}
/**
* PayPal refund type indicating whether refund was done in invoicing flow via PayPal or externally. In the case of the mark-as-refunded API, refund type is EXTERNAL and this is what is now supported. The PAYPAL value is provided for backward compatibility.
*
* @return string
*/
public function getType() {
return $this->type;
}
/**
* PayPal refund type indicating whether refund was done in invoicing flow via PayPal or externally. In the case of the mark-as-refunded API, refund type is EXTERNAL and this is what is now supported. The PAYPAL value is provided for backward compatibility.
*
* @return string
*/
public function getType()
{
return $this->type;
}
/**
* Date when the invoice was marked as refunded. If no date is specified, the current date and time is used as the default. In addition, the date must be after the invoice payment date.
*
* @param string $date
*/
public function setDate($date) {
$this->date = $date;
return $this;
}
/**
* Date when the invoice was marked as refunded. If no date is specified, the current date and time is used as the default. In addition, the date must be after the invoice payment date.
*
* @param string $date
*/
public function setDate($date)
{
$this->date = $date;
return $this;
}
/**
* Date when the invoice was marked as refunded. If no date is specified, the current date and time is used as the default. In addition, the date must be after the invoice payment date.
*
* @return string
*/
public function getDate() {
return $this->date;
}
/**
* Date when the invoice was marked as refunded. If no date is specified, the current date and time is used as the default. In addition, the date must be after the invoice payment date.
*
* @return string
*/
public function getDate()
{
return $this->date;
}
/**
* Optional note associated with the refund.
*
* @param string $note
*/
public function setNote($note) {
$this->note = $note;
return $this;
}
/**
* Optional note associated with the refund.
*
* @param string $note
*/
public function setNote($note)
{
$this->note = $note;
return $this;
}
/**
* Optional note associated with the refund.
*
* @return string
*/
public function getNote() {
return $this->note;
}
/**
* Optional note associated with the refund.
*
* @return string
*/
public function getNote()
{
return $this->note;
}
}

View File

@@ -117,9 +117,9 @@ class RelatedResources extends PPModel
/**
* Set Order
*
*
* @param \PayPal\Api\Order $order
*
*
* @return $this
*/
public function setOrder($order)
@@ -131,7 +131,7 @@ class RelatedResources extends PPModel
/**
* Get Order
*
*
* @return \PayPal\Api\Order
*/
public function getOrder()

File diff suppressed because it is too large Load Diff

View File

@@ -4,45 +4,50 @@ namespace PayPal\Api;
use PayPal\Common\PPModel;
use PayPal\Rest\ApiContext;
class ShippingCost extends PPModel {
/**
* Shipping cost in amount. Range of 0 to 999999.99.
*
* @param PayPal\Api\Currency $amount
*/
public function setAmount($amount) {
$this->amount = $amount;
return $this;
}
class ShippingCost extends PPModel
{
/**
* Shipping cost in amount. Range of 0 to 999999.99.
*
* @param PayPal\Api\Currency $amount
*/
public function setAmount($amount)
{
$this->amount = $amount;
return $this;
}
/**
* Shipping cost in amount. Range of 0 to 999999.99.
*
* @return PayPal\Api\Currency
*/
public function getAmount() {
return $this->amount;
}
/**
* Shipping cost in amount. Range of 0 to 999999.99.
*
* @return PayPal\Api\Currency
*/
public function getAmount()
{
return $this->amount;
}
/**
* Tax percentage on shipping amount.
*
* @param PayPal\Api\Tax $tax
*/
public function setTax($tax) {
$this->tax = $tax;
return $this;
}
/**
* Tax percentage on shipping amount.
*
* @param PayPal\Api\Tax $tax
*/
public function setTax($tax)
{
$this->tax = $tax;
return $this;
}
/**
* Tax percentage on shipping amount.
*
* @return PayPal\Api\Tax
*/
public function getTax() {
return $this->tax;
}
/**
* Tax percentage on shipping amount.
*
* @return PayPal\Api\Tax
*/
public function getTax()
{
return $this->tax;
}
}

View File

@@ -4,162 +4,182 @@ namespace PayPal\Api;
use PayPal\Common\PPModel;
use PayPal\Rest\ApiContext;
class ShippingInfo extends PPModel {
/**
* First name of the invoice recipient. 30 characters max.
*
* @param string $first_name
*/
public function setFirstName($first_name) {
$this->first_name = $first_name;
return $this;
}
class ShippingInfo extends PPModel
{
/**
* First name of the invoice recipient. 30 characters max.
*
* @param string $first_name
*/
public function setFirstName($first_name)
{
$this->first_name = $first_name;
return $this;
}
/**
* First name of the invoice recipient. 30 characters max.
*
* @return string
*/
public function getFirstName() {
return $this->first_name;
}
/**
* First name of the invoice recipient. 30 characters max.
*
* @return string
*/
public function getFirstName()
{
return $this->first_name;
}
/**
* First name of the invoice recipient. 30 characters max.
*
* @param string $first_name
* @deprecated. Instead use setFirstName
*/
public function setFirst_name($first_name) {
$this->first_name = $first_name;
return $this;
}
/**
* First name of the invoice recipient. 30 characters max.
*
* @return string
* @deprecated. Instead use getFirstName
*/
public function getFirst_name() {
return $this->first_name;
}
/**
* First name of the invoice recipient. 30 characters max.
*
* @param string $first_name
* @deprecated. Instead use setFirstName
*/
public function setFirst_name($first_name)
{
$this->first_name = $first_name;
return $this;
}
/**
* Last name of the invoice recipient. 30 characters max.
*
* @param string $last_name
*/
public function setLastName($last_name) {
$this->last_name = $last_name;
return $this;
}
/**
* First name of the invoice recipient. 30 characters max.
*
* @return string
* @deprecated. Instead use getFirstName
*/
public function getFirst_name()
{
return $this->first_name;
}
/**
* Last name of the invoice recipient. 30 characters max.
*
* @return string
*/
public function getLastName() {
return $this->last_name;
}
/**
* Last name of the invoice recipient. 30 characters max.
*
* @param string $last_name
*/
public function setLastName($last_name)
{
$this->last_name = $last_name;
return $this;
}
/**
* Last name of the invoice recipient. 30 characters max.
*
* @param string $last_name
* @deprecated. Instead use setLastName
*/
public function setLast_name($last_name) {
$this->last_name = $last_name;
return $this;
}
/**
* Last name of the invoice recipient. 30 characters max.
*
* @return string
* @deprecated. Instead use getLastName
*/
public function getLast_name() {
return $this->last_name;
}
/**
* Last name of the invoice recipient. 30 characters max.
*
* @return string
*/
public function getLastName()
{
return $this->last_name;
}
/**
* Company business name of the invoice recipient. 100 characters max.
*
* @param string $business_name
*/
public function setBusinessName($business_name) {
$this->business_name = $business_name;
return $this;
}
/**
* Last name of the invoice recipient. 30 characters max.
*
* @param string $last_name
* @deprecated. Instead use setLastName
*/
public function setLast_name($last_name)
{
$this->last_name = $last_name;
return $this;
}
/**
* Company business name of the invoice recipient. 100 characters max.
*
* @return string
*/
public function getBusinessName() {
return $this->business_name;
}
/**
* Last name of the invoice recipient. 30 characters max.
*
* @return string
* @deprecated. Instead use getLastName
*/
public function getLast_name()
{
return $this->last_name;
}
/**
* Company business name of the invoice recipient. 100 characters max.
*
* @param string $business_name
* @deprecated. Instead use setBusinessName
*/
public function setBusiness_name($business_name) {
$this->business_name = $business_name;
return $this;
}
/**
* Company business name of the invoice recipient. 100 characters max.
*
* @return string
* @deprecated. Instead use getBusinessName
*/
public function getBusiness_name() {
return $this->business_name;
}
/**
* Company business name of the invoice recipient. 100 characters max.
*
* @param string $business_name
*/
public function setBusinessName($business_name)
{
$this->business_name = $business_name;
return $this;
}
/**
*
*
* @param PayPal\Api\Phone $phone
*/
public function setPhone($phone) {
$this->phone = $phone;
return $this;
}
/**
* Company business name of the invoice recipient. 100 characters max.
*
* @return string
*/
public function getBusinessName()
{
return $this->business_name;
}
/**
*
*
* @return PayPal\Api\Phone
*/
public function getPhone() {
return $this->phone;
}
/**
* Company business name of the invoice recipient. 100 characters max.
*
* @param string $business_name
* @deprecated. Instead use setBusinessName
*/
public function setBusiness_name($business_name)
{
$this->business_name = $business_name;
return $this;
}
/**
* Company business name of the invoice recipient. 100 characters max.
*
* @return string
* @deprecated. Instead use getBusinessName
*/
public function getBusiness_name()
{
return $this->business_name;
}
/**
*
*
* @param PayPal\Api\Phone $phone
*/
public function setPhone($phone)
{
$this->phone = $phone;
return $this;
}
/**
*
*
* @return PayPal\Api\Phone
*/
public function getPhone()
{
return $this->phone;
}
/**
* Address of the invoice recipient.
*
* @param PayPal\Api\Address $address
*/
public function setAddress($address) {
$this->address = $address;
return $this;
}
/**
* Address of the invoice recipient.
*
* @param PayPal\Api\Address $address
*/
public function setAddress($address)
{
$this->address = $address;
return $this;
}
/**
* Address of the invoice recipient.
*
* @return PayPal\Api\Address
*/
public function getAddress() {
return $this->address;
}
/**
* Address of the invoice recipient.
*
* @return PayPal\Api\Address
*/
public function getAddress()
{
return $this->address;
}
}

View File

@@ -4,85 +4,94 @@ namespace PayPal\Api;
use PayPal\Common\PPModel;
use PayPal\Rest\ApiContext;
class Tax extends PPModel {
/**
* Identifier of the resource.
*
* @param string $id
*/
public function setId($id) {
$this->id = $id;
return $this;
}
class Tax extends PPModel
{
/**
* Identifier of the resource.
*
* @param string $id
*/
public function setId($id)
{
$this->id = $id;
return $this;
}
/**
* Identifier of the resource.
*
* @return string
*/
public function getId() {
return $this->id;
}
/**
* Identifier of the resource.
*
* @return string
*/
public function getId()
{
return $this->id;
}
/**
* Name of the tax. 10 characters max.
*
* @param string $name
*/
public function setName($name) {
$this->name = $name;
return $this;
}
/**
* Name of the tax. 10 characters max.
*
* @param string $name
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Name of the tax. 10 characters max.
*
* @return string
*/
public function getName() {
return $this->name;
}
/**
* Name of the tax. 10 characters max.
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Rate of the specified tax. Range of 0.001 to 99.999.
*
* @param PayPal\Api\number $percent
*/
public function setPercent($percent) {
$this->percent = $percent;
return $this;
}
/**
* Rate of the specified tax. Range of 0.001 to 99.999.
*
* @param PayPal\Api\number $percent
*/
public function setPercent($percent)
{
$this->percent = $percent;
return $this;
}
/**
* Rate of the specified tax. Range of 0.001 to 99.999.
*
* @return PayPal\Api\number
*/
public function getPercent() {
return $this->percent;
}
/**
* Rate of the specified tax. Range of 0.001 to 99.999.
*
* @return PayPal\Api\number
*/
public function getPercent()
{
return $this->percent;
}
/**
* Tax in the form of money. Cannot be specified in a request.
*
* @param PayPal\Api\Currency $amount
*/
public function setAmount($amount) {
$this->amount = $amount;
return $this;
}
/**
* Tax in the form of money. Cannot be specified in a request.
*
* @param PayPal\Api\Currency $amount
*/
public function setAmount($amount)
{
$this->amount = $amount;
return $this;
}
/**
* Tax in the form of money. Cannot be specified in a request.
*
* @return PayPal\Api\Currency
*/
public function getAmount() {
return $this->amount;
}
/**
* Tax in the form of money. Cannot be specified in a request.
*
* @return PayPal\Api\Currency
*/
public function getAmount()
{
return $this->amount;
}
}

View File

@@ -0,0 +1,28 @@
<?php
namespace PayPal\Common;
/**
* Class PPArrayUtil
* Util Class for Arrays
*
* @package PayPal\Common
*/
class PPArrayUtil
{
/**
*
* @param array $arr
* @return true if $arr is an associative array
*/
public static function isAssocArray(array $arr)
{
foreach ($arr as $k => $v) {
if (is_int($k)) {
return false;
}
}
return true;
}
}

View File

@@ -0,0 +1,148 @@
<?php
namespace PayPal\Common;
/**
* Generic Model class that all API domain classes extend
* Stores all member data in a Hashmap that enables easy
* JSON encoding/decoding
*/
class PPModel
{
private $_propMap = array();
/**
* Magic Get Method
*
* @param $key
* @return mixed
*/
public function __get($key)
{
return $this->_propMap[$key];
}
/**
* Magic Set Method
*
* @param $key
* @param $value
*/
public function __set($key, $value)
{
$this->_propMap[$key] = $value;
}
/**
* Magic isSet Method
*
* @param $key
* @return bool
*/
public function __isset($key)
{
return isset($this->_propMap[$key]);
}
/**
* Magic Unset Method
*
* @param $key
*/
public function __unset($key)
{
unset($this->_propMap[$key]);
}
/**
* Converts Params to Array
*
* @param $param
* @return array
*/
private function _convertToArray($param)
{
$ret = array();
foreach ($param as $k => $v) {
if ($v instanceof PPModel) {
$ret[$k] = $v->toArray();
} else if (is_array($v)) {
$ret[$k] = $this->_convertToArray($v);
} else {
$ret[$k] = $v;
}
}
return $ret;
}
/**
* Fills object value from Array list
*
* @param $arr
* @return $this
*/
public function fromArray($arr)
{
foreach ($arr as $k => $v) {
if (is_array($v)) {
$clazz = PPReflectionUtil::getPropertyClass(get_class($this), $k);
if (PPArrayUtil::isAssocArray($v)) {
/** @var self $o */
$o = new $clazz();
$o->fromArray($v);
$this->__set($k, $o);
} else {
$arr = array();
foreach ($v as $nk => $nv) {
if (is_array($nv)) {
$o = new $clazz();
$o->fromArray($nv);
$arr[$nk] = $o;
} else {
$arr[$nk] = $nv;
}
}
$this->__set($k, $arr);
}
} else {
$this->$k = $v;
}
}
return $this;
}
/**
* Fills object value from Json string
*
* @param $json
* @return $this
*/
public function fromJson($json)
{
return $this->fromArray(json_decode($json, true));
}
/**
* Returns array representation of object
*
* @return array
*/
public function toArray()
{
return $this->_convertToArray($this->_propMap);
}
/**
* Returns object JSON representation
*
* @param int $options http://php.net/manual/en/json.constants.php
* @return string
*/
public function toJSON($options = 0)
{
return json_encode($this->toArray(), $options);
}
}

View File

@@ -0,0 +1,102 @@
<?php
namespace PayPal\Common;
/**
* Class PPReflectionUtil
*
* @package PayPal\Common
*/
class PPReflectionUtil
{
/**
* Reflection Methods
*
* @var \ReflectionMethod[]
*/
private static $propertiesRefl = array();
/**
* Properties Type
*
* @var string[]
*/
private static $propertiesType = array();
/**
* Gets Property Class
*
* @param $class
* @param $propertyName
* @return string
*/
public static function getPropertyClass($class, $propertyName)
{
if (($annotations = self::propertyAnnotations($class, $propertyName)) && isset($annotations['return'])) {
$param = $annotations['return'];
}
if (isset($param)) {
$anno = explode(' ', $param);
return $anno[0];
} else {
return 'string';
}
}
/**
* Retrieves Annotations of each property
*
* @param $class
* @param $propertyName
* @throws \RuntimeException
* @return mixed
*/
public static function propertyAnnotations($class, $propertyName)
{
$class = is_object($class) ? get_class($class) : $class;
if (!class_exists('ReflectionProperty')) {
throw new \RuntimeException("Property type of " . $class . "::{$propertyName} cannot be resolved");
}
if ($annotations =& self::$propertiesType[$class][$propertyName]) {
return $annotations;
}
if (!($refl =& self::$propertiesRefl[$class][$propertyName])) {
$getter = method_exists($class, "get" . ucfirst($propertyName)) ?
"get" . ucfirst($propertyName) :
"get" . preg_replace_callback("/([_\-\s]?([a-z0-9]+))/", "self::replace_callback", $propertyName);
$refl = new \ReflectionMethod($class, $getter);
self::$propertiesRefl[$class][$propertyName] = $refl;
}
// todo: smarter regexp
if ( !preg_match_all(
'~\@([^\s@\(]+)[\t ]*(?:\(?([^\n@]+)\)?)?~i',
$refl->getDocComment(),
$annots,
PREG_PATTERN_ORDER)) {
return null;
}
foreach ($annots[1] as $i => $annot) {
$annotations[strtolower($annot)] = empty($annots[2][$i]) ? TRUE : rtrim($annots[2][$i], " \t\n\r)");
}
return $annotations;
}
/**
* preg_replace_callback callback function
*
* @param $match
* @return string
*/
private static function replace_callback($match)
{
return ucwords($match[2]);
}
}

View File

@@ -0,0 +1,59 @@
<?php
namespace PayPal\Common;
/**
* Class PPUserAgent
* PPUserAgent generates User Agent for curl requests
*
* @package PayPal\Common
*/
class PPUserAgent
{
/**
* Returns the value of the User-Agent header
* Add environment values and php version numbers
*
* @param string $sdkName
* @param string $sdkVersion
* @return string
*/
public static function getValue($sdkName, $sdkVersion)
{
$featureList = array(
'lang=PHP',
'v=' . PHP_VERSION,
'bit=' . self::_getPHPBit(),
'os=' . str_replace(' ', '_', php_uname('s') . ' ' . php_uname('r')),
'machine=' . php_uname('m')
);
if (defined('OPENSSL_VERSION_TEXT')) {
$opensslVersion = explode(' ', OPENSSL_VERSION_TEXT);
$featureList[] = 'openssl=' . $opensslVersion[1];
}
if (function_exists('curl_version')) {
$curlVersion = curl_version();
$featureList[] = 'curl=' . $curlVersion['version'];
}
return sprintf("PayPalSDK/%s %s (%s)", $sdkName, $sdkVersion, implode(';', $featureList));
}
/**
* Gets PHP Bit version
*
* @return int|string
*/
private static function _getPHPBit()
{
switch (PHP_INT_SIZE) {
case 4:
return '32';
case 8:
return '64';
default:
return PHP_INT_SIZE;
}
}
}

View File

@@ -0,0 +1,163 @@
<?php
namespace PayPal\Core;
/**
* Class PPConfigManager
*
* PPConfigManager loads the SDK configuration file and
* hands out appropriate config params to other classes
*
* @package PayPal\Core
*/
class PPConfigManager
{
/**
* Configuration Options
*
* @var array
*/
private $configs = array(
"http.ConnectionTimeOut" => "30",
"http.Retry" => "5",
);
/**
* Singleton Object
*
* @var $this
*/
private static $instance;
/**
* Private Constructor
*/
private function __construct()
{
if (defined('PP_CONFIG_PATH')) {
$configFile = constant('PP_CONFIG_PATH') . '/sdk_config.ini';
} else {
$configFile = implode(DIRECTORY_SEPARATOR,
array(dirname(__FILE__), "..", "config", "sdk_config.ini"));
}
$this->addConfigFromIni($configFile);
}
/**
* Returns the singleton object
*
* @return $this
*/
public static function getInstance()
{
if (!isset(self::$instance)) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Add Configuration from configuration.ini files
*
* @param string $fileName
* @return $this
*/
public function addConfigFromIni($fileName)
{
if ($configs = @parse_ini_file($fileName)) {
$this->addConfigs($configs);
}
return $this;
}
/**
* If a configuration exists in both arrays,
* then the element from the first array will be used and
* the matching key's element from the second array will be ignored.
*
* @param [] $config
* @return $this
*/
public function addConfigs($configs = [])
{
$this->configs = $configs + $this->configs;
return $this;
}
/**
* Simple getter for configuration params
* If an exact match for key is not found,
* does a "contains" search on the key
*
* @param string $searchKey
* @return array
*/
public function get($searchKey)
{
if (array_key_exists($searchKey, $this->configs)) {
return $this->configs[$searchKey];
} else {
$arr = array();
foreach ($this->configs as $k => $v) {
if (strstr($k, $searchKey)) {
$arr[$k] = $v;
}
}
return $arr;
}
}
/**
* Utility method for handling account configuration
* return config key corresponding to the API userId passed in
*
* If $userId is null, returns config keys corresponding to
* all configured accounts
*
* @param string|null $userId
* @return array|string
*/
public function getIniPrefix($userId = null)
{
if ($userId == null) {
$arr = array();
foreach ($this->configs as $key => $value) {
$pos = strpos($key, '.');
if (strstr($key, "acct")) {
$arr[] = substr($key, 0, $pos);
}
}
return array_unique($arr);
} else {
$iniPrefix = array_search($userId, $this->configs);
$pos = strpos($iniPrefix, '.');
$acct = substr($iniPrefix, 0, $pos);
return $acct;
}
}
/**
* returns the config file hashmap
*/
public function getConfigHashmap()
{
return $this->configs;
}
/**
* Disabling __clone call
*/
public function __clone()
{
trigger_error('Clone is not allowed.', E_USER_ERROR);
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace PayPal\Core;
/**
* Class PPConstants
* Placeholder for Paypal Constants
*
* @package PayPal\Core
*/
class PPConstants
{
const SDK_NAME = 'rest-api-sdk-php';
const SDK_VERSION = '0.11.0';
const REST_SANDBOX_ENDPOINT = "https://api.sandbox.paypal.com/";
const REST_LIVE_ENDPOINT = "https://api.paypal.com/";
}

View File

@@ -0,0 +1,167 @@
<?php
namespace PayPal\Core;
use PayPal\Auth\OAuthTokenCredential;
use PayPal\Exception\PPInvalidCredentialException;
/**
* Class PPCredentialManager
*
* PPCredentialManager holds all the credential information in one place.
*
* @package PayPal\Core
*/
class PPCredentialManager
{
/**
* Singleton Object
*
* @var self
*/
private static $instance;
/**
* Hashmap to contain credentials for accounts.
*
* @var array
*/
private $credentialHashmap = array();
/**
* Contains the API username of the default account to use
* when authenticating API calls
*
* @var string
*/
private $defaultAccountName;
/**
* Constructor initialize credential for multiple accounts specified in property file
*
* @param $config
* @throws \Exception
*/
private function __construct($config)
{
try {
$this->initCredential($config);
} catch (\Exception $e) {
$this->credentialHashmap = array();
throw $e;
}
}
/**
* Create singleton instance for this class.
*
* @param array|null $config
* @return PPCredentialManager
*/
public static function getInstance($config = null)
{
if (!self::$instance) {
self::$instance = new self($config == null ? PPConfigManager::getInstance()->getConfigHashmap() : $config);
}
return self::$instance;
}
/**
* Load credentials for multiple accounts, with priority given to Signature credential.
*
* @param [] $config
*/
private function initCredential($config)
{
$suffix = 1;
$prefix = "acct";
$arr = array();
foreach ($config as $k => $v) {
if (strstr($k, $prefix)) {
$arr[$k] = $v;
}
}
$credArr = $arr;
$arr = array();
foreach ($config as $key => $value) {
$pos = strpos($key, '.');
if (strstr($key, "acct")) {
$arr[] = substr($key, 0, $pos);
}
}
$arrayPartKeys = array_unique($arr);
$key = $prefix . $suffix;
$userName = null;
while (in_array($key, $arrayPartKeys)) {
if (isset($credArr[$key . ".ClientId"]) && isset($credArr[$key . ".ClientId"])) {
$userName = $key;
$this->credentialHashmap[$userName] = new OAuthTokenCredential(
$credArr[$key . ".ClientId"],
$credArr[$key . ".ClientSecret"]
);
}
if ($userName && $this->defaultAccountName == null) {
if (array_key_exists($key . '.UserName', $credArr)) {
$this->defaultAccountName = $credArr[$key . '.UserName'];
} else {
$this->defaultAccountName = $key;
}
}
$suffix++;
$key = $prefix . $suffix;
}
}
/**
* Sets credential object for users
*
* @param \PayPal\Auth\OAuthTokenCredential $credential
* @param string|null $userId User Id associated with the account
* @param bool $default If set, it would make it as a default credential for all requests
*
* @return $this
*/
public function setCredentialObject(OAuthTokenCredential $credential, $userId = null, $default = true)
{
$key = $userId == null ? 'default' : $userId;
$this->credentialHashmap[$key] = $credential;
if ($default) {
$this->defaultAccountName = $key;
}
return $this;
}
/**
* Obtain Credential Object based on UserId provided.
*
* @param null $userId
* @return OAuthTokenCredential
* @throws PPInvalidCredentialException
*/
public function getCredentialObject($userId = null)
{
if ($userId == null) {
$credObj = $this->credentialHashmap[$this->defaultAccountName];
} else if (array_key_exists($userId, $this->credentialHashmap)) {
$credObj = $this->credentialHashmap[$userId];
}
if (empty($credObj)) {
throw new PPInvalidCredentialException("Invalid userId $userId");
}
return $credObj;
}
/**
* Disabling __clone call
*/
public function __clone()
{
trigger_error('Clone is not allowed.', E_USER_ERROR);
}
}

View File

@@ -0,0 +1,258 @@
<?php
namespace PayPal\Core;
use PayPal\Exception\PPConfigurationException;
/**
* Class PPHttpConfig
* Http Configuration Class
*
* @package PayPal\Core
*/
class PPHttpConfig
{
/**
* Some default options for curl
* These are typically overridden by PPConnectionManager
*
* @var array
*/
public static $defaultCurlOptions = array(
CURLOPT_SSLVERSION => 3,
CURLOPT_CONNECTTIMEOUT => 10,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_TIMEOUT => 60, // maximum number of seconds to allow cURL functions to execute
CURLOPT_USERAGENT => 'PayPal-PHP-SDK',
CURLOPT_HTTPHEADER => array(),
CURLOPT_SSL_VERIFYHOST => 2,
CURLOPT_SSL_VERIFYPEER => 1
);
const HEADER_SEPARATOR = ';';
const HTTP_GET = 'GET';
const HTTP_POST = 'POST';
private $headers = array();
private $curlOptions;
private $url;
private $method;
/***
* Number of times to retry a failed HTTP call
*/
private $retryCount = 0;
/**
* Default Constructor
*
* @param string $url
* @param string $method HTTP method (GET, POST etc) defaults to POST
*/
public function __construct($url = null, $method = self::HTTP_POST)
{
$this->url = $url;
$this->method = $method;
$this->curlOptions = self::$defaultCurlOptions;
}
/**
* Gets Url
*
* @return null|string
*/
public function getUrl()
{
return $this->url;
}
/**
* Gets Method
*
* @return string
*/
public function getMethod()
{
return $this->method;
}
/**
* Gets all Headers
*
* @return array
*/
public function getHeaders()
{
return $this->headers;
}
/**
* Get Header by Name
*
* @param $name
* @return string|null
*/
public function getHeader($name)
{
if (array_key_exists($name, $this->headers)) {
return $this->headers[$name];
}
return null;
}
/**
* Sets Url
*
* @param $url
*/
public function setUrl($url)
{
$this->url = $url;
}
/**
* Set Headers
*
* @param array $headers
*/
public function setHeaders(array $headers = [])
{
$this->headers = $headers;
}
/**
* Adds a Header
*
* @param $name
* @param $value
* @param bool $overWrite allows you to override header value
*/
public function addHeader($name, $value, $overWrite = true)
{
if (!array_key_exists($name, $this->headers) || $overWrite) {
$this->headers[$name] = $value;
} else {
$this->headers[$name] = $this->headers[$name] . self::HEADER_SEPARATOR . $value;
}
}
/**
* Removes a Header
*
* @param $name
*/
public function removeHeader($name)
{
unset($this->headers[$name]);
}
/**
* Gets all curl options
*
* @return array
*/
public function getCurlOptions()
{
return $this->curlOptions;
}
/**
* Add Curl Option
*
* @param string $name
* @param mixed $value
*/
public function addCurlOption($name, $value)
{
$this->curlOptions[$name] = $value;
}
/**
* Set Curl Options. Overrides all curl options
*
* @param $options
*/
public function setCurlOptions($options)
{
$this->curlOptions = $options;
}
/**
* Set ssl parameters for certificate based client authentication
*
* @param $certPath
* @param null $passPhrase
*/
public function setSSLCert($certPath, $passPhrase = null)
{
$this->curlOptions[CURLOPT_SSLCERT] = realpath($certPath);
if (isset($passPhrase) && trim($passPhrase) != "") {
$this->curlOptions[CURLOPT_SSLCERTPASSWD] = $passPhrase;
}
}
/**
* Set connection timeout in seconds
*
* @param integer $timeout
*/
public function setHttpTimeout($timeout)
{
$this->curlOptions[CURLOPT_CONNECTTIMEOUT] = $timeout;
}
/**
* Set HTTP proxy information
*
* @param string $proxy
* @throws PPConfigurationException
*/
public function setHttpProxy($proxy)
{
$urlParts = parse_url($proxy);
if ($urlParts == false || !array_key_exists("host", $urlParts)) {
throw new PPConfigurationException("Invalid proxy configuration " . $proxy);
}
$this->curlOptions[CURLOPT_PROXY] = $urlParts["host"];
if (isset($urlParts["port"])) {
$this->curlOptions[CURLOPT_PROXY] .= ":" . $urlParts["port"];
}
if (isset($urlParts["user"])) {
$this->curlOptions[CURLOPT_PROXYUSERPWD] = $urlParts["user"] . ":" . $urlParts["pass"];
}
}
/**
* Set Http Retry Counts
*
* @param int $retryCount
*/
public function setHttpRetryCount($retryCount)
{
$this->retryCount = $retryCount;
}
/**
* Get Http Retry Counts
*
* @return int
*/
public function getHttpRetryCount()
{
return $this->retryCount;
}
/**
* Sets the User-Agent string on the HTTP request
*
* @param string $userAgentString
*/
public function setUserAgent($userAgentString)
{
$this->curlOptions[CURLOPT_USERAGENT] = $userAgentString;
}
}

View File

@@ -0,0 +1,171 @@
<?php
namespace PayPal\Core;
use PayPal\Exception\PPConfigurationException;
use PayPal\Exception\PPConnectionException;
/**
* A wrapper class based on the curl extension.
* Requires the PHP curl module to be enabled.
* See for full requirements the PHP manual: http://php.net/curl
*/
class PPHttpConnection
{
/**
* @var PPHttpConfig
*/
private $httpConfig;
/**
* HTTP status codes for which a retry must be attempted
* retry is currently attempted for Request timeout, Bad Gateway,
* Service Unavailable and Gateway timeout errors.
*/
private static $retryCodes = array('408', '502', '503', '504',);
/**
* LoggingManager
*
* @var PPLoggingManager
*/
private $logger;
/**
* Default Constructor
*
* @param PPHttpConfig $httpConfig
* @param array $config
* @throws PPConfigurationException
*/
public function __construct(PPHttpConfig $httpConfig, array $config)
{
if (!function_exists("curl_init")) {
throw new PPConfigurationException("Curl module is not available on this system");
}
$this->httpConfig = $httpConfig;
$this->logger = new PPLoggingManager(__CLASS__, $config);
}
/**
* Gets all Http Headers
*
* @return array
*/
private function getHttpHeaders()
{
$ret = array();
foreach ($this->httpConfig->getHeaders() as $k => $v) {
$ret[] = "$k: $v";
}
return $ret;
}
/**
* Executes an HTTP request
*
* @param string $data query string OR POST content as a string
* @throws PPConnectionException
*/
/**
* Executes an HTTP request
*
* @param string $data query string OR POST content as a string
* @return mixed
* @throws PPConnectionException
*/
public function execute($data)
{
//Initialize the logger
$this->logger->fine("Connecting to " . $this->httpConfig->getUrl());
$this->logger->fine("Payload " . $data);
//Initialize Curl Options
$ch = curl_init($this->httpConfig->getUrl());
curl_setopt_array($ch, $this->httpConfig->getCurlOptions());
curl_setopt($ch, CURLOPT_URL, $this->httpConfig->getUrl());
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, $this->getHttpHeaders());
//Determine Curl Options based on Method
switch ($this->httpConfig->getMethod()) {
case 'POST':
curl_setopt($ch, CURLOPT_POST, true);
case 'PUT':
case 'PATCH':
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
break;
}
//Default Option if Method not of given types in switch case
if ($this->httpConfig->getMethod() != NULL) {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $this->httpConfig->getMethod());
}
//Logging Each Headers for debugging purposes
foreach ($this->getHttpHeaders() as $header) {
//TODO: Strip out credentials and other secure info when logging.
$this->logger->info("Adding header $header");
}
//Execute Curl Request
$result = curl_exec($ch);
//Retry if Certificate Exception
if (curl_errno($ch) == 60) {
$this->logger->info("Invalid or no certificate authority found - Retrying using bundled CA certs file");
curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/cacert.pem');
$result = curl_exec($ch);
}
//Retrieve Response Status
$httpStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);
//Retry if Failing
$retries = 0;
if (in_array($httpStatus, self::$retryCodes) && $this->httpConfig->getHttpRetryCount() != null) {
$this->logger->info("Got $httpStatus response from server. Retrying");
do {
$result = curl_exec($ch);
$httpStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);
} while (in_array($httpStatus, self::$retryCodes) && (++$retries < $this->httpConfig->getHttpRetryCount()));
}
//Throw Exception if Retries and Certificates doenst work
if (curl_errno($ch)) {
$ex = new PPConnectionException(
$this->httpConfig->getUrl(),
curl_error($ch),
curl_errno($ch)
);
curl_close($ch);
throw $ex;
}
//Close the curl request
curl_close($ch);
//More Exceptions based on HttpStatus Code
if (in_array($httpStatus, self::$retryCodes)) {
$ex = new PPConnectionException(
$this->httpConfig->getUrl(),
"Got Http response code $httpStatus when accessing {$this->httpConfig->getUrl()}. " .
"Retried $retries times."
);
$ex->setData($result);
throw $ex;
} else if ($httpStatus < 200 || $httpStatus >= 300) {
$ex = new PPConnectionException(
$this->httpConfig->getUrl(),
"Got Http response code $httpStatus when accessing {$this->httpConfig->getUrl()}."
);
$ex->setData($result);
throw $ex;
}
//Return result object
return $result;
}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace PayPal\Core;
/**
* Logging Levels.
* Class containing all the constants for Logging Levels.
*/
class PPLoggingLevel
{
// FINE Logging Level
const FINE = 3;
// INFO Logging Level
const INFO = 2;
// WARN Logging Level
const WARN = 1;
// ERROR Logging Level
const ERROR = 0;
}

View File

@@ -0,0 +1,119 @@
<?php
namespace PayPal\Core;
/**
* Simple Logging Manager.
* This does an error_log for now
* Potential frameworks to use are PEAR logger, log4php from Apache
*/
class PPLoggingManager
{
/**
* Default Logging Level
*/
const DEFAULT_LOGGING_LEVEL = 0;
/**
* Logger Name
* @var string
*/
private $loggerName;
/**
* Log Enabled
*
* @var bool
*/
private $isLoggingEnabled;
/**
* Configured Logging Level
*
* @var int|mixed
*/
private $loggingLevel;
/**
* Configured Logging File
*
* @var string
*/
private $loggerFile;
/**
* @param $loggerName
* @param array|null $config
*/
public function __construct($loggerName, $config = null)
{
$this->loggerName = $loggerName;
$config = PPConfigManager::getInstance()->getConfigHashmap();
$this->isLoggingEnabled = (array_key_exists('log.LogEnabled', $config) && $config['log.LogEnabled'] == '1');
if ($this->isLoggingEnabled) {
$this->loggerFile = ($config['log.FileName']) ? $config['log.FileName'] : ini_get('error_log');
$loggingLevel = strtoupper($config['log.LogLevel']);
$this->loggingLevel =
(isset($loggingLevel) && defined(__NAMESPACE__ . "\\PPLoggingLevel::$loggingLevel")) ?
constant(__NAMESPACE__ . "\\PPLoggingLevel::$loggingLevel") :
PPLoggingManager::DEFAULT_LOGGING_LEVEL;
}
}
/**
* Default Logger
*
* @param string $message
* @param int $level
*/
private function log($message, $level = PPLoggingLevel::INFO)
{
if ($this->isLoggingEnabled && ($level <= $this->loggingLevel)) {
error_log($this->loggerName . ": $message\n", 3, $this->loggerFile);
}
}
/**
* Log Error
*
* @param string $message
*/
public function error($message)
{
$this->log($message, PPLoggingLevel::ERROR);
}
/**
* Log Warning
*
* @param string $message
*/
public function warning($message)
{
$this->log($message, PPLoggingLevel::WARN);
}
/**
* Log Info
*
* @param string $message
*/
public function info($message)
{
$this->log($message, PPLoggingLevel::INFO);
}
/**
* Log Fine
*
* @param string $message
*/
public function fine($message)
{
$this->log($message, PPLoggingLevel::FINE);
}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace PayPal\Exception;
/**
* Class PPConfigurationException
*
* @package PayPal\Exception
*/
class PPConfigurationException extends \Exception
{
/**
* Default Constructor
*
* @param string|null $message
* @param int $code
*/
public function __construct($message = null, $code = 0)
{
parent::__construct($message, $code);
}
}

View File

@@ -0,0 +1,68 @@
<?php
namespace PayPal\Exception;
/**
* Class PPConnectionException
*
* @package PayPal\Exception
*/
class PPConnectionException extends \Exception
{
/**
* The url that was being connected to when the exception occured
*
* @var string
*/
private $url;
/**
* Any response data that was returned by the server
*
* @var string
*/
private $data;
/**
* Default Constructor
*
* @param string $url
* @param string $message
* @param int $code
*/
public function __construct($url, $message, $code = 0)
{
parent::__construct($message, $code);
$this->url = $url;
}
/**
* Sets Data
*
* @param $data
*/
public function setData($data)
{
$this->data = $data;
}
/**
* Gets Data
*
* @return string
*/
public function getData()
{
return $this->data;
}
/**
* Gets Url
*
* @return string
*/
public function getUrl()
{
return $this->url;
}
}

View File

@@ -0,0 +1,36 @@
<?php
namespace PayPal\Exception;
/**
* Class PPInvalidCredentialException
*
* @package PayPal\Exception
*/
class PPInvalidCredentialException extends \Exception
{
/**
* Default Constructor
*
* @param string|null $message
* @param int $code
*/
public function __construct($message = null, $code = 0)
{
parent::__construct($message, $code);
}
/**
* prints error message
*
* @return string
*/
public function errorMessage()
{
$errorMsg = 'Error on line ' . $this->getLine() . ' in ' . $this->getFile()
. ': <b>' . $this->getMessage() . '</b>';
return $errorMsg;
}
}

View File

@@ -0,0 +1,37 @@
<?php
namespace PayPal\Exception;
/**
* Class PPMissingCredentialException
*
* @package PayPal\Exception
*/
class PPMissingCredentialException extends \Exception
{
/**
* Default Constructor
*
* @param string $message
* @param int $code
*/
public function __construct($message = null, $code = 0)
{
parent::__construct($message, $code);
}
/**
* prints error message
*
* @return string
*/
public function errorMessage()
{
$errorMsg = 'Error on line ' . $this->getLine() . ' in ' . $this->getFile()
. ': <b>' . $this->getMessage() . '</b>';
return $errorMsg;
}
}

View File

@@ -0,0 +1,20 @@
<?php
namespace PayPal\Handler;
/**
* Interface IPPHandler
*
* @package PayPal\Handler
*/
interface IPPHandler
{
/**
*
* @param \Paypal\Core\PPHttpConfig $httpConfig
* @param string $request
* @param mixed $options
* @return mixed
*/
public function handle($httpConfig, $request, $options);
}

View File

@@ -1,23 +1,19 @@
<?php
/**
* Call level parameters such as request id, credentials etc
*/
namespace PayPal\Rest;
use PayPal\Common\PPApiContext;
use PayPal\Core\PPConfigManager;
use PayPal\Core\PPCredentialManager;
/**
* Class ApiContext
*
* Call level parameters such as request id, credentials etc
*
* @package PayPal\Rest
*/
class ApiContext extends PPApiContext
class ApiContext
{
/**
* OAuth Credentials to use for this call
*
* @var \PayPal\Auth\OAuthTokenCredential $credential
*/
private $credential;
/**
* Unique request id to be used for this call
@@ -28,6 +24,14 @@ class ApiContext extends PPApiContext
*/
private $requestId;
/**
* This is a placeholder for holding credential for the request
* If the value is not set, it would get the value from @\PayPal\Core\PPCredentialManager
*
* @var \Paypal\Auth\OAuthTokenCredential
*/
private $credential;
/**
* Get Credential
*
@@ -35,6 +39,9 @@ class ApiContext extends PPApiContext
*/
public function getCredential()
{
if ($this->credential == null) {
return PPCredentialManager::getInstance()->getCredentialObject();
}
return $this->credential;
}
@@ -58,16 +65,46 @@ class ApiContext extends PPApiContext
* @param \PayPal\Auth\OAuthTokenCredential $credential
* @param string|null $requestId
*/
public function __construct($credential, $requestId = null)
public function __construct($credential = null, $requestId = null)
{
$this->credential = $credential;
$this->requestId = $requestId;
$this->credential = $credential;
}
/**
* Sets Config
*
* @param array $config SDK configuration parameters
*/
public function setConfig(array $config)
{
PPConfigManager::getInstance()->addConfigs($config);
}
/**
* Gets Configurations
*
* @return array
*/
public function getConfig()
{
return PPConfigManager::getInstance()->getConfigHashmap();
}
/**
* Gets a specific configuration from key
*
* @param $searchKey
*/
public function get($searchKey)
{
PPConfigManager::getInstance()->get($searchKey);
}
/**
* Generates a unique per request id that
* can be used to set the PayPal-Request-Id header
* that is used for idemptency
* that is used for idempotency
*
* @return string
*/

View File

@@ -4,6 +4,8 @@ namespace PayPal\Rest;
/**
* Interface IResource
*
* @package PayPal\Rest
*/
interface IResource
{

View File

@@ -51,14 +51,13 @@ class RestHandler implements IPPHandler
}
/**
* Handle
*
* @param \PayPal\Core\PPHttpConfig $httpConfig
* @param \PayPal\Core\PPRequest $request
* @param array $options
*
* @throws \PayPal\Exception\PPInvalidCredentialException
* @throws \PayPal\Exception\PPMissingCredentialException
* @param \Paypal\Core\PPHttpConfig $httpConfig
* @param string $request
* @param mixed $options
* @return mixed|void
* @throws PPConfigurationException
* @throws PPInvalidCredentialException
* @throws PPMissingCredentialException
*/
public function handle($httpConfig, $request, $options)
{
@@ -125,7 +124,9 @@ class RestHandler implements IPPHandler
break;
}
} else {
throw new PPConfigurationException('You must set one of service.endpoint or mode parameters in your configuration');
throw new PPConfigurationException(
'You must set one of service.endpoint or mode parameters in your configuration'
);
}
}
}

View File

@@ -0,0 +1,78 @@
<?php
namespace PayPal\Transport;
use PayPal\Core\PPLoggingManager;
use PayPal\Core\PPHttpConfig;
use PayPal\Core\PPHttpConnection;
/**
* Class PPRestCall
*
* @package PayPal\Transport
*/
class PPRestCall
{
/**
* Paypal Logger
*
* @var PPLoggingManager logger interface
*/
private $logger;
/**
* API Context
*
* @var \Paypal\Rest\ApiContext
*/
private $apiContext;
/**
* Default Constructor
*
* @param \Paypal\Rest\ApiContext $apiContext
*/
public function __construct(\Paypal\Rest\ApiContext $apiContext)
{
$this->apiContext = $apiContext;
$this->logger = new PPLoggingManager(__CLASS__, $apiContext->getConfig());
}
/**
* @param array $handlers Array of handlers
* @param string $path Resource path relative to base service endpoint
* @param string $method HTTP method - one of GET, POST, PUT, DELETE, PATCH etc
* @param string $data Request payload
* @param array $headers HTTP headers
* @return mixed
* @throws \PayPal\Exception\PPConnectionException
*/
public function execute($handlers = [], $path, $method, $data = '', $headers = array())
{
$config = $this->apiContext->getConfig();
$httpConfig = new PPHttpConfig(null, $method);
$httpConfig->setHeaders($headers +
array(
'Content-Type' => 'application/json'
)
);
/** @var \Paypal\Handler\IPPHandler $handler */
foreach ($handlers as $handler) {
if (!is_object($handler)) {
$fullHandler = "\\" . (string)$handler;
$handler = new $fullHandler($this->apiContext);
}
$handler->handle($httpConfig, $data, array('path' => $path, 'apiContext' => $this->apiContext));
}
$connection = new PPHttpConnection($httpConfig, $config);
$response = $connection->execute($data);
$this->logger->fine($response);
return $response;
}
}

View File

@@ -1,6 +1,11 @@
PayPal PHP SDK release notes
============================
v0.11.1
----
* Removed Dependency from SDK Core Project
* Enabled Future Payments
v0.11.0
----
* Ability for PUT and PATCH requests
@@ -25,7 +30,7 @@ v0.7.0
-----
* Added support for Auth and Capture APIs
* Types modified to match the API Spec
* Updated SDK to use namespace supported core library
* Updated SDK to use namespace supported core library
v0.6.0
-----
@@ -34,4 +39,4 @@ v0.6.0
v0.5.0
-----
* Initial Release
* Initial Release

View File

@@ -6,13 +6,12 @@
// Include the composer autoloader
// The location of your project's vendor autoloader.
$composerAutoload = dirname(dirname(dirname(__DIR__))) . '/autoload.php';
if (!file_exists($composerAutoload))
{
if (!file_exists($composerAutoload)) {
//If the project is used as its own project, it would use rest-api-sdk-php composer autoloader.
$composerAutoload = dirname(__DIR__) .'/vendor/autoload.php';
$composerAutoload = dirname(__DIR__) . '/vendor/autoload.php';
if(!file_exists($composerAutoload)) {
if (!file_exists($composerAutoload)) {
echo "The 'vendor' folder is missing. You must run 'composer update' to resolve application dependencies.\nPlease see the README for more information.\n";
exit(1);
}
@@ -32,46 +31,46 @@ $apiContext = getApiContext();
*
* @return PayPal\Rest\ApiContext
*/
function getApiContext() {
// ### Api context
// Use an ApiContext object to authenticate
// API calls. The clientId and clientSecret for the
// OAuthTokenCredential class can be retrieved from
// developer.paypal.com
function getApiContext()
{
$apiContext = new ApiContext(
new OAuthTokenCredential(
'EBWKjlELKMYqRNQ6sYvFo64FtaRLRR5BdHEESmha49TM',
'EO422dn3gQLgDbuwqTjzrFgFtaRLRR5BdHEESmha49TM'
)
);
// ### Api context
// Use an ApiContext object to authenticate
// API calls. The clientId and clientSecret for the
// OAuthTokenCredential class can be retrieved from
// developer.paypal.com
$apiContext = new ApiContext(
new OAuthTokenCredential(
'EBWKjlELKMYqRNQ6sYvFo64FtaRLRR5BdHEESmha49TM',
'EO422dn3gQLgDbuwqTjzrFgFtaRLRR5BdHEESmha49TM'
)
);
// #### SDK configuration
// #### SDK configuration
// Comment this line out and uncomment the PP_CONFIG_PATH
// 'define' block if you want to use static file
// based configuration
// Comment this line out and uncomment the PP_CONFIG_PATH
// 'define' block if you want to use static file
// based configuration
$apiContext->setConfig(
array(
'mode' => 'sandbox',
'http.ConnectionTimeOut' => 30,
'log.LogEnabled' => true,
'log.FileName' => '../PayPal.log',
'log.LogLevel' => 'FINE'
)
);
/*
// Register the sdk_config.ini file in current directory
// as the configuration source.
if(!defined("PP_CONFIG_PATH")) {
define("PP_CONFIG_PATH", __DIR__);
}
*/
$apiContext->setConfig(
array(
'mode' => 'sandbox',
'http.ConnectionTimeOut' => 30,
'log.LogEnabled' => true,
'log.FileName' => '../PayPal.log',
'log.LogLevel' => 'FINE'
)
);
return $apiContext;
/*
// Register the sdk_config.ini file in current directory
// as the configuration source.
if(!defined("PP_CONFIG_PATH")) {
define("PP_CONFIG_PATH", __DIR__);
}
*/
return $apiContext;
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,44 @@
<!DOCTYPE html><html lang="en"><head><title>invoice/CancelInvoice</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="invoice/CancelInvoice"><meta name="groc-project-path" content="sample/invoice/CancelInvoice.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">sample/invoice/CancelInvoice.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="cancel-invoice-sample">Cancel Invoice Sample</h1>
<p>This sample code demonstrate how you can cancel
an invoice.</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">Invoice</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">CancelNotification</span>;
<span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="retrieve-invoice">Retrieve Invoice</h3>
<p>Retrieve the invoice object by calling the
static <code>get</code> method
on the Payment class by passing a valid
Invoice ID
(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$invoice</span> = Invoice::get(<span class="hljs-string">"INV2-CJL7-PF4G-BLQF-5FWG"</span>, <span class="hljs-variable">$apiContext</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="cancel-notification-object">Cancel Notification Object</h3>
<p>This would send a notification to both merchant as well
the payer about the cancellation. The information of
merchant and payer is retrieved from the invoice details</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$notify</span> = <span class="hljs-keyword">new</span> CancelNotification();
<span class="hljs-variable">$notify</span>
-&gt;setSubject(<span class="hljs-string">"Past due"</span>)
-&gt;setNote(<span class="hljs-string">"Canceling invoice"</span>)
-&gt;setSendToMerchant(<span class="hljs-keyword">true</span>)
-&gt;setSendToPayer(<span class="hljs-keyword">true</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="cancel-invoice">Cancel Invoice</h3>
<p>Cancel invoice object by calling the
static <code>cancel</code> method
on the Invoice class by passing a valid
notification object
(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$cancelStatus</span> = <span class="hljs-variable">$invoice</span>-&gt;cancel(<span class="hljs-variable">$notify</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>);
}
<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(JSON_PRETTY_PRINT); <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>

View File

@@ -0,0 +1,95 @@
<!DOCTYPE html><html lang="en"><head><title>invoice/CreateInvoice</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="invoice/CreateInvoice"><meta name="groc-project-path" content="sample/invoice/CreateInvoice.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">sample/invoice/CreateInvoice.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-invoice-sample">Create Invoice Sample</h1>
<p>This sample code demonstrate how you can create
an invoice.</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">Invoice</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">MerchantInfo</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">BillingInfo</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">InvoiceItem</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Phone</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Address</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">PaymentTerm</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">ShippingInfo</span>;
<span class="hljs-variable">$invoice</span> = <span class="hljs-keyword">new</span> Invoice();</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="invoice-info">Invoice Info</h3>
<p>Fill in all the information that is
required for invoice APIs</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$invoice</span>
-&gt;setMerchantInfo(<span class="hljs-keyword">new</span> MerchantInfo())
-&gt;setBillingInfo(<span class="hljs-keyword">array</span>(<span class="hljs-keyword">new</span> BillingInfo()))
-&gt;setItems(<span class="hljs-keyword">array</span>(<span class="hljs-keyword">new</span> InvoiceItem()))
-&gt;setNote(<span class="hljs-string">"Medical Invoice 16 Jul, 2013 PST"</span>)
-&gt;setPaymentTerm(<span class="hljs-keyword">new</span> PaymentTerm())
-&gt;setShippingInfo(<span class="hljs-keyword">new</span> ShippingInfo());</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="merchant-info">Merchant Info</h3>
<p>A resource representing merchant information that can be
used to identify merchant</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$invoice</span>-&gt;getMerchantInfo()
-&gt;setEmail(<span class="hljs-string">"PPX.DevNet-facilitator@gmail.com"</span>)
-&gt;setFirstName(<span class="hljs-string">"Dennis"</span>)
-&gt;setLastName(<span class="hljs-string">"Doctor"</span>)
-&gt;setbusinessName(<span class="hljs-string">"Medical Professionals, LLC"</span>)
-&gt;setPhone(<span class="hljs-keyword">new</span> Phone())
-&gt;setAddress(<span class="hljs-keyword">new</span> Address());
<span class="hljs-variable">$invoice</span>-&gt;getMerchantInfo()-&gt;getPhone()
-&gt;setCountryCode(<span class="hljs-string">"001"</span>)
-&gt;setNationalNumber(<span class="hljs-string">"5032141716"</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="address-information">Address Information</h3>
<p>The address used for creating the invoice</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$invoice</span>-&gt;getMerchantInfo()-&gt;getAddress()
-&gt;setLine1(<span class="hljs-string">"1234 Main St."</span>)
-&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>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="billing-information">Billing Information</h3>
<p>Set the email address for each billing</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$billing</span> = <span class="hljs-variable">$invoice</span>-&gt;getBillingInfo();
<span class="hljs-variable">$billing</span>[<span class="hljs-number">0</span>]
-&gt;setEmail(<span class="hljs-string">"example@example.com"</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="items-list">Items List</h3>
<p>You could provide the list of all items for
detailed breakdown of invoice</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$items</span> = <span class="hljs-variable">$invoice</span>-&gt;getItems();
<span class="hljs-variable">$items</span>[<span class="hljs-number">0</span>]
-&gt;setName(<span class="hljs-string">"Sutures"</span>)
-&gt;setQuantity(<span class="hljs-number">100</span>)
-&gt;setUnitPrice(<span class="hljs-keyword">new</span> Currency());
<span class="hljs-variable">$items</span>[<span class="hljs-number">0</span>]-&gt;getUnitPrice()
-&gt;setCurrency(<span class="hljs-string">"USD"</span>)
-&gt;setValue(<span class="hljs-number">5</span>);
<span class="hljs-variable">$invoice</span>-&gt;getPaymentTerm()
-&gt;setTermType(<span class="hljs-string">"NET_45"</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="shipping-information">Shipping Information</h3></div></div></div><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-variable">$invoice</span>-&gt;getShippingInfo()
-&gt;setFirstName(<span class="hljs-string">"Sally"</span>)
-&gt;setLastName(<span class="hljs-string">"Patient"</span>)
-&gt;setBusinessName(<span class="hljs-string">"Not applicable"</span>)
-&gt;setPhone(<span class="hljs-keyword">new</span> Phone())
-&gt;setAddress(<span class="hljs-keyword">new</span> Address());
<span class="hljs-variable">$invoice</span>-&gt;getShippingInfo()-&gt;getPhone()
-&gt;setCountryCode(<span class="hljs-string">"001"</span>)
-&gt;setNationalNumber(<span class="hljs-string">"5039871234"</span>);
<span class="hljs-variable">$invoice</span>-&gt;getShippingInfo()-&gt;getAddress()
-&gt;setLine1(<span class="hljs-string">"1234 Main St."</span>)
-&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>);
<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
with a valid ApiContext (See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$invoice</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>);
}
<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(JSON_PRETTY_PRINT); <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>

View File

@@ -0,0 +1,28 @@
<!DOCTYPE html><html lang="en"><head><title>invoice/GetInvoice</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="invoice/GetInvoice"><meta name="groc-project-path" content="sample/invoice/GetInvoice.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">sample/invoice/GetInvoice.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-invoice-sample">Get Invoice Sample</h1>
<p>This sample code demonstrate how you can retrieve
an invoice.</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">Invoice</span>;
<span class="hljs-variable">$invoiceId</span> = <span class="hljs-string">"INV2-9DRB-YTHU-2V9Q-7Q24"</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="retrieve-invoice">Retrieve Invoice</h3>
<p>Retrieve the invoice object by calling the
static <code>get</code> method
on the Invoice class by passing a valid
Invoice ID
(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
<span class="hljs-variable">$invoice</span> = Invoice::get(<span class="hljs-variable">$invoiceId</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>);
}
<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(JSON_PRETTY_PRINT); <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>

View File

@@ -0,0 +1,26 @@
<!DOCTYPE html><html lang="en"><head><title>invoice/ListInvoice</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="invoice/ListInvoice"><meta name="groc-project-path" content="sample/invoice/ListInvoice.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">sample/invoice/ListInvoice.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="list-invoices-sample">List Invoices Sample</h1>
<p>This sample code demonstrate how you can get
all invoice from history.</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">Invoice</span>;
<span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="retrieve-invoices">Retrieve Invoices</h3>
<p>Retrieve the Invoice History object by calling the
static <code>get_all</code> method on the Invoice class.
Refer the method doc for valid values for keys
(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$invoices</span> = Invoice::get_all(<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>);
}
<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(JSON_PRETTY_PRINT); <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>

View File

@@ -0,0 +1,43 @@
<!DOCTYPE html><html lang="en"><head><title>invoice/RemindInvoice</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="invoice/RemindInvoice"><meta name="groc-project-path" content="sample/invoice/RemindInvoice.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">sample/invoice/RemindInvoice.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="remind-invoice-sample">Remind Invoice Sample</h1>
<p>This sample code demonstrate how you can remind
an invoice to the payer</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">Invoice</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Notification</span>;
<span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="retrieve-invoice">Retrieve Invoice</h3>
<p>Retrieve the invoice object by calling the
static <code>get</code> method
on the Invoice class by passing a valid
Invoice ID
(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$invoice</span> = Invoice::get(<span class="hljs-string">"INV2-9CAH-K5G7-2JPL-G4B4"</span>, <span class="hljs-variable">$apiContext</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="notification-object">Notification Object</h3>
<p>This would send a notification to both merchant as well
the payer. The information of merchant
and payer is retrieved from the invoice details</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$notify</span> = <span class="hljs-keyword">new</span> Notification();
<span class="hljs-variable">$notify</span>
-&gt;setSubject(<span class="hljs-string">"Past due"</span>)
-&gt;setNote(<span class="hljs-string">"Please pay soon"</span>)
-&gt;setSendToMerchant(<span class="hljs-keyword">true</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="remind-invoice">Remind Invoice</h3>
<p>Remind the notifiers by calling the
<code>remind</code> method
on the Invoice class by passing a valid
notification object
(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$remindStatus</span> = <span class="hljs-variable">$invoice</span>-&gt;remind(<span class="hljs-variable">$notify</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>);
}
<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(JSON_PRETTY_PRINT); <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>

View File

@@ -0,0 +1,31 @@
<!DOCTYPE html><html lang="en"><head><title>invoice/SendInvoice</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="invoice/SendInvoice"><meta name="groc-project-path" content="sample/invoice/SendInvoice.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">sample/invoice/SendInvoice.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-invoice-sample">Create Invoice Sample</h1>
<p>This sample code demonstrate how you can send
a legitimate invoice to the payer</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">Invoice</span>;
<span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="retrieve-invoice">Retrieve Invoice</h3>
<p>Retrieve the invoice object by calling the
static <code>get</code> method
on the Invoice class by passing a valid
Invoice ID
(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$invoice</span> = Invoice::get(<span class="hljs-string">"INV2-9DRB-YTHU-2V9Q-7Q24"</span>, <span class="hljs-variable">$apiContext</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="send-invoice">Send Invoice</h3>
<p>Send a legitimate invoice to the payer
with a valid ApiContext (See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$sendStatus</span> = <span class="hljs-variable">$invoice</span>-&gt;send(<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>);
}
<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(JSON_PRETTY_PRINT); <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>

View File

@@ -0,0 +1,39 @@
<!DOCTYPE html><html lang="en"><head><title>payments/AuthorizationCapture</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="payments/AuthorizationCapture"><meta name="groc-project-path" content="sample/payments/AuthorizationCapture.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">sample/payments/AuthorizationCapture.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="authorizationcapture">AuthorizationCapture</h1>
<p>This sample code demonstrates how you can capture
a previously authorized payment.
API used: /v1/payments/payment</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">Amount</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Capture</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Authorization</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="capture-payment">Capture Payment</h3>
<p>You can capture and process a previously created authorization
by invoking the $authorization-&gt;capture method
with a valid ApiContext (See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><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>Create a new authorization to get authorization Id
createAuthorization defined in common.php</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$authId</span> = createAuthorization(<span class="hljs-variable">$apiContext</span>);
<span class="hljs-variable">$amt</span> = <span class="hljs-keyword">new</span> Amount();
<span class="hljs-variable">$amt</span>-&gt;setCurrency(<span class="hljs-string">"USD"</span>)
-&gt;setTotal(<span class="hljs-string">"1.00"</span>);
<span class="hljs-comment">### Capture</span>
<span class="hljs-variable">$capture</span> = <span class="hljs-keyword">new</span> Capture();
<span class="hljs-variable">$capture</span>-&gt;setId(<span class="hljs-variable">$authId</span>)
-&gt;setAmount(<span class="hljs-variable">$amt</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Lookup the authorization.</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$authorization</span> = Authorization::get(<span class="hljs-variable">$authId</span>, <span class="hljs-variable">$apiContext</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Perform a capture</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$getCapture</span> = <span class="hljs-variable">$authorization</span>-&gt;capture(<span class="hljs-variable">$capture</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>);
}
<span class="hljs-preprocessor">?&gt;</span>
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Capturing an authorization&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div&gt;
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(JSON_PRETTY_PRINT);<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>

View File

@@ -0,0 +1,97 @@
<!DOCTYPE html><html lang="en"><head><title>payments/CreatePayment</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="payments/CreatePayment"><meta name="groc-project-path" content="sample/payments/CreatePayment.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">sample/payments/CreatePayment.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="createpaymentsample">CreatePaymentSample</h1>
<p>This sample code demonstrate how you can process
a direct credit card payment. Please note that direct
credit card payment and related features using the
REST API is restricted in some countries.
API used: /v1/payments/payment</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">Amount</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Details</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Item</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">ItemList</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">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">FundingInstrument</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>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="creditcard">CreditCard</h3>
<p>A resource representing a credit card that can be
used to fund a payment.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$card</span> = <span class="hljs-keyword">new</span> CreditCard();
<span class="hljs-variable">$card</span>-&gt;setType(<span class="hljs-string">"visa"</span>)
-&gt;setNumber(<span class="hljs-string">"4417119669820331"</span>)
-&gt;setExpireMonth(<span class="hljs-string">"11"</span>)
-&gt;setExpireYear(<span class="hljs-string">"2019"</span>)
-&gt;setCvv2(<span class="hljs-string">"012"</span>)
-&gt;setFirstName(<span class="hljs-string">"Joe"</span>)
-&gt;setLastName(<span class="hljs-string">"Shopper"</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="fundinginstrument">FundingInstrument</h3>
<p>A resource representing a Payer&#39;s funding instrument.
For direct credit card payments, set the CreditCard
field on this object.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$fi</span> = <span class="hljs-keyword">new</span> FundingInstrument();
<span class="hljs-variable">$fi</span>-&gt;setCreditCard(<span class="hljs-variable">$card</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 direct credit card payments, set payment method
to &#39;credit_card&#39; and add an array of funding instruments.</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;setFundingInstruments(<span class="hljs-keyword">array</span>(<span class="hljs-variable">$fi</span>));</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="itemized-information">Itemized information</h3>
<p>(Optional) Lets you specify item wise
information</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$item1</span> = <span class="hljs-keyword">new</span> Item();
<span class="hljs-variable">$item1</span>-&gt;setName(<span class="hljs-string">'Ground Coffee 40 oz'</span>)
-&gt;setDescription(<span class="hljs-string">'Ground Coffee 40 oz'</span>)
-&gt;setCurrency(<span class="hljs-string">'USD'</span>)
-&gt;setQuantity(<span class="hljs-number">1</span>)
-&gt;setTax(<span class="hljs-string">'0.30'</span>)
-&gt;setPrice(<span class="hljs-string">'7.50'</span>);
<span class="hljs-variable">$item2</span> = <span class="hljs-keyword">new</span> Item();
<span class="hljs-variable">$item2</span>-&gt;setName(<span class="hljs-string">'Granola bars'</span>)
-&gt;setDescription(<span class="hljs-string">'Granola Bars with Peanuts'</span>)
-&gt;setCurrency(<span class="hljs-string">'USD'</span>)
-&gt;setQuantity(<span class="hljs-number">5</span>)
-&gt;setTax(<span class="hljs-string">'0.20'</span>)
-&gt;setPrice(<span class="hljs-string">'2.00'</span>);
<span class="hljs-variable">$itemList</span> = <span class="hljs-keyword">new</span> ItemList();
<span class="hljs-variable">$itemList</span>-&gt;setItems(<span class="hljs-keyword">array</span>(<span class="hljs-variable">$item1</span>, <span class="hljs-variable">$item2</span>));</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="additional-payment-details">Additional payment details</h3>
<p>Use this optional field to set additional
payment information such as tax, shipping
charges etc.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$details</span> = <span class="hljs-keyword">new</span> Details();
<span class="hljs-variable">$details</span>-&gt;setShipping(<span class="hljs-string">'1.20'</span>)
-&gt;setTax(<span class="hljs-string">'1.30'</span>)
-&gt;setSubtotal(<span class="hljs-string">'17.50'</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="amount">Amount</h3>
<p>Lets you specify a payment amount.
You can also specify additional details
such as shipping, tax.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$amount</span> = <span class="hljs-keyword">new</span> Amount();
<span class="hljs-variable">$amount</span>-&gt;setCurrency(<span class="hljs-string">"USD"</span>)
-&gt;setTotal(<span class="hljs-string">"20.00"</span>)
-&gt;setDetails(<span class="hljs-variable">$details</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="transaction">Transaction</h3>
<p>A transaction defines the contract of a
payment - what is the payment for and who
is fulfilling it. </p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$transaction</span> = <span class="hljs-keyword">new</span> Transaction();
<span class="hljs-variable">$transaction</span>-&gt;setAmount(<span class="hljs-variable">$amount</span>)
-&gt;setItemList(<span class="hljs-variable">$itemList</span>)
-&gt;setDescription(<span class="hljs-string">"Payment description"</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="payment">Payment</h3>
<p>A Payment Resource; create one using
the above types and intent set to sale &#39;sale&#39;</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$payment</span> = <span class="hljs-keyword">new</span> Payment();
<span class="hljs-variable">$payment</span>-&gt;setIntent(<span class="hljs-string">"sale"</span>)
-&gt;setPayer(<span class="hljs-variable">$payer</span>)
-&gt;setTransactions(<span class="hljs-keyword">array</span>(<span class="hljs-variable">$transaction</span>));</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="create-payment">Create Payment</h3>
<p>Create a payment by calling the payment-&gt;create() method
with a valid ApiContext (See bootstrap.php for more on <code>ApiContext</code>)
The return object contains the state.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
<span class="hljs-variable">$payment</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>);
}
<span class="hljs-preprocessor">?&gt;</span>
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Direct Credit card payments&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div&gt;
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(JSON_PRETTY_PRINT);<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>

View File

@@ -0,0 +1,90 @@
<!DOCTYPE html><html lang="en"><head><title>payments/CreatePaymentUsingPayPal</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="payments/CreatePaymentUsingPayPal"><meta name="groc-project-path" content="sample/payments/CreatePaymentUsingPayPal.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">sample/payments/CreatePaymentUsingPayPal.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-payment-using-paypal-as-payment-method">Create Payment using PayPal as payment method</h1>
<p>This sample code demonstrates how you can process a
PayPal Account based Payment.
API used: /v1/payments/payment</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">Amount</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Details</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Item</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">ItemList</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">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>
<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();
<span class="hljs-variable">$payer</span>-&gt;setPaymentMethod(<span class="hljs-string">"paypal"</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="itemized-information">Itemized information</h3>
<p>(Optional) Lets you specify item wise
information</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$item1</span> = <span class="hljs-keyword">new</span> Item();
<span class="hljs-variable">$item1</span>-&gt;setName(<span class="hljs-string">'Ground Coffee 40 oz'</span>)
-&gt;setCurrency(<span class="hljs-string">'USD'</span>)
-&gt;setQuantity(<span class="hljs-number">1</span>)
-&gt;setPrice(<span class="hljs-string">'7.50'</span>);
<span class="hljs-variable">$item2</span> = <span class="hljs-keyword">new</span> Item();
<span class="hljs-variable">$item2</span>-&gt;setName(<span class="hljs-string">'Granola bars'</span>)
-&gt;setCurrency(<span class="hljs-string">'USD'</span>)
-&gt;setQuantity(<span class="hljs-number">5</span>)
-&gt;setPrice(<span class="hljs-string">'2.00'</span>);
<span class="hljs-variable">$itemList</span> = <span class="hljs-keyword">new</span> ItemList();
<span class="hljs-variable">$itemList</span>-&gt;setItems(<span class="hljs-keyword">array</span>(<span class="hljs-variable">$item1</span>, <span class="hljs-variable">$item2</span>));</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="additional-payment-details">Additional payment details</h3>
<p>Use this optional field to set additional
payment information such as tax, shipping
charges etc.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$details</span> = <span class="hljs-keyword">new</span> Details();
<span class="hljs-variable">$details</span>-&gt;setShipping(<span class="hljs-string">'1.20'</span>)
-&gt;setTax(<span class="hljs-string">'1.30'</span>)
-&gt;setSubtotal(<span class="hljs-string">'17.50'</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="amount">Amount</h3>
<p>Lets you specify a payment amount.
You can also specify additional details
such as shipping, tax.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$amount</span> = <span class="hljs-keyword">new</span> Amount();
<span class="hljs-variable">$amount</span>-&gt;setCurrency(<span class="hljs-string">"USD"</span>)
-&gt;setTotal(<span class="hljs-string">"20.00"</span>)
-&gt;setDetails(<span class="hljs-variable">$details</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="transaction">Transaction</h3>
<p>A transaction defines the contract of a
payment - what is the payment for and who
is fulfilling it. </p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$transaction</span> = <span class="hljs-keyword">new</span> Transaction();
<span class="hljs-variable">$transaction</span>-&gt;setAmount(<span class="hljs-variable">$amount</span>)
-&gt;setItemList(<span class="hljs-variable">$itemList</span>)
-&gt;setDescription(<span class="hljs-string">"Payment description"</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="redirect-urls">Redirect urls</h3>
<p>Set the urls that the buyer must be redirected to after
payment approval/ cancellation.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$baseUrl</span> = getBaseUrl();
<span class="hljs-variable">$redirectUrls</span> = <span class="hljs-keyword">new</span> RedirectUrls();
<span class="hljs-variable">$redirectUrls</span>-&gt;setReturnUrl(<span class="hljs-string">"$baseUrl/ExecutePayment.php?success=true"</span>)
-&gt;setCancelUrl(<span class="hljs-string">"$baseUrl/ExecutePayment.php?success=false"</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="payment">Payment</h3>
<p>A Payment Resource; create one using
the above types and intent set to &#39;sale&#39;</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$payment</span> = <span class="hljs-keyword">new</span> Payment();
<span class="hljs-variable">$payment</span>-&gt;setIntent(<span class="hljs-string">"sale"</span>)
-&gt;setPayer(<span class="hljs-variable">$payer</span>)
-&gt;setRedirectUrls(<span class="hljs-variable">$redirectUrls</span>)
-&gt;setTransactions(<span class="hljs-keyword">array</span>(<span class="hljs-variable">$transaction</span>));</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="create-payment">Create Payment</h3>
<p>Create a payment by calling the &#39;create&#39; method
passing it a valid apiContext.
(See bootstrap.php for more on <code>ApiContext</code>)
The return object contains the state and the
url to which the buyer must be redirected to
for payment approval</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
<span class="hljs-variable">$payment</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>);
}</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 $payment-&gt;getLinks()
method</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">foreach</span>(<span class="hljs-variable">$payment</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">$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>)) {
header(<span class="hljs-string">"Location: $redirectUrl"</span>);
<span class="hljs-keyword">exit</span>;
}</div></div></div></div></body></html>

View File

@@ -0,0 +1,86 @@
<!DOCTYPE html><html lang="en"><head><title>payments/CreatePaymentUsingSavedCard</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="payments/CreatePaymentUsingSavedCard"><meta name="groc-project-path" content="sample/payments/CreatePaymentUsingSavedCard.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">sample/payments/CreatePaymentUsingSavedCard.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-payment-using-a-saved-credit-card">Create payment using a saved credit card</h1>
<p>This sample code demonstrates how you can process a
Payment using a previously stored credit card token.
API used: /v1/payments/payment</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">Amount</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Details</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Item</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">ItemList</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">CreditCardToken</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">Payment</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-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="credit-card-token">Credit card token</h3>
<p>Saved credit card id from a previous call to
CreateCreditCard.php</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$creditCardToken</span> = <span class="hljs-keyword">new</span> CreditCardToken();
<span class="hljs-variable">$creditCardToken</span>-&gt;setCreditCardId(<span class="hljs-string">'CARD-29H07236G1554552FKINPBHQ'</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="fundinginstrument">FundingInstrument</h3>
<p>A resource representing a Payer&#39;s funding instrument.
For stored credit card payments, set the CreditCardToken
field on this object.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$fi</span> = <span class="hljs-keyword">new</span> FundingInstrument();
<span class="hljs-variable">$fi</span>-&gt;setCreditCardToken(<span class="hljs-variable">$creditCardToken</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 stored credit card payments, set payment method
to &#39;credit_card&#39;.</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;setFundingInstruments(<span class="hljs-keyword">array</span>(<span class="hljs-variable">$fi</span>));</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="itemized-information">Itemized information</h3>
<p>(Optional) Lets you specify item wise
information</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$item1</span> = <span class="hljs-keyword">new</span> Item();
<span class="hljs-variable">$item1</span>-&gt;setName(<span class="hljs-string">'Ground Coffee 40 oz'</span>)
-&gt;setCurrency(<span class="hljs-string">'USD'</span>)
-&gt;setQuantity(<span class="hljs-number">1</span>)
-&gt;setPrice(<span class="hljs-string">'7.50'</span>);
<span class="hljs-variable">$item2</span> = <span class="hljs-keyword">new</span> Item();
<span class="hljs-variable">$item2</span>-&gt;setName(<span class="hljs-string">'Granola bars'</span>)
-&gt;setCurrency(<span class="hljs-string">'USD'</span>)
-&gt;setQuantity(<span class="hljs-number">5</span>)
-&gt;setPrice(<span class="hljs-string">'2.00'</span>);
<span class="hljs-variable">$itemList</span> = <span class="hljs-keyword">new</span> ItemList();
<span class="hljs-variable">$itemList</span>-&gt;setItems(<span class="hljs-keyword">array</span>(<span class="hljs-variable">$item1</span>, <span class="hljs-variable">$item2</span>));</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="additional-payment-details">Additional payment details</h3>
<p>Use this optional field to set additional
payment information such as tax, shipping
charges etc.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$details</span> = <span class="hljs-keyword">new</span> Details();
<span class="hljs-variable">$details</span>-&gt;setShipping(<span class="hljs-string">'1.20'</span>)
-&gt;setTax(<span class="hljs-string">'1.30'</span>)
-&gt;setSubtotal(<span class="hljs-string">'17.50'</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="amount">Amount</h3>
<p>Lets you specify a payment amount.
You can also specify additional details
such as shipping, tax.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$amount</span> = <span class="hljs-keyword">new</span> Amount();
<span class="hljs-variable">$amount</span>-&gt;setCurrency(<span class="hljs-string">"USD"</span>)
-&gt;setTotal(<span class="hljs-string">"20.00"</span>)
-&gt;setDetails(<span class="hljs-variable">$details</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="transaction">Transaction</h3>
<p>A transaction defines the contract of a
payment - what is the payment for and who
is fulfilling it. </p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$transaction</span> = <span class="hljs-keyword">new</span> Transaction();
<span class="hljs-variable">$transaction</span>-&gt;setAmount(<span class="hljs-variable">$amount</span>)
-&gt;setItemList(<span class="hljs-variable">$itemList</span>)
-&gt;setDescription(<span class="hljs-string">"Payment description"</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="payment">Payment</h3>
<p>A Payment Resource; create one using
the above types and intent set to &#39;sale&#39;</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$payment</span> = <span class="hljs-keyword">new</span> Payment();
<span class="hljs-variable">$payment</span>-&gt;setIntent(<span class="hljs-string">"sale"</span>)
-&gt;setPayer(<span class="hljs-variable">$payer</span>)
-&gt;setTransactions(<span class="hljs-keyword">array</span>(<span class="hljs-variable">$transaction</span>));</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="create-payment">Create Payment</h3>
<p>Create a payment by calling the &#39;create&#39; method
passing it a valid apiContext.
(See bootstrap.php for more on <code>ApiContext</code>)
The return object contains the state.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
<span class="hljs-variable">$payment</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>);
}
<span class="hljs-preprocessor">?&gt;</span>
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Saved Credit card payments&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div&gt;
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(JSON_PRETTY_PRINT);<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>

View File

@@ -0,0 +1,31 @@
<!DOCTYPE html><html lang="en"><head><title>payments/ExecutePayment</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="payments/ExecutePayment"><meta name="groc-project-path" content="sample/payments/ExecutePayment.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">sample/payments/ExecutePayment.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="execute-payment-sample">Execute Payment Sample</h1>
<p>This sample shows how you can complete
a payment that has been approved by
the buyer by logging into paypal site.
You can optionally update transaction
information by passing in one or more transactions.
API used: POST &#39;/v1/payments/payment/<payment-id>/execute&#39;.</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">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
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.
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>);
<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(JSON_PRETTY_PRINT);
<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">"User cancelled payment."</span>;
}</div></div></div></div></body></html>

View File

@@ -0,0 +1,31 @@
<!DOCTYPE html><html lang="en"><head><title>payments/GetAuthorization</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="payments/GetAuthorization"><meta name="groc-project-path" content="sample/payments/GetAuthorization.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">sample/payments/GetAuthorization.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="getauthorization">GetAuthorization</h1>
<p>This sample code demonstrates how you can get details
of an authorized payment.
API used: /v1/payments/authorization/&lt;$authorizationId&gt;</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">Authorization</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="getauthorization">GetAuthorization</h3>
<p>You can retrieve info about an Authorization
by invoking the Authorization::get method
with a valid ApiContext (See bootstrap.php for more on <code>ApiContext</code>)
The return object contains the authorization state.</p></div></div><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>create a authorization to get authorization Id
createAuthorization is defined in common.php</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$authId</span> = createAuthorization(<span class="hljs-variable">$apiContext</span>);
</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Retrieve the authorization</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$authorization</span> = Authorization::get(<span class="hljs-variable">$authId</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>);
}
<span class="hljs-preprocessor">?&gt;</span>
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Lookup an authorization&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div&gt;
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(JSON_PRETTY_PRINT);<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>

View File

@@ -0,0 +1,47 @@
<!DOCTYPE html><html lang="en"><head><title>payments/GetCapture</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="payments/GetCapture"><meta name="groc-project-path" content="sample/payments/GetCapture.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">sample/payments/GetCapture.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="getcapture">GetCapture</h1>
<p>This sample code demonstrates how you can lookup the details
of a captured payment.
API used: /v1/payments/capture/&lt;$captureId&gt;</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">Capture</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Amount</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Authorization</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="create-a-mock-capture">Create a mock Capture</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>create a mock authorization to get authorization Id
createAuthorization is defined in common.php</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$authId</span> = createAuthorization(<span class="hljs-variable">$apiContext</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Lookup the authorization</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$authorization</span> = Authorization::get(<span class="hljs-variable">$authId</span>, <span class="hljs-variable">$apiContext</span>);
<span class="hljs-comment">### Capture</span>
<span class="hljs-variable">$amt</span> = <span class="hljs-keyword">new</span> Amount();
<span class="hljs-variable">$amt</span>-&gt;setCurrency(<span class="hljs-string">"USD"</span>)
-&gt;setTotal(<span class="hljs-string">"1.00"</span>);
</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Create a capture</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$captureInfo</span> = <span class="hljs-keyword">new</span> Capture();
<span class="hljs-variable">$captureInfo</span>-&gt;setId(<span class="hljs-variable">$authId</span>)
-&gt;setAmount(<span class="hljs-variable">$amt</span>);
<span class="hljs-variable">$capture</span> = <span class="hljs-variable">$authorization</span>-&gt;capture(<span class="hljs-variable">$captureInfo</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>);
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="retrieve-capture-details">Retrieve Capture details</h3>
<p>You can look up a capture by invoking the Capture::get method
with a valid ApiContext (See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
<span class="hljs-variable">$capture</span> = Capture::get(<span class="hljs-variable">$capture</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>);
}
<span class="hljs-preprocessor">?&gt;</span>
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Lookup a capture&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div&gt;
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(JSON_PRETTY_PRINT);<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>

View File

@@ -0,0 +1,33 @@
<!DOCTYPE html><html lang="en"><head><title>payments/GetPayment</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="payments/GetPayment"><meta name="groc-project-path" content="sample/payments/GetPayment.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">sample/payments/GetPayment.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="getpaymentsample">GetPaymentSample</h1>
<p>This sample code demonstrate how you can
retrieve a list of all Payment resources
you&#39;ve created using the Payments API.
Note various query parameters that you can
use to filter, and paginate through the
payments list.
API used: GET /v1/payments/payments</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">Payment</span>;
<span class="hljs-variable">$paymentId</span> = <span class="hljs-string">"PAY-0XL713371A312273YKE2GCNI"</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="retrieve-payment">Retrieve payment</h3>
<p>Retrieve the payment object by calling the
static <code>get</code> method
on the Payment class by passing a valid
Payment ID
(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
<span class="hljs-variable">$payment</span> = Payment::get(<span class="hljs-variable">$paymentId</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>);
}
<span class="hljs-preprocessor">?&gt;</span>
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Lookup a payment&lt;/title&gt;
&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(JSON_PRETTY_PRINT);<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>

View File

@@ -0,0 +1,32 @@
<!DOCTYPE html><html lang="en"><head><title>payments/ListPayments</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="payments/ListPayments"><meta name="groc-project-path" content="sample/payments/ListPayments.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">sample/payments/ListPayments.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="getpaymentlist">GetPaymentList</h1>
<p>This sample code demonstrate how you can
retrieve a list of all Payment resources
you&#39;ve created using the Payments API.
Note various query parameters that you can
use to filter, and paginate through the
payments list.
API used: GET /v1/payments/payments</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">Payment</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="retrieve-payment">Retrieve payment</h3>
<p>Retrieve the PaymentHistory object by calling the
static <code>get</code> method on the Payment class,
and pass a Map object that contains
query parameters for paginations and filtering.
Refer the method doc for valid values for keys
(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
<span class="hljs-variable">$payments</span> = Payment::all(<span class="hljs-keyword">array</span>(<span class="hljs-string">'count'</span> =&gt; <span class="hljs-number">10</span>, <span class="hljs-string">'start_index'</span> =&gt; <span class="hljs-number">5</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>);
}
<span class="hljs-preprocessor">?&gt;</span>
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Lookup payment history&lt;/title&gt;
&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(JSON_PRETTY_PRINT);<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>

View File

@@ -0,0 +1,37 @@
<!DOCTYPE html><html lang="en"><head><title>payments/Reauthorization</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="payments/Reauthorization"><meta name="groc-project-path" content="sample/payments/Reauthorization.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">sample/payments/Reauthorization.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"><h2 id="reauthorization-sample">Reauthorization Sample</h2>
<p>This sample code demonstrates how you can reauthorize a PayPal
account payment.
API used: v1/payments/authorization/{authorization_id}/reauthorize</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">Authorization</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Amount</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="reauthorization">Reauthorization</h3>
<p>Reauthorization is available only for PayPal account payments
and not for credit card payments.</p></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>You can reauthorize a payment only once 4 to 29
days after the 3-day honor period for the original authorization
has expired.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="lookup-authorization-using-the-authorization-id">Lookup authorization using the authorization id</h3></div></div></div><div class="segment"><div class="code"><div class="wrapper"> <span class="hljs-variable">$authorization</span> = Authorization::get(<span class="hljs-string">'7GH53639GA425732B'</span>, <span class="hljs-variable">$apiContext</span>);
<span class="hljs-variable">$amount</span> = <span class="hljs-keyword">new</span> Amount();
<span class="hljs-variable">$amount</span>-&gt;setCurrency(<span class="hljs-string">"USD"</span>);
<span class="hljs-variable">$amount</span>-&gt;setTotal(<span class="hljs-string">"1.00"</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="reauthorize-with-amount-being-reauthorized">Reauthorize with amount being reauthorized</h3></div></div></div><div class="segment"><div class="code"><div class="wrapper"> <span class="hljs-variable">$authorization</span>-&gt;setAmount(<span class="hljs-variable">$amount</span>);
<span class="hljs-variable">$reauthorization</span> = <span class="hljs-variable">$authorization</span>-&gt;reauthorize(<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>);
}
<span class="hljs-preprocessor">?&gt;</span>
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Reauthorize a payment&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div&gt;
Reauthorization Id:
<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(JSON_PRETTY_PRINT);<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>

View File

@@ -0,0 +1,52 @@
<!DOCTYPE html><html lang="en"><head><title>payments/RefundCapture</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="payments/RefundCapture"><meta name="groc-project-path" content="sample/payments/RefundCapture.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">sample/payments/RefundCapture.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="refund-capture-sample">Refund Capture Sample</h1>
<p>This sample code demonstrates how you can
process a refund on a Captured transaction.
API used: /v1/payments/capture/{<captureID>}/refund</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">Authorization</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Capture</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Refund</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Amount</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Rest</span>\<span class="hljs-title">ApiContext</span>;
<span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Create a mock authorization to get authorization Id</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$authId</span> = createAuthorization(<span class="hljs-variable">$apiContext</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Get the authorization</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$authorization</span> = Authorization::get(<span class="hljs-variable">$authId</span>, <span class="hljs-variable">$apiContext</span>);
</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="capture">Capture</h3></div></div></div><div class="segment"><div class="code"><div class="wrapper">
<span class="hljs-variable">$amt</span> = <span class="hljs-keyword">new</span> Amount();
<span class="hljs-variable">$amt</span>-&gt;setCurrency(<span class="hljs-string">"USD"</span>)
-&gt;setTotal(<span class="hljs-string">"1.00"</span>);
</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Create a capture</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$captureInfo</span> = <span class="hljs-keyword">new</span> Capture();
<span class="hljs-variable">$captureInfo</span>-&gt;setAmount(<span class="hljs-variable">$amt</span>);
<span class="hljs-variable">$capture</span> = <span class="hljs-variable">$authorization</span>-&gt;capture(<span class="hljs-variable">$captureInfo</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>);
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="refund">Refund</h3>
<p>Create a refund object indicating
refund amount and call the refund method</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$refund</span> = <span class="hljs-keyword">new</span> Refund();
<span class="hljs-variable">$refund</span>-&gt;setAmount(<span class="hljs-variable">$amt</span>);
<span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Create a new apiContext object so we send a new
PayPal-Request-Id (idempotency) header for this resource</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$apiContext</span> = getApiContext();
<span class="hljs-variable">$captureRefund</span> = <span class="hljs-variable">$capture</span>-&gt;refund(<span class="hljs-variable">$refund</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>);
}
<span class="hljs-preprocessor">?&gt;</span>
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Refund a captured payment&lt;/title&gt;
&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(JSON_PRETTY_PRINT);<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>

View File

@@ -0,0 +1,28 @@
<!DOCTYPE html><html lang="en"><head><title>payments/VoidAuthorization</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="payments/VoidAuthorization"><meta name="groc-project-path" content="sample/payments/VoidAuthorization.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">sample/payments/VoidAuthorization.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="voidauthorization">VoidAuthorization</h1>
<p>This sample code demonstrates how you can
void an authorized payment.
API used: /v1/payments/authorization/&lt;{authorizationid}&gt;/void&quot;</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">Authorization</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="voidauthorization">VoidAuthorization</h3>
<p>You can void a previously authorized payment
by invoking the $authorization-&gt;void method
with a valid ApiContext (See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><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>create an authorization to get authorization Id
createAuthorization is defined in common.php</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$authId</span> = createAuthorization(<span class="hljs-variable">$apiContext</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Lookup the authorization</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$authorization</span> = Authorization::get(<span class="hljs-variable">$authId</span>, <span class="hljs-variable">$apiContext</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Void the authorization </p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$voidedAuth</span> = <span class="hljs-variable">$authorization</span>-&gt;void(<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>);
}
<span class="hljs-preprocessor">?&gt;</span>
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Void an authorization&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&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(JSON_PRETTY_PRINT);<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>

View File

@@ -0,0 +1,28 @@
<!DOCTYPE html><html lang="en"><head><title>sale/GetSale</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="sale/GetSale"><meta name="groc-project-path" content="sample/sale/GetSale.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">sample/sale/GetSale.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-sale-sample">Get Sale sample</h1>
<p>Sale transactions are nothing but completed payments.
This sample code demonstrates how you can retrieve
details of completed Sale Transaction.
API used: /v1/payments/sale/{sale-id}</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">Sale</span>;
<span class="hljs-variable">$saleId</span> = <span class="hljs-string">'3RM92092UW5126232'</span>;
<span class="hljs-keyword">try</span> { </div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="retrieve-the-sale-object">Retrieve the sale object</h3>
<p>Pass the ID of the sale
transaction from your payment resource.</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$sale</span> = Sale::get(<span class="hljs-variable">$saleId</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>);
}
<span class="hljs-preprocessor">?&gt;</span>
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Lookup a sale&lt;/title&gt;
&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(JSON_PRETTY_PRINT)<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>

View File

@@ -0,0 +1,38 @@
<!DOCTYPE html><html lang="en"><head><title>sale/RefundSale</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="sale/RefundSale"><meta name="groc-project-path" content="sample/sale/RefundSale.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">sample/sale/RefundSale.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="sale-refund-sample">Sale Refund Sample</h1>
<p>This sample code demonstrate how you can
process a refund on a sale transaction created
using the Payments API.
API used: /v1/payments/sale/{sale-id}/refund</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">Amount</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Refund</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Sale</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="refund-amount">Refund amount</h3>
<p>Includes both the refunded amount (to Payer)
and refunded fee (to Payee). Use the $amt-&gt;details
field to mention fees refund details.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$amt</span> = <span class="hljs-keyword">new</span> Amount();
<span class="hljs-variable">$amt</span>-&gt;setCurrency(<span class="hljs-string">'USD'</span>)
-&gt;setTotal(<span class="hljs-string">'0.01'</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="refund-object">Refund object</h3></div></div></div><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-variable">$refund</span> = <span class="hljs-keyword">new</span> Refund();
<span class="hljs-variable">$refund</span>-&gt;setAmount(<span class="hljs-variable">$amt</span>);
<span class="hljs-variable">$saleId</span> = <span class="hljs-string">'3RM92092UW5126232'</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="sale">Sale</h3>
<p>A sale transaction.
Create a Sale object with the
given sale transaction id.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$sale</span> = <span class="hljs-keyword">new</span> Sale();
<span class="hljs-variable">$sale</span>-&gt;setId(<span class="hljs-variable">$saleId</span>);
<span class="hljs-keyword">try</span> { </div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Refund the sale
(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$sale</span>-&gt;refund(<span class="hljs-variable">$refund</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>);
}
<span class="hljs-preprocessor">?&gt;</span>
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Refund a sale&lt;/title&gt;
&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(JSON_PRETTY_PRINT);<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>

View File

@@ -0,0 +1,37 @@
<!DOCTYPE html><html lang="en"><head><title>vault/CreateCreditCard</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="vault/CreateCreditCard"><meta name="groc-project-path" content="sample/vault/CreateCreditCard.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">sample/vault/CreateCreditCard.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-credit-card-sample">Create Credit Card Sample</h1>
<p>You can store credit card details securely
with PayPal. You can then use the returned
Credit card id to process future payments.
API used: POST /v1/vault/credit-card</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">CreditCard</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="creditcard">CreditCard</h3>
<p>A resource representing a credit card that is
to be stored with PayPal.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$card</span> = <span class="hljs-keyword">new</span> CreditCard();
<span class="hljs-variable">$card</span>-&gt;setType(<span class="hljs-string">"visa"</span>)
-&gt;setNumber(<span class="hljs-string">"4417119669820331"</span>)
-&gt;setExpireMonth(<span class="hljs-string">"11"</span>)
-&gt;setExpireYear(<span class="hljs-string">"2019"</span>)
-&gt;setCvv2(<span class="hljs-string">"012"</span>)
-&gt;setFirstName(<span class="hljs-string">"Joe"</span>)
-&gt;setLastName(<span class="hljs-string">"Shopper"</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="save-card">Save card</h3>
<p>Creates the credit card as a resource
in the PayPal vault. The response contains
an &#39;id&#39; that you can use to refer to it
in future payments.
(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
<span class="hljs-variable">$card</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>);
}
<span class="hljs-preprocessor">?&gt;</span>
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Save a credit card&lt;/title&gt;
&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(JSON_PRETTY_PRINT);<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>

View File

@@ -0,0 +1,45 @@
<!DOCTYPE html><html lang="en"><head><title>vault/DeleteCreditCard</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="vault/DeleteCreditCard"><meta name="groc-project-path" content="sample/vault/DeleteCreditCard.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">sample/vault/DeleteCreditCard.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="delete-creditcard-sample">Delete CreditCard Sample</h1>
<p>This sample code demonstrate how you can
delete a saved credit card.
API used: /v1/vault/credit-card/{<creditCardId>}
NOTE: HTTP method used here is DELETE</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">CreditCard</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Store a mock card that can be deleted later.</p>
<h3 id="creditcard">CreditCard</h3>
<p>A resource representing a credit card that can be
used to fund a payment.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$card</span> = <span class="hljs-keyword">new</span> CreditCard();
<span class="hljs-variable">$card</span>-&gt;setType(<span class="hljs-string">"visa"</span>)
-&gt;setNumber(<span class="hljs-string">"4417119669820331"</span>)
-&gt;setExpireMonth(<span class="hljs-string">"11"</span>)
-&gt;setExpireYear(<span class="hljs-string">"2019"</span>)
-&gt;setCvv2(<span class="hljs-string">"012"</span>)
-&gt;setFirstName(<span class="hljs-string">"Joe"</span>)
-&gt;setLastName(<span class="hljs-string">"Shopper"</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="save-card">Save card</h3>
<p>Creates the credit card as a resource
in the PayPal vault. The response contains
an &#39;id&#39; that you can use to refer to it later.
(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
<span class="hljs-variable">$card</span> = <span class="hljs-variable">$card</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>);
}
<span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="delete-card">Delete Card</h3>
<p>Lookup and delete a saved credit card.
(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$creditCard</span> = CreditCard::get(<span class="hljs-variable">$card</span>-&gt;getId(), <span class="hljs-variable">$apiContext</span>);
<span class="hljs-variable">$creditCard</span>-&gt;delete(<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;
<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;Delete a saved credit card&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;p&gt; Credit Card deleted Successfully&lt;/p&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>

View File

@@ -0,0 +1,27 @@
<!DOCTYPE html><html lang="en"><head><title>vault/GetCreditCard</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="vault/GetCreditCard"><meta name="groc-project-path" content="sample/vault/GetCreditCard.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">sample/vault/GetCreditCard.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-credit-card-sample">Get Credit Card Sample</h1>
<p>The CreditCard resource allows you to
retrieve previously saved CreditCards.
API called: &#39;/v1/vault/credit-card&#39;
The following code takes you through
the process of retrieving a saved CreditCard</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">CreditCard</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>The cardId can be obtained from a previous save credit
card operation. Use $card-&gt;getId()</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$cardId</span> = <span class="hljs-string">"CARD-5AR29593TC404090HKIKN77Q"</span>;
<span class="hljs-comment">/// ### Retrieve card</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-keyword">try</span> {
<span class="hljs-variable">$card</span> = CreditCard::get(<span class="hljs-variable">$cardId</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>);
}
<span class="hljs-preprocessor">?&gt;</span>
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Lookup a saved credit card&lt;/title&gt;
&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(JSON_PRETTY_PRINT);<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>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 173 B

BIN
sample/images/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

BIN
sample/images/pp_v_rgb.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

View File

@@ -1,121 +1,310 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>PayPal REST API Samples</title>
<style>
.imagelink {
padding: 5px 0px 5px 28px;
}
.execute {
background: url('images/play_button.png') no-repeat left top;
}
.source {
background: url('images/edt-format-source-button.png') no-repeat left top;
}
.header {
font-weight: bold;
}
.header td {
padding: 10px 0px 10px 0px;
}
</style>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="images/favicon.ico">
<title>PayPal REST API Samples</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
<style>
body {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
}
</style>
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<center>
<h3>PayPal REST API Samples</h3>
</center>
<table cellspacing="5" width="85%">
<tbody>
<tr valign="top" class='header'>
<td>Payments</td>
</tr>
<tr valign="top">
<td>Direct credit card payments</td>
<td width="30%" ><a href="payments/CreatePayment.php" class="execute imagelink">Execute</a></td>
<td width="30%"><a href="source/CreatePayment.html" class="source imagelink">Source</a></td>
</tr>
<tr>
<td>PayPal account payments</td>
<td><a href="payments/CreatePaymentUsingPayPal.php" class="execute imagelink">Execute</a></td>
<td><a href="source/CreatePaymentUsingPayPal.html" class="source imagelink">Source</a></td>
</tr>
<tr>
<td>Stored credit card payments</td>
<td><a href="payments/CreatePaymentUsingSavedCard.php" class="execute imagelink">Execute</a></td>
<td><a href="source/CreatePaymentUsingSavedCard.html" class="source imagelink">Source</a></td>
<tr>
<td>Get payment details</td>
<td><a href="payments/GetPayment.php" class="execute imagelink" >Execute</a></td>
<td><a href="source/GetPayment.html" class="source imagelink" >Source</a></td>
</tr>
<tr>
<td>Get payment history</td>
<td><a href="payments/ListPayments.php" class="execute imagelink" >Execute</a></td>
<td><a href="source/ListPayments.html" class="source imagelink" >Source</a></td>
</tr>
<tr>
<td>Get sale details</td>
<td><a href="sale/GetSale.php" class="execute imagelink" >Execute</a></td>
<td><a href="source/GetSale.html" class="source imagelink" >Source</a></td>
</tr>
<tr>
<td>Refund a payment</td>
<td><a href="sale/RefundSale.php" class="execute imagelink" >Execute</a></td>
<td><a href="source/RefundSale.html" class="source imagelink" >Source</a></td>
</tr>
<tr valign="top" class='header'>
<td>Vault</td>
</tr>
<tr>
<td>Save a credit card</td>
<td><a href="vault/CreateCreditCard.php" class="execute imagelink" >Execute</a></td>
<td><a href="source/CreateCreditCard.html" class="source imagelink" >Source</a></td>
</tr>
<tr>
<td>Retrieve saved credit card</td>
<td><a href="vault/GetCreditCard.php" class="execute imagelink" >Execute</a></td>
<td><a href="source/GetCreditCard.html" class="source imagelink" >Source</a></td>
</tr>
<tr>
<td>Delete saved credit card</td>
<td><a href="vault/DeleteCreditCard.php" class="execute imagelink" >Execute</a></td>
<td><a href="source/DeleteCreditCard.html" class="source imagelink" >Source</a></td>
</tr>
<tr valign="top" class='header'>
<td>Authorization and capture</td>
</tr>
<tr>
<td>Get details of an authorized payment</td>
<td><a href="payments/GetAuthorization.php" class="execute imagelink" >Execute</a></td>
<td><a href="source/GetAuthorization.html" class="source imagelink" >Source</a></td>
</tr>
<tr>
<td>Capture an authorized payment</td>
<td><a href="payments/AuthorizationCapture.php" class="execute imagelink" >Execute</a></td>
<td><a href="source/AuthorizationCapture.html" class="source imagelink" >Source</a></td>
</tr>
<tr>
<td>Void an authorized payment</td>
<td><a href="payments/VoidAuthorization.php" class="execute imagelink" >Execute</a></td>
<td><a href="source/VoidAuthorization.html" class="source imagelink" >Source</a></td>
</tr>
<tr>
<td>Reauthorize a payment</td>
<td><a href="payments/Reauthorization.php" class="execute imagelink" >Execute</a></td>
<td><a href="source/Reauthorization.html" class="source imagelink" >Source</a></td>
</tr>
<tr>
<td>Get details of a captured payment</td>
<td><a href="payments/GetCapture.php" class="execute imagelink" >Execute</a></td>
<td><a href="source/GetCapture.html" class="source imagelink" >Source</a></td>
</tr>
<tr>
<td>Refund captured payment</td>
<td><a href="payments/RefundCapture.php" class="execute imagelink" >Execute</a></td>
<td><a href="source/RefundCapture.html" class="source imagelink" >Source</a></td>
</tr>
</tbody>
</table>
<!-- Main component for a primary marketing message or call to action -->
<div class="jumbotron">
<div class="container">
<div class="row">
<div class="col-md-3">
<img src="images/pp_v_rgb.png" height="200" />
</div>
<div class="col-md-9">
<h1> REST API Samples</h1>
<p>These examples are created to experiment with the rest-api-sdk-php capabilities. Each examples are designed to demonstrate the default use-cases in each segment.
Many examples should be executable, and should allow you to experience the default behavior of our sdk, to expedite your integration experience.</p>
<p>
</div>
</div>
</p>
</div>
</div>
<div class="container-fluid">
<div class="container">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">Payments</h3>
</div>
<!-- List group -->
<ul class="list-group">
<li class="list-group-item">
<div class="row">
<div class="col-md-9 "><h5>Direct credit card payments</h5></div>
<div class="col-md-3">
<a href="payments/CreatePayment.php" class="btn btn-primary pull-left" >Execute <i class="fa fa-play-circle-o"></i></a>
<a href="doc/payments/CreatePayment.html" class="btn btn-default pull-right" >Source <i class="fa fa-file-code-o"></i></a>
</div>
</div>
</li>
<li class="list-group-item">
<div class="row">
<div class="col-md-9 "><h5>PayPal account payments</h5></div>
<div class="col-md-3">
<a href="payments/CreatePaymentUsingPayPal.php" class="btn btn-primary pull-left" >Execute <i class="fa fa-play-circle-o"></i></a><a href="doc/payments/CreatePaymentUsingPayPal.html" class="btn btn-default pull-right" >Source <i class="fa fa-file-code-o"></i></a>
</div>
</div>
</li>
<li class="list-group-item">
<div class="row">
<div class="col-md-9 "><h5>Stored credit card payments</h5></div>
<div class="col-md-3">
<a href="payments/CreatePaymentUsingSavedCard.php" class="btn btn-primary pull-left" >Execute <i class="fa fa-play-circle-o"></i></a>
<a href="doc/payments/CreatePayment.html" class="btn btn-default pull-right" >Source <i class="fa fa-file-code-o"></i></a>
</div>
</div>
</li>
<li class="list-group-item">
<div class="row">
<div class="col-md-9 "><h5>Future payments* <small> (needs Authorization Code from Mobile SDK)</small></h5></div>
<div class="col-md-3"></div>
<div class="col-md-3">
<a href="doc/payments/CreateFuturePayment.html" class="btn btn-default pull-right" >Source <i class="fa fa-file-code-o"></i></a>
</div>
</div>
</li>
<li class="list-group-item">
<div class="row">
<div class="col-md-9 "><h5>Get payment details</h5></div>
<div class="col-md-3">
<a href="payments/GetPayment.php" class="btn btn-primary pull-left" >Execute <i class="fa fa-play-circle-o"></i></a>
<a href="doc/payments/CreatePayment.html" class="btn btn-default pull-right" >Source <i class="fa fa-file-code-o"></i></a>
</div>
</div>
</li>
<li class="list-group-item">
<div class="row">
<div class="col-md-9 "><h5>Get payment history</h5></div>
<div class="col-md-3">
<a href="payments/ListPayments.php" class="btn btn-primary pull-left" >Execute <i class="fa fa-play-circle-o"></i></a>
<a href="doc/payments/CreatePayment.html" class="btn btn-default pull-right" >Source <i class="fa fa-file-code-o"></i></a>
</div>
</div>
</li>
</ul>
</div>
<div class="panel panel-primary" >
<div class="panel-heading" >
<h3 class="panel-title">Sale</h3>
</div>
<!-- List group -->
<ul class="list-group">
<li class="list-group-item">
<div class="row">
<div class="col-md-9 "><h5>Get sale details</h5></div>
<div class="col-md-3">
<a href="sale/GetSale.php" class="btn btn-primary pull-left" >Execute <i class="fa fa-play-circle-o"></i></a>
<a href="doc/sale/GetSale.html" class="btn btn-default pull-right" >Source <i class="fa fa-file-code-o"></i></a>
</div>
</div>
</li>
<li class="list-group-item">
<div class="row">
<div class="col-md-9 "><h5>Refund a payment</h5></div>
<div class="col-md-3">
<a href="sale/RefundSale.php" class="btn btn-primary pull-left" >Execute <i class="fa fa-play-circle-o"></i></a>
<a href="doc/sale/RefundSale.html" class="btn btn-default pull-right" >Source <i class="fa fa-file-code-o"></i></a>
</div>
</div>
</li>
</ul>
</div>
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">Vault</h3>
</div>
<!-- List group -->
<ul class="list-group">
<li class="list-group-item">
<div class="row">
<div class="col-md-9 "><h5>Save a credit card</h5></div>
<div class="col-md-3">
<a href="vault/CreateCreditCard.php" class="btn btn-primary pull-left" >Execute <i class="fa fa-play-circle-o"></i></a>
<a href="doc/vault/CreateCreditCard.html" class="btn btn-default pull-right" >Source <i class="fa fa-file-code-o"></i></a>
</div>
</div>
</li>
<li class="list-group-item">
<div class="row">
<div class="col-md-9 "><h5>Retrieve saved credit card</h5></div>
<div class="col-md-3">
<a href="vault/GetCreditCard.php" class="btn btn-primary pull-left" >Execute <i class="fa fa-play-circle-o"></i></a>
<a href="doc/vault/GetCreditCard.html" class="btn btn-default pull-right" >Source <i class="fa fa-file-code-o"></i></a>
</div>
</div>
</li>
<li class="list-group-item">
<div class="row">
<div class="col-md-9 "><h5>Delete saved credit card</h5></div>
<div class="col-md-3">
<a href="vault/DeleteCreditCard.php" class="btn btn-primary pull-left" >Execute <i class="fa fa-play-circle-o"></i></a>
<a href="doc/vault/DeleteCreditCard.html" class="btn btn-default pull-right" >Source <i class="fa fa-file-code-o"></i></a>
</div>
</div>
</li>
</ul>
</div>
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">Authorization and capture</h3>
</div>
<!-- List group -->
<ul class="list-group">
<li class="list-group-item">
<div class="row">
<div class="col-md-9 "><h5>Get details of an authorized payment</h5></div>
<div class="col-md-3">
<a href="payments/GetAuthorization.php" class="btn btn-primary pull-left" >Execute <i class="fa fa-play-circle-o"></i></a>
<a href="doc/payments/GetAuthorization.html" class="btn btn-default pull-right" >Source <i class="fa fa-file-code-o"></i></a>
</div>
</div>
</li>
<li class="list-group-item">
<div class="row">
<div class="col-md-9 "><h5>Capture an authorized payment</h5></div>
<div class="col-md-3">
<a href="payments/AuthorizationCapture.php" class="btn btn-primary pull-left" >Execute <i class="fa fa-play-circle-o"></i></a>
<a href="doc/payments/AuthorizationCapture.html" class="btn btn-default pull-right" >Source <i class="fa fa-file-code-o"></i></a>
</div>
</div>
</li>
<li class="list-group-item">
<div class="row">
<div class="col-md-9 "><h5>Void an authorized payment</h5></div>
<div class="col-md-3">
<a href="payments/VoidAuthorization.php" class="btn btn-primary pull-left" >Execute <i class="fa fa-play-circle-o"></i></a>
<a href="doc/payments/VoidAuthorization.html" class="btn btn-default pull-right" >Source <i class="fa fa-file-code-o"></i></a>
</div>
</div>
</li>
<li class="list-group-item">
<div class="row">
<div class="col-md-9 "><h5>Reauthorize a payment</h5></div>
<div class="col-md-3">
<a href="payments/Reauthorization.php" class="btn btn-primary pull-left" >Execute <i class="fa fa-play-circle-o"></i></a>
<a href="doc/payments/Reauthorization.html" class="btn btn-default pull-right" >Source <i class="fa fa-file-code-o"></i></a>
</div>
</div>
</li>
<li class="list-group-item">
<div class="row">
<div class="col-md-9 "><h5>Get details of a captured payment</h5></div>
<div class="col-md-3">
<a href="payments/GetCapture.php" class="btn btn-primary pull-left" >Execute <i class="fa fa-play-circle-o"></i></a>
<a href="doc/payments/GetCapture.html" class="btn btn-default pull-right" >Source <i class="fa fa-file-code-o"></i></a>
</div>
</div>
</li>
<li class="list-group-item">
<div class="row">
<div class="col-md-9 "><h5>Refund captured payment</h5></div>
<div class="col-md-3">
<a href="payments/RefundCapture.php" class="btn btn-primary pull-left" >Execute <i class="fa fa-play-circle-o"></i></a>
<a href="doc/payments/RefundCapture.html" class="btn btn-default pull-right" >Source <i class="fa fa-file-code-o"></i></a>
</div>
</div>
</li>
</ul>
</div>
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">Invoice</h3>
</div>
<!-- List group -->
<ul class="list-group">
<li class="list-group-item">
<div class="row">
<div class="col-md-9 "><h5>Create Invoice</h5></div>
<div class="col-md-3">
<a href="invoice/CreateInvoice.php" class="btn btn-primary pull-left" >Execute <i class="fa fa-play-circle-o"></i></a>
<a href="doc/" class="btn btn-default pull-right" >Source <i class="fa fa-file-code-o"></i></a>
</div>
</div>
</li>
<li class="list-group-item">
<div class="row">
<div class="col-md-9 "><h5>Get Invoice</h5></div>
<div class="col-md-3">
<a href="invoice/GetInvoice.php" class="btn btn-primary pull-left" >Execute <i class="fa fa-play-circle-o"></i></a>
<a href="doc/" class="btn btn-default pull-right" >Source <i class="fa fa-file-code-o"></i></a>
</div>
</div>
</li>
<li class="list-group-item">
<div class="row">
<div class="col-md-9 "><h5>List All Invoice</h5></div>
<div class="col-md-3">
<a href="invoice/ListInvoice.php" class="btn btn-primary pull-left" >Execute <i class="fa fa-play-circle-o"></i></a>
<a href="doc/" class="btn btn-default pull-right" >Source <i class="fa fa-file-code-o"></i></a>
</div>
</div>
</li>
<li class="list-group-item">
<div class="row">
<div class="col-md-9 "><h5>Send Invoice</h5></div>
<div class="col-md-3">
<a href="invoice/SendInvoice.php" class="btn btn-primary pull-left" >Execute <i class="fa fa-play-circle-o"></i></a>
<a href="doc/" class="btn btn-default pull-right" >Source <i class="fa fa-file-code-o"></i></a>
</div>
</div>
</li>
<li class="list-group-item">
<div class="row">
<div class="col-md-9 "><h5>Remind Invoice</h5></div>
<div class="col-md-3">
<a href="invoice/RemindInvoice.php" class="btn btn-primary pull-left" >Execute <i class="fa fa-play-circle-o"></i></a>
<a href="doc/" class="btn btn-default pull-right" >Source <i class="fa fa-file-code-o"></i></a>
</div>
</div>
</li>
<li class="list-group-item">
<div class="row">
<div class="col-md-9 "><h5>Cancel Invoice</h5></div>
<div class="col-md-3">
<a href="invoice/CancelInvoice.php" class="btn btn-primary pull-left" >Execute <i class="fa fa-play-circle-o"></i></a>
<a href="doc/" class="btn btn-default pull-right" >Source <i class="fa fa-file-code-o"></i></a>
</div>
</div>
</li>
</ul>
</div>
</div>
</div> <!-- /container -->
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.2.0/js/scrollspy.min.js"></script>
</body>
</html>

View File

@@ -0,0 +1,57 @@
<?php
// # Cancel Invoice Sample
// This sample code demonstrate how you can cancel
// an invoice.
require __DIR__ . '/../bootstrap.php';
use PayPal\Api\Invoice;
use PayPal\Api\CancelNotification;
try {
// ### Retrieve Invoice
// Retrieve the invoice object by calling the
// static `get` method
// on the Payment class by passing a valid
// Invoice ID
// (See bootstrap.php for more on `ApiContext`)
$invoice = Invoice::get("INV2-CJL7-PF4G-BLQF-5FWG", $apiContext);
// ### Cancel Notification Object
// This would send a notification to both merchant as well
// the payer about the cancellation. The information of
// merchant and payer is retrieved from the invoice details
$notify = new CancelNotification();
$notify
->setSubject("Past due")
->setNote("Canceling invoice")
->setSendToMerchant(true)
->setSendToPayer(true);
// ### Cancel Invoice
// Cancel invoice object by calling the
// static `cancel` method
// on the Invoice class by passing a valid
// notification object
// (See bootstrap.php for more on `ApiContext`)
$cancelStatus = $invoice->cancel($notify, $apiContext);
} catch (PayPal\Exception\PPConnectionException $ex) {
echo "Exception: " . $ex->getMessage() . PHP_EOL;
var_dump($ex->getData());
exit(1);
}
?>
<html>
<head>
<title>Cancel Invoice</title>
</head>
<body>
<div>Cancel Invoice:</div>
<pre><?php echo $invoice->toJSON(JSON_PRETTY_PRINT); ?></pre>
<a href='../index.html'>Back</a>
</body>
</html>

View File

@@ -0,0 +1,119 @@
<?php
// # Create Invoice Sample
// This sample code demonstrate how you can create
// an invoice.
require __DIR__ . '/../bootstrap.php';
use PayPal\Api\Invoice;
use PayPal\Api\MerchantInfo;
use PayPal\Api\BillingInfo;
use PayPal\Api\InvoiceItem;
use PayPal\Api\Phone;
use PayPal\Api\Address;
use PayPal\Api\Currency;
use PayPal\Api\PaymentTerm;
use PayPal\Api\ShippingInfo;
$invoice = new Invoice();
// ### Invoice Info
// Fill in all the information that is
// required for invoice APIs
$invoice
->setMerchantInfo(new MerchantInfo())
->setBillingInfo(array(new BillingInfo()))
->setItems(array(new InvoiceItem()))
->setNote("Medical Invoice 16 Jul, 2013 PST")
->setPaymentTerm(new PaymentTerm())
->setShippingInfo(new ShippingInfo());
// ### Merchant Info
// A resource representing merchant information that can be
// used to identify merchant
$invoice->getMerchantInfo()
->setEmail("PPX.DevNet-facilitator@gmail.com")
->setFirstName("Dennis")
->setLastName("Doctor")
->setbusinessName("Medical Professionals, LLC")
->setPhone(new Phone())
->setAddress(new Address());
$invoice->getMerchantInfo()->getPhone()
->setCountryCode("001")
->setNationalNumber("5032141716");
// ### Address Information
// The address used for creating the invoice
$invoice->getMerchantInfo()->getAddress()
->setLine1("1234 Main St.")
->setCity("Portland")
->setState("OR")
->setPostalCode("97217")
->setCountryCode("US");
// ### Billing Information
// Set the email address for each billing
$billing = $invoice->getBillingInfo();
$billing[0]
->setEmail("example@example.com");
// ### Items List
// You could provide the list of all items for
// detailed breakdown of invoice
$items = $invoice->getItems();
$items[0]
->setName("Sutures")
->setQuantity(100)
->setUnitPrice(new Currency());
$items[0]->getUnitPrice()
->setCurrency("USD")
->setValue(5);
$invoice->getPaymentTerm()
->setTermType("NET_45");
// ### Shipping Information
$invoice->getShippingInfo()
->setFirstName("Sally")
->setLastName("Patient")
->setBusinessName("Not applicable")
->setPhone(new Phone())
->setAddress(new Address());
$invoice->getShippingInfo()->getPhone()
->setCountryCode("001")
->setNationalNumber("5039871234");
$invoice->getShippingInfo()->getAddress()
->setLine1("1234 Main St.")
->setCity("Portland")
->setState("OR")
->setPostalCode("97217")
->setCountryCode("US");
try {
// ### Create Invoice
// Create an invoice by calling the invoice->create() method
// with a valid ApiContext (See bootstrap.php for more on `ApiContext`)
$invoice->create($apiContext);
} catch (PayPal\Exception\PPConnectionException $ex) {
echo "Exception: " . $ex->getMessage() . PHP_EOL;
var_dump($ex->getData());
exit(1);
}
?>
<html>
<head>
<title>Invoice Creation</title>
</head>
<body>
<div>
Created Invoice:
<?php echo $invoice->getId(); ?>
</div>
<pre><?php echo $invoice->toJSON(JSON_PRETTY_PRINT); ?></pre>
<a href='../index.html'>Back</a>
</body>
</html>

View File

@@ -0,0 +1,35 @@
<?php
// # Get Invoice Sample
// This sample code demonstrate how you can retrieve
// an invoice.
require __DIR__ . '/../bootstrap.php';
use PayPal\Api\Invoice;
$invoiceId = "INV2-9DRB-YTHU-2V9Q-7Q24";
// ### Retrieve Invoice
// Retrieve the invoice object by calling the
// static `get` method
// on the Invoice class by passing a valid
// Invoice ID
// (See bootstrap.php for more on `ApiContext`)
try {
$invoice = Invoice::get($invoiceId, $apiContext);
} catch (PayPal\Exception\PPConnectionException $ex) {
echo "Exception:" . $ex->getMessage() . PHP_EOL;
var_dump($ex->getData());
exit(1);
}
?>
<html>
<head>
<title>Lookup invoice details</title>
</head>
<body>
<div>Retrieving Invoice: <?php echo $invoiceId;?></div>
<pre><?php echo $invoice->toJSON(JSON_PRETTY_PRINT); ?></pre>
<a href='../index.html'>Back</a>
</body>
</html>

View File

@@ -0,0 +1,32 @@
<?php
// # List Invoices Sample
// This sample code demonstrate how you can get
// all invoice from history.
require __DIR__ . '/../bootstrap.php';
use PayPal\Api\Invoice;
try {
// ### Retrieve Invoices
// Retrieve the Invoice History object by calling the
// static `get_all` method on the Invoice class.
// Refer the method doc for valid values for keys
// (See bootstrap.php for more on `ApiContext`)
$invoices = Invoice::get_all($apiContext);
} catch (PayPal\Exception\PPConnectionException $ex) {
echo "Exception:" . $ex->getMessage() . PHP_EOL;
var_dump($ex->getData());
exit(1);
}
?>
<html>
<head>
<title>Lookup invoice history</title>
</head>
<body>
<div>Got invoices </div>
<pre><?php echo $invoices->toJSON(JSON_PRETTY_PRINT); ?></pre>
<a href='../index.html'>Back</a>
</body>
</html>

View File

@@ -0,0 +1,55 @@
<?php
// # Remind Invoice Sample
// This sample code demonstrate how you can remind
// an invoice to the payer
require __DIR__ . '/../bootstrap.php';
use PayPal\Api\Invoice;
use PayPal\Api\Notification;
try {
// ### Retrieve Invoice
// Retrieve the invoice object by calling the
// static `get` method
// on the Invoice class by passing a valid
// Invoice ID
// (See bootstrap.php for more on `ApiContext`)
$invoice = Invoice::get("INV2-9CAH-K5G7-2JPL-G4B4", $apiContext);
// ### Notification Object
// This would send a notification to both merchant as well
// the payer. The information of merchant
// and payer is retrieved from the invoice details
$notify = new Notification();
$notify
->setSubject("Past due")
->setNote("Please pay soon")
->setSendToMerchant(true);
// ### Remind Invoice
// Remind the notifiers by calling the
// `remind` method
// on the Invoice class by passing a valid
// notification object
// (See bootstrap.php for more on `ApiContext`)
$remindStatus = $invoice->remind($notify, $apiContext);
} catch (PayPal\Exception\PPConnectionException $ex) {
echo "Exception: " . $ex->getMessage() . PHP_EOL;
var_dump($ex->getData());
exit(1);
}
?>
<html>
<head>
<title>Remind Invoice</title>
</head>
<body>
<div>Remind Invoice:</div>
<pre><?php echo $invoice->toJSON(JSON_PRETTY_PRINT); ?></pre>
<a href='../index.html'>Back</a>
</body>
</html>

View File

@@ -0,0 +1,40 @@
<?php
// # Create Invoice Sample
// This sample code demonstrate how you can send
// a legitimate invoice to the payer
require __DIR__ . '/../bootstrap.php';
use PayPal\Api\Invoice;
try {
// ### Retrieve Invoice
// Retrieve the invoice object by calling the
// static `get` method
// on the Invoice class by passing a valid
// Invoice ID
// (See bootstrap.php for more on `ApiContext`)
$invoice = Invoice::get("INV2-9DRB-YTHU-2V9Q-7Q24", $apiContext);
// ### Send Invoice
// Send a legitimate invoice to the payer
// with a valid ApiContext (See bootstrap.php for more on `ApiContext`)
$sendStatus = $invoice->send($apiContext);
} catch (PayPal\Exception\PPConnectionException $ex) {
echo "Exception: " . $ex->getMessage() . PHP_EOL;
var_dump($ex->getData());
exit(1);
}
?>
<html>
<head>
<title>Send Invoice</title>
</head>
<body>
<div>Send Invoice:</div>
<pre><?php echo $invoice->toJSON(JSON_PRETTY_PRINT); ?></pre>
<a href='../index.html'>Back</a>
</body>
</html>

View File

@@ -1,37 +0,0 @@
<?php
require __DIR__ . '/../bootstrap.php';
use PayPal\Api\Invoice;
use PayPal\Api\CancelNotification;
try {
$invoice = Invoice::get("INV2-CJL7-PF4G-BLQF-5FWG", $apiContext);
$notify = new CancelNotification();
$notify
->setSubject("Past due")
->setNote("Canceling invoice")
->setSendToMerchant(true)
->setSendToPayer(true);
$cancelStatus = $invoice->cancel($notify, $apiContext);
} catch (PayPal\Exception\PPConnectionException $ex) {
echo "Exception: " . $ex->getMessage() . PHP_EOL;
var_dump($ex->getData());
exit(1);
}
?>
<html>
<head>
<title>Cancel Invoice</title>
</head>
<body>
<div>Cancel Invoice:</div>
<pre><?php var_dump($invoice);?></pre>
<a href='../index.html'>Back</a>
</body>
</html>

View File

@@ -1,100 +0,0 @@
<?php
require __DIR__ . '/../bootstrap.php';
use PayPal\Api\Invoice;
use PayPal\Api\MerchantInfo;
use PayPal\Api\BillingInfo;
use PayPal\Api\InvoiceItem;
use PayPal\Api\Phone;
use PayPal\Api\Address;
use PayPal\Api\Currency;
use PayPal\Api\PaymentTerm;
use PayPal\Api\ShippingInfo;
$invoice = new Invoice();
$invoice
->setMerchantInfo(new MerchantInfo())
->setBillingInfo(array(new BillingInfo()))
->setItems(array(new InvoiceItem()))
->setNote("Medical Invoice 16 Jul, 2013 PST")
->setPaymentTerm(new PaymentTerm())
->setShippingInfo(new ShippingInfo());
$invoice->getMerchantInfo()
->setEmail("PPX.DevNet-facilitator@gmail.com")
->setFirstName("Dennis")
->setLastName("Doctor")
->setbusinessName("Medical Professionals, LLC")
->setPhone(new Phone())
->setAddress(new Address());
$invoice->getMerchantInfo()->getPhone()
->setCountryCode("001")
->setNationalNumber("5032141716");
$invoice->getMerchantInfo()->getAddress()
->setLine1("1234 Main St.")
->setCity("Portland")
->setState("OR")
->setPostalCode("97217")
->setCountryCode("US");
$billing = $invoice->getBillingInfo();
$billing[0]
->setEmail("example@example.com");
$items = $invoice->getItems();
$items[0]
->setName("Sutures")
->setQuantity(100)
->setUnitPrice(new Currency());
$items[0]->getUnitPrice()
->setCurrency("USD")
->setValue(5);
$invoice->getPaymentTerm()
->setTermType("NET_45");
$invoice->getShippingInfo()
->setFirstName("Sally")
->setLastName("Patient")
->setBusinessName("Not applicable")
->setPhone(new Phone())
->setAddress(new Address());
$invoice->getShippingInfo()->getPhone()
->setCountryCode("001")
->setNationalNumber("5039871234");
$invoice->getShippingInfo()->getAddress()
->setLine1("1234 Main St.")
->setCity("Portland")
->setState("OR")
->setPostalCode("97217")
->setCountryCode("US");
print(var_dump($invoice->toArray()));
try {
$invoice->create($apiContext);
} catch (PayPal\Exception\PPConnectionException $ex) {
echo "Exception: " . $ex->getMessage() . PHP_EOL;
var_dump($ex->getData());
exit(1);
}
?>
<html>
<head>
<title>Direct Credit card payments</title>
</head>
<body>
<div>
Created Invoice:
<?php echo $invoice->getId();?>
</div>
<pre><?php var_dump($invoice->toArray());?></pre>
<a href='../index.html'>Back</a>
</body>
</html>

View File

@@ -1,19 +0,0 @@
<?php
require __DIR__ . '/../bootstrap.php';
use PayPal\Api\Invoice;
$invoiceId = "INV2-9DRB-YTHU-2V9Q-7Q24";
$invoice = Invoice::get($invoiceId, $apiContext);
?>
<html>
<head>
<title>Lookup invoice details</title>
</head>
<body>
<div>Retrieving Invoice: <?php echo $invoiceId;?></div>
<pre><?php var_dump($invoice);?></pre>
<a href='../index.html'>Back</a>
</body>
</html>

View File

@@ -1,22 +0,0 @@
<?php
require __DIR__ . '/../bootstrap.php';
use PayPal\Api\Invoice;
try {
$invoices = Invoice::get_all($apiContext);
} catch (PayPal\Exception\PPConnectionException $ex) {
echo "Exception:" . $ex->getMessage() . PHP_EOL;
var_dump($ex->getData());
exit(1);
}
?>
<html>
<head>
<title>Lookup invoice history</title>
</head>
<body>
<div>Got invoices </div>
<pre><?php var_dump($invoices->toArray());?></pre>
<a href='../index.html'>Back</a>
</body>
</html>

View File

@@ -1,35 +0,0 @@
<?php
require __DIR__ . '/../bootstrap.php';
use PayPal\Api\Invoice;
use PayPal\Api\Notification;
try {
$invoice = Invoice::get("INV2-9CAH-K5G7-2JPL-G4B4", $apiContext);
$notify = new Notification();
$notify
->setSubject("Past due")
->setNote("Please pay soon")
->setSendToMerchant(true);
$remindStatus = $invoice->remind($notify, $apiContext);
} catch (PayPal\Exception\PPConnectionException $ex) {
echo "Exception: " . $ex->getMessage() . PHP_EOL;
var_dump($ex->getData());
exit(1);
}
?>
<html>
<head>
<title>Remind Invoice</title>
</head>
<body>
<div>Remind Invoice:</div>
<pre><?php var_dump($invoice);?></pre>
<a href='../index.html'>Back</a>
</body>
</html>

View File

@@ -1,27 +0,0 @@
<?php
require __DIR__ . '/../bootstrap.php';
use PayPal\Api\Invoice;
try {
$invoice = Invoice::get("INV2-9DRB-YTHU-2V9Q-7Q24", $apiContext);
$sendStatus = $invoice->send($apiContext);
} catch (PayPal\Exception\PPConnectionException $ex) {
echo "Exception: " . $ex->getMessage() . PHP_EOL;
var_dump($ex->getData());
exit(1);
}
?>
<html>
<head>
<title>Send Invoice</title>
</head>
<body>
<div>Send Invoice:</div>
<pre><?php var_dump($invoice);?></pre>
<a href='../index.html'>Back</a>
</body>
</html>

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