Yanz Mini Shell
[_]
[-]
[X]
[
HomeShell 1
] [
HomeShell 2
] [
Upload
] [
Command Shell
] [
Scripting
] [
About
]
[ Directory ] =>
/
home
admin
web
uyoxpress.com
public_html
Action
[*]
New File
[*]
New Folder
Sensitive File
[*]
/etc/passwd
[*]
/etc/shadow
[*]
/etc/resolv.conf
[
Delete
] [
Edit
] [
Rename
] [
Back
]
rest-api-sdk-php/.editorconfig 0000644 00000000266 15007532371 0012320 0 ustar 00 # EditorConfig: Manage project indentation rules. http://EditorConfig.org root = true [*] end_of_line = lf insert_final_newline = true [*.php] indent_style = space indent_size = 4 rest-api-sdk-php/.travis.yml 0000644 00000001426 15007532371 0011753 0 ustar 00 sudo: false language: php php: - 5.3 - 5.4 - 5.5 - 5.6 - 7.0 - hhvm matrix: allow_failures: - php: hhvm fast_finish: true before_script: - composer self-update - composer install --dev - composer require satooshi/php-coveralls:* --dev script: - mkdir build - mkdir build/coverage - phpunit after_success: - php vendor/bin/coveralls -v -c .coveralls.yml - if [ $TRAVIS_PHP_VERSION = '5.6' ] && [ $TRAVIS_BRANCH = 'master' ] && [ $TRAVIS_PULL_REQUEST = 'false' ]; then sh generate-api.sh; fi notifications: email: recipients: - DL-PP-PHP-SDK@paypal.com on_success: change env: global: secure: UazgSLMJmrhmO+Do9TDiu8EKop06Xc2Ghi9F/8rx/CLz2FDZ5UDdzDD8uetjfdOnmMV7oadq13FGxJb9YCqTiJPZFpKsGtEr/IcCdpkO2krluLuWw5Veh8YxRG4rcZ+UWS0JpfQ72L9Zp4dMqPRo8SzcfiZV3HMG1uKYKpTSKnM= rest-api-sdk-php/phpunit.xml 0000644 00000001747 15007532371 0012061 0 ustar 00 <?xml version="1.0" encoding="UTF-8"?> <phpunit bootstrap="./tests/bootstrap.php" colors="true" processIsolation="false" stopOnFailure="false" syntaxCheck="false" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" testSuiteLoaderClass="PHPUnit_Runner_StandardTestSuiteLoader"> <testsuites> <testsuite name="All"> <directory>tests</directory> </testsuite> </testsuites> <groups> <exclude> <group>integration</group> </exclude> </groups> <logging> <log type="junit" target="build/junit.xml" logIncompleteSkipped="false" /> <log type="coverage-clover" target="build/coverage/clover.xml"/> </logging> <filter> <whitelist> <directory suffix=".php">./lib</directory> <exclude> </exclude> </whitelist> </filter> </phpunit> rest-api-sdk-php/lib/PayPal/Api/Tax.php 0000644 00000004130 15007532371 0013547 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; use PayPal\Converter\FormatConverter; use PayPal\Validation\NumericValidator; /** * Class Tax * * Tax information. * * @package PayPal\Api * * @property string id * @property string name * @property \PayPal\Api\number percent * @property \PayPal\Api\Currency amount */ class Tax extends PayPalModel { /** * Identifier of the resource. * * @param string $id * * @return $this */ public function setId($id) { $this->id = $id; return $this; } /** * Identifier of the resource. * * @return string */ public function getId() { return $this->id; } /** * Name of the tax. 10 characters max. * * @param string $name * * @return $this */ public function setName($name) { $this->name = $name; return $this; } /** * 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 string|double $percent * * @return $this */ public function setPercent($percent) { NumericValidator::validate($percent, "Percent"); $percent = FormatConverter::formatToPrice($percent); $this->percent = $percent; return $this; } /** * Rate of the specified tax. Range of 0.001 to 99.999. * * @return string */ public function getPercent() { return $this->percent; } /** * Tax in the form of money. Cannot be specified in a request. * * @param \PayPal\Api\Currency $amount * * @return $this */ 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; } } rest-api-sdk-php/lib/PayPal/Api/OpenIdUserinfo.php 0000644 00000025511 15007532371 0015712 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalResourceModel; use PayPal\Rest\ApiContext; /** * Class OpenIdUserinfo * * OpenIdConnect UserInfo Resource * * @property string user_id * @property string sub * @property mixed name * @property string given_name * @property string family_name * @property string middle_name * @property string picture * @property string email * @property bool email_verified * @property string gender * @property string birthday * @property string zoneinfo * @property string locale * @property string language * @property bool verified * @property string phone_number * @property OpenIdAddress address * @property mixed verified_account * @property mixed account_type * @property string age_range * @property string payer_id */ class OpenIdUserinfo extends PayPalResourceModel { /** * Subject - Identifier for the End-User at the Issuer. * * @param string $user_id * @return self */ public function setUserId($user_id) { $this->user_id = $user_id; return $this; } /** * Subject - Identifier for the End-User at the Issuer. * * @return string */ public function getUserId() { return $this->user_id; } /** * Subject - Identifier for the End-User at the Issuer. * * @param string $sub * @return self */ public function setSub($sub) { $this->sub = $sub; return $this; } /** * Subject - Identifier for the End-User at the Issuer. * * @return string */ public function getSub() { return $this->sub; } /** * End-User's full name in displayable form including all name parts, possibly including titles and suffixes, ordered according to the End-User's locale and preferences. * * @param string $name * @return self */ public function setName($name) { $this->name = $name; return $this; } /** * End-User's full name in displayable form including all name parts, possibly including titles and suffixes, ordered according to the End-User's locale and preferences. * * @return string */ public function getName() { return $this->name; } /** * Given name(s) or first name(s) of the End-User * * @param string $given_name * @return self */ public function setGivenName($given_name) { $this->given_name = $given_name; return $this; } /** * Given name(s) or first name(s) of the End-User * * @return string */ public function getGivenName() { return $this->given_name; } /** * Surname(s) or last name(s) of the End-User. * * @param string $family_name * @return self */ public function setFamilyName($family_name) { $this->family_name = $family_name; return $this; } /** * Surname(s) or last name(s) of the End-User. * * @return string */ public function getFamilyName() { return $this->family_name; } /** * Middle name(s) of the End-User. * * @param string $middle_name * @return self */ public function setMiddleName($middle_name) { $this->middle_name = $middle_name; return $this; } /** * Middle name(s) of the End-User. * * @return string */ public function getMiddleName() { return $this->middle_name; } /** * URL of the End-User's profile picture. * * @param string $picture * @return self */ public function setPicture($picture) { $this->picture = $picture; return $this; } /** * URL of the End-User's profile picture. * * @return string */ public function getPicture() { return $this->picture; } /** * End-User's preferred e-mail address. * * @param string $email * @return self */ public function setEmail($email) { $this->email = $email; return $this; } /** * End-User's preferred e-mail address. * * @return string */ public function getEmail() { return $this->email; } /** * True if the End-User's e-mail address has been verified; otherwise false. * * @param boolean $email_verified * @return self */ public function setEmailVerified($email_verified) { $this->email_verified = $email_verified; return $this; } /** * True if the End-User's e-mail address has been verified; otherwise false. * * @return boolean */ public function getEmailVerified() { return $this->email_verified; } /** * End-User's gender. * * @param string $gender * @return self */ public function setGender($gender) { $this->gender = $gender; return $this; } /** * End-User's gender. * * @return string */ public function getGender() { return $this->gender; } /** * End-User's birthday, represented as an YYYY-MM-DD format. They year MAY be 0000, indicating it is omited. To represent only the year, YYYY format would be used. * * @param string $birthday * @return self */ public function setBirthday($birthday) { $this->birthday = $birthday; return $this; } /** * End-User's birthday, represented as an YYYY-MM-DD format. They year MAY be 0000, indicating it is omited. To represent only the year, YYYY format would be used. * * @return string */ public function getBirthday() { return $this->birthday; } /** * Time zone database representing the End-User's time zone * * @param string $zoneinfo * @return self */ public function setZoneinfo($zoneinfo) { $this->zoneinfo = $zoneinfo; return $this; } /** * Time zone database representing the End-User's time zone * * @return string */ public function getZoneinfo() { return $this->zoneinfo; } /** * End-User's locale. * * @param string $locale * @return self */ public function setLocale($locale) { $this->locale = $locale; return $this; } /** * End-User's locale. * * @return string */ public function getLocale() { return $this->locale; } /** * End-User's language. * * @param string $language * @return self */ public function setLanguage($language) { $this->language = $language; return $this; } /** * End-User's language. * * @return string */ public function getLanguage() { return $this->language; } /** * End-User's verified status. * * @param boolean $verified * @return self */ public function setVerified($verified) { $this->verified = $verified; return $this; } /** * End-User's verified status. * * @return boolean */ public function getVerified() { return $this->verified; } /** * End-User's preferred telephone number. * * @param string $phone_number * @return self */ public function setPhoneNumber($phone_number) { $this->phone_number = $phone_number; return $this; } /** * End-User's preferred telephone number. * * @return string */ public function getPhoneNumber() { return $this->phone_number; } /** * End-User's preferred address. * * @param \PayPal\Api\OpenIdAddress $address * @return self */ public function setAddress($address) { $this->address = $address; return $this; } /** * End-User's preferred address. * * @return \PayPal\Api\OpenIdAddress */ public function getAddress() { return $this->address; } /** * Verified account status. * * @param boolean $verified_account * @return self */ public function setVerifiedAccount($verified_account) { $this->verified_account = $verified_account; return $this; } /** * Verified account status. * * @return boolean */ public function getVerifiedAccount() { return $this->verified_account; } /** * Account type. * * @param string $account_type * @return self */ public function setAccountType($account_type) { $this->account_type = $account_type; return $this; } /** * Account type. * * @return string */ public function getAccountType() { return $this->account_type; } /** * Account holder age range. * * @param string $age_range * @return self */ public function setAgeRange($age_range) { $this->age_range = $age_range; return $this; } /** * Account holder age range. * * @return string */ public function getAgeRange() { return $this->age_range; } /** * Account payer identifier. * * @param string $payer_id * @return self */ public function setPayerId($payer_id) { $this->payer_id = $payer_id; return $this; } /** * Account payer identifier. * * @return string */ public function getPayerId() { return $this->payer_id; } /** * returns user details * * @path /v1/identity/openidconnect/userinfo * @method GET * @param array $params (allowed values are access_token) * access_token - access token from the createFromAuthorizationCode / createFromRefreshToken calls * @param ApiContext $apiContext Optional API Context * @return OpenIdUserinfo */ public static function getUserinfo($params, $apiContext = null) { static $allowedParams = array('schema' => 1); $params = is_array($params) ? $params : array(); if (!array_key_exists('schema', $params)) { $params['schema'] = 'openid'; } $requestUrl = "/v1/identity/openidconnect/userinfo?" . http_build_query(array_intersect_key($params, $allowedParams)); $json = self::executeCall( $requestUrl, "GET", "", array( 'Authorization' => "Bearer " . $params['access_token'], 'Content-Type' => 'x-www-form-urlencoded' ), $apiContext ); $ret = new OpenIdUserinfo(); $ret->fromJson($json); return $ret; } } rest-api-sdk-php/lib/PayPal/Api/Payout.php 0000644 00000011561 15007532371 0014302 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalResourceModel; use PayPal\Rest\ApiContext; use PayPal\Transport\PayPalRestCall; use PayPal\Validation\ArgumentValidator; /** * Class Payout * * This object represents a set of payouts that includes status data for the payouts. This object enables you to create a payout using a POST request. * * @package PayPal\Api * * @property \PayPal\Api\PayoutSenderBatchHeader sender_batch_header * @property \PayPal\Api\PayoutItem[] items * @property \PayPal\Api\Links[] links */ class Payout extends PayPalResourceModel { /** * The original batch header as provided by the payment sender. * * @param \PayPal\Api\PayoutSenderBatchHeader $sender_batch_header * * @return $this */ public function setSenderBatchHeader($sender_batch_header) { $this->sender_batch_header = $sender_batch_header; return $this; } /** * The original batch header as provided by the payment sender. * * @return \PayPal\Api\PayoutSenderBatchHeader */ public function getSenderBatchHeader() { return $this->sender_batch_header; } /** * An array of payout items (that is, a set of individual payouts). * * @param \PayPal\Api\PayoutItem[] $items * * @return $this */ public function setItems($items) { $this->items = $items; return $this; } /** * An array of payout items (that is, a set of individual payouts). * * @return \PayPal\Api\PayoutItem[] */ public function getItems() { return $this->items; } /** * Append Items to the list. * * @param \PayPal\Api\PayoutItem $payoutItem * @return $this */ public function addItem($payoutItem) { if (!$this->getItems()) { return $this->setItems(array($payoutItem)); } else { return $this->setItems( array_merge($this->getItems(), array($payoutItem)) ); } } /** * Remove Items from the list. * * @param \PayPal\Api\PayoutItem $payoutItem * @return $this */ public function removeItem($payoutItem) { return $this->setItems( array_diff($this->getItems(), array($payoutItem)) ); } /** * Create a payout batch resource by passing a sender_batch_header and an items array to the request URI. The sender_batch_header contains payout parameters that describe the handling of a batch resource while the items array conatins payout items. * * @param array $params * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return PayoutBatch */ public function create($params = array(), $apiContext = null, $restCall = null) { $params = $params ? $params : array(); ArgumentValidator::validate($params, 'params'); $payLoad = $this->toJSON(); $allowedParams = array( 'sync_mode' => 1, ); $json = self::executeCall( "/v1/payments/payouts" . "?" . http_build_query(array_intersect_key($params, $allowedParams)), "POST", $payLoad, null, $apiContext, $restCall ); $ret = new PayoutBatch(); $ret->fromJson($json); return $ret; } /** * You can submit a payout with a synchronous API call, which immediately returns the results of a PayPal payment. * * @param ApiContext $apiContext * @param PayPalRestCall $restCall * @return PayoutBatch */ public function createSynchronous($apiContext = null, $restCall = null) { $params = array('sync_mode' => 'true'); return $this->create($params, $apiContext, $restCall); } /** * Obtain the status of a specific batch resource by passing the payout batch ID to the request URI. You can issue this call multiple times to get the current status. * * @param string $payoutBatchId * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return PayoutBatch */ public static function get($payoutBatchId, $apiContext = null, $restCall = null) { ArgumentValidator::validate($payoutBatchId, 'payoutBatchId'); $payLoad = ""; $json = self::executeCall( "/v1/payments/payouts/$payoutBatchId", "GET", $payLoad, null, $apiContext, $restCall ); $ret = new PayoutBatch(); $ret->fromJson($json); return $ret; } } rest-api-sdk-php/lib/PayPal/Api/InstallmentInfo.php 0000644 00000006042 15007532371 0016125 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class InstallmentInfo * * A resource representing installment information available for a transaction * * @package PayPal\Api * * @property string installment_id * @property string network * @property string issuer * @property \PayPal\Api\InstallmentOption[] installment_options */ class InstallmentInfo extends PayPalModel { /** * Installment id. * * @param string $installment_id * * @return $this */ public function setInstallmentId($installment_id) { $this->installment_id = $installment_id; return $this; } /** * Installment id. * * @return string */ public function getInstallmentId() { return $this->installment_id; } /** * Credit card network. * Valid Values: ["VISA", "MASTERCARD"] * * @param string $network * * @return $this */ public function setNetwork($network) { $this->network = $network; return $this; } /** * Credit card network. * * @return string */ public function getNetwork() { return $this->network; } /** * Credit card issuer. * * @param string $issuer * * @return $this */ public function setIssuer($issuer) { $this->issuer = $issuer; return $this; } /** * Credit card issuer. * * @return string */ public function getIssuer() { return $this->issuer; } /** * List of available installment options and the cost associated with each one. * * @param \PayPal\Api\InstallmentOption[] $installment_options * * @return $this */ public function setInstallmentOptions($installment_options) { $this->installment_options = $installment_options; return $this; } /** * List of available installment options and the cost associated with each one. * * @return \PayPal\Api\InstallmentOption[] */ public function getInstallmentOptions() { return $this->installment_options; } /** * Append InstallmentOptions to the list. * * @param \PayPal\Api\InstallmentOption $installmentOption * @return $this */ public function addInstallmentOption($installmentOption) { if (!$this->getInstallmentOptions()) { return $this->setInstallmentOptions(array($installmentOption)); } else { return $this->setInstallmentOptions( array_merge($this->getInstallmentOptions(), array($installmentOption)) ); } } /** * Remove InstallmentOptions from the list. * * @param \PayPal\Api\InstallmentOption $installmentOption * @return $this */ public function removeInstallmentOption($installmentOption) { return $this->setInstallmentOptions( array_diff($this->getInstallmentOptions(), array($installmentOption)) ); } } rest-api-sdk-php/lib/PayPal/Api/CreditCardToken.php 0000644 00000007700 15007532371 0016026 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class CreditCardToken * * A resource representing a credit card that can be used to fund a payment. * * @package PayPal\Api * * @property string credit_card_id * @property string payer_id * @property string last4 * @property string type * @property int expire_month * @property int expire_year */ class CreditCardToken extends PayPalModel { /** * ID of credit card previously stored using `/vault/credit-card`. * * @param string $credit_card_id * * @return $this */ public function setCreditCardId($credit_card_id) { $this->credit_card_id = $credit_card_id; return $this; } /** * ID of credit card previously stored using `/vault/credit-card`. * * @return string */ public function getCreditCardId() { return $this->credit_card_id; } /** * A unique identifier that you can assign and track when storing a credit card or using a stored credit card. This ID can help to avoid unintentional use or misuse of credit cards. This ID can be any value you would like to associate with the saved card, such as a UUID, username, or email address. **Required when using a stored credit card if a payer_id was originally provided when storing the credit card in vault.** * * @param string $payer_id * * @return $this */ public function setPayerId($payer_id) { $this->payer_id = $payer_id; return $this; } /** * A unique identifier that you can assign and track when storing a credit card or using a stored credit card. This ID can help to avoid unintentional use or misuse of credit cards. This ID can be any value you would like to associate with the saved card, such as a UUID, username, or email address. **Required when using a stored credit card if a payer_id was originally provided when storing the credit card in vault.** * * @return string */ public function getPayerId() { return $this->payer_id; } /** * Last four digits of the stored credit card number. * * @param string $last4 * * @return $this */ public function setLast4($last4) { $this->last4 = $last4; return $this; } /** * Last four digits of the stored credit card number. * * @return string */ public function getLast4() { return $this->last4; } /** * Credit card type. Valid types are: `visa`, `mastercard`, `discover`, `amex`. Values are presented in lowercase and not should not be used for display. * * @param string $type * * @return $this */ public function setType($type) { $this->type = $type; return $this; } /** * Credit card type. Valid types are: `visa`, `mastercard`, `discover`, `amex`. Values are presented in lowercase and not should not be used for display. * * @return string */ public function getType() { return $this->type; } /** * Expiration month with no leading zero. Acceptable values are 1 through 12. * * @param int $expire_month * * @return $this */ public function setExpireMonth($expire_month) { $this->expire_month = $expire_month; return $this; } /** * Expiration month with no leading zero. Acceptable values are 1 through 12. * * @return int */ public function getExpireMonth() { return $this->expire_month; } /** * 4-digit expiration year. * * @param int $expire_year * * @return $this */ public function setExpireYear($expire_year) { $this->expire_year = $expire_year; return $this; } /** * 4-digit expiration year. * * @return int */ public function getExpireYear() { return $this->expire_year; } } rest-api-sdk-php/lib/PayPal/Api/PaymentDefinition.php 0000644 00000011636 15007532371 0016452 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class PaymentDefinition * * Resource representing payment definition scheduling information. * * @package PayPal\Api * * @property string id * @property string name * @property string type * @property string frequency_interval * @property string frequency * @property string cycles * @property \PayPal\Api\Currency amount * @property \PayPal\Api\ChargeModel[] charge_models */ class PaymentDefinition extends PayPalModel { /** * Identifier of the payment_definition. 128 characters max. * * @param string $id * * @return $this */ public function setId($id) { $this->id = $id; return $this; } /** * Identifier of the payment_definition. 128 characters max. * * @return string */ public function getId() { return $this->id; } /** * Name of the payment definition. 128 characters max. * * @param string $name * * @return $this */ public function setName($name) { $this->name = $name; return $this; } /** * Name of the payment definition. 128 characters max. * * @return string */ public function getName() { return $this->name; } /** * Type of the payment definition. Allowed values: `TRIAL`, `REGULAR`. * * @param string $type * * @return $this */ public function setType($type) { $this->type = $type; return $this; } /** * Type of the payment definition. Allowed values: `TRIAL`, `REGULAR`. * * @return string */ public function getType() { return $this->type; } /** * How frequently the customer should be charged. * * @param string $frequency_interval * * @return $this */ public function setFrequencyInterval($frequency_interval) { $this->frequency_interval = $frequency_interval; return $this; } /** * How frequently the customer should be charged. * * @return string */ public function getFrequencyInterval() { return $this->frequency_interval; } /** * Frequency of the payment definition offered. Allowed values: `WEEK`, `DAY`, `YEAR`, `MONTH`. * * @param string $frequency * * @return $this */ public function setFrequency($frequency) { $this->frequency = $frequency; return $this; } /** * Frequency of the payment definition offered. Allowed values: `WEEK`, `DAY`, `YEAR`, `MONTH`. * * @return string */ public function getFrequency() { return $this->frequency; } /** * Number of cycles in this payment definition. * * @param string $cycles * * @return $this */ public function setCycles($cycles) { $this->cycles = $cycles; return $this; } /** * Number of cycles in this payment definition. * * @return string */ public function getCycles() { return $this->cycles; } /** * Amount that will be charged at the end of each cycle for this payment definition. * * @param \PayPal\Api\Currency $amount * * @return $this */ public function setAmount($amount) { $this->amount = $amount; return $this; } /** * Amount that will be charged at the end of each cycle for this payment definition. * * @return \PayPal\Api\Currency */ public function getAmount() { return $this->amount; } /** * Array of charge_models for this payment definition. * * @param \PayPal\Api\ChargeModel[] $charge_models * * @return $this */ public function setChargeModels($charge_models) { $this->charge_models = $charge_models; return $this; } /** * Array of charge_models for this payment definition. * * @return \PayPal\Api\ChargeModel[] */ public function getChargeModels() { return $this->charge_models; } /** * Append ChargeModels to the list. * * @param \PayPal\Api\ChargeModel $chargeModel * @return $this */ public function addChargeModel($chargeModel) { if (!$this->getChargeModels()) { return $this->setChargeModels(array($chargeModel)); } else { return $this->setChargeModels( array_merge($this->getChargeModels(), array($chargeModel)) ); } } /** * Remove ChargeModels from the list. * * @param \PayPal\Api\ChargeModel $chargeModel * @return $this */ public function removeChargeModel($chargeModel) { return $this->setChargeModels( array_diff($this->getChargeModels(), array($chargeModel)) ); } } rest-api-sdk-php/lib/PayPal/Api/Presentation.php 0000644 00000003370 15007532371 0015473 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class Presentation * * Parameters for style and presentation. * * @package PayPal\Api * * @property string brand_name * @property string logo_image * @property string locale_code */ class Presentation extends PayPalModel { /** * A label that overrides the business name in the PayPal account on the PayPal pages. * * * @param string $brand_name * * @return $this */ public function setBrandName($brand_name) { $this->brand_name = $brand_name; return $this; } /** * A label that overrides the business name in the PayPal account on the PayPal pages. * * @return string */ public function getBrandName() { return $this->brand_name; } /** * A URL to logo image. Allowed vaues: `.gif`, `.jpg`, or `.png`. * * * @param string $logo_image * * @return $this */ public function setLogoImage($logo_image) { $this->logo_image = $logo_image; return $this; } /** * A URL to logo image. Allowed vaues: `.gif`, `.jpg`, or `.png`. * * @return string */ public function getLogoImage() { return $this->logo_image; } /** * Locale of pages displayed by PayPal payment experience. * * * @param string $locale_code * * @return $this */ public function setLocaleCode($locale_code) { $this->locale_code = $locale_code; return $this; } /** * Locale of pages displayed by PayPal payment experience. * * @return string */ public function getLocaleCode() { return $this->locale_code; } } rest-api-sdk-php/lib/PayPal/Api/CountryCode.php 0000644 00000001305 15007532371 0015252 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class CountryCode * * Representation of a country code. * * @package PayPal\Api * * @property string country_code */ class CountryCode extends PayPalModel { /** * ISO country code based on 2-character IS0-3166-1 codes. * * @param string $country_code * * @return $this */ public function setCountryCode($country_code) { $this->country_code = $country_code; return $this; } /** * ISO country code based on 2-character IS0-3166-1 codes. * * @return string */ public function getCountryCode() { return $this->country_code; } } rest-api-sdk-php/lib/PayPal/Api/Agreement.php 0000644 00000050041 15007532371 0014724 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalResourceModel; use PayPal\Core\PayPalConstants; use PayPal\Rest\ApiContext; use PayPal\Transport\PayPalRestCall; use PayPal\Validation\ArgumentValidator; /** * Class Agreement * * A resource representing an agreement. * * @package PayPal\Api * * @property string id * @property string state * @property string name * @property string description * @property string start_date * @property \PayPal\Api\Payer payer * @property \PayPal\Api\Address shipping_address * @property \PayPal\Api\MerchantPreferences override_merchant_preferences * @property \PayPal\Api\OverrideChargeModel[] override_charge_models * @property \PayPal\Api\Plan plan * @property string create_time * @property string update_time * @property \PayPal\Api\AgreementDetails agreement_details */ class Agreement extends PayPalResourceModel { /** * Identifier of the agreement. * * @param string $id * * @return $this */ public function setId($id) { $this->id = $id; return $this; } /** * Identifier of the agreement. * * @return string */ public function getId() { return $this->id; } /** * State of the agreement. * * @param string $state * * @return $this */ public function setState($state) { $this->state = $state; return $this; } /** * State of the agreement. * * @return string */ public function getState() { return $this->state; } /** * Name of the agreement. * * @param string $name * * @return $this */ public function setName($name) { $this->name = $name; return $this; } /** * Name of the agreement. * * @return string */ public function getName() { return $this->name; } /** * Description of the agreement. * * @param string $description * * @return $this */ public function setDescription($description) { $this->description = $description; return $this; } /** * Description of the agreement. * * @return string */ public function getDescription() { return $this->description; } /** * Start date of the agreement. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). * * @param string $start_date * * @return $this */ public function setStartDate($start_date) { $this->start_date = $start_date; return $this; } /** * Start date of the agreement. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). * * @return string */ public function getStartDate() { return $this->start_date; } /** * Details of the buyer who is enrolling in this agreement. This information is gathered from execution of the approval URL. * * @param \PayPal\Api\Payer $payer * * @return $this */ public function setPayer($payer) { $this->payer = $payer; return $this; } /** * Details of the buyer who is enrolling in this agreement. This information is gathered from execution of the approval URL. * * @return \PayPal\Api\Payer */ public function getPayer() { return $this->payer; } /** * Shipping address object of the agreement, which should be provided if it is different from the default address. * * @param \PayPal\Api\Address $shipping_address * * @return $this */ public function setShippingAddress($shipping_address) { $this->shipping_address = $shipping_address; return $this; } /** * Shipping address object of the agreement, which should be provided if it is different from the default address. * * @return \PayPal\Api\Address */ public function getShippingAddress() { return $this->shipping_address; } /** * Default merchant preferences from the billing plan are used, unless override preferences are provided here. * * @param \PayPal\Api\MerchantPreferences $override_merchant_preferences * * @return $this */ public function setOverrideMerchantPreferences($override_merchant_preferences) { $this->override_merchant_preferences = $override_merchant_preferences; return $this; } /** * Default merchant preferences from the billing plan are used, unless override preferences are provided here. * * @return \PayPal\Api\MerchantPreferences */ public function getOverrideMerchantPreferences() { return $this->override_merchant_preferences; } /** * Array of override_charge_model for this agreement if needed to change the default models from the billing plan. * * @param \PayPal\Api\OverrideChargeModel[] $override_charge_models * * @return $this */ public function setOverrideChargeModels($override_charge_models) { $this->override_charge_models = $override_charge_models; return $this; } /** * Array of override_charge_model for this agreement if needed to change the default models from the billing plan. * * @return \PayPal\Api\OverrideChargeModel[] */ public function getOverrideChargeModels() { return $this->override_charge_models; } /** * Append OverrideChargeModels to the list. * * @param \PayPal\Api\OverrideChargeModel $overrideChargeModel * @return $this */ public function addOverrideChargeModel($overrideChargeModel) { if (!$this->getOverrideChargeModels()) { return $this->setOverrideChargeModels(array($overrideChargeModel)); } else { return $this->setOverrideChargeModels( array_merge($this->getOverrideChargeModels(), array($overrideChargeModel)) ); } } /** * Remove OverrideChargeModels from the list. * * @param \PayPal\Api\OverrideChargeModel $overrideChargeModel * @return $this */ public function removeOverrideChargeModel($overrideChargeModel) { return $this->setOverrideChargeModels( array_diff($this->getOverrideChargeModels(), array($overrideChargeModel)) ); } /** * Plan details for this agreement. * * @param \PayPal\Api\Plan $plan * * @return $this */ public function setPlan($plan) { $this->plan = $plan; return $this; } /** * Plan details for this agreement. * * @return \PayPal\Api\Plan */ public function getPlan() { return $this->plan; } /** * Date and time that this resource was created. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). * * @param string $create_time * * @return $this */ public function setCreateTime($create_time) { $this->create_time = $create_time; return $this; } /** * Date and time that this resource was created. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). * * @return string */ public function getCreateTime() { return $this->create_time; } /** * Date and time that this resource was updated. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). * * @param string $update_time * * @return $this */ public function setUpdateTime($update_time) { $this->update_time = $update_time; return $this; } /** * Date and time that this resource was updated. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). * * @return string */ public function getUpdateTime() { return $this->update_time; } /** * Agreement Details * * @param \PayPal\Api\AgreementDetails $agreement_details * * @return $this */ public function setAgreementDetails($agreement_details) { $this->agreement_details = $agreement_details; return $this; } /** * Agreement Details * * @return \PayPal\Api\AgreementDetails */ public function getAgreementDetails() { return $this->agreement_details; } /** * Get Approval Link * * @return null|string */ public function getApprovalLink() { return $this->getLink(PayPalConstants::APPROVAL_URL); } /** * Create a new billing agreement by passing the details for the agreement, including the name, description, start date, payer, and billing plan in the request JSON. * * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return Agreement */ public function create($apiContext = null, $restCall = null) { $payLoad = $this->toJSON(); $json = self::executeCall( "/v1/payments/billing-agreements/", "POST", $payLoad, null, $apiContext, $restCall ); $this->fromJson($json); return $this; } /** * Execute a billing agreement after buyer approval by passing the payment token to the request URI. * * @param $paymentToken * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return Agreement */ public function execute($paymentToken, $apiContext = null, $restCall = null) { ArgumentValidator::validate($paymentToken, 'paymentToken'); $payLoad = ""; $json = self::executeCall( "/v1/payments/billing-agreements/$paymentToken/agreement-execute", "POST", $payLoad, null, $apiContext, $restCall ); $this->fromJson($json); return $this; } /** * Retrieve details for a particular billing agreement by passing the ID of the agreement to the request URI. * * @param string $agreementId * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return Agreement */ public static function get($agreementId, $apiContext = null, $restCall = null) { ArgumentValidator::validate($agreementId, 'agreementId'); $payLoad = ""; $json = self::executeCall( "/v1/payments/billing-agreements/$agreementId", "GET", $payLoad, null, $apiContext, $restCall ); $ret = new Agreement(); $ret->fromJson($json); return $ret; } /** * Update details of a billing agreement, such as the description, shipping address, and start date, by passing the ID of the agreement to the request URI. * * @param PatchRequest $patchRequest * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return bool */ public function update($patchRequest, $apiContext = null, $restCall = null) { ArgumentValidator::validate($this->getId(), "Id"); ArgumentValidator::validate($patchRequest, 'patchRequest'); $payLoad = $patchRequest->toJSON(); self::executeCall( "/v1/payments/billing-agreements/{$this->getId()}", "PATCH", $payLoad, null, $apiContext, $restCall ); return true; } /** * Suspend a particular billing agreement by passing the ID of the agreement to the request URI. * * @param AgreementStateDescriptor $agreementStateDescriptor * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return bool */ public function suspend($agreementStateDescriptor, $apiContext = null, $restCall = null) { ArgumentValidator::validate($this->getId(), "Id"); ArgumentValidator::validate($agreementStateDescriptor, 'agreementStateDescriptor'); $payLoad = $agreementStateDescriptor->toJSON(); self::executeCall( "/v1/payments/billing-agreements/{$this->getId()}/suspend", "POST", $payLoad, null, $apiContext, $restCall ); return true; } /** * Reactivate a suspended billing agreement by passing the ID of the agreement to the appropriate URI. In addition, pass an agreement_state_descriptor object in the request JSON that includes a note about the reason for changing the state of the agreement and the amount and currency for the agreement. * * @param AgreementStateDescriptor $agreementStateDescriptor * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return bool */ public function reActivate($agreementStateDescriptor, $apiContext = null, $restCall = null) { ArgumentValidator::validate($this->getId(), "Id"); ArgumentValidator::validate($agreementStateDescriptor, 'agreementStateDescriptor'); $payLoad = $agreementStateDescriptor->toJSON(); self::executeCall( "/v1/payments/billing-agreements/{$this->getId()}/re-activate", "POST", $payLoad, null, $apiContext, $restCall ); return true; } /** * Cancel a billing agreement by passing the ID of the agreement to the request URI. In addition, pass an agreement_state_descriptor object in the request JSON that includes a note about the reason for changing the state of the agreement and the amount and currency for the agreement. * * @param AgreementStateDescriptor $agreementStateDescriptor * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return bool */ public function cancel($agreementStateDescriptor, $apiContext = null, $restCall = null) { ArgumentValidator::validate($this->getId(), "Id"); ArgumentValidator::validate($agreementStateDescriptor, 'agreementStateDescriptor'); $payLoad = $agreementStateDescriptor->toJSON(); self::executeCall( "/v1/payments/billing-agreements/{$this->getId()}/cancel", "POST", $payLoad, null, $apiContext, $restCall ); return true; } /** * Bill an outstanding amount for an agreement by passing the ID of the agreement to the request URI. In addition, pass an agreement_state_descriptor object in the request JSON that includes a note about the reason for changing the state of the agreement and the amount and currency for the agreement. * * @param AgreementStateDescriptor $agreementStateDescriptor * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return bool */ public function billBalance($agreementStateDescriptor, $apiContext = null, $restCall = null) { ArgumentValidator::validate($this->getId(), "Id"); ArgumentValidator::validate($agreementStateDescriptor, 'agreementStateDescriptor'); $payLoad = $agreementStateDescriptor->toJSON(); self::executeCall( "/v1/payments/billing-agreements/{$this->getId()}/bill-balance", "POST", $payLoad, null, $apiContext, $restCall ); return true; } /** * Set the balance for an agreement by passing the ID of the agreement to the request URI. In addition, pass a common_currency object in the request JSON that specifies the currency type and value of the balance. * * @param Currency $currency * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return bool */ public function setBalance($currency, $apiContext = null, $restCall = null) { ArgumentValidator::validate($this->getId(), "Id"); ArgumentValidator::validate($currency, 'currency'); $payLoad = $currency->toJSON(); self::executeCall( "/v1/payments/billing-agreements/{$this->getId()}/set-balance", "POST", $payLoad, null, $apiContext, $restCall ); return true; } /** * List transactions for a billing agreement by passing the ID of the agreement, as well as the start and end dates of the range of transactions to list, to the request URI. * * @deprecated Please use searchTransactions Instead * @param string $agreementId * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return AgreementTransactions */ public static function transactions($agreementId, $apiContext = null, $restCall = null) { ArgumentValidator::validate($agreementId, 'agreementId'); $payLoad = ""; $json = self::executeCall( "/v1/payments/billing-agreements/$agreementId/transactions", "GET", $payLoad, null, $apiContext, $restCall ); $ret = new AgreementTransactions(); $ret->fromJson($json); return $ret; } /** * List transactions for a billing agreement by passing the ID of the agreement, as well as the start and end dates of the range of transactions to list, to the request URI. * * @param string $agreementId * @param array $params Parameters for search string. Options: start_date, and end_date * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return AgreementTransactions */ public static function searchTransactions($agreementId, $params = array(), $apiContext = null, $restCall = null) { ArgumentValidator::validate($agreementId, 'agreementId'); ArgumentValidator::validate($params, 'params'); $allowedParams = array( 'start_date' => 1, 'end_date' => 1, ); $payLoad = ""; $json = self::executeCall( "/v1/payments/billing-agreements/$agreementId/transactions?" . http_build_query(array_intersect_key($params, $allowedParams)), "GET", $payLoad, null, $apiContext, $restCall ); $ret = new AgreementTransactions(); $ret->fromJson($json); return $ret; } } rest-api-sdk-php/lib/PayPal/Api/PaymentExecution.php 0000644 00000005405 15007532371 0016322 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class PaymentExecution * * Let's you execute a PayPal Account based Payment resource with the payer_id obtained from web approval url. * * @package PayPal\Api * * @property string payer_id * @property string carrier_account_id * @property \PayPal\Api\Transaction[] transactions */ class PaymentExecution extends PayPalModel { /** * The ID of the Payer, passed in the `return_url` by PayPal. * * @param string $payer_id * * @return $this */ public function setPayerId($payer_id) { $this->payer_id = $payer_id; return $this; } /** * The ID of the Payer, passed in the `return_url` by PayPal. * * @return string */ public function getPayerId() { return $this->payer_id; } /** * Carrier account id for a carrier billing payment. For a carrier billing payment, payer_id is not applicable. * * @param string $carrier_account_id * * @return $this */ public function setCarrierAccountId($carrier_account_id) { $this->carrier_account_id = $carrier_account_id; return $this; } /** * Carrier account id for a carrier billing payment. For a carrier billing payment, payer_id is not applicable. * * @return string */ public function getCarrierAccountId() { return $this->carrier_account_id; } /** * Transactional details including the amount and item details. * * @param \PayPal\Api\Transaction[] $transactions * * @return $this */ public function setTransactions($transactions) { $this->transactions = $transactions; return $this; } /** * Transactional details including the amount and item details. * * @return \PayPal\Api\Transaction[] */ public function getTransactions() { return $this->transactions; } /** * Append Transactions to the list. * * @param \PayPal\Api\Transaction $transaction * @return $this */ public function addTransaction($transaction) { if (!$this->getTransactions()) { return $this->setTransactions(array($transaction)); } else { return $this->setTransactions( array_merge($this->getTransactions(), array($transaction)) ); } } /** * Remove Transactions from the list. * * @param \PayPal\Api\Transaction $transaction * @return $this */ public function removeTransaction($transaction) { return $this->setTransactions( array_diff($this->getTransactions(), array($transaction)) ); } } rest-api-sdk-php/lib/PayPal/Api/Address.php 0000644 00000001153 15007532371 0014402 0 ustar 00 <?php namespace PayPal\Api; /** * Class Address * * Base Address object used as billing address in a payment or extended for Shipping Address. * * @package PayPal\Api * * @property string phone */ class Address extends BaseAddress { /** * Phone number in E.123 format. * * @param string $phone * * @return $this */ public function setPhone($phone) { $this->phone = $phone; return $this; } /** * Phone number in E.123 format. * * @return string */ public function getPhone() { return $this->phone; } } rest-api-sdk-php/lib/PayPal/Api/FuturePayment.php 0000644 00000003764 15007532371 0015637 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Rest\ApiContext; use PayPal\Transport\PayPalRestCall; /** * Class FuturePayment * * @package PayPal\Api */ class FuturePayment extends Payment { /** * Extends the Payment object to create future payments * * @param null $apiContext * @param string|null $clientMetadataId * @return $this */ public function create($apiContext = null, $clientMetadataId = null) { if ($apiContext == null) { $apiContext = new ApiContext(self::$credential); } $headers = array(); if ($clientMetadataId != null) { $headers = array( 'PAYPAL-CLIENT-METADATA-ID' => $clientMetadataId ); } $payLoad = $this->toJSON(); $call = new PayPalRestCall($apiContext); $json = $call->execute( array('PayPal\Handler\RestHandler'), "/v1/payments/payment", "POST", $payLoad, $headers ); $this->fromJson($json); return $this; } /** * Get a Refresh Token from Authorization Code * * @param $authorizationCode * @param ApiContext $apiContext * @return string|null refresh token */ public static function getRefreshToken($authorizationCode, $apiContext = null) { $apiContext = $apiContext ? $apiContext : new ApiContext(self::$credential); $credential = $apiContext->getCredential(); return $credential->getRefreshToken($apiContext->getConfig(), $authorizationCode); } /** * Updates Access Token using long lived refresh token * * @param string|null $refreshToken * @param ApiContext $apiContext * @return void */ public function updateAccessToken($refreshToken, $apiContext) { $apiContext = $apiContext ? $apiContext : new ApiContext(self::$credential); $apiContext->getCredential()->updateAccessToken($apiContext->getConfig(), $refreshToken); } } rest-api-sdk-php/lib/PayPal/Api/Patch.php 0000644 00000004302 15007532371 0014053 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class Patch * * A JSON patch object used for applying partial updates to resources. * * @package PayPal\Api * * @property string op * @property string path * @property mixed value * @property string from */ class Patch extends PayPalModel { /** * The operation to perform. * Valid Values: ["add", "remove", "replace", "move", "copy", "test"] * * @param string $op * * @return $this */ public function setOp($op) { $this->op = $op; return $this; } /** * The operation to perform. * * @return string */ public function getOp() { return $this->op; } /** * String containing a JSON Pointer value that references a location within the target document where the operation is performed. * * @param string $path * * @return $this */ public function setPath($path) { $this->path = $path; return $this; } /** * String containing a JSON Pointer value that references a location within the target document where the operation is performed. * * @return string */ public function getPath() { return $this->path; } /** * New value to apply based on the operation. * * @param mixed $value * * @return $this */ public function setValue($value) { $this->value = $value; return $this; } /** * New value to apply based on the operation. * * @return mixed */ public function getValue() { return $this->value; } /** * A string containing a JSON Pointer value that references the location in the target document to move the value from. * * @param string $from * * @return $this */ public function setFrom($from) { $this->from = $from; return $this; } /** * A string containing a JSON Pointer value that references the location in the target document to move the value from. * * @return string */ public function getFrom() { return $this->from; } } rest-api-sdk-php/lib/PayPal/Api/FundingSource.php 0000644 00000014207 15007532371 0015574 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class FundingSource * * specifies the funding source details. * * @package PayPal\Api * * @property string funding_mode * @property string funding_instrument_type * @property string soft_descriptor * @property \PayPal\Api\Currency amount * @property \PayPal\Api\Currency negative_balance_amount * @property string legal_text * @property \PayPal\Api\FundingDetail funding_detail * @property string additional_text * @property \PayPal\Api\FundingInstrument extends * @property \PayPal\Api\Links[] links */ class FundingSource extends PayPalModel { /** * specifies funding mode of the instrument * Valid Values: ["INSTANT_TRANSFER", "MANUAL_BANK_TRANSFER", "DELAYED_TRANSFER", "ECHECK"] * * @param string $funding_mode * * @return $this */ public function setFundingMode($funding_mode) { $this->funding_mode = $funding_mode; return $this; } /** * specifies funding mode of the instrument * * @return string */ public function getFundingMode() { return $this->funding_mode; } /** * Instrument type for this funding source * Valid Values: ["BALANCE", "PAYMENT_CARD", "BANK_ACCOUNT", "CREDIT", "INCENTIVE"] * * @param string $funding_instrument_type * * @return $this */ public function setFundingInstrumentType($funding_instrument_type) { $this->funding_instrument_type = $funding_instrument_type; return $this; } /** * Instrument type for this funding source * * @return string */ public function getFundingInstrumentType() { return $this->funding_instrument_type; } /** * Soft descriptor used when charging this funding source. * * @param string $soft_descriptor * * @return $this */ public function setSoftDescriptor($soft_descriptor) { $this->soft_descriptor = $soft_descriptor; return $this; } /** * Soft descriptor used when charging this funding source. * * @return string */ public function getSoftDescriptor() { return $this->soft_descriptor; } /** * Total anticipated amount of money to be pulled from instrument. * * @param \PayPal\Api\Currency $amount * * @return $this */ public function setAmount($amount) { $this->amount = $amount; return $this; } /** * Total anticipated amount of money to be pulled from instrument. * * @return \PayPal\Api\Currency */ public function getAmount() { return $this->amount; } /** * Additional amount to be pulled from the instrument to recover a negative balance on the buyer * * @param \PayPal\Api\Currency $amount * * @return $this */ public function setNegativeBalanceAmount($amount) { $this->amount = $amount; return $this; } /** * Additional amount to be pulled from the instrument to recover a negative balance on the buyer * * @return \PayPal\Api\Currency */ public function getNegativeBalanceAmount() { return $this->amount; } /** * Localized legal text relevant to funding source. * * @param string $legal_text * * @return $this */ public function setLegalText($legal_text) { $this->legal_text = $legal_text; return $this; } /** * Localized legal text relevant to funding source. * * @return string */ public function getLegalText() { return $this->legal_text; } /** * Additional detail of the funding. * * @param \PayPal\Api\FundingDetail $funding_detail * * @return $this */ public function setFundingDetail($funding_detail) { $this->funding_detail = $funding_detail; return $this; } /** * Additional detail of the funding. * * @return \PayPal\Api\FundingDetail */ public function getFundingDetail() { return $this->funding_detail; } /** * Additional text relevant to funding source. * * @param string $additional_text * * @return $this */ public function setAdditionalText($additional_text) { $this->additional_text = $additional_text; return $this; } /** * Additional text relevant to funding source. * * @return string */ public function getAdditionalText() { return $this->additional_text; } /** * Sets Extends * * @param \PayPal\Api\FundingInstrument $extends * * @return $this */ public function setExtends($extends) { $this->extends = $extends; return $this; } /** * Gets Extends * * @return \PayPal\Api\FundingInstrument */ public function getExtends() { return $this->extends; } /** * Sets Links * * @param \PayPal\Api\Links[] $links * * @return $this */ public function setLinks($links) { $this->links = $links; return $this; } /** * Gets Links * * @return \PayPal\Api\Links[] */ public function getLinks() { return $this->links; } /** * Append Links to the list. * * @param \PayPal\Api\Links $links * @return $this */ public function addLink($links) { if (!$this->getLinks()) { return $this->setLinks(array($links)); } else { return $this->setLinks( array_merge($this->getLinks(), array($links)) ); } } /** * Remove Links from the list. * * @param \PayPal\Api\Links $links * @return $this */ public function removeLink($links) { return $this->setLinks( array_diff($this->getLinks(), array($links)) ); } } rest-api-sdk-php/lib/PayPal/Api/RefundDetail.php 0000644 00000004541 15007532371 0015367 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class RefundDetail * * Invoicing refund information. * * @package PayPal\Api * * @property string type * @property string date * @property string note */ class RefundDetail extends PayPalModel { /** * 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. * Valid Values: ["PAYPAL", "EXTERNAL"] * * @param string $type * * @return $this */ 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; } /** * 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. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). * * @param string $date * * @return $this */ 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. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). * * @return string */ public function getDate() { return $this->date; } /** * Optional note associated with the refund. * * @param string $note * * @return $this */ public function setNote($note) { $this->note = $note; return $this; } /** * Optional note associated with the refund. * * @return string */ public function getNote() { return $this->note; } } rest-api-sdk-php/lib/PayPal/Api/Plan.php 0000644 00000027503 15007532371 0013716 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; use PayPal\Common\PayPalResourceModel; use PayPal\Rest\ApiContext; use PayPal\Transport\PayPalRestCall; use PayPal\Validation\ArgumentValidator; /** * Class Plan * * Billing plan resource that will be used to create a billing agreement. * * @package PayPal\Api * * @property string id * @property string name * @property string description * @property string type * @property string state * @property string create_time * @property string update_time * @property \PayPal\Api\PaymentDefinition[] payment_definitions * @property \PayPal\Api\Terms[] terms * @property \PayPal\Api\MerchantPreferences merchant_preferences */ class Plan extends PayPalResourceModel { /** * Identifier of the billing plan. 128 characters max. * * @param string $id * * @return $this */ public function setId($id) { $this->id = $id; return $this; } /** * Identifier of the billing plan. 128 characters max. * * @return string */ public function getId() { return $this->id; } /** * Name of the billing plan. 128 characters max. * * @param string $name * * @return $this */ public function setName($name) { $this->name = $name; return $this; } /** * Name of the billing plan. 128 characters max. * * @return string */ public function getName() { return $this->name; } /** * Description of the billing plan. 128 characters max. * * @param string $description * * @return $this */ public function setDescription($description) { $this->description = $description; return $this; } /** * Description of the billing plan. 128 characters max. * * @return string */ public function getDescription() { return $this->description; } /** * Type of the billing plan. Allowed values: `FIXED`, `INFINITE`. * * @param string $type * * @return $this */ public function setType($type) { $this->type = $type; return $this; } /** * Type of the billing plan. Allowed values: `FIXED`, `INFINITE`. * * @return string */ public function getType() { return $this->type; } /** * Status of the billing plan. Allowed values: `CREATED`, `ACTIVE`, `INACTIVE`, and `DELETED`. * * @param string $state * * @return $this */ public function setState($state) { $this->state = $state; return $this; } /** * Status of the billing plan. Allowed values: `CREATED`, `ACTIVE`, `INACTIVE`, and `DELETED`. * * @return string */ public function getState() { return $this->state; } /** * Time when the billing plan was created. Format YYYY-MM-DDTimeTimezone, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). * * @param string $create_time * * @return $this */ public function setCreateTime($create_time) { $this->create_time = $create_time; return $this; } /** * Time when the billing plan was created. Format YYYY-MM-DDTimeTimezone, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). * * @return string */ public function getCreateTime() { return $this->create_time; } /** * Time when this billing plan was updated. Format YYYY-MM-DDTimeTimezone, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). * * @param string $update_time * * @return $this */ public function setUpdateTime($update_time) { $this->update_time = $update_time; return $this; } /** * Time when this billing plan was updated. Format YYYY-MM-DDTimeTimezone, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). * * @return string */ public function getUpdateTime() { return $this->update_time; } /** * Array of payment definitions for this billing plan. * * @param \PayPal\Api\PaymentDefinition[] $payment_definitions * * @return $this */ public function setPaymentDefinitions($payment_definitions) { $this->payment_definitions = $payment_definitions; return $this; } /** * Array of payment definitions for this billing plan. * * @return \PayPal\Api\PaymentDefinition[] */ public function getPaymentDefinitions() { return $this->payment_definitions; } /** * Append PaymentDefinitions to the list. * * @param \PayPal\Api\PaymentDefinition $paymentDefinition * @return $this */ public function addPaymentDefinition($paymentDefinition) { if (!$this->getPaymentDefinitions()) { return $this->setPaymentDefinitions(array($paymentDefinition)); } else { return $this->setPaymentDefinitions( array_merge($this->getPaymentDefinitions(), array($paymentDefinition)) ); } } /** * Remove PaymentDefinitions from the list. * * @param \PayPal\Api\PaymentDefinition $paymentDefinition * @return $this */ public function removePaymentDefinition($paymentDefinition) { return $this->setPaymentDefinitions( array_diff($this->getPaymentDefinitions(), array($paymentDefinition)) ); } /** * Array of terms for this billing plan. * * @param \PayPal\Api\Terms[] $terms * * @return $this */ public function setTerms($terms) { $this->terms = $terms; return $this; } /** * Array of terms for this billing plan. * * @return \PayPal\Api\Terms[] */ public function getTerms() { return $this->terms; } /** * Append Terms to the list. * * @param \PayPal\Api\Terms $terms * @return $this */ public function addTerm($terms) { if (!$this->getTerms()) { return $this->setTerms(array($terms)); } else { return $this->setTerms( array_merge($this->getTerms(), array($terms)) ); } } /** * Remove Terms from the list. * * @param \PayPal\Api\Terms $terms * @return $this */ public function removeTerm($terms) { return $this->setTerms( array_diff($this->getTerms(), array($terms)) ); } /** * Specific preferences such as: set up fee, max fail attempts, autobill amount, and others that are configured for this billing plan. * * @param \PayPal\Api\MerchantPreferences $merchant_preferences * * @return $this */ public function setMerchantPreferences($merchant_preferences) { $this->merchant_preferences = $merchant_preferences; return $this; } /** * Specific preferences such as: set up fee, max fail attempts, autobill amount, and others that are configured for this billing plan. * * @return \PayPal\Api\MerchantPreferences */ public function getMerchantPreferences() { return $this->merchant_preferences; } /** * Retrieve the details for a particular billing plan by passing the billing plan ID to the request URI. * * @param string $planId * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return Plan */ public static function get($planId, $apiContext = null, $restCall = null) { ArgumentValidator::validate($planId, 'planId'); $payLoad = ""; $json = self::executeCall( "/v1/payments/billing-plans/$planId", "GET", $payLoad, null, $apiContext, $restCall ); $ret = new Plan(); $ret->fromJson($json); return $ret; } /** * Create a new billing plan by passing the details for the plan, including the plan name, description, and type, to the request URI. * * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return Plan */ public function create($apiContext = null, $restCall = null) { $payLoad = $this->toJSON(); $json = self::executeCall( "/v1/payments/billing-plans/", "POST", $payLoad, null, $apiContext, $restCall ); $this->fromJson($json); return $this; } /** * Replace specific fields within a billing plan by passing the ID of the billing plan to the request URI. In addition, pass a patch object in the request JSON that specifies the operation to perform, field to update, and new value for each update. * * @param PatchRequest $patchRequest * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return bool */ public function update($patchRequest, $apiContext = null, $restCall = null) { ArgumentValidator::validate($this->getId(), "Id"); ArgumentValidator::validate($patchRequest, 'patchRequest'); $payLoad = $patchRequest->toJSON(); self::executeCall( "/v1/payments/billing-plans/{$this->getId()}", "PATCH", $payLoad, null, $apiContext, $restCall ); return true; } /** * Delete a billing plan by passing the ID of the billing plan to the request URI. * * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return bool */ public function delete($apiContext = null, $restCall = null) { ArgumentValidator::validate($this->getId(), "Id"); $patchRequest = new PatchRequest(); $patch = new Patch(); $value = new PayPalModel('{ "state":"DELETED" }'); $patch->setOp('replace') ->setPath('/') ->setValue($value); $patchRequest->addPatch($patch); return $this->update($patchRequest, $apiContext, $restCall); } /** * List billing plans according to optional query string parameters specified. * * @param array $params * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return PlanList */ public static function all($params, $apiContext = null, $restCall = null) { ArgumentValidator::validate($params, 'params'); $payLoad = ""; $allowedParams = array( 'page_size' => 1, 'status' => 1, 'page' => 1, 'total_required' => 1 ); $json = self::executeCall( "/v1/payments/billing-plans/" . "?" . http_build_query(array_intersect_key($params, $allowedParams)), "GET", $payLoad, null, $apiContext, $restCall ); $ret = new PlanList(); $ret->fromJson($json); return $ret; } } rest-api-sdk-php/lib/PayPal/Api/BillingInfo.php 0000644 00000012232 15007532371 0015211 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class BillingInfo * * Billing information for the invoice recipient. * * @package PayPal\Api * * @property string email * @property string first_name * @property string last_name * @property string business_name * @property \PayPal\Api\InvoiceAddress address * @property string language * @property string additional_info * @property string notification_channel * @property \PayPal\Api\Phone phone */ class BillingInfo extends PayPalModel { /** * Email address of the invoice recipient. 260 characters max. * * @param string $email * * @return $this */ 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; } /** * First name of the invoice recipient. 30 characters max. * * @param string $first_name * * @return $this */ 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; } /** * Last name of the invoice recipient. 30 characters max. * * @param string $last_name * * @return $this */ public function setLastName($last_name) { $this->last_name = $last_name; return $this; } /** * 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 * * @return $this */ public function setBusinessName($business_name) { $this->business_name = $business_name; 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. * * @param \PayPal\Api\InvoiceAddress $address * * @return $this */ public function setAddress($address) { $this->address = $address; return $this; } /** * Address of the invoice recipient. * * @return \PayPal\Api\InvoiceAddress */ 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. * Valid Values: ["da_DK", "de_DE", "en_AU", "en_GB", "en_US", "es_ES", "es_XC", "fr_CA", "fr_FR", "fr_XC", "he_IL", "id_ID", "it_IT", "ja_JP", "nl_NL", "no_NO", "pl_PL", "pt_BR", "pt_PT", "ru_RU", "sv_SE", "th_TH", "tr_TR", "zh_CN", "zh_HK", "zh_TW", "zh_XC"] * * @param string $language * * @return $this */ 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; } /** * Option to display additional information such as business hours. 40 characters max. * * @param string $additional_info * * @return $this */ 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; } /** * Preferred notification channel of the payer. Email by default. * Valid Values: ["SMS", "EMAIL"] * * @param string $notification_channel * * @return $this */ public function setNotificationChannel($notification_channel) { $this->notification_channel = $notification_channel; return $this; } /** * Preferred notification channel of the payer. Email by default. * * @return string */ public function getNotificationChannel() { return $this->notification_channel; } /** * Mobile Phone number of the recipient to which SMS will be sent if notification_channel is SMS. * * @param \PayPal\Api\Phone $phone * * @return $this */ public function setPhone($phone) { $this->phone = $phone; return $this; } /** * Mobile Phone number of the recipient to which SMS will be sent if notification_channel is SMS. * * @return \PayPal\Api\Phone */ public function getPhone() { return $this->phone; } } rest-api-sdk-php/lib/PayPal/Api/FmfDetails.php 0000644 00000004541 15007532371 0015037 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class FmfDetails * * Details of Fraud Management Filter (FMF). * * @package PayPal\Api * * @property string filter_type * @property string filter_id * @property string name * @property string description */ class FmfDetails extends PayPalModel { /** * Type of filter. * Valid Values: ["ACCEPT", "PENDING", "DENY", "REPORT"] * * @param string $filter_type * * @return $this */ public function setFilterType($filter_type) { $this->filter_type = $filter_type; return $this; } /** * Type of filter. * * @return string */ public function getFilterType() { return $this->filter_type; } /** * Filter Identifier. * Valid Values: ["AVS_NO_MATCH", "AVS_PARTIAL_MATCH", "AVS_UNAVAILABLE_OR_UNSUPPORTED", "CARD_SECURITY_CODE_MISMATCH", "MAXIMUM_TRANSACTION_AMOUNT", "UNCONFIRMED_ADDRESS", "COUNTRY_MONITOR", "LARGE_ORDER_NUMBER", "BILLING_OR_SHIPPING_ADDRESS_MISMATCH", "RISKY_ZIP_CODE", "SUSPECTED_FREIGHT_FORWARDER_CHECK", "TOTAL_PURCHASE_PRICE_MINIMUM", "IP_ADDRESS_VELOCITY", "RISKY_EMAIL_ADDRESS_DOMAIN_CHECK", "RISKY_BANK_IDENTIFICATION_NUMBER_CHECK", "RISKY_IP_ADDRESS_RANGE", "PAYPAL_FRAUD_MODEL"] * * @param string $filter_id * * @return $this */ public function setFilterId($filter_id) { $this->filter_id = $filter_id; return $this; } /** * Filter Identifier. * * @return string */ public function getFilterId() { return $this->filter_id; } /** * Name of the filter * * @param string $name * * @return $this */ public function setName($name) { $this->name = $name; return $this; } /** * Name of the filter * * @return string */ public function getName() { return $this->name; } /** * Description of the filter. * * @param string $description * * @return $this */ public function setDescription($description) { $this->description = $description; return $this; } /** * Description of the filter. * * @return string */ public function getDescription() { return $this->description; } } rest-api-sdk-php/lib/PayPal/Api/NameValuePair.php 0000644 00000002241 15007532371 0015505 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class NameValuePair * * Used to define a type for name-value pairs. The use of name value pairs in an API should be limited and approved by architecture. * * @package PayPal\Api * * @property string name * @property string value */ class NameValuePair extends PayPalModel { /** * Key for the name value pair. The value name types should be correlated * * @param string $name * * @return $this */ public function setName($name) { $this->name = $name; return $this; } /** * Key for the name value pair. The value name types should be correlated * * @return string */ public function getName() { return $this->name; } /** * Value for the name value pair. * * @param string $value * * @return $this */ public function setValue($value) { $this->value = $value; return $this; } /** * Value for the name value pair. * * @return string */ public function getValue() { return $this->value; } } rest-api-sdk-php/lib/PayPal/Api/Authorization.php 0000644 00000035302 15007532371 0015660 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalResourceModel; use PayPal\Rest\ApiContext; use PayPal\Validation\ArgumentValidator; /** * Class Authorization * * An authorization transaction. * * @package PayPal\Api * * @property string id * @property \PayPal\Api\Amount amount * @property string payment_mode * @property string state * @property string reason_code * @property string pending_reason * @property string protection_eligibility * @property string protection_eligibility_type * @property \PayPal\Api\FmfDetails fmf_details * @property string parent_payment * @property \PayPal\Api\ProcessorResponse processor_response * @property string valid_until * @property string create_time * @property string update_time * @property \PayPal\Api\Links[] links */ class Authorization extends PayPalResourceModel { /** * ID of the authorization transaction. * * @param string $id * * @return $this */ public function setId($id) { $this->id = $id; return $this; } /** * ID of the authorization transaction. * * @return string */ public function getId() { return $this->id; } /** * Amount being authorized. * * @param \PayPal\Api\Amount $amount * * @return $this */ public function setAmount($amount) { $this->amount = $amount; return $this; } /** * Amount being authorized. * * @return \PayPal\Api\Amount */ public function getAmount() { return $this->amount; } /** * Specifies the payment mode of the transaction. * Valid Values: ["INSTANT_TRANSFER"] * * @param string $payment_mode * * @return $this */ public function setPaymentMode($payment_mode) { $this->payment_mode = $payment_mode; return $this; } /** * Specifies the payment mode of the transaction. * * @return string */ public function getPaymentMode() { return $this->payment_mode; } /** * State of the authorization. * Valid Values: ["pending", "authorized", "partially_captured", "captured", "expired", "voided"] * * @param string $state * * @return $this */ public function setState($state) { $this->state = $state; return $this; } /** * State of the authorization. * * @return string */ public function getState() { return $this->state; } /** * Reason code, `AUTHORIZATION`, for a transaction state of `pending`. * Valid Values: ["AUTHORIZATION"] * * @param string $reason_code * * @return $this */ public function setReasonCode($reason_code) { $this->reason_code = $reason_code; return $this; } /** * Reason code, `AUTHORIZATION`, for a transaction state of `pending`. * * @return string */ public function getReasonCode() { return $this->reason_code; } /** * [DEPRECATED] Reason code for the transaction state being Pending.Obsolete. use reason_code field instead. * Valid Values: ["AUTHORIZATION"] * * @param string $pending_reason * * @return $this */ public function setPendingReason($pending_reason) { $this->pending_reason = $pending_reason; return $this; } /** * @deprecated [DEPRECATED] Reason code for the transaction state being Pending.Obsolete. use reason_code field instead. * * @return string */ public function getPendingReason() { return $this->pending_reason; } /** * The level of seller protection in force for the transaction. Only supported when the `payment_method` is set to `paypal`. Allowed values:<br> `ELIGIBLE`- Merchant is protected by PayPal's Seller Protection Policy for Unauthorized Payments and Item Not Received.<br> `PARTIALLY_ELIGIBLE`- Merchant is protected by PayPal's Seller Protection Policy for Item Not Received or Unauthorized Payments. Refer to `protection_eligibility_type` for specifics. <br> `INELIGIBLE`- Merchant is not protected under the Seller Protection Policy. * Valid Values: ["ELIGIBLE", "PARTIALLY_ELIGIBLE", "INELIGIBLE"] * * @param string $protection_eligibility * * @return $this */ public function setProtectionEligibility($protection_eligibility) { $this->protection_eligibility = $protection_eligibility; return $this; } /** * The level of seller protection in force for the transaction. Only supported when the `payment_method` is set to `paypal`. Allowed values:<br> `ELIGIBLE`- Merchant is protected by PayPal's Seller Protection Policy for Unauthorized Payments and Item Not Received.<br> `PARTIALLY_ELIGIBLE`- Merchant is protected by PayPal's Seller Protection Policy for Item Not Received or Unauthorized Payments. Refer to `protection_eligibility_type` for specifics. <br> `INELIGIBLE`- Merchant is not protected under the Seller Protection Policy. * * @return string */ public function getProtectionEligibility() { return $this->protection_eligibility; } /** * The kind of seller protection in force for the transaction. This property is returned only when the `protection_eligibility` property is set to `ELIGIBLE`or `PARTIALLY_ELIGIBLE`. Only supported when the `payment_method` is set to `paypal`. Allowed values:<br> `ITEM_NOT_RECEIVED_ELIGIBLE`- Sellers are protected against claims for items not received.<br> `UNAUTHORIZED_PAYMENT_ELIGIBLE`- Sellers are protected against claims for unauthorized payments.<br> One or both of the allowed values can be returned. * Valid Values: ["ITEM_NOT_RECEIVED_ELIGIBLE", "UNAUTHORIZED_PAYMENT_ELIGIBLE", "ITEM_NOT_RECEIVED_ELIGIBLE,UNAUTHORIZED_PAYMENT_ELIGIBLE"] * * @param string $protection_eligibility_type * * @return $this */ public function setProtectionEligibilityType($protection_eligibility_type) { $this->protection_eligibility_type = $protection_eligibility_type; return $this; } /** * The kind of seller protection in force for the transaction. This property is returned only when the `protection_eligibility` property is set to `ELIGIBLE`or `PARTIALLY_ELIGIBLE`. Only supported when the `payment_method` is set to `paypal`. Allowed values:<br> `ITEM_NOT_RECEIVED_ELIGIBLE`- Sellers are protected against claims for items not received.<br> `UNAUTHORIZED_PAYMENT_ELIGIBLE`- Sellers are protected against claims for unauthorized payments.<br> One or both of the allowed values can be returned. * * @return string */ public function getProtectionEligibilityType() { return $this->protection_eligibility_type; } /** * Fraud Management Filter (FMF) details applied for the payment that could result in accept, deny, or pending action. Returned in a payment response only if the merchant has enabled FMF in the profile settings and one of the fraud filters was triggered based on those settings. See [Fraud Management Filters Summary](https://developer.paypal.com/docs/classic/fmf/integration-guide/FMFSummary/) for more information. * * @param \PayPal\Api\FmfDetails $fmf_details * * @return $this */ public function setFmfDetails($fmf_details) { $this->fmf_details = $fmf_details; return $this; } /** * Fraud Management Filter (FMF) details applied for the payment that could result in accept, deny, or pending action. Returned in a payment response only if the merchant has enabled FMF in the profile settings and one of the fraud filters was triggered based on those settings. See [Fraud Management Filters Summary](https://developer.paypal.com/docs/classic/fmf/integration-guide/FMFSummary/) for more information. * * @return \PayPal\Api\FmfDetails */ public function getFmfDetails() { return $this->fmf_details; } /** * ID of the Payment resource that this transaction is based on. * * @param string $parent_payment * * @return $this */ public function setParentPayment($parent_payment) { $this->parent_payment = $parent_payment; return $this; } /** * ID of the Payment resource that this transaction is based on. * * @return string */ public function getParentPayment() { return $this->parent_payment; } /** * Response codes returned by the processor concerning the submitted payment. Only supported when the `payment_method` is set to `credit_card`. * * @param \PayPal\Api\ProcessorResponse $processor_response * * @return $this */ public function setProcessorResponse($processor_response) { $this->processor_response = $processor_response; return $this; } /** * Response codes returned by the processor concerning the submitted payment. Only supported when the `payment_method` is set to `credit_card`. * * @return \PayPal\Api\ProcessorResponse */ public function getProcessorResponse() { return $this->processor_response; } /** * Authorization expiration time and date as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6). * * @param string $valid_until * * @return $this */ public function setValidUntil($valid_until) { $this->valid_until = $valid_until; return $this; } /** * Authorization expiration time and date as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6). * * @return string */ public function getValidUntil() { return $this->valid_until; } /** * Time of authorization as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6). * * @param string $create_time * * @return $this */ public function setCreateTime($create_time) { $this->create_time = $create_time; return $this; } /** * Time of authorization as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6). * * @return string */ public function getCreateTime() { return $this->create_time; } /** * Time that the resource was last updated. * * @param string $update_time * * @return $this */ public function setUpdateTime($update_time) { $this->update_time = $update_time; return $this; } /** * Time that the resource was last updated. * * @return string */ public function getUpdateTime() { return $this->update_time; } /** * Retrieve details about a previously created authorization by passing the authorization_id in the request URI. * * @param string $authorizationId * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return Authorization */ public static function get($authorizationId, $apiContext = null, $restCall = null) { ArgumentValidator::validate($authorizationId, 'authorizationId'); $payLoad = ""; $json = self::executeCall( "/v1/payments/authorization/$authorizationId", "GET", $payLoad, null, $apiContext, $restCall ); $ret = new Authorization(); $ret->fromJson($json); return $ret; } /** * Capture and process a previously created authorization by passing the authorization_id in the request URI. To use this request, the original payment call must have the intent set to authorize. * * @param Capture $capture * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return Capture */ public function capture($capture, $apiContext = null, $restCall = null) { ArgumentValidator::validate($this->getId(), "Id"); ArgumentValidator::validate($capture, 'capture'); $payLoad = $capture->toJSON(); $json = self::executeCall( "/v1/payments/authorization/{$this->getId()}/capture", "POST", $payLoad, null, $apiContext, $restCall ); $ret = new Capture(); $ret->fromJson($json); return $ret; } /** * Void (cancel) a previously authorized payment by passing the authorization_id in the request URI. Note that a fully captured authorization cannot be voided. * * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return Authorization */ public function void($apiContext = null, $restCall = null) { ArgumentValidator::validate($this->getId(), "Id"); $payLoad = ""; $json = self::executeCall( "/v1/payments/authorization/{$this->getId()}/void", "POST", $payLoad, null, $apiContext, $restCall ); $this->fromJson($json); return $this; } /** * Reauthorize a PayPal account payment by passing the authorization_id in the request URI. You should reauthorize a payment after the initial 3-day honor period to ensure that funds are still available. Request supports only amount field * * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return Authorization */ public function reauthorize($apiContext = null, $restCall = null) { ArgumentValidator::validate($this->getId(), "Id"); $payLoad = $this->toJSON(); $json = self::executeCall( "/v1/payments/authorization/{$this->getId()}/reauthorize", "POST", $payLoad, null, $apiContext, $restCall ); $this->fromJson($json); return $this; } } rest-api-sdk-php/lib/PayPal/Api/Currency.php 0000644 00000002703 15007532371 0014611 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; use PayPal\Converter\FormatConverter; use PayPal\Validation\NumericValidator; /** * Class Currency * * Base object for all financial value related fields (balance, payment due, etc.) * * @package PayPal\Api * * @property string currency * @property string value */ class Currency extends PayPalModel { /** * 3 letter currency code as defined by ISO 4217. * * @param string $currency * * @return $this */ public function setCurrency($currency) { $this->currency = $currency; return $this; } /** * 3 letter currency code as defined by ISO 4217. * * @return string */ public function getCurrency() { return $this->currency; } /** * amount up to N digit after the decimals separator as defined in ISO 4217 for the appropriate currency code. * * @param string|double $value * * @return $this */ public function setValue($value) { NumericValidator::validate($value, "Value"); $value = FormatConverter::formatToPrice($value, $this->getCurrency()); $this->value = $value; return $this; } /** * amount up to N digit after the decimals separator as defined in ISO 4217 for the appropriate currency code. * * @return string */ public function getValue() { return $this->value; } } rest-api-sdk-php/lib/PayPal/Api/AgreementTransactions.php 0000644 00000003617 15007532371 0017324 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class AgreementTransactions * * A resource representing agreement_transactions that is returned during a transaction search. * * @package PayPal\Api * * @property \PayPal\Api\AgreementTransaction[] agreement_transaction_list */ class AgreementTransactions extends PayPalModel { /** * Array of agreement_transaction object. * * @param \PayPal\Api\AgreementTransaction[] $agreement_transaction_list * * @return $this */ public function setAgreementTransactionList($agreement_transaction_list) { $this->agreement_transaction_list = $agreement_transaction_list; return $this; } /** * Array of agreement_transaction object. * * @return \PayPal\Api\AgreementTransaction[] */ public function getAgreementTransactionList() { return $this->agreement_transaction_list; } /** * Append AgreementTransactionList to the list. * * @param \PayPal\Api\AgreementTransaction $agreementTransaction * @return $this */ public function addAgreementTransactionList($agreementTransaction) { if (!$this->getAgreementTransactionList()) { return $this->setAgreementTransactionList(array($agreementTransaction)); } else { return $this->setAgreementTransactionList( array_merge($this->getAgreementTransactionList(), array($agreementTransaction)) ); } } /** * Remove AgreementTransactionList from the list. * * @param \PayPal\Api\AgreementTransaction $agreementTransaction * @return $this */ public function removeAgreementTransactionList($agreementTransaction) { return $this->setAgreementTransactionList( array_diff($this->getAgreementTransactionList(), array($agreementTransaction)) ); } } rest-api-sdk-php/lib/PayPal/Api/PaymentCard.php 0000644 00000022334 15007532371 0015230 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class PaymentCard * * A resource representing a payment card that can be used to fund a payment. * * @package PayPal\Api * * @property string id * @property string number * @property string type * @property string expire_month * @property string expire_year * @property string start_month * @property string start_year * @property string cvv2 * @property string first_name * @property string last_name * @property string billing_country * @property \PayPal\Api\Address billing_address * @property string external_customer_id * @property string status * @property string valid_until * @property string issue_number * @property \PayPal\Api\Links[] links */ class PaymentCard extends PayPalModel { /** * ID of the credit card being saved for later use. * * @param string $id * * @return $this */ public function setId($id) { $this->id = $id; return $this; } /** * ID of the credit card being saved for later use. * * @return string */ public function getId() { return $this->id; } /** * Card number. * * @param string $number * * @return $this */ public function setNumber($number) { $this->number = $number; return $this; } /** * Card number. * * @return string */ public function getNumber() { return $this->number; } /** * Type of the Card. * Valid Values: ["VISA", "AMEX", "SOLO", "JCB", "STAR", "DELTA", "DISCOVER", "SWITCH", "MAESTRO", "CB_NATIONALE", "CONFINOGA", "COFIDIS", "ELECTRON", "CETELEM", "CHINA_UNION_PAY", "MASTERCARD"] * * @param string $type * * @return $this */ public function setType($type) { $this->type = $type; return $this; } /** * Type of the Card. * * @return string */ public function getType() { return $this->type; } /** * 2 digit card expiry month. * * @param string $expire_month * * @return $this */ public function setExpireMonth($expire_month) { $this->expire_month = $expire_month; return $this; } /** * 2 digit card expiry month. * * @return string */ public function getExpireMonth() { return $this->expire_month; } /** * 4 digit card expiry year * * @param string $expire_year * * @return $this */ public function setExpireYear($expire_year) { $this->expire_year = $expire_year; return $this; } /** * 4 digit card expiry year * * @return string */ public function getExpireYear() { return $this->expire_year; } /** * 2 digit card start month. Needed for UK Maestro Card. * * @param string $start_month * * @return $this */ public function setStartMonth($start_month) { $this->start_month = $start_month; return $this; } /** * 2 digit card start month. Needed for UK Maestro Card. * * @return string */ public function getStartMonth() { return $this->start_month; } /** * 4 digit card start year. Needed for UK Maestro Card. * * @param string $start_year * * @return $this */ public function setStartYear($start_year) { $this->start_year = $start_year; return $this; } /** * 4 digit card start year. Needed for UK Maestro Card. * * @return string */ public function getStartYear() { return $this->start_year; } /** * Card validation code. Only supported when making a Payment but not when saving a payment card for future use. * * @param string $cvv2 * * @return $this */ public function setCvv2($cvv2) { $this->cvv2 = $cvv2; return $this; } /** * Card validation code. Only supported when making a Payment but not when saving a payment card for future use. * * @return string */ public function getCvv2() { return $this->cvv2; } /** * Card holder's first name. * * @param string $first_name * * @return $this */ public function setFirstName($first_name) { $this->first_name = $first_name; return $this; } /** * Card holder's first name. * * @return string */ public function getFirstName() { return $this->first_name; } /** * Card holder's last name. * * @param string $last_name * * @return $this */ public function setLastName($last_name) { $this->last_name = $last_name; return $this; } /** * Card holder's last name. * * @return string */ public function getLastName() { return $this->last_name; } /** * 2 letter country code * * @param string $billing_country * * @return $this */ public function setBillingCountry($billing_country) { $this->billing_country = $billing_country; return $this; } /** * 2 letter country code * * @return string */ public function getBillingCountry() { return $this->billing_country; } /** * Billing Address associated with this card. * * @param \PayPal\Api\Address $billing_address * * @return $this */ public function setBillingAddress($billing_address) { $this->billing_address = $billing_address; return $this; } /** * Billing Address associated with this card. * * @return \PayPal\Api\Address */ public function getBillingAddress() { return $this->billing_address; } /** * A unique identifier of the customer to whom this card account belongs to. Generated and provided by the facilitator. This is required when creating or using a stored funding instrument in vault. * * @param string $external_customer_id * * @return $this */ public function setExternalCustomerId($external_customer_id) { $this->external_customer_id = $external_customer_id; return $this; } /** * A unique identifier of the customer to whom this card account belongs to. Generated and provided by the facilitator. This is required when creating or using a stored funding instrument in vault. * * @return string */ public function getExternalCustomerId() { return $this->external_customer_id; } /** * State of the funding instrument. * Valid Values: ["EXPIRED", "ACTIVE"] * * @param string $status * * @return $this */ public function setStatus($status) { $this->status = $status; return $this; } /** * State of the funding instrument. * * @return string */ public function getStatus() { return $this->status; } /** * Date/Time until this resource can be used fund a payment. * * @param string $valid_until * * @return $this */ public function setValidUntil($valid_until) { $this->valid_until = $valid_until; return $this; } /** * Date/Time until this resource can be used fund a payment. * * @return string */ public function getValidUntil() { return $this->valid_until; } /** * 1-2 digit card issue number. Needed for UK Maestro Card. * * @param string $issue_number * * @return $this */ public function setIssueNumber($issue_number) { $this->issue_number = $issue_number; return $this; } /** * 1-2 digit card issue number. Needed for UK Maestro Card. * * @return string */ public function getIssueNumber() { return $this->issue_number; } /** * Sets Links * * @param \PayPal\Api\Links[] $links * * @return $this */ public function setLinks($links) { $this->links = $links; return $this; } /** * Gets Links * * @return \PayPal\Api\Links[] */ public function getLinks() { return $this->links; } /** * Append Links to the list. * * @param \PayPal\Api\Links $links * @return $this */ public function addLink($links) { if (!$this->getLinks()) { return $this->setLinks(array($links)); } else { return $this->setLinks( array_merge($this->getLinks(), array($links)) ); } } /** * Remove Links from the list. * * @param \PayPal\Api\Links $links * @return $this */ public function removeLink($links) { return $this->setLinks( array_diff($this->getLinks(), array($links)) ); } } rest-api-sdk-php/lib/PayPal/Api/CreditCardList.php 0000644 00000005105 15007532371 0015656 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalResourceModel; /** * Class CreditCardList * * A list of Credit Card Resources * * @package PayPal\Api * * @property \PayPal\Api\CreditCard[] items * @property \PayPal\Api\Links[] links * @property int total_items * @property int total_pages */ class CreditCardList extends PayPalResourceModel { /** * A list of credit card resources * * @param \PayPal\Api\CreditCard[] $items * * @return $this */ public function setItems($items) { $this->items = $items; return $this; } /** * A list of credit card resources * * @return \PayPal\Api\CreditCard[] */ public function getItems() { return $this->items; } /** * Append Items to the list. * * @param \PayPal\Api\CreditCard $creditCard * @return $this */ public function addItem($creditCard) { if (!$this->getItems()) { return $this->setItems(array($creditCard)); } else { return $this->setItems( array_merge($this->getItems(), array($creditCard)) ); } } /** * Remove Items from the list. * * @param \PayPal\Api\CreditCard $creditCard * @return $this */ public function removeItem($creditCard) { return $this->setItems( array_diff($this->getItems(), array($creditCard)) ); } /** * Total number of items present in the given list. Note that the number of items might be larger than the records in the current page. * * @param int $total_items * * @return $this */ public function setTotalItems($total_items) { $this->total_items = $total_items; return $this; } /** * Total number of items present in the given list. Note that the number of items might be larger than the records in the current page. * * @return int */ public function getTotalItems() { return $this->total_items; } /** * Total number of pages that exist, for the total number of items, with the given page size. * * @param int $total_pages * * @return $this */ public function setTotalPages($total_pages) { $this->total_pages = $total_pages; return $this; } /** * Total number of pages that exist, for the total number of items, with the given page size. * * @return int */ public function getTotalPages() { return $this->total_pages; } } rest-api-sdk-php/lib/PayPal/Api/CustomAmount.php 0000644 00000002217 15007532371 0015455 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class CustomAmount * * Custom amount applied on an invoice. If a label is included then the amount cannot be empty. * * @package PayPal\Api * * @property string label * @property \PayPal\Api\Currency amount */ class CustomAmount extends PayPalModel { /** * Custom amount label. 25 characters max. * * @param string $label * * @return $this */ 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 value. Range of 0 to 999999.99. * * @param \PayPal\Api\Currency $amount * * @return $this */ 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; } } rest-api-sdk-php/lib/PayPal/Api/InputFields.php 0000644 00000006362 15007532371 0015252 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class InputFields * * Parameters for input fields customization. * * @package PayPal\Api * * @property bool allow_note * @property int no_shipping * @property int address_override */ class InputFields extends PayPalModel { /** * Enables the buyer to enter a note to the merchant on the PayPal page during checkout. * * * @param bool $allow_note * * @return $this */ public function setAllowNote($allow_note) { $this->allow_note = $allow_note; return $this; } /** * Enables the buyer to enter a note to the merchant on the PayPal page during checkout. * * @return bool */ public function getAllowNote() { return $this->allow_note; } /** * Determines whether or not PayPal displays shipping address fields on the experience pages. Allowed values: `0`, `1`, or `2`. When set to `0`, PayPal displays the shipping address on the PayPal pages. When set to `1`, PayPal does not display shipping address fields whatsoever. When set to `2`, if you do not pass the shipping address, PayPal obtains it from the buyer's account profile. For digital goods, this field is required, and you must set it to `1`. * * * @param int $no_shipping * * @return $this */ public function setNoShipping($no_shipping) { $this->no_shipping = $no_shipping; return $this; } /** * Determines whether or not PayPal displays shipping address fields on the experience pages. Allowed values: `0`, `1`, or `2`. When set to `0`, PayPal displays the shipping address on the PayPal pages. When set to `1`, PayPal does not display shipping address fields whatsoever. When set to `2`, if you do not pass the shipping address, PayPal obtains it from the buyer's account profile. For digital goods, this field is required, and you must set it to `1`. * * @return int */ public function getNoShipping() { return $this->no_shipping; } /** * Determines whether or not the PayPal pages should display the shipping address and not the shipping address on file with PayPal for this buyer. Displaying the PayPal street address on file does not allow the buyer to edit that address. Allowed values: `0` or `1`. When set to `0`, the PayPal pages should not display the shipping address. When set to `1`, the PayPal pages should display the shipping address. * * * @param int $address_override * * @return $this */ public function setAddressOverride($address_override) { $this->address_override = $address_override; return $this; } /** * Determines whether or not the PayPal pages should display the shipping address and not the shipping address on file with PayPal for this buyer. Displaying the PayPal street address on file does not allow the buyer to edit that address. Allowed values: `0` or `1`. When set to `0`, the PayPal pages should not display the shipping address. When set to `1`, the PayPal pages should display the shipping address. * * @return int */ public function getAddressOverride() { return $this->address_override; } } rest-api-sdk-php/lib/PayPal/Api/Terms.php 0000644 00000006102 15007532371 0014106 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class Terms * * Resource representing terms used by the plan. * * @package PayPal\Api * * @property string id * @property string type * @property \PayPal\Api\Currency max_billing_amount * @property string occurrences * @property \PayPal\Api\Currency amount_range * @property string buyer_editable */ class Terms extends PayPalModel { /** * Identifier of the terms. 128 characters max. * * @param string $id * * @return $this */ public function setId($id) { $this->id = $id; return $this; } /** * Identifier of the terms. 128 characters max. * * @return string */ public function getId() { return $this->id; } /** * Term type. Allowed values: `MONTHLY`, `WEEKLY`, `YEARLY`. * * @param string $type * * @return $this */ public function setType($type) { $this->type = $type; return $this; } /** * Term type. Allowed values: `MONTHLY`, `WEEKLY`, `YEARLY`. * * @return string */ public function getType() { return $this->type; } /** * Max Amount associated with this term. * * @param \PayPal\Api\Currency $max_billing_amount * * @return $this */ public function setMaxBillingAmount($max_billing_amount) { $this->max_billing_amount = $max_billing_amount; return $this; } /** * Max Amount associated with this term. * * @return \PayPal\Api\Currency */ public function getMaxBillingAmount() { return $this->max_billing_amount; } /** * How many times money can be pulled during this term. * * @param string $occurrences * * @return $this */ public function setOccurrences($occurrences) { $this->occurrences = $occurrences; return $this; } /** * How many times money can be pulled during this term. * * @return string */ public function getOccurrences() { return $this->occurrences; } /** * Amount_range associated with this term. * * @param \PayPal\Api\Currency $amount_range * * @return $this */ public function setAmountRange($amount_range) { $this->amount_range = $amount_range; return $this; } /** * Amount_range associated with this term. * * @return \PayPal\Api\Currency */ public function getAmountRange() { return $this->amount_range; } /** * Buyer's ability to edit the amount in this term. * * @param string $buyer_editable * * @return $this */ public function setBuyerEditable($buyer_editable) { $this->buyer_editable = $buyer_editable; return $this; } /** * Buyer's ability to edit the amount in this term. * * @return string */ public function getBuyerEditable() { return $this->buyer_editable; } } rest-api-sdk-php/lib/PayPal/Api/Sale.php 0000644 00000042452 15007532371 0013710 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalResourceModel; use PayPal\Rest\ApiContext; use PayPal\Validation\ArgumentValidator; /** * Class Sale * * A sale transaction. * * @package PayPal\Api * * @property string id * @property string purchase_unit_reference_id * @property \PayPal\Api\Amount amount * @property string payment_mode * @property string state * @property string reason_code * @property string protection_eligibility * @property string protection_eligibility_type * @property string clearing_time * @property string payment_hold_status * @property string[] payment_hold_reasons * @property \PayPal\Api\Currency transaction_fee * @property \PayPal\Api\Currency receivable_amount * @property string exchange_rate * @property \PayPal\Api\FmfDetails fmf_details * @property string receipt_id * @property string parent_payment * @property \PayPal\Api\ProcessorResponse processor_response * @property string billing_agreement_id * @property string create_time * @property string update_time * @property \PayPal\Api\Links[] links */ class Sale extends PayPalResourceModel { /** * ID of the sale transaction. * * @param string $id * * @return $this */ public function setId($id) { $this->id = $id; return $this; } /** * ID of the sale transaction. * * @return string */ public function getId() { return $this->id; } /** * Identifier of the purchased unit associated with this object. * * @param string $purchase_unit_reference_id * * @return $this */ public function setPurchaseUnitReferenceId($purchase_unit_reference_id) { $this->purchase_unit_reference_id = $purchase_unit_reference_id; return $this; } /** * Identifier of the purchased unit associated with this object. * * @return string */ public function getPurchaseUnitReferenceId() { return $this->purchase_unit_reference_id; } /** * Amount being collected. * * @param \PayPal\Api\Amount $amount * * @return $this */ public function setAmount($amount) { $this->amount = $amount; return $this; } /** * Amount being collected. * * @return \PayPal\Api\Amount */ public function getAmount() { return $this->amount; } /** * Specifies payment mode of the transaction. Only supported when the `payment_method` is set to `paypal`. * Valid Values: ["INSTANT_TRANSFER", "MANUAL_BANK_TRANSFER", "DELAYED_TRANSFER", "ECHECK"] * * @param string $payment_mode * * @return $this */ public function setPaymentMode($payment_mode) { $this->payment_mode = $payment_mode; return $this; } /** * Specifies payment mode of the transaction. Only supported when the `payment_method` is set to `paypal`. * * @return string */ public function getPaymentMode() { return $this->payment_mode; } /** * State of the sale. * Valid Values: ["completed", "partially_refunded", "pending", "refunded"] * * @param string $state * * @return $this */ public function setState($state) { $this->state = $state; return $this; } /** * State of the sale. * * @return string */ public function getState() { return $this->state; } /** * Reason code for the transaction state being Pending or Reversed. Only supported when the `payment_method` is set to `paypal`. * Valid Values: ["CHARGEBACK", "GUARANTEE", "BUYER_COMPLAINT", "REFUND", "UNCONFIRMED_SHIPPING_ADDRESS", "ECHECK", "INTERNATIONAL_WITHDRAWAL", "RECEIVING_PREFERENCE_MANDATES_MANUAL_ACTION", "PAYMENT_REVIEW", "REGULATORY_REVIEW", "UNILATERAL", "VERIFICATION_REQUIRED"] * * @param string $reason_code * * @return $this */ public function setReasonCode($reason_code) { $this->reason_code = $reason_code; return $this; } /** * Reason code for the transaction state being Pending or Reversed. Only supported when the `payment_method` is set to `paypal`. * * @return string */ public function getReasonCode() { return $this->reason_code; } /** * The level of seller protection in force for the transaction. Only supported when the `payment_method` is set to `paypal`. * Valid Values: ["ELIGIBLE", "PARTIALLY_ELIGIBLE", "INELIGIBLE"] * * @param string $protection_eligibility * * @return $this */ public function setProtectionEligibility($protection_eligibility) { $this->protection_eligibility = $protection_eligibility; return $this; } /** * The level of seller protection in force for the transaction. Only supported when the `payment_method` is set to `paypal`. * * @return string */ public function getProtectionEligibility() { return $this->protection_eligibility; } /** * The kind of seller protection in force for the transaction. It is returned only when protection_eligibility is ELIGIBLE or PARTIALLY_ELIGIBLE. Only supported when the `payment_method` is set to `paypal`. * Valid Values: ["ITEM_NOT_RECEIVED_ELIGIBLE", "UNAUTHORIZED_PAYMENT_ELIGIBLE", "ITEM_NOT_RECEIVED_ELIGIBLE,UNAUTHORIZED_PAYMENT_ELIGIBLE"] * * @param string $protection_eligibility_type * * @return $this */ public function setProtectionEligibilityType($protection_eligibility_type) { $this->protection_eligibility_type = $protection_eligibility_type; return $this; } /** * The kind of seller protection in force for the transaction. It is returned only when protection_eligibility is ELIGIBLE or PARTIALLY_ELIGIBLE. Only supported when the `payment_method` is set to `paypal`. * * @return string */ public function getProtectionEligibilityType() { return $this->protection_eligibility_type; } /** * Expected clearing time for eCheck transactions. Only supported when the `payment_method` is set to `paypal`. * * @param string $clearing_time * * @return $this */ public function setClearingTime($clearing_time) { $this->clearing_time = $clearing_time; return $this; } /** * Expected clearing time for eCheck transactions. Only supported when the `payment_method` is set to `paypal`. * * @return string */ public function getClearingTime() { return $this->clearing_time; } /** * Status of the Recipient Fund. For now, it will be returned only when fund status is held * Valid Values: ["HELD"] * * @param string $payment_hold_status * * @return $this */ public function setPaymentHoldStatus($payment_hold_status) { $this->payment_hold_status = $payment_hold_status; return $this; } /** * Status of the Recipient Fund. For now, it will be returned only when fund status is held * * @return string */ public function getPaymentHoldStatus() { return $this->payment_hold_status; } /** * Reasons for PayPal holding recipient fund. It is set only if payment hold status is held * * @param string[] $payment_hold_reasons * * @return $this */ public function setPaymentHoldReasons($payment_hold_reasons) { $this->payment_hold_reasons = $payment_hold_reasons; return $this; } /** * Reasons for PayPal holding recipient fund. It is set only if payment hold status is held * * @return string[] */ public function getPaymentHoldReasons() { return $this->payment_hold_reasons; } /** * Append PaymentHoldReasons to the list. * * @param string $string * @return $this */ public function addPaymentHoldReason($string) { if (!$this->getPaymentHoldReasons()) { return $this->setPaymentHoldReasons(array($string)); } else { return $this->setPaymentHoldReasons( array_merge($this->getPaymentHoldReasons(), array($string)) ); } } /** * Remove PaymentHoldReasons from the list. * * @param string $string * @return $this */ public function removePaymentHoldReason($string) { return $this->setPaymentHoldReasons( array_diff($this->getPaymentHoldReasons(), array($string)) ); } /** * Transaction fee charged by PayPal for this transaction. * * @param \PayPal\Api\Currency $transaction_fee * * @return $this */ public function setTransactionFee($transaction_fee) { $this->transaction_fee = $transaction_fee; return $this; } /** * Transaction fee charged by PayPal for this transaction. * * @return \PayPal\Api\Currency */ public function getTransactionFee() { return $this->transaction_fee; } /** * Net amount the merchant receives for this transaction in their receivable currency. Returned only in cross-currency use cases where a merchant bills a buyer in a non-primary currency for that buyer. * * @param \PayPal\Api\Currency $receivable_amount * * @return $this */ public function setReceivableAmount($receivable_amount) { $this->receivable_amount = $receivable_amount; return $this; } /** * Net amount the merchant receives for this transaction in their receivable currency. Returned only in cross-currency use cases where a merchant bills a buyer in a non-primary currency for that buyer. * * @return \PayPal\Api\Currency */ public function getReceivableAmount() { return $this->receivable_amount; } /** * Exchange rate applied for this transaction. Returned only in cross-currency use cases where a merchant bills a buyer in a non-primary currency for that buyer. * * @param string $exchange_rate * * @return $this */ public function setExchangeRate($exchange_rate) { $this->exchange_rate = $exchange_rate; return $this; } /** * Exchange rate applied for this transaction. Returned only in cross-currency use cases where a merchant bills a buyer in a non-primary currency for that buyer. * * @return string */ public function getExchangeRate() { return $this->exchange_rate; } /** * Fraud Management Filter (FMF) details applied for the payment that could result in accept, deny, or pending action. Returned in a payment response only if the merchant has enabled FMF in the profile settings and one of the fraud filters was triggered based on those settings. See [Fraud Management Filters Summary](/docs/classic/fmf/integration-guide/FMFSummary/) for more information. * * @param \PayPal\Api\FmfDetails $fmf_details * * @return $this */ public function setFmfDetails($fmf_details) { $this->fmf_details = $fmf_details; return $this; } /** * Fraud Management Filter (FMF) details applied for the payment that could result in accept, deny, or pending action. Returned in a payment response only if the merchant has enabled FMF in the profile settings and one of the fraud filters was triggered based on those settings. See [Fraud Management Filters Summary](/docs/classic/fmf/integration-guide/FMFSummary/) for more information. * * @return \PayPal\Api\FmfDetails */ public function getFmfDetails() { return $this->fmf_details; } /** * Receipt id is a payment identification number returned for guest users to identify the payment. * * @param string $receipt_id * * @return $this */ public function setReceiptId($receipt_id) { $this->receipt_id = $receipt_id; return $this; } /** * Receipt id is a payment identification number returned for guest users to identify the payment. * * @return string */ public function getReceiptId() { return $this->receipt_id; } /** * ID of the payment resource on which this transaction is based. * * @param string $parent_payment * * @return $this */ public function setParentPayment($parent_payment) { $this->parent_payment = $parent_payment; return $this; } /** * ID of the payment resource on which this transaction is based. * * @return string */ public function getParentPayment() { return $this->parent_payment; } /** * Response codes returned by the processor concerning the submitted payment. Only supported when the `payment_method` is set to `credit_card`. * * @param \PayPal\Api\ProcessorResponse $processor_response * * @return $this */ public function setProcessorResponse($processor_response) { $this->processor_response = $processor_response; return $this; } /** * Response codes returned by the processor concerning the submitted payment. Only supported when the `payment_method` is set to `credit_card`. * * @return \PayPal\Api\ProcessorResponse */ public function getProcessorResponse() { return $this->processor_response; } /** * ID of the billing agreement used as reference to execute this transaction. * * @param string $billing_agreement_id * * @return $this */ public function setBillingAgreementId($billing_agreement_id) { $this->billing_agreement_id = $billing_agreement_id; return $this; } /** * ID of the billing agreement used as reference to execute this transaction. * * @return string */ public function getBillingAgreementId() { return $this->billing_agreement_id; } /** * Time of sale as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6) * * @param string $create_time * * @return $this */ public function setCreateTime($create_time) { $this->create_time = $create_time; return $this; } /** * Time of sale as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6) * * @return string */ public function getCreateTime() { return $this->create_time; } /** * Time the resource was last updated in UTC ISO8601 format. * * @param string $update_time * * @return $this */ public function setUpdateTime($update_time) { $this->update_time = $update_time; return $this; } /** * Time the resource was last updated in UTC ISO8601 format. * * @return string */ public function getUpdateTime() { return $this->update_time; } /** * Retrieve details about a sale transaction by passing the sale_id in the request URI. This request returns only the sales that were created via the REST API. * * @param string $saleId * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return Sale */ public static function get($saleId, $apiContext = null, $restCall = null) { ArgumentValidator::validate($saleId, 'saleId'); $payLoad = ""; $json = self::executeCall( "/v1/payments/sale/$saleId", "GET", $payLoad, null, $apiContext, $restCall ); $ret = new Sale(); $ret->fromJson($json); return $ret; } /** * Refund a completed payment by passing the sale_id in the request URI. In addition, include an empty JSON payload in the request body for a full refund. For a partial refund, include an amount object in the request body. * * @param Refund $refund * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return Refund */ public function refund($refund, $apiContext = null, $restCall = null) { ArgumentValidator::validate($this->getId(), "Id"); ArgumentValidator::validate($refund, 'refund'); $payLoad = $refund->toJSON(); $json = self::executeCall( "/v1/payments/sale/{$this->getId()}/refund", "POST", $payLoad, null, $apiContext, $restCall ); $ret = new Refund(); $ret->fromJson($json); return $ret; } } rest-api-sdk-php/lib/PayPal/Api/WebProfile.php 0000644 00000017722 15007532371 0015064 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalResourceModel; use PayPal\Rest\ApiContext; use PayPal\Transport\PayPalRestCall; use PayPal\Validation\ArgumentValidator; /** * Class WebProfile * * Payment Web experience profile resource * * @package PayPal\Api * * @property string id * @property string name * @property \PayPal\Api\FlowConfig flow_config * @property \PayPal\Api\InputFields input_fields * @property \PayPal\Api\Presentation presentation */ class WebProfile extends PayPalResourceModel { /** * ID of the web experience profile. * * * @param string $id * * @return $this */ public function setId($id) { $this->id = $id; return $this; } /** * ID of the web experience profile. * * @return string */ public function getId() { return $this->id; } /** * Name of the web experience profile. * * * @param string $name * * @return $this */ public function setName($name) { $this->name = $name; return $this; } /** * Name of the web experience profile. * * @return string */ public function getName() { return $this->name; } /** * Parameters for flow configuration. * * * @param \PayPal\Api\FlowConfig $flow_config * * @return $this */ public function setFlowConfig($flow_config) { $this->flow_config = $flow_config; return $this; } /** * Parameters for flow configuration. * * @return \PayPal\Api\FlowConfig */ public function getFlowConfig() { return $this->flow_config; } /** * Parameters for input fields customization. * * * @param \PayPal\Api\InputFields $input_fields * * @return $this */ public function setInputFields($input_fields) { $this->input_fields = $input_fields; return $this; } /** * Parameters for input fields customization. * * @return \PayPal\Api\InputFields */ public function getInputFields() { return $this->input_fields; } /** * Parameters for style and presentation. * * * @param \PayPal\Api\Presentation $presentation * * @return $this */ public function setPresentation($presentation) { $this->presentation = $presentation; return $this; } /** * Parameters for style and presentation. * * @return \PayPal\Api\Presentation */ public function getPresentation() { return $this->presentation; } /** * Create a web experience profile by passing the name of the profile and other profile details in the request JSON to the request URI. * * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return CreateProfileResponse */ public function create($apiContext = null, $restCall = null) { $payLoad = $this->toJSON(); $json = self::executeCall( "/v1/payment-experience/web-profiles/", "POST", $payLoad, null, $apiContext, $restCall ); $ret = new CreateProfileResponse(); $ret->fromJson($json); return $ret; } /** * Update a web experience profile by passing the ID of the profile to the request URI. In addition, pass the profile details in the request JSON. If your request does not include values for all profile detail fields, the previously set values for the omitted fields are removed by this operation. * * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return bool */ public function update($apiContext = null, $restCall = null) { ArgumentValidator::validate($this->getId(), "Id"); $payLoad = $this->toJSON(); self::executeCall( "/v1/payment-experience/web-profiles/{$this->getId()}", "PUT", $payLoad, null, $apiContext, $restCall ); return true; } /** * Partially update an existing web experience profile by passing the ID of the profile to the request URI. In addition, pass a patch object in the request JSON that specifies the operation to perform, path of the profile location to update, and a new value if needed to complete the operation. * * @param Patch[] $patch * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return bool */ public function partial_update($patch, $apiContext = null, $restCall = null) { ArgumentValidator::validate($this->getId(), "Id"); ArgumentValidator::validate($patch, 'patch'); $payload = array(); foreach ($patch as $patchObject) { $payload[] = $patchObject->toArray(); } $payLoad = json_encode($payload); self::executeCall( "/v1/payment-experience/web-profiles/{$this->getId()}", "PATCH", $payLoad, null, $apiContext, $restCall ); return true; } /** * Retrieve the details of a particular web experience profile by passing the ID of the profile to the request URI. * * @param string $profileId * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return WebProfile */ public static function get($profileId, $apiContext = null, $restCall = null) { ArgumentValidator::validate($profileId, 'profileId'); $payLoad = ""; $json = self::executeCall( "/v1/payment-experience/web-profiles/$profileId", "GET", $payLoad, null, $apiContext, $restCall ); $ret = new WebProfile(); $ret->fromJson($json); return $ret; } /** * Lists all web experience profiles that exist for a merchant (or subject). * * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return WebProfile[] */ public static function get_list($apiContext = null, $restCall = null) { $payLoad = ""; $json = self::executeCall( "/v1/payment-experience/web-profiles/", "GET", $payLoad, null, $apiContext, $restCall ); return WebProfile::getList($json); } /** * Delete an existing web experience profile by passing the profile ID to the request URI. * * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return bool */ public function delete($apiContext = null, $restCall = null) { ArgumentValidator::validate($this->getId(), "Id"); $payLoad = ""; self::executeCall( "/v1/payment-experience/web-profiles/{$this->getId()}", "DELETE", $payLoad, null, $apiContext, $restCall ); return true; } } rest-api-sdk-php/lib/PayPal/Api/CarrierAccountToken.php 0000644 00000002626 15007532371 0016730 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class CarrierAccountToken * * A resource representing a carrier account that can be used to fund a payment. * * @package PayPal\Api * * @property string carrier_account_id * @property string external_customer_id */ class CarrierAccountToken extends PayPalModel { /** * ID of a previously saved carrier account resource. * * @param string $carrier_account_id * * @return $this */ public function setCarrierAccountId($carrier_account_id) { $this->carrier_account_id = $carrier_account_id; return $this; } /** * ID of a previously saved carrier account resource. * * @return string */ public function getCarrierAccountId() { return $this->carrier_account_id; } /** * The unique identifier of the payer used when saving this carrier account instrument. * * @param string $external_customer_id * * @return $this */ public function setExternalCustomerId($external_customer_id) { $this->external_customer_id = $external_customer_id; return $this; } /** * The unique identifier of the payer used when saving this carrier account instrument. * * @return string */ public function getExternalCustomerId() { return $this->external_customer_id; } } rest-api-sdk-php/lib/PayPal/Api/Image.php 0000644 00000001763 15007532371 0014046 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class Image * * @package PayPal\Api * * @property string image */ class Image extends PayPalModel { /** * List of invoices belonging to a merchant. * * @param string $imageBase64String * * @return $this */ public function setImage($imageBase64String) { $this->image = $imageBase64String; return $this; } /** * Get Image as Base-64 encoded String * * @return string */ public function getImage() { return $this->image; } /** * Stores the Image to file * * @param string $name File Name * @return string File name */ public function saveToFile($name = null) { // Self Generate File Location if (!$name) { $name = uniqid() . '.png'; } // Save to File file_put_contents($name, base64_decode($this->getImage())); return $name; } } rest-api-sdk-php/lib/PayPal/Api/PatchRequest.php 0000644 00000003507 15007532371 0015432 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class PatchRequest * * Request object used for a JSON Patch. * * @package PayPal\Api * * @property \PayPal\Api\Patch[] patches */ class PatchRequest extends PayPalModel { /** * Placeholder for holding array of patch objects * * @param \PayPal\Api\Patch[] $patches * * @return $this */ public function setPatches($patches) { $this->patches = $patches; return $this; } /** * Placeholder for holding array of patch objects * * @return \PayPal\Api\Patch[] */ public function getPatches() { return $this->patches; } /** * Append Patches to the list. * * @param \PayPal\Api\Patch $patch * @return $this */ public function addPatch($patch) { if (!$this->getPatches()) { return $this->setPatches(array($patch)); } else { return $this->setPatches( array_merge($this->getPatches(), array($patch)) ); } } /** * Remove Patches from the list. * * @param \PayPal\Api\Patch $patch * @return $this */ public function removePatch($patch) { return $this->setPatches( array_diff($this->getPatches(), array($patch)) ); } /** * As PatchRequest holds the array of Patch object, we would override the json conversion to return * a json representation of array of Patch objects. * * @param int $options * @return mixed|string */ public function toJSON($options = 0) { $json = array(); foreach ($this->getPatches() as $patch) { $json[] = $patch->toArray(); } return str_replace('\\/', '/', json_encode($json, $options)); } } rest-api-sdk-php/lib/PayPal/Api/CreditCardHistory.php 0000644 00000003471 15007532371 0016410 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class CreditCardHistory * * A list of Credit Card Resources * * @package PayPal\Api * * @property \PayPal\Api\CreditCard[] credit_cards * @property int count * @property string next_id */ class CreditCardHistory extends PayPalModel { /** * A list of credit card resources * * * @param \PayPal\Api\CreditCard[] $credit_cards * @return $this */ public function setCreditCards($credit_cards) { $this->{"credit-cards"} = $credit_cards; return $this; } /** * A list of credit card resources * * @return \PayPal\Api\CreditCard */ public function getCreditCards() { return $this->{"credit-cards"}; } /** * Number of items returned in each range of results. Note that the last results range could have fewer items than the requested number of items. * * * @param int $count * * @return $this */ public function setCount($count) { $this->count = $count; return $this; } /** * Number of items returned in each range of results. Note that the last results range could have fewer items than the requested number of items. * * @return int */ public function getCount() { return $this->count; } /** * Identifier of the next element to get the next range of results. * * * @param string $next_id * * @return $this */ public function setNextId($next_id) { $this->next_id = $next_id; return $this; } /** * Identifier of the next element to get the next range of results. * * @return string */ public function getNextId() { return $this->next_id; } } rest-api-sdk-php/lib/PayPal/Api/OpenIdAddress.php 0000644 00000004623 15007532371 0015506 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class OpenIdAddress * * End-User's preferred address. * * @package PayPal\Api * * @property string street_address * @property string locality * @property string region * @property string postal_code * @property string country */ class OpenIdAddress extends PayPalModel { /** * Full street address component, which may include house number, street name. * * @param string $street_address * @return self */ public function setStreetAddress($street_address) { $this->street_address = $street_address; return $this; } /** * Full street address component, which may include house number, street name. * * @return string */ public function getStreetAddress() { return $this->street_address; } /** * City or locality component. * * @param string $locality * @return self */ public function setLocality($locality) { $this->locality = $locality; return $this; } /** * City or locality component. * * @return string */ public function getLocality() { return $this->locality; } /** * State, province, prefecture or region component. * * @param string $region * @return self */ public function setRegion($region) { $this->region = $region; return $this; } /** * State, province, prefecture or region component. * * @return string */ public function getRegion() { return $this->region; } /** * Zip code or postal code component. * * @param string $postal_code * @return self */ public function setPostalCode($postal_code) { $this->postal_code = $postal_code; return $this; } /** * Zip code or postal code component. * * @return string */ public function getPostalCode() { return $this->postal_code; } /** * Country name component. * * @param string $country * @return self */ public function setCountry($country) { $this->country = $country; return $this; } /** * Country name component. * * @return string */ public function getCountry() { return $this->country; } } rest-api-sdk-php/lib/PayPal/Api/WebhookEventType.php 0000644 00000005565 15007532371 0016272 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalResourceModel; use PayPal\Rest\ApiContext; use PayPal\Transport\PayPalRestCall; use PayPal\Validation\ArgumentValidator; /** * Class WebhookEventType * * Contains the information for a Webhooks event-type * * @package PayPal\Api * * @property string name * @property string description */ class WebhookEventType extends PayPalResourceModel { /** * Unique event-type name. * * @param string $name * * @return $this */ public function setName($name) { $this->name = $name; return $this; } /** * Unique event-type name. * * @return string */ public function getName() { return $this->name; } /** * Human readable description of the event-type * * @param string $description * * @return $this */ public function setDescription($description) { $this->description = $description; return $this; } /** * Human readable description of the event-type * * @return string */ public function getDescription() { return $this->description; } /** * Retrieves the list of events-types subscribed by the given Webhook. * * @param string $webhookId * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return WebhookEventTypeList */ public static function subscribedEventTypes($webhookId, $apiContext = null, $restCall = null) { ArgumentValidator::validate($webhookId, 'webhookId'); $payLoad = ""; $json = self::executeCall( "/v1/notifications/webhooks/$webhookId/event-types", "GET", $payLoad, null, $apiContext, $restCall ); $ret = new WebhookEventTypeList(); $ret->fromJson($json); return $ret; } /** * Retrieves the master list of available Webhooks events-types resources for any webhook to subscribe to. * * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return WebhookEventTypeList */ public static function availableEventTypes($apiContext = null, $restCall = null) { $payLoad = ""; $json = self::executeCall( "/v1/notifications/webhooks-event-types", "GET", $payLoad, null, $apiContext, $restCall ); $ret = new WebhookEventTypeList(); $ret->fromJson($json); return $ret; } } rest-api-sdk-php/lib/PayPal/Api/MerchantPreferences.php 0000644 00000013673 15007532371 0016752 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; use PayPal\Validation\UrlValidator; /** * Class MerchantPreferences * * Resource representing merchant preferences like max failed attempts, set up fee and others for a plan. * * @package PayPal\Api * * @property string id * @property \PayPal\Api\Currency setup_fee * @property string cancel_url * @property string return_url * @property string notify_url * @property string max_fail_attempts * @property string auto_bill_amount * @property string initial_fail_amount_action * @property string accepted_payment_type * @property string char_set */ class MerchantPreferences extends PayPalModel { /** * Identifier of the merchant_preferences. 128 characters max. * * @param string $id * * @return $this */ public function setId($id) { $this->id = $id; return $this; } /** * Identifier of the merchant_preferences. 128 characters max. * * @return string */ public function getId() { return $this->id; } /** * Setup fee amount. Default is 0. * * @param \PayPal\Api\Currency $setup_fee * * @return $this */ public function setSetupFee($setup_fee) { $this->setup_fee = $setup_fee; return $this; } /** * Setup fee amount. Default is 0. * * @return \PayPal\Api\Currency */ public function getSetupFee() { return $this->setup_fee; } /** * Redirect URL on cancellation of agreement request. 1000 characters max. * * @param string $cancel_url * @throws \InvalidArgumentException * @return $this */ public function setCancelUrl($cancel_url) { UrlValidator::validate($cancel_url, "CancelUrl"); $this->cancel_url = $cancel_url; return $this; } /** * Redirect URL on cancellation of agreement request. 1000 characters max. * * @return string */ public function getCancelUrl() { return $this->cancel_url; } /** * Redirect URL on creation of agreement request. 1000 characters max. * * @param string $return_url * @throws \InvalidArgumentException * @return $this */ public function setReturnUrl($return_url) { UrlValidator::validate($return_url, "ReturnUrl"); $this->return_url = $return_url; return $this; } /** * Redirect URL on creation of agreement request. 1000 characters max. * * @return string */ public function getReturnUrl() { return $this->return_url; } /** * Notify URL on agreement creation. 1000 characters max. * * @param string $notify_url * @throws \InvalidArgumentException * @return $this */ public function setNotifyUrl($notify_url) { UrlValidator::validate($notify_url, "NotifyUrl"); $this->notify_url = $notify_url; return $this; } /** * Notify URL on agreement creation. 1000 characters max. * * @return string */ public function getNotifyUrl() { return $this->notify_url; } /** * Total number of failed attempts allowed. Default is 0, representing an infinite number of failed attempts. * * @param string $max_fail_attempts * * @return $this */ public function setMaxFailAttempts($max_fail_attempts) { $this->max_fail_attempts = $max_fail_attempts; return $this; } /** * Total number of failed attempts allowed. Default is 0, representing an infinite number of failed attempts. * * @return string */ public function getMaxFailAttempts() { return $this->max_fail_attempts; } /** * Allow auto billing for the outstanding amount of the agreement in the next cycle. Allowed values: `YES`, `NO`. Default is `NO`. * * @param string $auto_bill_amount * * @return $this */ public function setAutoBillAmount($auto_bill_amount) { $this->auto_bill_amount = $auto_bill_amount; return $this; } /** * Allow auto billing for the outstanding amount of the agreement in the next cycle. Allowed values: `YES`, `NO`. Default is `NO`. * * @return string */ public function getAutoBillAmount() { return $this->auto_bill_amount; } /** * Action to take if a failure occurs during initial payment. Allowed values: `CONTINUE`, `CANCEL`. Default is continue. * * @param string $initial_fail_amount_action * * @return $this */ public function setInitialFailAmountAction($initial_fail_amount_action) { $this->initial_fail_amount_action = $initial_fail_amount_action; return $this; } /** * Action to take if a failure occurs during initial payment. Allowed values: `CONTINUE`, `CANCEL`. Default is continue. * * @return string */ public function getInitialFailAmountAction() { return $this->initial_fail_amount_action; } /** * Payment types that are accepted for this plan. * * @param string $accepted_payment_type * * @return $this */ public function setAcceptedPaymentType($accepted_payment_type) { $this->accepted_payment_type = $accepted_payment_type; return $this; } /** * Payment types that are accepted for this plan. * * @return string */ public function getAcceptedPaymentType() { return $this->accepted_payment_type; } /** * char_set for this plan. * * @param string $char_set * * @return $this */ public function setCharSet($char_set) { $this->char_set = $char_set; return $this; } /** * char_set for this plan. * * @return string */ public function getCharSet() { return $this->char_set; } } rest-api-sdk-php/lib/PayPal/Api/CarrierAccount.php 0000644 00000005753 15007532371 0015733 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class CarrierAccount * * Payment Instrument that facilitates carrier billing * * @package PayPal\Api * * @property string id * @property string phone_number * @property string external_customer_id * @property string phone_source * @property \PayPal\Api\CountryCode country_code */ class CarrierAccount extends PayPalModel { /** * ID that identifies the payer�s carrier account. Can be used in subsequent REST API calls, e.g. for making payments. * * @param string $id * * @return $this */ public function setId($id) { $this->id = $id; return $this; } /** * ID that identifies the payer�s carrier account. Can be used in subsequent REST API calls, e.g. for making payments. * * @return string */ public function getId() { return $this->id; } /** * The payer�s phone number in E.164 format. * * @param string $phone_number * * @return $this */ public function setPhoneNumber($phone_number) { $this->phone_number = $phone_number; return $this; } /** * The payer�s phone number in E.164 format. * * @return string */ public function getPhoneNumber() { return $this->phone_number; } /** * User identifier as created by the merchant. * * @param string $external_customer_id * * @return $this */ public function setExternalCustomerId($external_customer_id) { $this->external_customer_id = $external_customer_id; return $this; } /** * User identifier as created by the merchant. * * @return string */ public function getExternalCustomerId() { return $this->external_customer_id; } /** * The method of obtaining the phone number (USER_PROVIDED or READ_FROM_DEVICE). * Valid Values: ["READ_FROM_DEVICE", "USER_PROVIDED"] * * @param string $phone_source * * @return $this */ public function setPhoneSource($phone_source) { $this->phone_source = $phone_source; return $this; } /** * The method of obtaining the phone number (USER_PROVIDED or READ_FROM_DEVICE). * * @return string */ public function getPhoneSource() { return $this->phone_source; } /** * The country where the phone number is registered. Specified in 2-character IS0-3166-1 format. * * @param \PayPal\Api\CountryCode $country_code * * @return $this */ public function setCountryCode($country_code) { $this->country_code = $country_code; return $this; } /** * The country where the phone number is registered. Specified in 2-character IS0-3166-1 format. * * @return \PayPal\Api\CountryCode */ public function getCountryCode() { return $this->country_code; } } rest-api-sdk-php/lib/PayPal/Api/PayoutBatch.php 0000644 00000004621 15007532371 0015243 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class PayoutBatch * * The batch status as generated by PayPal. * * @package PayPal\Api * * @property \PayPal\Api\PayoutBatchHeader batch_header * @property \PayPal\Api\PayoutItemDetails[] items * @property \PayPal\Api\Links[] links */ class PayoutBatch extends PayPalModel { /** * A batch header that includes the generated batch status. * * @param \PayPal\Api\PayoutBatchHeader $batch_header * * @return $this */ public function setBatchHeader($batch_header) { $this->batch_header = $batch_header; return $this; } /** * A batch header that includes the generated batch status. * * @return \PayPal\Api\PayoutBatchHeader */ public function getBatchHeader() { return $this->batch_header; } /** * Array of the items in a batch payout. * * @param \PayPal\Api\PayoutItemDetails[] $items * * @return $this */ public function setItems($items) { $this->items = $items; return $this; } /** * Array of the items in a batch payout. * * @return \PayPal\Api\PayoutItemDetails[] */ public function getItems() { return $this->items; } /** * Append Items to the list. * * @param \PayPal\Api\PayoutItemDetails $payoutItemDetails * @return $this */ public function addItem($payoutItemDetails) { if (!$this->getItems()) { return $this->setItems(array($payoutItemDetails)); } else { return $this->setItems( array_merge($this->getItems(), array($payoutItemDetails)) ); } } /** * Remove Items from the list. * * @param \PayPal\Api\PayoutItemDetails $payoutItemDetails * @return $this */ public function removeItem($payoutItemDetails) { return $this->setItems( array_diff($this->getItems(), array($payoutItemDetails)) ); } /** * Sets Links * * @param \PayPal\Api\Links[] $links * * @return $this */ public function setLinks($links) { $this->links = $links; return $this; } /** * Gets Links * * @return \PayPal\Api\Links[] */ public function getLinks() { return $this->links; } } rest-api-sdk-php/lib/PayPal/Api/PaymentDetail.php 0000644 00000007442 15007532371 0015564 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class PaymentDetail * * Invoicing payment information. * * @package PayPal\Api * * @property string type * @property string transaction_id * @property string transaction_type * @property string date * @property string method * @property string note */ class PaymentDetail extends PayPalModel { /** * 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. * Valid Values: ["PAYPAL", "EXTERNAL"] * * @param string $type * * @return $this */ 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 transaction id. Mandatory field in case the type value is PAYPAL. * * @param string $transaction_id * * @return $this */ 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; } /** * Type of the transaction. * Valid Values: ["SALE", "AUTHORIZATION", "CAPTURE"] * * @param string $transaction_type * * @return $this */ public function setTransactionType($transaction_type) { $this->transaction_type = $transaction_type; return $this; } /** * 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, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). * * @param string $date * * @return $this */ public function setDate($date) { $this->date = $date; return $this; } /** * Date when the invoice was paid. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). * * @return string */ public function getDate() { return $this->date; } /** * Payment mode or method. This field is mandatory if the value of the type field is EXTERNAL. * Valid Values: ["BANK_TRANSFER", "CASH", "CHECK", "CREDIT_CARD", "DEBIT_CARD", "PAYPAL", "WIRE_TRANSFER", "OTHER"] * * @param string $method * * @return $this */ 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 EXTERNAL. * * @return string */ public function getMethod() { return $this->method; } /** * Optional note associated with the payment. * * @param string $note * * @return $this */ public function setNote($note) { $this->note = $note; return $this; } /** * Optional note associated with the payment. * * @return string */ public function getNote() { return $this->note; } } rest-api-sdk-php/lib/PayPal/Api/Invoice.php 0000644 00000066667 15007532371 0014436 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalResourceModel; use PayPal\Rest\ApiContext; use PayPal\Transport\PayPalRestCall; use PayPal\Validation\ArgumentValidator; use PayPal\Validation\UrlValidator; /** * Class Invoice * * Detailed invoice information. * * @package PayPal\Api * * @property string id * @property string number * @property string uri * @property string status * @property \PayPal\Api\MerchantInfo merchant_info * @property \PayPal\Api\BillingInfo[] billing_info * @property \PayPal\Api\ShippingInfo shipping_info * @property \PayPal\Api\InvoiceItem[] items * @property string invoice_date * @property \PayPal\Api\PaymentTerm payment_term * @property \PayPal\Api\Cost discount * @property \PayPal\Api\ShippingCost shipping_cost * @property \PayPal\Api\CustomAmount custom * @property bool tax_calculated_after_discount * @property bool tax_inclusive * @property string terms * @property string note * @property string merchant_memo * @property string logo_url * @property \PayPal\Api\Currency total_amount * @property \PayPal\Api\PaymentDetail[] payments * @property \PayPal\Api\RefundDetail[] refunds * @property \PayPal\Api\Metadata metadata * @property string additional_data */ class Invoice extends PayPalResourceModel { /** * Unique invoice resource identifier. * * @param string $id * * @return $this */ public function setId($id) { $this->id = $id; return $this; } /** * Unique invoice resource identifier. * * @return string */ public function getId() { return $this->id; } /** * Unique number that appears on the invoice. If left blank will be auto-incremented from the last number. 25 characters max. * * @param string $number * * @return $this */ public function setNumber($number) { $this->number = $number; return $this; } /** * Unique number that appears on the invoice. If left blank will be auto-incremented from the last number. 25 characters max. * * @return string */ public function getNumber() { return $this->number; } /** * URI of the invoice resource. * * @param string $uri * * @return $this */ public function setUri($uri) { $this->uri = $uri; return $this; } /** * URI of the invoice resource. * * @return string */ public function getUri() { return $this->uri; } /** * Status of the invoice. * Valid Values: ["DRAFT", "SENT", "PAID", "MARKED_AS_PAID", "CANCELLED", "REFUNDED", "PARTIALLY_REFUNDED", "MARKED_AS_REFUNDED"] * * @param string $status * * @return $this */ public function setStatus($status) { $this->status = $status; return $this; } /** * Status of the invoice. * * @return string */ public function getStatus() { return $this->status; } /** * Information about the merchant who is sending the invoice. * * @param \PayPal\Api\MerchantInfo $merchant_info * * @return $this */ public function setMerchantInfo($merchant_info) { $this->merchant_info = $merchant_info; return $this; } /** * Information about the merchant who is sending the invoice. * * @return \PayPal\Api\MerchantInfo */ public function getMerchantInfo() { return $this->merchant_info; } /** * Email address of invoice recipient (required) and optional billing information. (Note: We currently only allow one recipient). * * @param \PayPal\Api\BillingInfo[] $billing_info * * @return $this */ public function setBillingInfo($billing_info) { $this->billing_info = $billing_info; return $this; } /** * Email address of invoice recipient (required) and optional billing information. (Note: We currently only allow one recipient). * * @return \PayPal\Api\BillingInfo[] */ public function getBillingInfo() { return $this->billing_info; } /** * Append BillingInfo to the list. * * @param \PayPal\Api\BillingInfo $billingInfo * @return $this */ public function addBillingInfo($billingInfo) { if (!$this->getBillingInfo()) { return $this->setBillingInfo(array($billingInfo)); } else { return $this->setBillingInfo( array_merge($this->getBillingInfo(), array($billingInfo)) ); } } /** * Remove BillingInfo from the list. * * @param \PayPal\Api\BillingInfo $billingInfo * @return $this */ public function removeBillingInfo($billingInfo) { return $this->setBillingInfo( array_diff($this->getBillingInfo(), array($billingInfo)) ); } /** * Shipping information for entities to whom items are being shipped. * * @param \PayPal\Api\ShippingInfo $shipping_info * * @return $this */ public function setShippingInfo($shipping_info) { $this->shipping_info = $shipping_info; return $this; } /** * Shipping information for entities to whom items are being shipped. * * @return \PayPal\Api\ShippingInfo */ public function getShippingInfo() { return $this->shipping_info; } /** * List of items included in the invoice. 100 items max per invoice. * * @param \PayPal\Api\InvoiceItem[] $items * * @return $this */ public function setItems($items) { $this->items = $items; return $this; } /** * List of items included in the invoice. 100 items max per invoice. * * @return \PayPal\Api\InvoiceItem[] */ public function getItems() { return $this->items; } /** * Append Items to the list. * * @param \PayPal\Api\InvoiceItem $invoiceItem * @return $this */ public function addItem($invoiceItem) { if (!$this->getItems()) { return $this->setItems(array($invoiceItem)); } else { return $this->setItems( array_merge($this->getItems(), array($invoiceItem)) ); } } /** * Remove Items from the list. * * @param \PayPal\Api\InvoiceItem $invoiceItem * @return $this */ public function removeItem($invoiceItem) { return $this->setItems( array_diff($this->getItems(), array($invoiceItem)) ); } /** * Date on which the invoice was enabled. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). * * @param string $invoice_date * * @return $this */ public function setInvoiceDate($invoice_date) { $this->invoice_date = $invoice_date; return $this; } /** * Date on which the invoice was enabled. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). * * @return string */ public function getInvoiceDate() { return $this->invoice_date; } /** * Optional field to pass payment deadline for the invoice. Either term_type or due_date can be passed, but not both. * * @param \PayPal\Api\PaymentTerm $payment_term * * @return $this */ public function setPaymentTerm($payment_term) { $this->payment_term = $payment_term; return $this; } /** * Optional field to pass payment deadline for the invoice. Either term_type or due_date can be passed, but not both. * * @return \PayPal\Api\PaymentTerm */ public function getPaymentTerm() { return $this->payment_term; } /** * Invoice level discount in percent or amount. * * @param \PayPal\Api\Cost $discount * * @return $this */ public function setDiscount($discount) { $this->discount = $discount; return $this; } /** * Invoice level discount in percent or amount. * * @return \PayPal\Api\Cost */ public function getDiscount() { return $this->discount; } /** * Shipping cost in percent or amount. * * @param \PayPal\Api\ShippingCost $shipping_cost * * @return $this */ public function setShippingCost($shipping_cost) { $this->shipping_cost = $shipping_cost; return $this; } /** * Shipping cost in percent or amount. * * @return \PayPal\Api\ShippingCost */ public function getShippingCost() { return $this->shipping_cost; } /** * Custom amount applied on an invoice. If a label is included then the amount cannot be empty. * * @param \PayPal\Api\CustomAmount $custom * * @return $this */ public function setCustom($custom) { $this->custom = $custom; return $this; } /** * Custom amount applied on an invoice. If a label is included then the amount cannot be empty. * * @return \PayPal\Api\CustomAmount */ public function getCustom() { return $this->custom; } /** * Indicates whether tax is calculated before or after a discount. If false (the default), the tax is calculated before a discount. If true, the tax is calculated after a discount. * * @param bool $tax_calculated_after_discount * * @return $this */ public function setTaxCalculatedAfterDiscount($tax_calculated_after_discount) { $this->tax_calculated_after_discount = $tax_calculated_after_discount; return $this; } /** * Indicates whether tax is calculated before or after a discount. If false (the default), the tax is calculated before a discount. If true, the tax is calculated after a discount. * * @return bool */ public function getTaxCalculatedAfterDiscount() { return $this->tax_calculated_after_discount; } /** * A flag indicating whether the unit price includes tax. Default is false * * @param bool $tax_inclusive * * @return $this */ public function setTaxInclusive($tax_inclusive) { $this->tax_inclusive = $tax_inclusive; return $this; } /** * A flag indicating whether the unit price includes tax. Default is false * * @return bool */ public function getTaxInclusive() { return $this->tax_inclusive; } /** * General terms of the invoice. 4000 characters max. * * @param string $terms * * @return $this */ public function setTerms($terms) { $this->terms = $terms; return $this; } /** * General terms of the invoice. 4000 characters max. * * @return string */ public function getTerms() { return $this->terms; } /** * Note to the payer. 4000 characters max. * * @param string $note * * @return $this */ public function setNote($note) { $this->note = $note; return $this; } /** * Note to the payer. 4000 characters max. * * @return string */ public function getNote() { return $this->note; } /** * Bookkeeping memo that is private to the merchant. 150 characters max. * * @param string $merchant_memo * * @return $this */ public function setMerchantMemo($merchant_memo) { $this->merchant_memo = $merchant_memo; return $this; } /** * Bookkeeping memo that is private to the merchant. 150 characters max. * * @return string */ public function getMerchantMemo() { return $this->merchant_memo; } /** * Full URL of an external image to use as the logo. 4000 characters max. * * @param string $logo_url * @throws \InvalidArgumentException * @return $this */ public function setLogoUrl($logo_url) { UrlValidator::validate($logo_url, "LogoUrl"); $this->logo_url = $logo_url; return $this; } /** * Full URL of an external image to use as the logo. 4000 characters max. * * @return string */ public function getLogoUrl() { return $this->logo_url; } /** * The total amount of the invoice. * * @param \PayPal\Api\Currency $total_amount * * @return $this */ public function setTotalAmount($total_amount) { $this->total_amount = $total_amount; return $this; } /** * The total amount of the invoice. * * @return \PayPal\Api\Currency */ public function getTotalAmount() { return $this->total_amount; } /** * List of payment details for the invoice. * * @param \PayPal\Api\PaymentDetail[] $payments * * @return $this */ public function setPayments($payments) { $this->payments = $payments; return $this; } /** * List of payment details for the invoice. * * @return \PayPal\Api\PaymentDetail[] */ public function getPayments() { return $this->payments; } /** * Append PaymentDetails to the list. * * @param \PayPal\Api\PaymentDetail $paymentDetail * @return $this */ public function addPaymentDetail($paymentDetail) { if (!$this->getPayments()) { return $this->setPayments(array($paymentDetail)); } else { return $this->setPayments( array_merge($this->getPayments(), array($paymentDetail)) ); } } /** * Remove PaymentDetails from the list. * * @param \PayPal\Api\PaymentDetail $paymentDetail * @return $this */ public function removePaymentDetail($paymentDetail) { return $this->setPayments( array_diff($this->getPayments(), array($paymentDetail)) ); } /** * List of refund details for the invoice. * * @param \PayPal\Api\RefundDetail[] $refunds * * @return $this */ public function setRefunds($refunds) { $this->refunds = $refunds; return $this; } /** * List of refund details for the invoice. * * @return \PayPal\Api\RefundDetail[] */ public function getRefunds() { return $this->refunds; } /** * Append RefundDetails to the list. * * @param \PayPal\Api\RefundDetail $refundDetail * @return $this */ public function addRefundDetail($refundDetail) { if (!$this->getRefunds()) { return $this->setRefunds(array($refundDetail)); } else { return $this->setRefunds( array_merge($this->getRefunds(), array($refundDetail)) ); } } /** * Remove RefundDetails from the list. * * @param \PayPal\Api\RefundDetail $refundDetail * @return $this */ public function removeRefundDetail($refundDetail) { return $this->setRefunds( array_diff($this->getRefunds(), array($refundDetail)) ); } /** * Audit information for the invoice. * * @param \PayPal\Api\Metadata $metadata * * @return $this */ public function setMetadata($metadata) { $this->metadata = $metadata; return $this; } /** * Audit information for the invoice. * * @return \PayPal\Api\Metadata */ public function getMetadata() { return $this->metadata; } /** * Any miscellaneous invoice data. 4000 characters max. * * @param string $additional_data * * @return $this */ public function setAdditionalData($additional_data) { $this->additional_data = $additional_data; return $this; } /** * Any miscellaneous invoice data. 4000 characters max. * * @return string */ public function getAdditionalData() { return $this->additional_data; } /** * Create a new invoice by passing the details for the invoice, including the merchant_info, to the request URI. * * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return Invoice */ public function create($apiContext = null, $restCall = null) { $payLoad = $this->toJSON(); $json = self::executeCall( "/v1/invoicing/invoices", "POST", $payLoad, null, $apiContext, $restCall ); $this->fromJson($json); return $this; } /** * Search for a specific invoice or invoices by passing a search object that specifies your search criteria to the request URI. * * @param Search $search * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return InvoiceSearchResponse */ public static function search($search, $apiContext = null, $restCall = null) { ArgumentValidator::validate($search, 'search'); $payLoad = $search->toJSON(); $json = self::executeCall( "/v1/invoicing/search", "POST", $payLoad, null, $apiContext, $restCall ); $ret = new InvoiceSearchResponse(); $ret->fromJson($json); return $ret; } /** * Send a specific invoice to its intended recipient by passing the invoice ID to the request URI. Optionally, you can specify whether to send the merchant an invoice update notification by using the notify_merchant query parameter. By default, notify_merchant is true. * * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return bool */ public function send($apiContext = null, $restCall = null) { ArgumentValidator::validate($this->getId(), "Id"); $payLoad = ""; self::executeCall( "/v1/invoicing/invoices/{$this->getId()}/send", "POST", $payLoad, null, $apiContext, $restCall ); return true; } /** * Send a reminder about a specific invoice to its intended recipient by providing the ID of the invoice in the request URI. In addition, pass a notification object that specifies the subject of the reminder and other details in the request JSON. * * @param Notification $notification * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return bool */ public function remind($notification, $apiContext = null, $restCall = null) { ArgumentValidator::validate($this->getId(), "Id"); ArgumentValidator::validate($notification, 'notification'); $payLoad = $notification->toJSON(); self::executeCall( "/v1/invoicing/invoices/{$this->getId()}/remind", "POST", $payLoad, null, $apiContext, $restCall ); return true; } /** * Cancel an invoice by passing the invoice ID to the request URI. * * @param CancelNotification $cancelNotification * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return bool */ public function cancel($cancelNotification, $apiContext = null, $restCall = null) { ArgumentValidator::validate($this->getId(), "Id"); ArgumentValidator::validate($cancelNotification, 'cancelNotification'); $payLoad = $cancelNotification->toJSON(); self::executeCall( "/v1/invoicing/invoices/{$this->getId()}/cancel", "POST", $payLoad, null, $apiContext, $restCall ); return true; } /** * Mark the status of an invoice as paid by passing the invoice ID to the request URI. In addition, pass a payment detail object that specifies the payment method and other details in the request JSON. * * @param PaymentDetail $paymentDetail * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return bool */ public function recordPayment($paymentDetail, $apiContext = null, $restCall = null) { ArgumentValidator::validate($this->getId(), "Id"); ArgumentValidator::validate($paymentDetail, 'paymentDetail'); $payLoad = $paymentDetail->toJSON(); self::executeCall( "/v1/invoicing/invoices/{$this->getId()}/record-payment", "POST", $payLoad, null, $apiContext, $restCall ); return true; } /** * Mark the status of an invoice as refunded by passing the invoice ID to the request URI. In addition, pass a refund-detail object that specifies the type of refund and other details in the request JSON. * * @param RefundDetail $refundDetail * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return bool */ public function recordRefund($refundDetail, $apiContext = null, $restCall = null) { ArgumentValidator::validate($this->getId(), "Id"); ArgumentValidator::validate($refundDetail, 'refundDetail'); $payLoad = $refundDetail->toJSON(); self::executeCall( "/v1/invoicing/invoices/{$this->getId()}/record-refund", "POST", $payLoad, null, $apiContext, $restCall ); return true; } /** * Retrieve the details for a particular invoice by passing the invoice ID to the request URI. * * @param string $invoiceId * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return Invoice */ public static function get($invoiceId, $apiContext = null, $restCall = null) { ArgumentValidator::validate($invoiceId, 'invoiceId'); $payLoad = ""; $json = self::executeCall( "/v1/invoicing/invoices/$invoiceId", "GET", $payLoad, null, $apiContext, $restCall ); $ret = new Invoice(); $ret->fromJson($json); return $ret; } /** * List some or all invoices for a merchant according to optional query string parameters specified. * * @param array $params * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return InvoiceSearchResponse */ public static function getAll($params = array(), $apiContext = null, $restCall = null) { ArgumentValidator::validate($params, 'params'); $allowedParams = array( 'page' => 1, 'page_size' => 1, 'total_count_required' => 1 ); $payLoad = ""; $json = self::executeCall( "/v1/invoicing/invoices/?" . http_build_query(array_intersect_key($params, $allowedParams)), "GET", $payLoad, null, $apiContext, $restCall ); $ret = new InvoiceSearchResponse(); $ret->fromJson($json); return $ret; } /** * Fully update an invoice by passing the invoice ID to the request URI. In addition, pass a complete invoice object in the request JSON. Partial updates are not supported. * * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return Invoice */ public function update($apiContext = null, $restCall = null) { ArgumentValidator::validate($this->getId(), "Id"); $payLoad = $this->toJSON(); $json = self::executeCall( "/v1/invoicing/invoices/{$this->getId()}", "PUT", $payLoad, null, $apiContext, $restCall ); $this->fromJson($json); return $this; } /** * Delete a particular invoice by passing the invoice ID to the request URI. * * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return bool */ public function delete($apiContext = null, $restCall = null) { ArgumentValidator::validate($this->getId(), "Id"); $payLoad = ""; self::executeCall( "/v1/invoicing/invoices/{$this->getId()}", "DELETE", $payLoad, null, $apiContext, $restCall ); return true; } /** * Generate a QR code for an invoice by passing the invoice ID to the request URI. The request generates a QR code that is 500 pixels in width and height. You can change the dimensions of the returned code by specifying optional query parameters. * * @param array $params * @param string $invoiceId * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return Image */ public static function qrCode($invoiceId, $params = array(), $apiContext = null, $restCall = null) { ArgumentValidator::validate($invoiceId, 'invoiceId'); ArgumentValidator::validate($params, 'params'); $allowedParams = array( 'width' => 1, 'height' => 1, 'action' => 1 ); $payLoad = ""; $json = self::executeCall( "/v1/invoicing/invoices/$invoiceId/qr-code?" . http_build_query(array_intersect_key($params, $allowedParams)), "GET", $payLoad, null, $apiContext, $restCall ); $ret = new Image(); $ret->fromJson($json); return $ret; } } rest-api-sdk-php/lib/PayPal/Api/CreateProfileResponse.php 0000644 00000001133 15007532371 0017256 0 ustar 00 <?php namespace PayPal\Api; /** * Class CreateProfileResponse * * Response schema for create profile api * * @package PayPal\Api * * @property string id */ class CreateProfileResponse extends WebProfile { /** * ID of the payment web experience profile. * * * @param string $id * * @return $this */ public function setId($id) { $this->id = $id; return $this; } /** * ID of the payment web experience profile. * * @return string */ public function getId() { return $this->id; } } rest-api-sdk-php/lib/PayPal/Api/CreditFinancingOffered.php 0000644 00000007625 15007532371 0017351 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class CreditFinancingOffered * * Credit financing offered to customer on PayPal side with opt-in/opt-out status * * @package PayPal\Api * * @property \PayPal\Api\Currency total_cost * @property \PayPal\Api\number term * @property \PayPal\Api\Currency monthly_payment * @property \PayPal\Api\Currency total_interest * @property bool payer_acceptance * @property bool cart_amount_immutable */ class CreditFinancingOffered extends PayPalModel { /** * This is the estimated total payment amount including interest and fees the user will pay during the lifetime of the loan. * * @param \PayPal\Api\Currency $total_cost * * @return $this */ public function setTotalCost($total_cost) { $this->total_cost = $total_cost; return $this; } /** * This is the estimated total payment amount including interest and fees the user will pay during the lifetime of the loan. * * @return \PayPal\Api\Currency */ public function getTotalCost() { return $this->total_cost; } /** * Length of financing terms in month * * @param \PayPal\Api\number $term * * @return $this */ public function setTerm($term) { $this->term = $term; return $this; } /** * Length of financing terms in month * * @return \PayPal\Api\number */ public function getTerm() { return $this->term; } /** * This is the estimated amount per month that the customer will need to pay including fees and interest. * * @param \PayPal\Api\Currency $monthly_payment * * @return $this */ public function setMonthlyPayment($monthly_payment) { $this->monthly_payment = $monthly_payment; return $this; } /** * This is the estimated amount per month that the customer will need to pay including fees and interest. * * @return \PayPal\Api\Currency */ public function getMonthlyPayment() { return $this->monthly_payment; } /** * Estimated interest or fees amount the payer will have to pay during the lifetime of the loan. * * @param \PayPal\Api\Currency $total_interest * * @return $this */ public function setTotalInterest($total_interest) { $this->total_interest = $total_interest; return $this; } /** * Estimated interest or fees amount the payer will have to pay during the lifetime of the loan. * * @return \PayPal\Api\Currency */ public function getTotalInterest() { return $this->total_interest; } /** * Status on whether the customer ultimately was approved for and chose to make the payment using the approved installment credit. * * @param bool $payer_acceptance * * @return $this */ public function setPayerAcceptance($payer_acceptance) { $this->payer_acceptance = $payer_acceptance; return $this; } /** * Status on whether the customer ultimately was approved for and chose to make the payment using the approved installment credit. * * @return bool */ public function getPayerAcceptance() { return $this->payer_acceptance; } /** * Indicates whether the cart amount is editable after payer's acceptance on PayPal side * * @param bool $cart_amount_immutable * * @return $this */ public function setCartAmountImmutable($cart_amount_immutable) { $this->cart_amount_immutable = $cart_amount_immutable; return $this; } /** * Indicates whether the cart amount is editable after payer's acceptance on PayPal side * * @return bool */ public function getCartAmountImmutable() { return $this->cart_amount_immutable; } } rest-api-sdk-php/lib/PayPal/Api/RecipientBankingInstruction.php 0000644 00000006236 15007532371 0020502 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class RecipientBankingInstruction * * Recipient bank Details. * * @package PayPal\Api * * @property string bank_name * @property string account_holder_name * @property string account_number * @property string routing_number * @property string international_bank_account_number * @property string bank_identifier_code */ class RecipientBankingInstruction extends PayPalModel { /** * Name of the financial institution. * * @param string $bank_name * * @return $this */ public function setBankName($bank_name) { $this->bank_name = $bank_name; return $this; } /** * Name of the financial institution. * * @return string */ public function getBankName() { return $this->bank_name; } /** * Name of the account holder * * @param string $account_holder_name * * @return $this */ public function setAccountHolderName($account_holder_name) { $this->account_holder_name = $account_holder_name; return $this; } /** * Name of the account holder * * @return string */ public function getAccountHolderName() { return $this->account_holder_name; } /** * bank account number * * @param string $account_number * * @return $this */ public function setAccountNumber($account_number) { $this->account_number = $account_number; return $this; } /** * bank account number * * @return string */ public function getAccountNumber() { return $this->account_number; } /** * bank routing number * * @param string $routing_number * * @return $this */ public function setRoutingNumber($routing_number) { $this->routing_number = $routing_number; return $this; } /** * bank routing number * * @return string */ public function getRoutingNumber() { return $this->routing_number; } /** * IBAN equivalent of the bank * * @param string $international_bank_account_number * * @return $this */ public function setInternationalBankAccountNumber($international_bank_account_number) { $this->international_bank_account_number = $international_bank_account_number; return $this; } /** * IBAN equivalent of the bank * * @return string */ public function getInternationalBankAccountNumber() { return $this->international_bank_account_number; } /** * BIC identifier of the financial institution * * @param string $bank_identifier_code * * @return $this */ public function setBankIdentifierCode($bank_identifier_code) { $this->bank_identifier_code = $bank_identifier_code; return $this; } /** * BIC identifier of the financial institution * * @return string */ public function getBankIdentifierCode() { return $this->bank_identifier_code; } } rest-api-sdk-php/lib/PayPal/Api/Phone.php 0000644 00000003266 15007532371 0014075 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class Phone * * Information related to the Payer. In case of PayPal Wallet payment, this information will be filled in by PayPal after the user approves the payment using their PayPal Wallet. * * @package PayPal\Api * * @property string country_code * @property string national_number * @property string extension */ class Phone extends PayPalModel { /** * Country code (from in E.164 format) * * @param string $country_code * * @return $this */ public function setCountryCode($country_code) { $this->country_code = $country_code; return $this; } /** * Country code (from in E.164 format) * * @return string */ public function getCountryCode() { return $this->country_code; } /** * In-country phone number (from in E.164 format) * * @param string $national_number * * @return $this */ public function setNationalNumber($national_number) { $this->national_number = $national_number; return $this; } /** * In-country phone number (from in E.164 format) * * @return string */ public function getNationalNumber() { return $this->national_number; } /** * Phone extension * * @param string $extension * * @return $this */ public function setExtension($extension) { $this->extension = $extension; return $this; } /** * Phone extension * * @return string */ public function getExtension() { return $this->extension; } } rest-api-sdk-php/lib/PayPal/Api/AgreementDetails.php 0000644 00000011263 15007532371 0016235 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class AgreementDetails * * A resource representing the agreement details. * * @package PayPal\Api * * @property \PayPal\Api\Currency outstanding_balance * @property string cycles_remaining * @property string cycles_completed * @property string next_billing_date * @property string last_payment_date * @property \PayPal\Api\Currency last_payment_amount * @property string final_payment_date * @property string failed_payment_count */ class AgreementDetails extends PayPalModel { /** * The outstanding balance for this agreement. * * @param \PayPal\Api\Currency $outstanding_balance * * @return $this */ public function setOutstandingBalance($outstanding_balance) { $this->outstanding_balance = $outstanding_balance; return $this; } /** * The outstanding balance for this agreement. * * @return \PayPal\Api\Currency */ public function getOutstandingBalance() { return $this->outstanding_balance; } /** * Number of cycles remaining for this agreement. * * @param string $cycles_remaining * * @return $this */ public function setCyclesRemaining($cycles_remaining) { $this->cycles_remaining = $cycles_remaining; return $this; } /** * Number of cycles remaining for this agreement. * * @return string */ public function getCyclesRemaining() { return $this->cycles_remaining; } /** * Number of cycles completed for this agreement. * * @param string $cycles_completed * * @return $this */ public function setCyclesCompleted($cycles_completed) { $this->cycles_completed = $cycles_completed; return $this; } /** * Number of cycles completed for this agreement. * * @return string */ public function getCyclesCompleted() { return $this->cycles_completed; } /** * The next billing date for this agreement, represented as 2014-02-19T10:00:00Z format. * * @param string $next_billing_date * * @return $this */ public function setNextBillingDate($next_billing_date) { $this->next_billing_date = $next_billing_date; return $this; } /** * The next billing date for this agreement, represented as 2014-02-19T10:00:00Z format. * * @return string */ public function getNextBillingDate() { return $this->next_billing_date; } /** * Last payment date for this agreement, represented as 2014-06-09T09:42:31Z format. * * @param string $last_payment_date * * @return $this */ public function setLastPaymentDate($last_payment_date) { $this->last_payment_date = $last_payment_date; return $this; } /** * Last payment date for this agreement, represented as 2014-06-09T09:42:31Z format. * * @return string */ public function getLastPaymentDate() { return $this->last_payment_date; } /** * Last payment amount for this agreement. * * @param \PayPal\Api\Currency $last_payment_amount * * @return $this */ public function setLastPaymentAmount($last_payment_amount) { $this->last_payment_amount = $last_payment_amount; return $this; } /** * Last payment amount for this agreement. * * @return \PayPal\Api\Currency */ public function getLastPaymentAmount() { return $this->last_payment_amount; } /** * Last payment date for this agreement, represented as 2015-02-19T10:00:00Z format. * * @param string $final_payment_date * * @return $this */ public function setFinalPaymentDate($final_payment_date) { $this->final_payment_date = $final_payment_date; return $this; } /** * Last payment date for this agreement, represented as 2015-02-19T10:00:00Z format. * * @return string */ public function getFinalPaymentDate() { return $this->final_payment_date; } /** * Total number of failed payments for this agreement. * * @param string $failed_payment_count * * @return $this */ public function setFailedPaymentCount($failed_payment_count) { $this->failed_payment_count = $failed_payment_count; return $this; } /** * Total number of failed payments for this agreement. * * @return string */ public function getFailedPaymentCount() { return $this->failed_payment_count; } } rest-api-sdk-php/lib/PayPal/Api/FundingInstrument.php 0000644 00000017412 15007532371 0016505 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class FundingInstrument * * A resource representing a Payer's funding instrument. An instance of this schema is valid if and only if it is valid against exactly one of these supported properties * * @package PayPal\Api * * @property \PayPal\Api\CreditCard credit_card * @property \PayPal\Api\CreditCardToken credit_card_token * @property \PayPal\Api\Billing billing */ class FundingInstrument extends PayPalModel { /** * Credit Card instrument. * * @param \PayPal\Api\CreditCard $credit_card * * @return $this */ public function setCreditCard($credit_card) { $this->credit_card = $credit_card; return $this; } /** * Credit Card instrument. * * @return \PayPal\Api\CreditCard */ public function getCreditCard() { return $this->credit_card; } /** * PayPal vaulted credit Card instrument. * * @param \PayPal\Api\CreditCardToken $credit_card_token * * @return $this */ public function setCreditCardToken($credit_card_token) { $this->credit_card_token = $credit_card_token; return $this; } /** * PayPal vaulted credit Card instrument. * * @return \PayPal\Api\CreditCardToken */ public function getCreditCardToken() { return $this->credit_card_token; } /** * Payment Card information. * * @deprecated Not publicly available * @param \PayPal\Api\PaymentCard $payment_card * * @return $this */ public function setPaymentCard($payment_card) { $this->payment_card = $payment_card; return $this; } /** * Payment Card information. * * @deprecated Not publicly available * @return \PayPal\Api\PaymentCard */ public function getPaymentCard() { return $this->payment_card; } /** * Bank Account information. * * @deprecated Not publicly available * @param \PayPal\Api\ExtendedBankAccount $bank_account * * @return $this */ public function setBankAccount($bank_account) { $this->bank_account = $bank_account; return $this; } /** * Bank Account information. * * @deprecated Not publicly available * @return \PayPal\Api\ExtendedBankAccount */ public function getBankAccount() { return $this->bank_account; } /** * Vaulted bank account instrument. * * @deprecated Not publicly available * @param \PayPal\Api\BankToken $bank_account_token * * @return $this */ public function setBankAccountToken($bank_account_token) { $this->bank_account_token = $bank_account_token; return $this; } /** * Vaulted bank account instrument. * * @deprecated Not publicly available * @return \PayPal\Api\BankToken */ public function getBankAccountToken() { return $this->bank_account_token; } /** * PayPal credit funding instrument. * * @deprecated Not publicly available * @param \PayPal\Api\Credit $credit * * @return $this */ public function setCredit($credit) { $this->credit = $credit; return $this; } /** * PayPal credit funding instrument. * * @deprecated Not publicly available * @return \PayPal\Api\Credit */ public function getCredit() { return $this->credit; } /** * Incentive funding instrument. * * @deprecated Not publicly available * @param \PayPal\Api\Incentive $incentive * * @return $this */ public function setIncentive($incentive) { $this->incentive = $incentive; return $this; } /** * Incentive funding instrument. * * @deprecated Not publicly available * @return \PayPal\Api\Incentive */ public function getIncentive() { return $this->incentive; } /** * External funding instrument. * * @deprecated Not publicly available * @param \PayPal\Api\ExternalFunding $external_funding * * @return $this */ public function setExternalFunding($external_funding) { $this->external_funding = $external_funding; return $this; } /** * External funding instrument. * * @deprecated Not publicly available * @return \PayPal\Api\ExternalFunding */ public function getExternalFunding() { return $this->external_funding; } /** * Carrier account token instrument. * * @deprecated Not publicly available * @param \PayPal\Api\CarrierAccountToken $carrier_account_token * * @return $this */ public function setCarrierAccountToken($carrier_account_token) { $this->carrier_account_token = $carrier_account_token; return $this; } /** * Carrier account token instrument. * * @deprecated Not publicly available * @return \PayPal\Api\CarrierAccountToken */ public function getCarrierAccountToken() { return $this->carrier_account_token; } /** * Carrier account instrument * * @deprecated Not publicly available * @param \PayPal\Api\CarrierAccount $carrier_account * * @return $this */ public function setCarrierAccount($carrier_account) { $this->carrier_account = $carrier_account; return $this; } /** * Carrier account instrument * * @deprecated Not publicly available * @return \PayPal\Api\CarrierAccount */ public function getCarrierAccount() { return $this->carrier_account; } /** * Private Label Card funding instrument. These are store cards provided by merchants to drive business with value to customer with convenience and rewards. * * @deprecated Not publicly available * @param \PayPal\Api\PrivateLabelCard $private_label_card * * @return $this */ public function setPrivateLabelCard($private_label_card) { $this->private_label_card = $private_label_card; return $this; } /** * Private Label Card funding instrument. These are store cards provided by merchants to drive business with value to customer with convenience and rewards. * * @deprecated Not publicly available * @return \PayPal\Api\PrivateLabelCard */ public function getPrivateLabelCard() { return $this->private_label_card; } /** * Billing instrument that references pre-approval information for the payment * * @param \PayPal\Api\Billing $billing * * @return $this */ public function setBilling($billing) { $this->billing = $billing; return $this; } /** * Billing instrument that references pre-approval information for the payment * * @return \PayPal\Api\Billing */ public function getBilling() { return $this->billing; } /** * Alternate Payment information - Mostly regional payment providers. For e.g iDEAL in Netherlands * * @deprecated Not publicly available * @param \PayPal\Api\AlternatePayment $alternate_payment * * @return $this */ public function setAlternatePayment($alternate_payment) { $this->alternate_payment = $alternate_payment; return $this; } /** * Alternate Payment information - Mostly regional payment providers. For e.g iDEAL in Netherlands * * @deprecated Not publicly available * @return \PayPal\Api\AlternatePayment */ public function getAlternatePayment() { return $this->alternate_payment; } } rest-api-sdk-php/lib/PayPal/Api/Billing.php 0000644 00000001362 15007532371 0014377 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class Billing * * Billing instrument used to charge the payer. * * @package PayPal\Api * * @property string billing_agreement_id */ class Billing extends PayPalModel { /** * Identifier of the instrument in PayPal Wallet * * @param string $billing_agreement_id * * @return $this */ public function setBillingAgreementId($billing_agreement_id) { $this->billing_agreement_id = $billing_agreement_id; return $this; } /** * Identifier of the instrument in PayPal Wallet * * @return string */ public function getBillingAgreementId() { return $this->billing_agreement_id; } } rest-api-sdk-php/lib/PayPal/Api/PayoutItemDetails.php 0000644 00000014010 15007532371 0016417 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class PayoutItemDetails * * This object contains status and other data for an individual payout of a batch. * * @package PayPal\Api * * @property string payout_item_id * @property string transaction_id * @property string transaction_status * @property \PayPal\Api\Currency payout_item_fee * @property string payout_batch_id * @property string sender_batch_id * @property \PayPal\Api\PayoutItem payout_item * @property string time_processed * @property \PayPal\Api\Error errors * @property \PayPal\Api\Links[] links */ class PayoutItemDetails extends PayPalModel { /** * An ID for an individual payout. Provided by PayPal, such as in the case of getting the status of a batch request. 30 characters max. * * @param string $payout_item_id * * @return $this */ public function setPayoutItemId($payout_item_id) { $this->payout_item_id = $payout_item_id; return $this; } /** * An ID for an individual payout. Provided by PayPal, such as in the case of getting the status of a batch request. 30 characters max. * * @return string */ public function getPayoutItemId() { return $this->payout_item_id; } /** * Generated ID for the transaction. 30 characters max. * * @param string $transaction_id * * @return $this */ public function setTransactionId($transaction_id) { $this->transaction_id = $transaction_id; return $this; } /** * Generated ID for the transaction. 30 characters max. * * @return string */ public function getTransactionId() { return $this->transaction_id; } /** * Status of a transaction. * * @param string $transaction_status * * @return $this */ public function setTransactionStatus($transaction_status) { $this->transaction_status = $transaction_status; return $this; } /** * Status of a transaction. * * @return string */ public function getTransactionStatus() { return $this->transaction_status; } /** * Amount of money in U.S. dollars for fees. * * @param \PayPal\Api\Currency $payout_item_fee * * @return $this */ public function setPayoutItemFee($payout_item_fee) { $this->payout_item_fee = $payout_item_fee; return $this; } /** * Amount of money in U.S. dollars for fees. * * @return \PayPal\Api\Currency */ public function getPayoutItemFee() { return $this->payout_item_fee; } /** * An ID for the batch payout. Generated by PayPal. 30 characters max. * * @param string $payout_batch_id * * @return $this */ public function setPayoutBatchId($payout_batch_id) { $this->payout_batch_id = $payout_batch_id; return $this; } /** * An ID for the batch payout. Generated by PayPal. 30 characters max. * * @return string */ public function getPayoutBatchId() { return $this->payout_batch_id; } /** * Sender-created ID for tracking the batch in an accounting system. 30 characters max. * * @param string $sender_batch_id * * @return $this */ public function setSenderBatchId($sender_batch_id) { $this->sender_batch_id = $sender_batch_id; return $this; } /** * Sender-created ID for tracking the batch in an accounting system. 30 characters max. * * @return string */ public function getSenderBatchId() { return $this->sender_batch_id; } /** * The data for a payout item that the sender initially provided. * * @param \PayPal\Api\PayoutItem $payout_item * * @return $this */ public function setPayoutItem($payout_item) { $this->payout_item = $payout_item; return $this; } /** * The data for a payout item that the sender initially provided. * * @return \PayPal\Api\PayoutItem */ public function getPayoutItem() { return $this->payout_item; } /** * Time of the last processing for this item. * * @param string $time_processed * * @return $this */ public function setTimeProcessed($time_processed) { $this->time_processed = $time_processed; return $this; } /** * Time of the last processing for this item. * * @return string */ public function getTimeProcessed() { return $this->time_processed; } /** * Sets Error * * @param \PayPal\Api\Error $errors * * @return $this */ public function setErrors($errors) { $this->errors = $errors; return $this; } /** * Gets Error * * @return \PayPal\Api\Error */ public function getErrors() { return $this->errors; } /** * Sets Links * * @param \PayPal\Api\Links[] $links * * @return $this */ public function setLinks($links) { $this->links = $links; return $this; } /** * Gets Links * * @return \PayPal\Api\Links[] */ public function getLinks() { return $this->links; } /** * Append Links to the list. * * @param \PayPal\Api\Links $links * @return $this */ public function addLink($links) { if (!$this->getLinks()) { return $this->setLinks(array($links)); } else { return $this->setLinks( array_merge($this->getLinks(), array($links)) ); } } /** * Remove Links from the list. * * @param \PayPal\Api\Links $links * @return $this */ public function removeLink($links) { return $this->setLinks( array_diff($this->getLinks(), array($links)) ); } } rest-api-sdk-php/lib/PayPal/Api/Item.php 0000644 00000023256 15007532371 0013723 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; use PayPal\Converter\FormatConverter; use PayPal\Validation\NumericValidator; use PayPal\Validation\UrlValidator; /** * Class Item * * Item details. * * @package PayPal\Api * * @property string sku * @property string name * @property string description * @property string quantity * @property string price * @property string currency * @property string tax * @property string url * @property string category */ class Item extends PayPalModel { /** * Stock keeping unit corresponding (SKU) to item. * * @param string $sku * * @return $this */ public function setSku($sku) { $this->sku = $sku; return $this; } /** * Stock keeping unit corresponding (SKU) to item. * * @return string */ public function getSku() { return $this->sku; } /** * Item name. 127 characters max. * * @param string $name * * @return $this */ public function setName($name) { $this->name = $name; return $this; } /** * Item name. 127 characters max. * * @return string */ public function getName() { return $this->name; } /** * Description of the item. Only supported when the `payment_method` is set to `paypal`. * * @param string $description * * @return $this */ public function setDescription($description) { $this->description = $description; return $this; } /** * Description of the item. Only supported when the `payment_method` is set to `paypal`. * * @return string */ public function getDescription() { return $this->description; } /** * Number of a particular item. 10 characters max. * * @param string $quantity * * @return $this */ public function setQuantity($quantity) { $this->quantity = $quantity; return $this; } /** * Number of a particular item. 10 characters max. * * @return string */ public function getQuantity() { return $this->quantity; } /** * Item cost. 10 characters max. * * @param string|double $price * * @return $this */ public function setPrice($price) { NumericValidator::validate($price, "Price"); $price = FormatConverter::formatToPrice($price, $this->getCurrency()); $this->price = $price; return $this; } /** * Item cost. 10 characters max. * * @return string */ public function getPrice() { return $this->price; } /** * 3-letter [currency code](https://developer.paypal.com/docs/integration/direct/rest_api_payment_country_currency_support/). * * @param string $currency * * @return $this */ public function setCurrency($currency) { $this->currency = $currency; return $this; } /** * 3-letter [currency code](https://developer.paypal.com/docs/integration/direct/rest_api_payment_country_currency_support/). * * @return string */ public function getCurrency() { return $this->currency; } /** * Tax of the item. Only supported when the `payment_method` is set to `paypal`. * * @param string|double $tax * * @return $this */ public function setTax($tax) { NumericValidator::validate($tax, "Tax"); $tax = FormatConverter::formatToPrice($tax, $this->getCurrency()); $this->tax = $tax; return $this; } /** * Tax of the item. Only supported when the `payment_method` is set to `paypal`. * * @return string */ public function getTax() { return $this->tax; } /** * URL linking to item information. Available to payer in transaction history. * * @param string $url * @throws \InvalidArgumentException * @return $this */ public function setUrl($url) { UrlValidator::validate($url, "Url"); $this->url = $url; return $this; } /** * URL linking to item information. Available to payer in transaction history. * * @return string */ public function getUrl() { return $this->url; } /** * Category type of the item. * Valid Values: ["DIGITAL", "PHYSICAL"] * * @param string $category * * @return $this */ public function setCategory($category) { $this->category = $category; return $this; } /** * Category type of the item. * * @return string */ public function getCategory() { return $this->category; } /** * Weight of the item. * * @deprecated Not publicly available * @param \PayPal\Api\Measurement $weight * * @return $this */ public function setWeight($weight) { $this->weight = $weight; return $this; } /** * Weight of the item. * * @deprecated Not publicly available * @return \PayPal\Api\Measurement */ public function getWeight() { return $this->weight; } /** * Length of the item. * * @deprecated Not publicly available * @param \PayPal\Api\Measurement $length * * @return $this */ public function setLength($length) { $this->length = $length; return $this; } /** * Length of the item. * * @deprecated Not publicly available * @return \PayPal\Api\Measurement */ public function getLength() { return $this->length; } /** * Height of the item. * * @deprecated Not publicly available * @param \PayPal\Api\Measurement $height * * @return $this */ public function setHeight($height) { $this->height = $height; return $this; } /** * Height of the item. * * @deprecated Not publicly available * @return \PayPal\Api\Measurement */ public function getHeight() { return $this->height; } /** * Width of the item. * * @deprecated Not publicly available * @param \PayPal\Api\Measurement $width * * @return $this */ public function setWidth($width) { $this->width = $width; return $this; } /** * Width of the item. * * @deprecated Not publicly available * @return \PayPal\Api\Measurement */ public function getWidth() { return $this->width; } /** * Set of optional data used for PayPal risk determination. * * @deprecated Not publicly available * @param \PayPal\Api\NameValuePair[] $supplementary_data * * @return $this */ public function setSupplementaryData($supplementary_data) { $this->supplementary_data = $supplementary_data; return $this; } /** * Set of optional data used for PayPal risk determination. * * @deprecated Not publicly available * @return \PayPal\Api\NameValuePair[] */ public function getSupplementaryData() { return $this->supplementary_data; } /** * Append SupplementaryData to the list. * * @deprecated Not publicly available * @param \PayPal\Api\NameValuePair $nameValuePair * @return $this */ public function addSupplementaryData($nameValuePair) { if (!$this->getSupplementaryData()) { return $this->setSupplementaryData(array($nameValuePair)); } else { return $this->setSupplementaryData( array_merge($this->getSupplementaryData(), array($nameValuePair)) ); } } /** * Remove SupplementaryData from the list. * * @deprecated Not publicly available * @param \PayPal\Api\NameValuePair $nameValuePair * @return $this */ public function removeSupplementaryData($nameValuePair) { return $this->setSupplementaryData( array_diff($this->getSupplementaryData(), array($nameValuePair)) ); } /** * Set of optional data used for PayPal post-transaction notifications. * * @deprecated Not publicly available * @param \PayPal\Api\NameValuePair[] $postback_data * * @return $this */ public function setPostbackData($postback_data) { $this->postback_data = $postback_data; return $this; } /** * Set of optional data used for PayPal post-transaction notifications. * * @deprecated Not publicly available * @return \PayPal\Api\NameValuePair[] */ public function getPostbackData() { return $this->postback_data; } /** * Append PostbackData to the list. * * @deprecated Not publicly available * @param \PayPal\Api\NameValuePair $nameValuePair * @return $this */ public function addPostbackData($nameValuePair) { if (!$this->getPostbackData()) { return $this->setPostbackData(array($nameValuePair)); } else { return $this->setPostbackData( array_merge($this->getPostbackData(), array($nameValuePair)) ); } } /** * Remove PostbackData from the list. * * @deprecated Not publicly available * @param \PayPal\Api\NameValuePair $nameValuePair * @return $this */ public function removePostbackData($nameValuePair) { return $this->setPostbackData( array_diff($this->getPostbackData(), array($nameValuePair)) ); } } rest-api-sdk-php/lib/PayPal/Api/Search.php 0000644 00000025706 15007532371 0014234 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class Search * * Invoice search parameters. * * @package PayPal\Api * * @property string email * @property string recipient_first_name * @property string recipient_last_name * @property string recipient_business_name * @property string number * @property string status * @property \PayPal\Api\Currency lower_total_amount * @property \PayPal\Api\Currency upper_total_amount * @property string start_invoice_date * @property string end_invoice_date * @property string start_due_date * @property string end_due_date * @property string start_payment_date * @property string end_payment_date * @property string start_creation_date * @property string end_creation_date * @property \PayPal\Api\number page * @property \PayPal\Api\number page_size * @property bool total_count_required */ class Search extends PayPalModel { /** * Initial letters of the email address. * * @param string $email * * @return $this */ public function setEmail($email) { $this->email = $email; return $this; } /** * Initial letters of the email address. * * @return string */ public function getEmail() { return $this->email; } /** * Initial letters of the recipient's first name. * * @param string $recipient_first_name * * @return $this */ public function setRecipientFirstName($recipient_first_name) { $this->recipient_first_name = $recipient_first_name; return $this; } /** * Initial letters of the recipient's first name. * * @return string */ public function getRecipientFirstName() { return $this->recipient_first_name; } /** * Initial letters of the recipient's last name. * * @param string $recipient_last_name * * @return $this */ public function setRecipientLastName($recipient_last_name) { $this->recipient_last_name = $recipient_last_name; return $this; } /** * Initial letters of the recipient's last name. * * @return string */ public function getRecipientLastName() { return $this->recipient_last_name; } /** * Initial letters of the recipient's business name. * * @param string $recipient_business_name * * @return $this */ public function setRecipientBusinessName($recipient_business_name) { $this->recipient_business_name = $recipient_business_name; return $this; } /** * Initial letters of the recipient's business name. * * @return string */ public function getRecipientBusinessName() { return $this->recipient_business_name; } /** * The invoice number that appears on the invoice. * * @param string $number * * @return $this */ public function setNumber($number) { $this->number = $number; return $this; } /** * The invoice number that appears on the invoice. * * @return string */ public function getNumber() { return $this->number; } /** * Status of the invoice. * Valid Values: ["DRAFT", "SENT", "PAID", "MARKED_AS_PAID", "CANCELLED", "REFUNDED", "PARTIALLY_REFUNDED", "MARKED_AS_REFUNDED"] * * @param string $status * * @return $this */ public function setStatus($status) { $this->status = $status; return $this; } /** * Status of the invoice. * * @return string */ public function getStatus() { return $this->status; } /** * Lower limit of total amount. * * @param \PayPal\Api\Currency $lower_total_amount * * @return $this */ public function setLowerTotalAmount($lower_total_amount) { $this->lower_total_amount = $lower_total_amount; return $this; } /** * Lower limit of total amount. * * @return \PayPal\Api\Currency */ public function getLowerTotalAmount() { return $this->lower_total_amount; } /** * Upper limit of total amount. * * @param \PayPal\Api\Currency $upper_total_amount * * @return $this */ public function setUpperTotalAmount($upper_total_amount) { $this->upper_total_amount = $upper_total_amount; return $this; } /** * Upper limit of total amount. * * @return \PayPal\Api\Currency */ public function getUpperTotalAmount() { return $this->upper_total_amount; } /** * Start invoice date. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). * * @param string $start_invoice_date * * @return $this */ public function setStartInvoiceDate($start_invoice_date) { $this->start_invoice_date = $start_invoice_date; return $this; } /** * Start invoice date. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). * * @return string */ public function getStartInvoiceDate() { return $this->start_invoice_date; } /** * End invoice date. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). * * @param string $end_invoice_date * * @return $this */ public function setEndInvoiceDate($end_invoice_date) { $this->end_invoice_date = $end_invoice_date; return $this; } /** * End invoice date. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). * * @return string */ public function getEndInvoiceDate() { return $this->end_invoice_date; } /** * Start invoice due date. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). * * @param string $start_due_date * * @return $this */ public function setStartDueDate($start_due_date) { $this->start_due_date = $start_due_date; return $this; } /** * Start invoice due date. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). * * @return string */ public function getStartDueDate() { return $this->start_due_date; } /** * End invoice due date. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). * * @param string $end_due_date * * @return $this */ public function setEndDueDate($end_due_date) { $this->end_due_date = $end_due_date; return $this; } /** * End invoice due date. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). * * @return string */ public function getEndDueDate() { return $this->end_due_date; } /** * Start invoice payment date. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). * * @param string $start_payment_date * * @return $this */ public function setStartPaymentDate($start_payment_date) { $this->start_payment_date = $start_payment_date; return $this; } /** * Start invoice payment date. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). * * @return string */ public function getStartPaymentDate() { return $this->start_payment_date; } /** * End invoice payment date. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). * * @param string $end_payment_date * * @return $this */ public function setEndPaymentDate($end_payment_date) { $this->end_payment_date = $end_payment_date; return $this; } /** * End invoice payment date. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). * * @return string */ public function getEndPaymentDate() { return $this->end_payment_date; } /** * Start invoice creation date. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). * * @param string $start_creation_date * * @return $this */ public function setStartCreationDate($start_creation_date) { $this->start_creation_date = $start_creation_date; return $this; } /** * Start invoice creation date. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). * * @return string */ public function getStartCreationDate() { return $this->start_creation_date; } /** * End invoice creation date. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). * * @param string $end_creation_date * * @return $this */ public function setEndCreationDate($end_creation_date) { $this->end_creation_date = $end_creation_date; return $this; } /** * End invoice creation date. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). * * @return string */ public function getEndCreationDate() { return $this->end_creation_date; } /** * Offset of the search results. * * @param \PayPal\Api\number $page * * @return $this */ public function setPage($page) { $this->page = $page; return $this; } /** * Offset of the search results. * * @return \PayPal\Api\number */ public function getPage() { return $this->page; } /** * Page size of the search results. * * @param \PayPal\Api\number $page_size * * @return $this */ public function setPageSize($page_size) { $this->page_size = $page_size; return $this; } /** * Page size of the search results. * * @return \PayPal\Api\number */ public function getPageSize() { return $this->page_size; } /** * A flag indicating whether total count is required in the response. * * @param bool $total_count_required * * @return $this */ public function setTotalCountRequired($total_count_required) { $this->total_count_required = $total_count_required; return $this; } /** * A flag indicating whether total count is required in the response. * * @return bool */ public function getTotalCountRequired() { return $this->total_count_required; } } rest-api-sdk-php/lib/PayPal/Api/CancelNotification.php 0000644 00000004100 15007532371 0016544 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class CancelNotification * * Email/SMS notification. * * @package PayPal\Api * * @property string subject * @property string note * @property bool send_to_merchant * @property bool send_to_payer */ class CancelNotification extends PayPalModel { /** * Subject of the notification. * * @param string $subject * * @return $this */ public function setSubject($subject) { $this->subject = $subject; return $this; } /** * Subject of the notification. * * @return string */ public function getSubject() { return $this->subject; } /** * Note to the payer. * * @param string $note * * @return $this */ public function setNote($note) { $this->note = $note; return $this; } /** * 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 bool $send_to_merchant * * @return $this */ 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 bool */ public function getSendToMerchant() { return $this->send_to_merchant; } /** * A flag indicating whether a copy of the email has to be sent to the payer. * * @param bool $send_to_payer * * @return $this */ 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. * * @return bool */ public function getSendToPayer() { return $this->send_to_payer; } } rest-api-sdk-php/lib/PayPal/Api/CreditCard.php 0000644 00000036010 15007532371 0015021 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalResourceModel; use PayPal\Rest\ApiContext; use PayPal\Transport\PayPalRestCall; use PayPal\Validation\ArgumentValidator; /** * Class CreditCard * * @package PayPal\Api * * @property string number * @property string type * @property int expire_month * @property int expire_year * @property string cvv2 * @property string first_name * @property string last_name * @property \PayPal\Api\Address billing_address * @property string external_customer_id * @property string state * @property string valid_until * @property \PayPal\Api\Links[] links */ class CreditCard extends PayPalResourceModel { /** * ID of the credit card. This ID is provided in the response when storing credit cards. **Required if using a stored credit card.** * * @deprecated Not publicly available * @param string $id * * @return $this */ public function setId($id) { $this->id = $id; return $this; } /** * ID of the credit card. This ID is provided in the response when storing credit cards. **Required if using a stored credit card.** * * @deprecated Not publicly available * @return string */ public function getId() { return $this->id; } /** * Credit card number. Numeric characters only with no spaces or punctuation. The string must conform with modulo and length required by each credit card type. *Redacted in responses.* * * @param string $number * * @return $this */ public function setNumber($number) { $this->number = $number; return $this; } /** * Credit card number. Numeric characters only with no spaces or punctuation. The string must conform with modulo and length required by each credit card type. *Redacted in responses.* * * @return string */ public function getNumber() { return $this->number; } /** * Credit card type. Valid types are: `visa`, `mastercard`, `discover`, `amex` * * @param string $type * * @return $this */ public function setType($type) { $this->type = $type; return $this; } /** * Credit card type. Valid types are: `visa`, `mastercard`, `discover`, `amex` * * @return string */ public function getType() { return $this->type; } /** * Expiration month with no leading zero. Acceptable values are 1 through 12. * * @param int $expire_month * * @return $this */ public function setExpireMonth($expire_month) { $this->expire_month = $expire_month; return $this; } /** * Expiration month with no leading zero. Acceptable values are 1 through 12. * * @return int */ public function getExpireMonth() { return $this->expire_month; } /** * 4-digit expiration year. * * @param int $expire_year * * @return $this */ public function setExpireYear($expire_year) { $this->expire_year = $expire_year; return $this; } /** * 4-digit expiration year. * * @return int */ public function getExpireYear() { return $this->expire_year; } /** * 3-4 digit card validation code. * * @param string $cvv2 * * @return $this */ public function setCvv2($cvv2) { $this->cvv2 = $cvv2; return $this; } /** * 3-4 digit card validation code. * * @return string */ public function getCvv2() { return $this->cvv2; } /** * Cardholder's first name. * * @param string $first_name * * @return $this */ public function setFirstName($first_name) { $this->first_name = $first_name; return $this; } /** * Cardholder's first name. * * @return string */ public function getFirstName() { return $this->first_name; } /** * Cardholder's last name. * * @param string $last_name * * @return $this */ public function setLastName($last_name) { $this->last_name = $last_name; return $this; } /** * Cardholder's last name. * * @return string */ public function getLastName() { return $this->last_name; } /** * Billing Address associated with this card. * * @param \PayPal\Api\Address $billing_address * * @return $this */ public function setBillingAddress($billing_address) { $this->billing_address = $billing_address; return $this; } /** * Billing Address associated with this card. * * @return \PayPal\Api\Address */ public function getBillingAddress() { return $this->billing_address; } /** * A unique identifier of the customer to whom this bank account belongs. Generated and provided by the facilitator. **This is now used in favor of `payer_id` when creating or using a stored funding instrument in the vault.** * * @param string $external_customer_id * * @return $this */ public function setExternalCustomerId($external_customer_id) { $this->external_customer_id = $external_customer_id; return $this; } /** * A unique identifier of the customer to whom this bank account belongs. Generated and provided by the facilitator. **This is now used in favor of `payer_id` when creating or using a stored funding instrument in the vault.** * * @return string */ public function getExternalCustomerId() { return $this->external_customer_id; } /** * A user provided, optional convenvience field that functions as a unique identifier for the merchant on behalf of whom this credit card is being stored for. Note that this has no relation to PayPal merchant id * * @param string $merchant_id * * @return $this */ public function setMerchantId($merchant_id) { $this->merchant_id = $merchant_id; return $this; } /** * A user provided, optional convenvience field that functions as a unique identifier for the merchant on behalf of whom this credit card is being stored for. Note that this has no relation to PayPal merchant id * * @return string */ public function getMerchantId() { return $this->merchant_id; } /** * A unique identifier that you can assign and track when storing a credit card or using a stored credit card. This ID can help to avoid unintentional use or misuse of credit cards. This ID can be any value you would like to associate with the saved card, such as a UUID, username, or email address. Required when using a stored credit card if a payer_id was originally provided when storing the credit card in vault. * * @deprecated This is being deprecated in favor of the `external_customer_id` property. * @param string $payer_id * * @return $this */ public function setPayerId($payer_id) { $this->payer_id = $payer_id; return $this; } /** * A unique identifier that you can assign and track when storing a credit card or using a stored credit card. This ID can help to avoid unintentional use or misuse of credit cards. This ID can be any value you would like to associate with the saved card, such as a UUID, username, or email address. Required when using a stored credit card if a payer_id was originally provided when storing the credit card in vault. * * @deprecated This is being deprecated in favor of the `external_customer_id` property. * @return string */ public function getPayerId() { return $this->payer_id; } /** * A unique identifier of the bank account resource. Generated and provided by the facilitator so it can be used to restrict the usage of the bank account to the specific merchant. * * @param string $external_card_id * * @return $this */ public function setExternalCardId($external_card_id) { $this->external_card_id = $external_card_id; return $this; } /** * A unique identifier of the bank account resource. Generated and provided by the facilitator so it can be used to restrict the usage of the bank account to the specific merchant. * * @return string */ public function getExternalCardId() { return $this->external_card_id; } /** * State of the funding instrument. * Valid Values: ["expired", "ok"] * * @param string $state * * @return $this */ public function setState($state) { $this->state = $state; return $this; } /** * State of the credit card funding instrument. * * @return string */ public function getState() { return $this->state; } /** * Funding instrument expiration date. * * @param string $create_time * * @return $this */ public function setCreateTime($create_time) { $this->create_time = $create_time; return $this; } /** * Resource creation time as ISO8601 date-time format (ex: 1994-11-05T13:15:30Z) that indicates creation time. * * @return string */ public function getCreateTime() { return $this->create_time; } /** * Resource creation time as ISO8601 date-time format (ex: 1994-11-05T13:15:30Z) that indicates the updation time. * * @param string $update_time * * @return $this */ public function setUpdateTime($update_time) { $this->update_time = $update_time; return $this; } /** * Resource creation time as ISO8601 date-time format (ex: 1994-11-05T13:15:30Z) that indicates the updation time. * * @return string */ public function getUpdateTime() { return $this->update_time; } /** * Date/Time until this resource can be used fund a payment. * * @param string $valid_until * * @return $this */ public function setValidUntil($valid_until) { $this->valid_until = $valid_until; return $this; } /** * Funding instrument expiration date. * * @return string */ public function getValidUntil() { return $this->valid_until; } /** * Creates a new Credit Card Resource (aka Tokenize). * * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return CreditCard */ public function create($apiContext = null, $restCall = null) { $payLoad = $this->toJSON(); $json = self::executeCall( "/v1/vault/credit-cards", "POST", $payLoad, null, $apiContext, $restCall ); $this->fromJson($json); return $this; } /** * Obtain the Credit Card resource for the given identifier. * * @param string $creditCardId * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return CreditCard */ public static function get($creditCardId, $apiContext = null, $restCall = null) { ArgumentValidator::validate($creditCardId, 'creditCardId'); $payLoad = ""; $json = self::executeCall( "/v1/vault/credit-cards/$creditCardId", "GET", $payLoad, null, $apiContext, $restCall ); $ret = new CreditCard(); $ret->fromJson($json); return $ret; } /** * Delete the Credit Card resource for the given identifier. * * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return bool */ public function delete($apiContext = null, $restCall = null) { ArgumentValidator::validate($this->getId(), "Id"); $payLoad = ""; self::executeCall( "/v1/vault/credit-cards/{$this->getId()}", "DELETE", $payLoad, null, $apiContext, $restCall ); return true; } /** * Update information in a previously saved card. Only the modified fields need to be passed in the request. * * @param PatchRequest $patchRequest * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return CreditCard */ public function update($patchRequest, $apiContext = null, $restCall = null) { ArgumentValidator::validate($this->getId(), "Id"); ArgumentValidator::validate($patchRequest, 'patch'); $payload = $patchRequest->toJSON(); $json = self::executeCall( "/v1/vault/credit-cards/{$this->getId()}", "PATCH", $payload, null, $apiContext, $restCall ); $this->fromJson($json); return $this; } /** * Retrieves a list of Credit Card resources. * * @param array $params * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return CreditCardList */ public static function all($params, $apiContext = null, $restCall = null) { if (is_null($params)) { $params = array(); } ArgumentValidator::validate($params, 'params'); $payLoad = ""; $allowedParams = array( 'page_size' => 1, 'page' => 1, 'start_time' => 1, 'end_time' => 1, 'sort_order' => 1, 'sort_by' => 1, 'merchant_id' => 1, 'external_card_id' => 1, 'external_customer_id' => 1, ); $json = self::executeCall( "/v1/vault/credit-cards" . "?" . http_build_query(array_intersect_key($params, $allowedParams)), "GET", $payLoad, null, $apiContext, $restCall ); $ret = new CreditCardList(); $ret->fromJson($json); return $ret; } } rest-api-sdk-php/lib/PayPal/Api/Webhook.php 0000644 00000014671 15007532371 0014424 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalResourceModel; use PayPal\Rest\ApiContext; use PayPal\Transport\PayPalRestCall; use PayPal\Validation\ArgumentValidator; use PayPal\Validation\UrlValidator; /** * Class Webhook * * Represents Webhook resource. * * @package PayPal\Api * * @property string id * @property string url * @property \PayPal\Api\WebhookEventType[] event_types */ class Webhook extends PayPalResourceModel { /** * Identifier of the webhook resource. * * @param string $id * * @return $this */ public function setId($id) { $this->id = $id; return $this; } /** * Identifier of the webhook resource. * * @return string */ public function getId() { return $this->id; } /** * Webhook notification endpoint url. * * @param string $url * @throws \InvalidArgumentException * @return $this */ public function setUrl($url) { UrlValidator::validate($url, "Url"); $this->url = $url; return $this; } /** * Webhook notification endpoint url. * * @return string */ public function getUrl() { return $this->url; } /** * List of Webhooks event-types. * * @param \PayPal\Api\WebhookEventType[] $event_types * * @return $this */ public function setEventTypes($event_types) { $this->event_types = $event_types; return $this; } /** * List of Webhooks event-types. * * @return \PayPal\Api\WebhookEventType[] */ public function getEventTypes() { return $this->event_types; } /** * Append EventTypes to the list. * * @param \PayPal\Api\WebhookEventType $webhookEventType * @return $this */ public function addEventType($webhookEventType) { if (!$this->getEventTypes()) { return $this->setEventTypes(array($webhookEventType)); } else { return $this->setEventTypes( array_merge($this->getEventTypes(), array($webhookEventType)) ); } } /** * Remove EventTypes from the list. * * @param \PayPal\Api\WebhookEventType $webhookEventType * @return $this */ public function removeEventType($webhookEventType) { return $this->setEventTypes( array_diff($this->getEventTypes(), array($webhookEventType)) ); } /** * Creates the Webhook for the application associated with the access token. * * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return Webhook */ public function create($apiContext = null, $restCall = null) { $payLoad = $this->toJSON(); $json = self::executeCall( "/v1/notifications/webhooks", "POST", $payLoad, null, $apiContext, $restCall ); $this->fromJson($json); return $this; } /** * Retrieves the Webhook identified by webhook_id for the application associated with access token. * * @param string $webhookId * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return Webhook */ public static function get($webhookId, $apiContext = null, $restCall = null) { ArgumentValidator::validate($webhookId, 'webhookId'); $payLoad = ""; $json = self::executeCall( "/v1/notifications/webhooks/$webhookId", "GET", $payLoad, null, $apiContext, $restCall ); $ret = new Webhook(); $ret->fromJson($json); return $ret; } /** * Retrieves all Webhooks for the application associated with access token. * * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return WebhookList */ public static function getAll($apiContext = null, $restCall = null) { $payLoad = ""; $json = self::executeCall( "/v1/notifications/webhooks", "GET", $payLoad, null, $apiContext, $restCall ); $ret = new WebhookList(); $ret->fromJson($json); return $ret; } /** * Updates the Webhook identified by webhook_id for the application associated with access token. * * @param PatchRequest $patchRequest * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return Webhook */ public function update($patchRequest, $apiContext = null, $restCall = null) { ArgumentValidator::validate($this->getId(), "Id"); ArgumentValidator::validate($patchRequest, 'patchRequest'); $payLoad = $patchRequest->toJSON(); $json = self::executeCall( "/v1/notifications/webhooks/{$this->getId()}", "PATCH", $payLoad, null, $apiContext, $restCall ); $this->fromJson($json); return $this; } /** * Deletes the Webhook identified by webhook_id for the application associated with access token. * * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return bool */ public function delete($apiContext = null, $restCall = null) { ArgumentValidator::validate($this->getId(), "Id"); $payLoad = ""; self::executeCall( "/v1/notifications/webhooks/{$this->getId()}", "DELETE", $payLoad, null, $apiContext, $restCall ); return true; } } rest-api-sdk-php/lib/PayPal/Api/MerchantInfo.php 0000644 00000011476 15007532371 0015403 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class MerchantInfo * * Business information of the merchant that will appear on the invoice. * * @package PayPal\Api * * @property string email * @property string first_name * @property string last_name * @property \PayPal\Api\InvoiceAddress address * @property string business_name * @property \PayPal\Api\Phone phone * @property \PayPal\Api\Phone fax * @property string website * @property string tax_id * @property string additional_info */ class MerchantInfo extends PayPalModel { /** * Email address of the merchant. 260 characters max. * * @param string $email * * @return $this */ 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; } /** * First name of the merchant. 30 characters max. * * @param string $first_name * * @return $this */ 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; } /** * Last name of the merchant. 30 characters max. * * @param string $last_name * * @return $this */ public function setLastName($last_name) { $this->last_name = $last_name; return $this; } /** * Last name of the merchant. 30 characters max. * * @return string */ public function getLastName() { return $this->last_name; } /** * Address of the merchant. * * @param \PayPal\Api\InvoiceAddress $address * * @return $this */ public function setAddress($address) { $this->address = $address; return $this; } /** * Address of the merchant. * * @return \PayPal\Api\InvoiceAddress */ public function getAddress() { return $this->address; } /** * Company business name of the merchant. 100 characters max. * * @param string $business_name * * @return $this */ 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; } /** * Phone number of the merchant. * * @param \PayPal\Api\Phone $phone * * @return $this */ 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 * * @return $this */ public function setFax($fax) { $this->fax = $fax; return $this; } /** * 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 * * @return $this */ public function setWebsite($website) { $this->website = $website; return $this; } /** * 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 * * @return $this */ 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; } /** * Option to display additional information such as business hours. 40 characters max. * * @param string $additional_info * * @return $this */ 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; } } rest-api-sdk-php/lib/PayPal/Api/ExtendedBankAccount.php 0000644 00000001737 15007532371 0016676 0 ustar 00 <?php namespace PayPal\Api; /** * Class ExtendedBankAccount * * A resource representing a bank account that can be used to fund a payment including support for SEPA. * * @package PayPal\Api * */ class ExtendedBankAccount extends BankAccount { /** * Identifier of the direct debit mandate to validate. Currently supported only for EU bank accounts(SEPA). * * @deprecated Not publicly available * @param string $mandate_reference_number * * @return $this */ public function setMandateReferenceNumber($mandate_reference_number) { $this->mandate_reference_number = $mandate_reference_number; return $this; } /** * Identifier of the direct debit mandate to validate. Currently supported only for EU bank accounts(SEPA). * * @deprecated Not publicly available * @return string */ public function getMandateReferenceNumber() { return $this->mandate_reference_number; } } rest-api-sdk-php/lib/PayPal/Api/WebhookEventTypeList.php 0000644 00000003011 15007532371 0017106 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class WebhookEventTypeList * * List of Webhooks event-types * * @package PayPal\Api * * @property \PayPal\Api\WebhookEventType[] event_types */ class WebhookEventTypeList extends PayPalModel { /** * A list of Webhooks event-types * * @param \PayPal\Api\WebhookEventType[] $event_types * * @return $this */ public function setEventTypes($event_types) { $this->event_types = $event_types; return $this; } /** * A list of Webhooks event-types * * @return \PayPal\Api\WebhookEventType[] */ public function getEventTypes() { return $this->event_types; } /** * Append EventTypes to the list. * * @param \PayPal\Api\WebhookEventType $webhookEventType * @return $this */ public function addEventType($webhookEventType) { if (!$this->getEventTypes()) { return $this->setEventTypes(array($webhookEventType)); } else { return $this->setEventTypes( array_merge($this->getEventTypes(), array($webhookEventType)) ); } } /** * Remove EventTypes from the list. * * @param \PayPal\Api\WebhookEventType $webhookEventType * @return $this */ public function removeEventType($webhookEventType) { return $this->setEventTypes( array_diff($this->getEventTypes(), array($webhookEventType)) ); } } rest-api-sdk-php/lib/PayPal/Api/WebhookEventList.php 0000644 00000006037 15007532371 0016257 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class WebhookEventList * * List of Webhooks event resources * * @package PayPal\Api * * @property \PayPal\Api\WebhookEvent[] events * @property int count * @property \PayPal\Api\Links[] links */ class WebhookEventList extends PayPalModel { /** * A list of Webhooks event resources * * @param \PayPal\Api\WebhookEvent[] $events * * @return $this */ public function setEvents($events) { $this->events = $events; return $this; } /** * A list of Webhooks event resources * * @return \PayPal\Api\WebhookEvent[] */ public function getEvents() { return $this->events; } /** * Append Events to the list. * * @param \PayPal\Api\WebhookEvent $webhookEvent * @return $this */ public function addEvent($webhookEvent) { if (!$this->getEvents()) { return $this->setEvents(array($webhookEvent)); } else { return $this->setEvents( array_merge($this->getEvents(), array($webhookEvent)) ); } } /** * Remove Events from the list. * * @param \PayPal\Api\WebhookEvent $webhookEvent * @return $this */ public function removeEvent($webhookEvent) { return $this->setEvents( array_diff($this->getEvents(), array($webhookEvent)) ); } /** * Number of items returned in each range of results. Note that the last results range could have fewer items than the requested number of items. * * @param int $count * * @return $this */ public function setCount($count) { $this->count = $count; return $this; } /** * Number of items returned in each range of results. Note that the last results range could have fewer items than the requested number of items. * * @return int */ public function getCount() { return $this->count; } /** * Sets Links * * @param \PayPal\Api\Links[] $links * * @return $this */ public function setLinks($links) { $this->links = $links; return $this; } /** * Gets Links * * @return \PayPal\Api\Links[] */ public function getLinks() { return $this->links; } /** * Append Links to the list. * * @param \PayPal\Api\Links $links * @return $this */ public function addLink($links) { if (!$this->getLinks()) { return $this->setLinks(array($links)); } else { return $this->setLinks( array_merge($this->getLinks(), array($links)) ); } } /** * Remove Links from the list. * * @param \PayPal\Api\Links $links * @return $this */ public function removeLink($links) { return $this->setLinks( array_diff($this->getLinks(), array($links)) ); } } rest-api-sdk-php/lib/PayPal/Api/PaymentHistory.php 0000644 00000004670 15007532371 0016023 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class PaymentHistory * * List of Payments made by the seller. * * @package PayPal\Api * * @property \PayPal\Api\Payment[] payments * @property int count * @property string next_id */ class PaymentHistory extends PayPalModel { /** * A list of Payment resources * * @param \PayPal\Api\Payment[] $payments * * @return $this */ public function setPayments($payments) { $this->payments = $payments; return $this; } /** * A list of Payment resources * * @return \PayPal\Api\Payment[] */ public function getPayments() { return $this->payments; } /** * Append Payments to the list. * * @param \PayPal\Api\Payment $payment * @return $this */ public function addPayment($payment) { if (!$this->getPayments()) { return $this->setPayments(array($payment)); } else { return $this->setPayments( array_merge($this->getPayments(), array($payment)) ); } } /** * Remove Payments from the list. * * @param \PayPal\Api\Payment $payment * @return $this */ public function removePayment($payment) { return $this->setPayments( array_diff($this->getPayments(), array($payment)) ); } /** * Number of items returned in each range of results. Note that the last results range could have fewer items than the requested number of items. * * @param int $count * * @return $this */ public function setCount($count) { $this->count = $count; return $this; } /** * Number of items returned in each range of results. Note that the last results range could have fewer items than the requested number of items. * * @return int */ public function getCount() { return $this->count; } /** * Identifier of the next element to get the next range of results. * * @param string $next_id * * @return $this */ public function setNextId($next_id) { $this->next_id = $next_id; return $this; } /** * Identifier of the next element to get the next range of results. * * @return string */ public function getNextId() { return $this->next_id; } } rest-api-sdk-php/lib/PayPal/Api/AlternatePayment.php 0000644 00000004205 15007532371 0016273 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class AlternatePayment * * A resource representing a alternate payment account that can be used to fund a payment. * * @package PayPal\Api * * @property string alternate_payment_account_id * @property string external_customer_id * @property string alternate_payment_provider_id */ class AlternatePayment extends PayPalModel { /** * The unique identifier of the alternate payment account. * * @param string $alternate_payment_account_id * * @return $this */ public function setAlternatePaymentAccountId($alternate_payment_account_id) { $this->alternate_payment_account_id = $alternate_payment_account_id; return $this; } /** * The unique identifier of the alternate payment account. * * @return string */ public function getAlternatePaymentAccountId() { return $this->alternate_payment_account_id; } /** * The unique identifier of the payer * * @param string $external_customer_id * * @return $this */ public function setExternalCustomerId($external_customer_id) { $this->external_customer_id = $external_customer_id; return $this; } /** * The unique identifier of the payer * * @return string */ public function getExternalCustomerId() { return $this->external_customer_id; } /** * Alternate Payment provider id. This is an optional attribute needed only for certain alternate providers e.g Ideal * * @param string $alternate_payment_provider_id * * @return $this */ public function setAlternatePaymentProviderId($alternate_payment_provider_id) { $this->alternate_payment_provider_id = $alternate_payment_provider_id; return $this; } /** * Alternate Payment provider id. This is an optional attribute needed only for certain alternate providers e.g Ideal * * @return string */ public function getAlternatePaymentProviderId() { return $this->alternate_payment_provider_id; } } rest-api-sdk-php/lib/PayPal/Api/AgreementStateDescriptor.php 0000644 00000002175 15007532371 0017771 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class AgreementStateDescriptor * * Description of the current state of the agreement. * * @package PayPal\Api * * @property string note * @property \PayPal\Api\Currency amount */ class AgreementStateDescriptor extends PayPalModel { /** * Reason for changing the state of the agreement. * * @param string $note * * @return $this */ public function setNote($note) { $this->note = $note; return $this; } /** * Reason for changing the state of the agreement. * * @return string */ public function getNote() { return $this->note; } /** * The amount and currency of the agreement. * * @param \PayPal\Api\Currency $amount * * @return $this */ public function setAmount($amount) { $this->amount = $amount; return $this; } /** * The amount and currency of the agreement. * * @return \PayPal\Api\Currency */ public function getAmount() { return $this->amount; } } rest-api-sdk-php/lib/PayPal/Api/Capture.php 0000644 00000015033 15007532371 0014422 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalResourceModel; use PayPal\Rest\ApiContext; use PayPal\Validation\ArgumentValidator; /** * Class Capture * * A capture transaction. * * @package PayPal\Api * * @property string id * @property \PayPal\Api\Amount amount * @property bool is_final_capture * @property string state * @property string parent_payment * @property \PayPal\Api\Currency transaction_fee * @property string create_time * @property string update_time * @property \PayPal\Api\Links[] links */ class Capture extends PayPalResourceModel { /** * ID of the capture transaction. * * @param string $id * * @return $this */ public function setId($id) { $this->id = $id; return $this; } /** * ID of the capture transaction. * * @return string */ public function getId() { return $this->id; } /** * Amount being captured. If the amount matches the orginally authorized amount, the state of the authorization changes to `captured`. If not, the state of the authorization changes to `partially_captured`. * * @param \PayPal\Api\Amount $amount * * @return $this */ public function setAmount($amount) { $this->amount = $amount; return $this; } /** * Amount being captured. If the amount matches the orginally authorized amount, the state of the authorization changes to `captured`. If not, the state of the authorization changes to `partially_captured`. * * @return \PayPal\Api\Amount */ public function getAmount() { return $this->amount; } /** * If set to `true`, all remaining funds held by the authorization will be released in the funding instrument. * * @param bool $is_final_capture * * @return $this */ public function setIsFinalCapture($is_final_capture) { $this->is_final_capture = $is_final_capture; return $this; } /** * If set to `true`, all remaining funds held by the authorization will be released in the funding instrument. * * @return bool */ public function getIsFinalCapture() { return $this->is_final_capture; } /** * State of the capture. * Valid Values: ["pending", "completed", "refunded", "partially_refunded"] * * @param string $state * * @return $this */ public function setState($state) { $this->state = $state; return $this; } /** * State of the capture. * * @return string */ public function getState() { return $this->state; } /** * ID of the payment resource on which this transaction is based. * * @param string $parent_payment * * @return $this */ public function setParentPayment($parent_payment) { $this->parent_payment = $parent_payment; return $this; } /** * ID of the payment resource on which this transaction is based. * * @return string */ public function getParentPayment() { return $this->parent_payment; } /** * Transaction fee applicable for this payment. * * @param \PayPal\Api\Currency $transaction_fee * * @return $this */ public function setTransactionFee($transaction_fee) { $this->transaction_fee = $transaction_fee; return $this; } /** * Transaction fee applicable for this payment. * * @return \PayPal\Api\Currency */ public function getTransactionFee() { return $this->transaction_fee; } /** * Time of capture as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6). * * @param string $create_time * * @return $this */ public function setCreateTime($create_time) { $this->create_time = $create_time; return $this; } /** * Time of capture as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6). * * @return string */ public function getCreateTime() { return $this->create_time; } /** * Time that the resource was last updated. * * @param string $update_time * * @return $this */ public function setUpdateTime($update_time) { $this->update_time = $update_time; return $this; } /** * Time that the resource was last updated. * * @return string */ public function getUpdateTime() { return $this->update_time; } /** * Retrieve details about a captured payment by passing the capture_id in the request URI. * * @param string $captureId * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return Capture */ public static function get($captureId, $apiContext = null, $restCall = null) { ArgumentValidator::validate($captureId, 'captureId'); $payLoad = ""; $json = self::executeCall( "/v1/payments/capture/$captureId", "GET", $payLoad, null, $apiContext, $restCall ); $ret = new Capture(); $ret->fromJson($json); return $ret; } /** * Refund a captured payment by passing the capture_id in the request URI. In addition, include an amount object in the body of the request JSON. * * @param Refund $refund * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return Refund */ public function refund($refund, $apiContext = null, $restCall = null) { ArgumentValidator::validate($this->getId(), "Id"); ArgumentValidator::validate($refund, 'refund'); $payLoad = $refund->toJSON(); $json = self::executeCall( "/v1/payments/capture/{$this->getId()}/refund", "POST", $payLoad, null, $apiContext, $restCall ); $ret = new Refund(); $ret->fromJson($json); return $ret; } } rest-api-sdk-php/lib/PayPal/Api/OpenIdError.php 0000644 00000003474 15007532371 0015215 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class OpenIdError * * Error resource * * @property string error * @property string error_description * @property string error_uri */ class OpenIdError extends PayPalModel { /** * A single ASCII error code from the following enum. * * @param string $error * @return self */ public function setError($error) { $this->error = $error; return $this; } /** * A single ASCII error code from the following enum. * * @return string */ public function getError() { return $this->error; } /** * A resource ID that indicates the starting resource in the returned results. * * @param string $error_description * @return self */ public function setErrorDescription($error_description) { $this->error_description = $error_description; return $this; } /** * A resource ID that indicates the starting resource in the returned results. * * @return string */ public function getErrorDescription() { return $this->error_description; } /** * A URI identifying a human-readable web page with information about the error, used to provide the client developer with additional information about the error. * * @param string $error_uri * @return self */ public function setErrorUri($error_uri) { $this->error_uri = $error_uri; return $this; } /** * A URI identifying a human-readable web page with information about the error, used to provide the client developer with additional information about the error. * * @return string */ public function getErrorUri() { return $this->error_uri; } } rest-api-sdk-php/lib/PayPal/Api/FlowConfig.php 0000644 00000003614 15007532371 0015056 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; use PayPal\Validation\UrlValidator; /** * Class FlowConfig * * Parameters for flow configuration. * * @package PayPal\Api * * @property string landing_page_type * @property string bank_txn_pending_url */ class FlowConfig extends PayPalModel { /** * Type of PayPal page to be displayed when a user lands on the PayPal site for checkout. Allowed values: `Billing` or `Login`. When set to `Billing`, the Non-PayPal account landing page is used. When set to `Login`, the PayPal account login landing page is used. * * * @param string $landing_page_type * * @return $this */ public function setLandingPageType($landing_page_type) { $this->landing_page_type = $landing_page_type; return $this; } /** * Type of PayPal page to be displayed when a user lands on the PayPal site for checkout. Allowed values: `Billing` or `Login`. When set to `Billing`, the Non-PayPal account landing page is used. When set to `Login`, the PayPal account login landing page is used. * * @return string */ public function getLandingPageType() { return $this->landing_page_type; } /** * The URL on the merchant site for transferring to after a bank transfer payment. * * * @param string $bank_txn_pending_url * @throws \InvalidArgumentException * @return $this */ public function setBankTxnPendingUrl($bank_txn_pending_url) { UrlValidator::validate($bank_txn_pending_url, "BankTxnPendingUrl"); $this->bank_txn_pending_url = $bank_txn_pending_url; return $this; } /** * The URL on the merchant site for transferring to after a bank transfer payment. * * @return string */ public function getBankTxnPendingUrl() { return $this->bank_txn_pending_url; } } rest-api-sdk-php/lib/PayPal/Api/Cost.php 0000644 00000002570 15007532371 0013731 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; use PayPal\Converter\FormatConverter; use PayPal\Validation\NumericValidator; /** * Class Cost * * Cost as a percent. For example, 10% should be entered as 10. Alternatively, cost as an amount. For example, an amount of 5 should be entered as 5. * * @package PayPal\Api * * @property string percent * @property \PayPal\Api\Currency amount */ class Cost extends PayPalModel { /** * Cost in percent. Range of 0 to 100. * * @param string $percent * * @return $this */ public function setPercent($percent) { NumericValidator::validate($percent, "Percent"); $percent = FormatConverter::formatToNumber($percent); $this->percent = $percent; return $this; } /** * Cost in percent. Range of 0 to 100. * * @return string */ public function getPercent() { return $this->percent; } /** * Cost in amount. Range of 0 to 999999.99. * * @param \PayPal\Api\Currency $amount * * @return $this */ 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; } } rest-api-sdk-php/lib/PayPal/Api/Refund.php 0000644 00000014015 15007532371 0014241 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalResourceModel; use PayPal\Rest\ApiContext; use PayPal\Validation\ArgumentValidator; /** * Class Refund * * A refund transaction. * * @package PayPal\Api * * @property string id * @property \PayPal\Api\Amount amount * @property string state * @property string reason * @property string sale_id * @property string capture_id * @property string parent_payment * @property string description * @property string create_time * @property string update_time * @property \PayPal\Api\Links[] links */ class Refund extends PayPalResourceModel { /** * ID of the refund transaction. 17 characters max. * * @param string $id * * @return $this */ public function setId($id) { $this->id = $id; return $this; } /** * ID of the refund transaction. 17 characters max. * * @return string */ public function getId() { return $this->id; } /** * Details including both refunded amount (to payer) and refunded fee (to payee). 10 characters max. * * @param \PayPal\Api\Amount $amount * * @return $this */ public function setAmount($amount) { $this->amount = $amount; return $this; } /** * Details including both refunded amount (to payer) and refunded fee (to payee). 10 characters max. * * @return \PayPal\Api\Amount */ public function getAmount() { return $this->amount; } /** * State of the refund. * Valid Values: ["pending", "completed", "failed"] * * @param string $state * * @return $this */ public function setState($state) { $this->state = $state; return $this; } /** * State of the refund. * * @return string */ public function getState() { return $this->state; } /** * Reason description for the Sale transaction being refunded. * * @param string $reason * * @return $this */ public function setReason($reason) { $this->reason = $reason; return $this; } /** * Reason description for the Sale transaction being refunded. * * @return string */ public function getReason() { return $this->reason; } /** * ID of the Sale transaction being refunded. * * @param string $sale_id * * @return $this */ public function setSaleId($sale_id) { $this->sale_id = $sale_id; return $this; } /** * ID of the Sale transaction being refunded. * * @return string */ public function getSaleId() { return $this->sale_id; } /** * ID of the sale transaction being refunded. * * @param string $capture_id * * @return $this */ public function setCaptureId($capture_id) { $this->capture_id = $capture_id; return $this; } /** * ID of the sale transaction being refunded. * * @return string */ public function getCaptureId() { return $this->capture_id; } /** * ID of the payment resource on which this transaction is based. * * @param string $parent_payment * * @return $this */ public function setParentPayment($parent_payment) { $this->parent_payment = $parent_payment; return $this; } /** * ID of the payment resource on which this transaction is based. * * @return string */ public function getParentPayment() { return $this->parent_payment; } /** * Description of what is being refunded for. * * @param string $description * * @return $this */ public function setDescription($description) { $this->description = $description; return $this; } /** * Description of what is being refunded for. * * @return string */ public function getDescription() { return $this->description; } /** * Time of refund as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6). * * @param string $create_time * * @return $this */ public function setCreateTime($create_time) { $this->create_time = $create_time; return $this; } /** * Time of refund as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6). * * @return string */ public function getCreateTime() { return $this->create_time; } /** * Time that the resource was last updated. * * @param string $update_time * * @return $this */ public function setUpdateTime($update_time) { $this->update_time = $update_time; return $this; } /** * Time that the resource was last updated. * * @return string */ public function getUpdateTime() { return $this->update_time; } /** * Retrieve details about a specific refund by passing the refund_id in the request URI. * * @param string $refundId * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return Refund */ public static function get($refundId, $apiContext = null, $restCall = null) { ArgumentValidator::validate($refundId, 'refundId'); $payLoad = ""; $json = self::executeCall( "/v1/payments/refund/$refundId", "GET", $payLoad, null, $apiContext, $restCall ); $ret = new Refund(); $ret->fromJson($json); return $ret; } } rest-api-sdk-php/lib/PayPal/Api/PrivateLabelCard.php 0000644 00000006056 15007532371 0016170 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class PrivateLabelCard * * A resource representing a type of merchant branded payment card. To promote customer value (convenience and earning rewards) and retailer value (merchants drive business using the store cards), PayPal will support as payment method. * * @package PayPal\Api * * @property string id * @property string card_number * @property string issuer_id * @property string issuer_name * @property string image_key */ class PrivateLabelCard extends PayPalModel { /** * encrypted identifier of the private label card instrument. * * @param string $id * * @return $this */ public function setId($id) { $this->id = $id; return $this; } /** * encrypted identifier of the private label card instrument. * * @return string */ public function getId() { return $this->id; } /** * last 4 digits of the card number. * * @param string $card_number * * @return $this */ public function setCardNumber($card_number) { $this->card_number = $card_number; return $this; } /** * last 4 digits of the card number. * * @return string */ public function getCardNumber() { return $this->card_number; } /** * Merchants providing private label store cards have associated issuer account. This value indicates encrypted account number of the associated issuer account. * * @param string $issuer_id * * @return $this */ public function setIssuerId($issuer_id) { $this->issuer_id = $issuer_id; return $this; } /** * Merchants providing private label store cards have associated issuer account. This value indicates encrypted account number of the associated issuer account. * * @return string */ public function getIssuerId() { return $this->issuer_id; } /** * Merchants providing private label store cards have associated issuer account. This value indicates name on the issuer account. * * @param string $issuer_name * * @return $this */ public function setIssuerName($issuer_name) { $this->issuer_name = $issuer_name; return $this; } /** * Merchants providing private label store cards have associated issuer account. This value indicates name on the issuer account. * * @return string */ public function getIssuerName() { return $this->issuer_name; } /** * This value indicates URL to access PLCC program logo image * * @param string $image_key * * @return $this */ public function setImageKey($image_key) { $this->image_key = $image_key; return $this; } /** * This value indicates URL to access PLCC program logo image * * @return string */ public function getImageKey() { return $this->image_key; } } rest-api-sdk-php/lib/PayPal/Api/AgreementTransaction.php 0000644 00000011435 15007532371 0017136 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class AgreementTransaction * * A resource representing an agreement_transaction that is returned during a transaction search. * * @package PayPal\Api * * @property string transaction_id * @property string status * @property string transaction_type * @property \PayPal\Api\Currency amount * @property \PayPal\Api\Currency fee_amount * @property \PayPal\Api\Currency net_amount * @property string payer_email * @property string payer_name * @property string time_stamp * @property string time_zone */ class AgreementTransaction extends PayPalModel { /** * Id corresponding to this transaction. * * @param string $transaction_id * * @return $this */ public function setTransactionId($transaction_id) { $this->transaction_id = $transaction_id; return $this; } /** * Id corresponding to this transaction. * * @return string */ public function getTransactionId() { return $this->transaction_id; } /** * State of the subscription at this time. * * @param string $status * * @return $this */ public function setStatus($status) { $this->status = $status; return $this; } /** * State of the subscription at this time. * * @return string */ public function getStatus() { return $this->status; } /** * Type of transaction, usually Recurring Payment. * * @param string $transaction_type * * @return $this */ public function setTransactionType($transaction_type) { $this->transaction_type = $transaction_type; return $this; } /** * Type of transaction, usually Recurring Payment. * * @return string */ public function getTransactionType() { return $this->transaction_type; } /** * Amount for this transaction. * * @param \PayPal\Api\Currency $amount * * @return $this */ public function setAmount($amount) { $this->amount = $amount; return $this; } /** * Amount for this transaction. * * @return \PayPal\Api\Currency */ public function getAmount() { return $this->amount; } /** * Fee amount for this transaction. * * @param \PayPal\Api\Currency $fee_amount * * @return $this */ public function setFeeAmount($fee_amount) { $this->fee_amount = $fee_amount; return $this; } /** * Fee amount for this transaction. * * @return \PayPal\Api\Currency */ public function getFeeAmount() { return $this->fee_amount; } /** * Net amount for this transaction. * * @param \PayPal\Api\Currency $net_amount * * @return $this */ public function setNetAmount($net_amount) { $this->net_amount = $net_amount; return $this; } /** * Net amount for this transaction. * * @return \PayPal\Api\Currency */ public function getNetAmount() { return $this->net_amount; } /** * Email id of payer. * * @param string $payer_email * * @return $this */ public function setPayerEmail($payer_email) { $this->payer_email = $payer_email; return $this; } /** * Email id of payer. * * @return string */ public function getPayerEmail() { return $this->payer_email; } /** * Business name of payer. * * @param string $payer_name * * @return $this */ public function setPayerName($payer_name) { $this->payer_name = $payer_name; return $this; } /** * Business name of payer. * * @return string */ public function getPayerName() { return $this->payer_name; } /** * Time at which this transaction happened. * * @param string $time_stamp * * @return $this */ public function setTimeStamp($time_stamp) { $this->time_stamp = $time_stamp; return $this; } /** * Time at which this transaction happened. * * @return string */ public function getTimeStamp() { return $this->time_stamp; } /** * Time zone of time_updated field. * * @param string $time_zone * * @return $this */ public function setTimeZone($time_zone) { $this->time_zone = $time_zone; return $this; } /** * Time zone of time_updated field. * * @return string */ public function getTimeZone() { return $this->time_zone; } } rest-api-sdk-php/lib/PayPal/Api/ItemList.php 0000644 00000007064 15007532371 0014556 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class ItemList * * Items and related shipping address within a transaction. * * @package PayPal\Api * * @property \PayPal\Api\Item[] items * @property \PayPal\Api\ShippingAddress shipping_address * @property string shipping_method * @property string shipping_phone_number */ class ItemList extends PayPalModel { /** * List of items. * * @param \PayPal\Api\Item[] $items * * @return $this */ public function setItems($items) { $this->items = $items; return $this; } /** * List of items. * * @return \PayPal\Api\Item[] */ public function getItems() { return $this->items; } /** * Append Items to the list. * * @param \PayPal\Api\Item $item * @return $this */ public function addItem($item) { if (!$this->getItems()) { return $this->setItems(array($item)); } else { return $this->setItems( array_merge($this->getItems(), array($item)) ); } } /** * Remove Items from the list. * * @param \PayPal\Api\Item $item * @return $this */ public function removeItem($item) { return $this->setItems( array_diff($this->getItems(), array($item)) ); } /** * Shipping address, if different than the payer address. * * @param \PayPal\Api\ShippingAddress $shipping_address * * @return $this */ public function setShippingAddress($shipping_address) { $this->shipping_address = $shipping_address; return $this; } /** * Shipping address, if different than the payer address. * * @return \PayPal\Api\ShippingAddress */ public function getShippingAddress() { return $this->shipping_address; } /** * Shipping method used for this payment like USPSParcel etc. * * @param string $shipping_method * * @return $this */ public function setShippingMethod($shipping_method) { $this->shipping_method = $shipping_method; return $this; } /** * Shipping method used for this payment like USPSParcel etc. * * @return string */ public function getShippingMethod() { return $this->shipping_method; } /** * Allows merchant's to share payer’s contact number with PayPal for the current payment. Final contact number of payer associated with the transaction might be same as shipping_phone_number or different based on Payer’s action on PayPal. The phone number must be represented in its canonical international format, as defined by the E.164 numbering plan * * @param string $shipping_phone_number * * @return $this */ public function setShippingPhoneNumber($shipping_phone_number) { $this->shipping_phone_number = $shipping_phone_number; return $this; } /** * Allows merchant's to share payer’s contact number with PayPal for the current payment. Final contact number of payer associated with the transaction might be same as shipping_phone_number or different based on Payer’s action on PayPal. The phone number must be represented in its canonical international format, as defined by the E.164 numbering plan * * @return string */ public function getShippingPhoneNumber() { return $this->shipping_phone_number; } } rest-api-sdk-php/lib/PayPal/Api/OpenIdTokeninfo.php 0000644 00000017774 15007532371 0016070 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalResourceModel; use PayPal\Rest\ApiContext; use PayPal\Transport\PayPalRestCall; /** * Class OpenIdTokeninfo * * Token grant resource * * @property string scope * @property string access_token * @property string refresh_token * @property string token_type * @property string id_token * @property int expires_in */ class OpenIdTokeninfo extends PayPalResourceModel { /** * OPTIONAL, if identical to the scope requested by the client; otherwise, REQUIRED. * * @param string $scope * @return self */ public function setScope($scope) { $this->scope = $scope; return $this; } /** * OPTIONAL, if identical to the scope requested by the client; otherwise, REQUIRED. * * @return string */ public function getScope() { return $this->scope; } /** * The access token issued by the authorization server. * * @param string $access_token * @return self */ public function setAccessToken($access_token) { $this->access_token = $access_token; return $this; } /** * The access token issued by the authorization server. * * @return string */ public function getAccessToken() { return $this->access_token; } /** * The refresh token, which can be used to obtain new access tokens using the same authorization grant as described in OAuth2.0 RFC6749 in Section 6. * * @param string $refresh_token * @return self */ public function setRefreshToken($refresh_token) { $this->refresh_token = $refresh_token; return $this; } /** * The refresh token, which can be used to obtain new access tokens using the same authorization grant as described in OAuth2.0 RFC6749 in Section 6. * * @return string */ public function getRefreshToken() { return $this->refresh_token; } /** * The type of the token issued as described in OAuth2.0 RFC6749 (Section 7.1). Value is case insensitive. * * @param string $token_type * @return self */ public function setTokenType($token_type) { $this->token_type = $token_type; return $this; } /** * The type of the token issued as described in OAuth2.0 RFC6749 (Section 7.1). Value is case insensitive. * * @return string */ public function getTokenType() { return $this->token_type; } /** * The id_token is a session token assertion that denotes the user's authentication status * * @param string $id_token * @return self */ public function setIdToken($id_token) { $this->id_token = $id_token; return $this; } /** * The id_token is a session token assertion that denotes the user's authentication status * * @return string */ public function getIdToken() { return $this->id_token; } /** * The lifetime in seconds of the access token. * * @param integer $expires_in * @return self */ public function setExpiresIn($expires_in) { $this->expires_in = $expires_in; return $this; } /** * The lifetime in seconds of the access token. * * @return integer */ public function getExpiresIn() { return $this->expires_in; } /** * Creates an Access Token from an Authorization Code. * * @path /v1/identity/openidconnect/tokenservice * @method POST * @param array $params (allowed values are client_id, client_secret, grant_type, code and redirect_uri) * (required) client_id from developer portal * (required) client_secret from developer portal * (required) code is Authorization code previously received from the authorization server * (required) redirect_uri Redirection endpoint that must match the one provided during the * authorization request that ended in receiving the authorization code. * (optional) grant_type is the Token grant type. Defaults to authorization_code * @param string $clientId * @param string $clientSecret * @param ApiContext $apiContext Optional API Context * @param PayPalRestCall $restCall * @return OpenIdTokeninfo */ public static function createFromAuthorizationCode($params, $clientId = null, $clientSecret = null, $apiContext = null, $restCall = null) { static $allowedParams = array('grant_type' => 1, 'code' => 1, 'redirect_uri' => 1); if (!array_key_exists('grant_type', $params)) { $params['grant_type'] = 'authorization_code'; } $apiContext = $apiContext ? $apiContext : new ApiContext(self::$credential); if (sizeof($apiContext->get($clientId)) > 0) { $clientId = $apiContext->get($clientId); } if (sizeof($apiContext->get($clientSecret)) > 0) { $clientSecret = $apiContext->get($clientSecret); } $clientId = $clientId ? $clientId : $apiContext->getCredential()->getClientId(); $clientSecret = $clientSecret ? $clientSecret : $apiContext->getCredential()->getClientSecret(); $json = self::executeCall( "/v1/identity/openidconnect/tokenservice", "POST", http_build_query(array_intersect_key($params, $allowedParams)), array( 'Content-Type' => 'application/x-www-form-urlencoded', 'Authorization' => 'Basic ' . base64_encode($clientId . ":" . $clientSecret) ), $apiContext, $restCall ); $token = new OpenIdTokeninfo(); $token->fromJson($json); return $token; } /** * Creates an Access Token from an Refresh Token. * * @path /v1/identity/openidconnect/tokenservice * @method POST * @param array $params (allowed values are grant_type and scope) * (required) client_id from developer portal * (required) client_secret from developer portal * (optional) refresh_token refresh token. If one is not passed, refresh token from the current object is used. * (optional) grant_type is the Token grant type. Defaults to refresh_token * (optional) scope is an array that either the same or a subset of the scope passed to the authorization request * @param APIContext $apiContext Optional API Context * @return OpenIdTokeninfo */ public function createFromRefreshToken($params, $apiContext = null) { static $allowedParams = array('grant_type' => 1, 'refresh_token' => 1, 'scope' => 1); $apiContext = $apiContext ? $apiContext : new ApiContext(self::$credential); if (!array_key_exists('grant_type', $params)) { $params['grant_type'] = 'refresh_token'; } if (!array_key_exists('refresh_token', $params)) { $params['refresh_token'] = $this->getRefreshToken(); } $clientId = isset($params['client_id']) ? $params['client_id'] : $apiContext->getCredential()->getClientId(); $clientSecret = isset($params['client_secret']) ? $params['client_secret'] : $apiContext->getCredential()->getClientSecret(); $json = self::executeCall( "/v1/identity/openidconnect/tokenservice", "POST", http_build_query(array_intersect_key($params, $allowedParams)), array( 'Content-Type' => 'application/x-www-form-urlencoded', 'Authorization' => 'Basic ' . base64_encode($clientId . ":" . $clientSecret) ), $apiContext ); $this->fromJson($json); return $this; } } rest-api-sdk-php/lib/PayPal/Api/PaymentInstruction.php 0000644 00000011066 15007532371 0016700 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalResourceModel; use PayPal\Rest\ApiContext; use PayPal\Validation\ArgumentValidator; /** * Class PaymentInstruction * * Contain details of how and when the payment should be made to PayPal in cases of manual bank transfer. * * @package PayPal\Api * * @property string reference_number * @property string instruction_type * @property \PayPal\Api\RecipientBankingInstruction recipient_banking_instruction * @property \PayPal\Api\Currency amount * @property string payment_due_date * @property string note * @property \PayPal\Api\Links[] links */ class PaymentInstruction extends PayPalResourceModel { /** * ID of payment instruction * * @param string $reference_number * * @return $this */ public function setReferenceNumber($reference_number) { $this->reference_number = $reference_number; return $this; } /** * ID of payment instruction * * @return string */ public function getReferenceNumber() { return $this->reference_number; } /** * Type of payment instruction * Valid Values: ["MANUAL_BANK_TRANSFER", "PAY_UPON_INVOICE"] * * @param string $instruction_type * * @return $this */ public function setInstructionType($instruction_type) { $this->instruction_type = $instruction_type; return $this; } /** * Type of payment instruction * * @return string */ public function getInstructionType() { return $this->instruction_type; } /** * Recipient bank Details. * * @param \PayPal\Api\RecipientBankingInstruction $recipient_banking_instruction * * @return $this */ public function setRecipientBankingInstruction($recipient_banking_instruction) { $this->recipient_banking_instruction = $recipient_banking_instruction; return $this; } /** * Recipient bank Details. * * @return \PayPal\Api\RecipientBankingInstruction */ public function getRecipientBankingInstruction() { return $this->recipient_banking_instruction; } /** * Amount to be transferred * * @param \PayPal\Api\Currency $amount * * @return $this */ public function setAmount($amount) { $this->amount = $amount; return $this; } /** * Amount to be transferred * * @return \PayPal\Api\Currency */ public function getAmount() { return $this->amount; } /** * Date by which payment should be received * * @param string $payment_due_date * * @return $this */ public function setPaymentDueDate($payment_due_date) { $this->payment_due_date = $payment_due_date; return $this; } /** * Date by which payment should be received * * @return string */ public function getPaymentDueDate() { return $this->payment_due_date; } /** * Additional text regarding payment handling * * @param string $note * * @return $this */ public function setNote($note) { $this->note = $note; return $this; } /** * Additional text regarding payment handling * * @return string */ public function getNote() { return $this->note; } /** * Retrieve a payment instruction by passing the payment_id in the request URI. Use this request if you are implementing a solution that includes delayed payment like Pay Upon Invoice (PUI). * * @param string $paymentId * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return PaymentInstruction */ public static function get($paymentId, $apiContext = null, $restCall = null) { ArgumentValidator::validate($paymentId, 'paymentId'); $payLoad = ""; $json = self::executeCall( "/v1/payments/payment/$paymentId/payment-instruction", "GET", $payLoad, null, $apiContext, $restCall ); $ret = new PaymentInstruction(); $ret->fromJson($json); return $ret; } } rest-api-sdk-php/lib/PayPal/Api/Payee.php 0000644 00000007433 15007532371 0014067 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class Payee * * A resource representing a Payee who receives the funds and fulfills the order. * * @package PayPal\Api * * @property string email * @property string merchant_id */ class Payee extends PayPalModel { /** * Email Address associated with the Payee's PayPal Account. If the provided email address is not associated with any PayPal Account, the payee can only receiver PayPal Wallet Payments. Direct Credit Card Payments will be denied due to card compliance requirements. * * @param string $email * * @return $this */ public function setEmail($email) { $this->email = $email; return $this; } /** * Email Address associated with the Payee's PayPal Account. If the provided email address is not associated with any PayPal Account, the payee can only receiver PayPal Wallet Payments. Direct Credit Card Payments will be denied due to card compliance requirements. * * @return string */ public function getEmail() { return $this->email; } /** * Encrypted PayPal account identifier for the Payee. * * @param string $merchant_id * * @return $this */ public function setMerchantId($merchant_id) { $this->merchant_id = $merchant_id; return $this; } /** * Encrypted PayPal account identifier for the Payee. * * @return string */ public function getMerchantId() { return $this->merchant_id; } /** * First Name of the Payee. * * @deprecated Not publicly available * @param string $first_name * * @return $this */ public function setFirstName($first_name) { $this->first_name = $first_name; return $this; } /** * First Name of the Payee. * * @deprecated Not publicly available * @return string */ public function getFirstName() { return $this->first_name; } /** * Last Name of the Payee. * * @deprecated Not publicly available * @param string $last_name * * @return $this */ public function setLastName($last_name) { $this->last_name = $last_name; return $this; } /** * Last Name of the Payee. * * @deprecated Not publicly available * @return string */ public function getLastName() { return $this->last_name; } /** * Unencrypted PayPal account Number of the Payee * * @deprecated Not publicly available * @param string $account_number * * @return $this */ public function setAccountNumber($account_number) { $this->account_number = $account_number; return $this; } /** * Unencrypted PayPal account Number of the Payee * * @deprecated Not publicly available * @return string */ public function getAccountNumber() { return $this->account_number; } /** * Information related to the Payer. In case of PayPal Wallet payment, this information will be filled in by PayPal after the user approves the payment using their PayPal Wallet. * * @deprecated Not publicly available * @param \PayPal\Api\Phone $phone * * @return $this */ public function setPhone($phone) { $this->phone = $phone; return $this; } /** * Information related to the Payer. In case of PayPal Wallet payment, this information will be filled in by PayPal after the user approves the payment using their PayPal Wallet. * * @deprecated Not publicly available * @return \PayPal\Api\Phone */ public function getPhone() { return $this->phone; } } rest-api-sdk-php/lib/PayPal/Api/ShippingAddress.php 0000644 00000004057 15007532371 0016112 0 ustar 00 <?php namespace PayPal\Api; /** * Class ShippingAddress * * Extended Address object used as shipping address in a payment. * * @package PayPal\Api * * @property string id * @property string recipient_name * @property bool default_address * @property bool preferred_address */ class ShippingAddress extends Address { /** * Address ID assigned in PayPal system. * * @param string $id * * @return $this */ public function setId($id) { $this->id = $id; return $this; } /** * Address ID assigned in PayPal system. * * @return string */ public function getId() { return $this->id; } /** * Name of the recipient at this address. * * @param string $recipient_name * * @return $this */ public function setRecipientName($recipient_name) { $this->recipient_name = $recipient_name; return $this; } /** * Name of the recipient at this address. * * @return string */ public function getRecipientName() { return $this->recipient_name; } /** * Default shipping address of the Payer. * * @param bool $default_address * * @return $this */ public function setDefaultAddress($default_address) { $this->default_address = $default_address; return $this; } /** * Default shipping address of the Payer. * * @return bool */ public function getDefaultAddress() { return $this->default_address; } /** * Shipping Address marked as preferred by Payer. * * @param bool $preferred_address * * @return $this */ public function setPreferredAddress($preferred_address) { $this->preferred_address = $preferred_address; return $this; } /** * Shipping Address marked as preferred by Payer. * * @return bool */ public function getPreferredAddress() { return $this->preferred_address; } } rest-api-sdk-php/lib/PayPal/Api/WebhookEvent.php 0000644 00000020775 15007532371 0015430 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalResourceModel; use PayPal\Exception\PayPalConnectionException; use PayPal\Rest\ApiContext; use PayPal\Transport\PayPalRestCall; use PayPal\Validation\ArgumentValidator; use PayPal\Validation\JsonValidator; /** * Class WebhookEvent * * Represents a Webhooks event * * @package PayPal\Api * * @property string id * @property string create_time * @property string resource_type * @property string event_type * @property string summary * @property mixed resource */ class WebhookEvent extends PayPalResourceModel { /** * Identifier of the Webhooks event resource. * * @param string $id * * @return $this */ public function setId($id) { $this->id = $id; return $this; } /** * Identifier of the Webhooks event resource. * * @return string */ public function getId() { return $this->id; } /** * Time the resource was created. * * @param string $create_time * * @return $this */ public function setCreateTime($create_time) { $this->create_time = $create_time; return $this; } /** * Time the resource was created. * * @return string */ public function getCreateTime() { return $this->create_time; } /** * Name of the resource contained in resource element. * * @param string $resource_type * * @return $this */ public function setResourceType($resource_type) { $this->resource_type = $resource_type; return $this; } /** * Name of the resource contained in resource element. * * @return string */ public function getResourceType() { return $this->resource_type; } /** * Name of the event type that occurred on resource, identified by data_resource element, to trigger the Webhooks event. * * @param string $event_type * * @return $this */ public function setEventType($event_type) { $this->event_type = $event_type; return $this; } /** * Name of the event type that occurred on resource, identified by data_resource element, to trigger the Webhooks event. * * @return string */ public function getEventType() { return $this->event_type; } /** * A summary description of the event. E.g. A successful payment authorization was created for $$ * * @param string $summary * * @return $this */ public function setSummary($summary) { $this->summary = $summary; return $this; } /** * A summary description of the event. E.g. A successful payment authorization was created for $$ * * @return string */ public function getSummary() { return $this->summary; } /** * This contains the resource that is identified by resource_type element. * * @param \PayPal\Common\PayPalModel $resource * * @return $this */ public function setResource($resource) { $this->resource = $resource; return $this; } /** * This contains the resource that is identified by resource_type element. * * @return \PayPal\Common\PayPalModel */ public function getResource() { return $this->resource; } /** * Validates Received Event from Webhook, and returns the webhook event object. Because security verifications by verifying certificate chain is not enabled in PHP yet, * we need to fallback to default behavior of retrieving the ID attribute of the data, and make a separate GET call to PayPal APIs, to retrieve the data. * This is important to do again, as hacker could have faked the data, and the retrieved data cannot be trusted without either doing client side security validation, or making a separate call * to PayPal APIs to retrieve the actual data. This limits the hacker to mimick a fake data, as hacker wont be able to predict the Id correctly. * * NOTE: PLEASE DO NOT USE THE DATA PROVIDED IN WEBHOOK DIRECTLY, AS HACKER COULD PASS IN FAKE DATA. IT IS VERY IMPORTANT THAT YOU RETRIEVE THE ID AND MAKE A SEPARATE CALL TO PAYPAL API. * * @param string $body * @param ApiContext $apiContext * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return WebhookEvent * @throws \InvalidArgumentException if input arguments are incorrect, or Id is not found. * @throws PayPalConnectionException if any exception from PayPal APIs other than not found is sent. */ public static function validateAndGetReceivedEvent($body, $apiContext = null, $restCall = null) { if ($body == null | empty($body)){ throw new \InvalidArgumentException("Body cannot be null or empty"); } if (!JsonValidator::validate($body, true)) { throw new \InvalidArgumentException("Request Body is not a valid JSON."); } $object = new WebhookEvent($body); if ($object->getId() == null) { throw new \InvalidArgumentException("Id attribute not found in JSON. Possible reason could be invalid JSON Object"); } try { return self::get($object->getId(), $apiContext, $restCall); } catch(PayPalConnectionException $ex) { if ($ex->getCode() == 404) { // It means that the given webhook event Id is not found for this merchant. throw new \InvalidArgumentException("Webhook Event Id provided in the data is incorrect. This could happen if anyone other than PayPal is faking the incoming webhook data."); } throw $ex; } } /** * Retrieves the Webhooks event resource identified by event_id. Can be used to retrieve the payload for an event. * * @param string $eventId * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return WebhookEvent */ public static function get($eventId, $apiContext = null, $restCall = null) { ArgumentValidator::validate($eventId, 'eventId'); $payLoad = ""; $json = self::executeCall( "/v1/notifications/webhooks-events/$eventId", "GET", $payLoad, null, $apiContext, $restCall ); $ret = new WebhookEvent(); $ret->fromJson($json); return $ret; } /** * Resends the Webhooks event resource identified by event_id. * * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return WebhookEvent */ public function resend($apiContext = null, $restCall = null) { ArgumentValidator::validate($this->getId(), "Id"); $payLoad = ""; $json = self::executeCall( "/v1/notifications/webhooks-events/{$this->getId()}/resend", "POST", $payLoad, null, $apiContext, $restCall ); $this->fromJson($json); return $this; } /** * Retrieves the list of Webhooks events resources for the application associated with token. The developers can use it to see list of past webhooks events. * * @param array $params * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return WebhookEventList */ public static function all($params, $apiContext = null, $restCall = null) { ArgumentValidator::validate($params, 'params'); $payLoad = ""; $allowedParams = array( 'page_size' => 1, 'start_time' => 1, 'end_time' => 1, ); $json = self::executeCall( "/v1/notifications/webhooks-events" . "?" . http_build_query(array_intersect_key($params, $allowedParams)), "GET", $payLoad, null, $apiContext, $restCall ); $ret = new WebhookEventList(); $ret->fromJson($json); return $ret; } } rest-api-sdk-php/lib/PayPal/Api/Transaction.php 0000644 00000002443 15007532371 0015305 0 ustar 00 <?php namespace PayPal\Api; /** * Class Transaction * * A transaction defines the contract of a payment - what is the payment for and who is fulfilling it. * * @package PayPal\Api * */ class Transaction extends TransactionBase { /** * Additional transactions for complex payment scenarios. * * * @param self $transactions * * @return $this */ public function setTransactions($transactions) { $this->transactions = $transactions; return $this; } /** * Additional transactions for complex payment scenarios. * * @return self[] */ public function getTransactions() { return $this->transactions; } /** * Identifier to the purchase unit corresponding to this sale transaction * * @param string $purchase_unit_reference_id * * @return $this */ public function setPurchaseUnitReferenceId($purchase_unit_reference_id) { $this->purchase_unit_reference_id = $purchase_unit_reference_id; return $this; } /** * Identifier to the purchase unit corresponding to this sale transaction * * @return string */ public function getPurchaseUnitReferenceId() { return $this->purchase_unit_reference_id; } } rest-api-sdk-php/lib/PayPal/Api/PotentialPayerInfo.php 0000644 00000004457 15007532371 0016603 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class PotentialPayerInfo * * A resource representing a information about a potential Payer. * * @package PayPal\Api * * @property string email * @property string external_remember_me_id * @property \PayPal\Api\Address billing_address */ class PotentialPayerInfo extends PayPalModel { /** * Email address representing the potential payer. * * @param string $email * * @return $this */ public function setEmail($email) { $this->email = $email; return $this; } /** * Email address representing the potential payer. * * @return string */ public function getEmail() { return $this->email; } /** * ExternalRememberMe id representing the potential payer * * @param string $external_remember_me_id * * @return $this */ public function setExternalRememberMeId($external_remember_me_id) { $this->external_remember_me_id = $external_remember_me_id; return $this; } /** * ExternalRememberMe id representing the potential payer * * @return string */ public function getExternalRememberMeId() { return $this->external_remember_me_id; } /** * Account Number representing the potential payer * @deprecated Not publicly available * @param string $account_number * * @return $this */ public function setAccountNumber($account_number) { $this->account_number = $account_number; return $this; } /** * Account Number representing the potential payer * @deprecated Not publicly available * @return string */ public function getAccountNumber() { return $this->account_number; } /** * Billing address of the potential payer. * * @param \PayPal\Api\Address $billing_address * * @return $this */ public function setBillingAddress($billing_address) { $this->billing_address = $billing_address; return $this; } /** * Billing address of the potential payer. * * @return \PayPal\Api\Address */ public function getBillingAddress() { return $this->billing_address; } } rest-api-sdk-php/lib/PayPal/Api/Incentive.php 0000644 00000010667 15007532371 0014753 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; use PayPal\Validation\UrlValidator; /** * Class Incentive * * A resource representing a incentive. * * @package PayPal\Api * * @property string id * @property string code * @property string name * @property string description * @property \PayPal\Api\Currency minimum_purchase_amount * @property string logo_image_url * @property string expiry_date * @property string type * @property string terms */ class Incentive extends PayPalModel { /** * Identifier of the instrument in PayPal Wallet * * @param string $id * * @return $this */ public function setId($id) { $this->id = $id; return $this; } /** * Identifier of the instrument in PayPal Wallet * * @return string */ public function getId() { return $this->id; } /** * Code that identifies the incentive. * * @param string $code * * @return $this */ public function setCode($code) { $this->code = $code; return $this; } /** * Code that identifies the incentive. * * @return string */ public function getCode() { return $this->code; } /** * Name of the incentive. * * @param string $name * * @return $this */ public function setName($name) { $this->name = $name; return $this; } /** * Name of the incentive. * * @return string */ public function getName() { return $this->name; } /** * Description of the incentive. * * @param string $description * * @return $this */ public function setDescription($description) { $this->description = $description; return $this; } /** * Description of the incentive. * * @return string */ public function getDescription() { return $this->description; } /** * Indicates incentive is applicable for this minimum purchase amount. * * @param \PayPal\Api\Currency $minimum_purchase_amount * * @return $this */ public function setMinimumPurchaseAmount($minimum_purchase_amount) { $this->minimum_purchase_amount = $minimum_purchase_amount; return $this; } /** * Indicates incentive is applicable for this minimum purchase amount. * * @return \PayPal\Api\Currency */ public function getMinimumPurchaseAmount() { return $this->minimum_purchase_amount; } /** * Logo image url for the incentive. * * @param string $logo_image_url * @throws \InvalidArgumentException * @return $this */ public function setLogoImageUrl($logo_image_url) { UrlValidator::validate($logo_image_url, "LogoImageUrl"); $this->logo_image_url = $logo_image_url; return $this; } /** * Logo image url for the incentive. * * @return string */ public function getLogoImageUrl() { return $this->logo_image_url; } /** * expiry date of the incentive. * * @param string $expiry_date * * @return $this */ public function setExpiryDate($expiry_date) { $this->expiry_date = $expiry_date; return $this; } /** * expiry date of the incentive. * * @return string */ public function getExpiryDate() { return $this->expiry_date; } /** * Specifies type of incentive * Valid Values: ["COUPON", "GIFT_CARD", "MERCHANT_SPECIFIC_BALANCE", "VOUCHER"] * * @param string $type * * @return $this */ public function setType($type) { $this->type = $type; return $this; } /** * Specifies type of incentive * * @return string */ public function getType() { return $this->type; } /** * URI to the associated terms * * @param string $terms * * @return $this */ public function setTerms($terms) { $this->terms = $terms; return $this; } /** * URI to the associated terms * * @return string */ public function getTerms() { return $this->terms; } } rest-api-sdk-php/lib/PayPal/Api/BillingAgreementToken.php 0000644 00000000466 15007532371 0017234 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class BillingAgreementToken * * PayPal generated billing agreement token. It is a token returned by /v1/billing-agreements/agreement-token API end point. * * @package PayPal\Api * */ class BillingAgreementToken extends PayPalModel { } rest-api-sdk-php/lib/PayPal/Api/CurrencyConversion.php 0000644 00000012776 15007532371 0016672 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; use PayPal\Validation\UrlValidator; /** * Class CurrencyConversion * * Object used to store the currency conversion rate. * * @package PayPal\Api * * @property string conversion_date * @property string from_currency * @property string from_amount * @property string to_currency * @property string to_amount * @property string conversion_type * @property bool conversion_type_changeable * @property \PayPal\Api\Links[] links */ class CurrencyConversion extends PayPalModel { /** * Date of validity for the conversion rate. * * @param string $conversion_date * * @return $this */ public function setConversionDate($conversion_date) { $this->conversion_date = $conversion_date; return $this; } /** * Date of validity for the conversion rate. * * @return string */ public function getConversionDate() { return $this->conversion_date; } /** * 3 letter currency code * * @param string $from_currency * * @return $this */ public function setFromCurrency($from_currency) { $this->from_currency = $from_currency; return $this; } /** * 3 letter currency code * * @return string */ public function getFromCurrency() { return $this->from_currency; } /** * Amount participating in currency conversion, set to 1 as default * * @param string $from_amount * * @return $this */ public function setFromAmount($from_amount) { $this->from_amount = $from_amount; return $this; } /** * Amount participating in currency conversion, set to 1 as default * * @return string */ public function getFromAmount() { return $this->from_amount; } /** * 3 letter currency code * * @param string $to_currency * * @return $this */ public function setToCurrency($to_currency) { $this->to_currency = $to_currency; return $this; } /** * 3 letter currency code * * @return string */ public function getToCurrency() { return $this->to_currency; } /** * Amount resulting from currency conversion. * * @param string $to_amount * * @return $this */ public function setToAmount($to_amount) { $this->to_amount = $to_amount; return $this; } /** * Amount resulting from currency conversion. * * @return string */ public function getToAmount() { return $this->to_amount; } /** * Field indicating conversion type applied. * Valid Values: ["PAYPAL", "VENDOR"] * * @param string $conversion_type * * @return $this */ public function setConversionType($conversion_type) { $this->conversion_type = $conversion_type; return $this; } /** * Field indicating conversion type applied. * * @return string */ public function getConversionType() { return $this->conversion_type; } /** * Allow Payer to change conversion type. * * @param bool $conversion_type_changeable * * @return $this */ public function setConversionTypeChangeable($conversion_type_changeable) { $this->conversion_type_changeable = $conversion_type_changeable; return $this; } /** * Allow Payer to change conversion type. * * @return bool */ public function getConversionTypeChangeable() { return $this->conversion_type_changeable; } /** * Base URL to web applications endpoint * Valid Values: ["https://www.paypal.com/{country_code}/webapps/xocspartaweb/webflow/sparta/proxwebflow", "https://www.paypal.com/{country_code}/proxflow"] * * @deprecated Not publicly available * @param string $web_url * @throws \InvalidArgumentException * @return $this */ public function setWebUrl($web_url) { UrlValidator::validate($web_url, "WebUrl"); $this->web_url = $web_url; return $this; } /** * Base URL to web applications endpoint * * @deprecated Not publicly available * @return string */ public function getWebUrl() { return $this->web_url; } /** * Sets Links * * @param \PayPal\Api\Links[] $links * * @return $this */ public function setLinks($links) { $this->links = $links; return $this; } /** * Gets Links * * @return \PayPal\Api\Links[] */ public function getLinks() { return $this->links; } /** * Append Links to the list. * * @param \PayPal\Api\Links $links * @return $this */ public function addLink($links) { if (!$this->getLinks()) { return $this->setLinks(array($links)); } else { return $this->setLinks( array_merge($this->getLinks(), array($links)) ); } } /** * Remove Links from the list. * * @param \PayPal\Api\Links $links * @return $this */ public function removeLink($links) { return $this->setLinks( array_diff($this->getLinks(), array($links)) ); } } rest-api-sdk-php/lib/PayPal/Api/PayerInfo.php 0000644 00000021204 15007532371 0014710 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class PayerInfo * * A resource representing a information about Payer. * * @package PayPal\Api * * @property string email * @property string external_remember_me_id * @property string salutation * @property string first_name * @property string middle_name * @property string last_name * @property string suffix * @property string payer_id * @property string phone * @property string phone_type * @property string birth_date * @property string tax_id * @property string tax_id_type * @property string country_code * @property \PayPal\Api\Address billing_address * @property \PayPal\Api\ShippingAddress shipping_address */ class PayerInfo extends PayPalModel { /** * Email address representing the payer. 127 characters max. * * @param string $email * * @return $this */ public function setEmail($email) { $this->email = $email; return $this; } /** * Email address representing the payer. 127 characters max. * * @return string */ public function getEmail() { return $this->email; } /** * External Remember Me id representing the payer * * @param string $external_remember_me_id * * @return $this */ public function setExternalRememberMeId($external_remember_me_id) { $this->external_remember_me_id = $external_remember_me_id; return $this; } /** * External Remember Me id representing the payer * * @return string */ public function getExternalRememberMeId() { return $this->external_remember_me_id; } /** * Account Number representing the Payer * * @deprecated Not publicly available * @param string $account_number * * @return $this */ public function setAccountNumber($account_number) { $this->account_number = $account_number; return $this; } /** * Account Number representing the Payer * * @deprecated Not publicly available * @return string */ public function getAccountNumber() { return $this->account_number; } /** * Salutation of the payer. * * @param string $salutation * * @return $this */ public function setSalutation($salutation) { $this->salutation = $salutation; return $this; } /** * Salutation of the payer. * * @return string */ public function getSalutation() { return $this->salutation; } /** * First name of the payer. * * @param string $first_name * * @return $this */ public function setFirstName($first_name) { $this->first_name = $first_name; return $this; } /** * First name of the payer. * * @return string */ public function getFirstName() { return $this->first_name; } /** * Middle name of the payer. * * @param string $middle_name * * @return $this */ public function setMiddleName($middle_name) { $this->middle_name = $middle_name; return $this; } /** * Middle name of the payer. * * @return string */ public function getMiddleName() { return $this->middle_name; } /** * Last name of the payer. * * @param string $last_name * * @return $this */ public function setLastName($last_name) { $this->last_name = $last_name; return $this; } /** * Last name of the payer. * * @return string */ public function getLastName() { return $this->last_name; } /** * Suffix of the payer. * * @param string $suffix * * @return $this */ public function setSuffix($suffix) { $this->suffix = $suffix; return $this; } /** * Suffix of the payer. * * @return string */ public function getSuffix() { return $this->suffix; } /** * PayPal assigned encrypted Payer ID. * * @param string $payer_id * * @return $this */ public function setPayerId($payer_id) { $this->payer_id = $payer_id; return $this; } /** * PayPal assigned encrypted Payer ID. * * @return string */ public function getPayerId() { return $this->payer_id; } /** * Phone number representing the payer. 20 characters max. * * @param string $phone * * @return $this */ public function setPhone($phone) { $this->phone = $phone; return $this; } /** * Phone number representing the payer. 20 characters max. * * @return string */ public function getPhone() { return $this->phone; } /** * Phone type * Valid Values: ["HOME", "WORK", "MOBILE", "OTHER"] * * @param string $phone_type * * @return $this */ public function setPhoneType($phone_type) { $this->phone_type = $phone_type; return $this; } /** * Phone type * * @return string */ public function getPhoneType() { return $this->phone_type; } /** * Birth date of the Payer in ISO8601 format (yyyy-mm-dd). * * @param string $birth_date * * @return $this */ public function setBirthDate($birth_date) { $this->birth_date = $birth_date; return $this; } /** * Birth date of the Payer in ISO8601 format (yyyy-mm-dd). * * @return string */ public function getBirthDate() { return $this->birth_date; } /** * Payer’s tax ID. Only supported when the `payment_method` is set to `paypal`. * * @param string $tax_id * * @return $this */ public function setTaxId($tax_id) { $this->tax_id = $tax_id; return $this; } /** * Payer’s tax ID. Only supported when the `payment_method` is set to `paypal`. * * @return string */ public function getTaxId() { return $this->tax_id; } /** * Payer’s tax ID type. Allowed values: `BR_CPF` or `BR_CNPJ`. Only supported when the `payment_method` is set to `paypal`. * Valid Values: ["BR_CPF", "BR_CNPJ"] * * @param string $tax_id_type * * @return $this */ public function setTaxIdType($tax_id_type) { $this->tax_id_type = $tax_id_type; return $this; } /** * Payer’s tax ID type. Allowed values: `BR_CPF` or `BR_CNPJ`. Only supported when the `payment_method` is set to `paypal`. * * @return string */ public function getTaxIdType() { return $this->tax_id_type; } /** * Two-letter registered country code of the payer to identify the buyer country. * * @param string $country_code * * @return $this */ public function setCountryCode($country_code) { $this->country_code = $country_code; return $this; } /** * Two-letter registered country code of the payer to identify the buyer country. * * @return string */ public function getCountryCode() { return $this->country_code; } /** * Billing address of the Payer. * * @param \PayPal\Api\Address $billing_address * * @return $this */ public function setBillingAddress($billing_address) { $this->billing_address = $billing_address; return $this; } /** * Billing address of the Payer. * * @return \PayPal\Api\Address */ public function getBillingAddress() { return $this->billing_address; } /** * Shipping address of payer PayPal account. * * @param \PayPal\Api\ShippingAddress $shipping_address * * @return $this */ public function setShippingAddress($shipping_address) { $this->shipping_address = $shipping_address; return $this; } /** * Shipping address of payer PayPal account. * * @return \PayPal\Api\ShippingAddress */ public function getShippingAddress() { return $this->shipping_address; } } rest-api-sdk-php/lib/PayPal/Api/Amount.php 0000644 00000004421 15007532371 0014261 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; use PayPal\Converter\FormatConverter; use PayPal\Validation\NumericValidator; /** * Class Amount * * payment amount with break-ups. * * @package PayPal\Api * * @property string currency * @property string total * @property \PayPal\Api\Details details */ class Amount extends PayPalModel { /** * 3-letter [currency code](https://developer.paypal.com/docs/integration/direct/rest_api_payment_country_currency_support/). PayPal does not support all currencies. * * @param string $currency * * @return $this */ public function setCurrency($currency) { $this->currency = $currency; return $this; } /** * 3-letter [currency code](https://developer.paypal.com/docs/integration/direct/rest_api_payment_country_currency_support/). PayPal does not support all currencies. * * @return string */ public function getCurrency() { return $this->currency; } /** * Total amount charged from the payer to the payee. In case of a refund, this is the refunded amount to the original payer from the payee. 10 characters max with support for 2 decimal places. * * @param string|double $total * * @return $this */ public function setTotal($total) { NumericValidator::validate($total, "Total"); $total = FormatConverter::formatToPrice($total, $this->getCurrency()); $this->total = $total; return $this; } /** * Total amount charged from the payer to the payee. In case of a refund, this is the refunded amount to the original payer from the payee. 10 characters max with support for 2 decimal places. * * @return string */ public function getTotal() { return $this->total; } /** * Additional details of the payment amount. * * @param \PayPal\Api\Details $details * * @return $this */ public function setDetails($details) { $this->details = $details; return $this; } /** * Additional details of the payment amount. * * @return \PayPal\Api\Details */ public function getDetails() { return $this->details; } } rest-api-sdk-php/lib/PayPal/Api/Links.php 0000644 00000004725 15007532371 0014105 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class Links * * * * @package PayPal\Api * * @property string href * @property string rel * @property \PayPal\Api\HyperSchema targetSchema * @property string method * @property string enctype * @property \PayPal\Api\HyperSchema schema */ class Links extends PayPalModel { /** * Sets Href * * @param string $href * * @return $this */ public function setHref($href) { $this->href = $href; return $this; } /** * Gets Href * * @return string */ public function getHref() { return $this->href; } /** * Sets Rel * * @param string $rel * * @return $this */ public function setRel($rel) { $this->rel = $rel; return $this; } /** * Gets Rel * * @return string */ public function getRel() { return $this->rel; } /** * Sets TargetSchema * * @param \PayPal\Api\HyperSchema $targetSchema * * @return $this */ public function setTargetSchema($targetSchema) { $this->targetSchema = $targetSchema; return $this; } /** * Gets TargetSchema * * @return \PayPal\Api\HyperSchema */ public function getTargetSchema() { return $this->targetSchema; } /** * Sets Method * * @param string $method * * @return $this */ public function setMethod($method) { $this->method = $method; return $this; } /** * Gets Method * * @return string */ public function getMethod() { return $this->method; } /** * Sets Enctype * * @param string $enctype * * @return $this */ public function setEnctype($enctype) { $this->enctype = $enctype; return $this; } /** * Gets Enctype * * @return string */ public function getEnctype() { return $this->enctype; } /** * Sets Schema * * @param \PayPal\Api\HyperSchema $schema * * @return $this */ public function setSchema($schema) { $this->schema = $schema; return $this; } /** * Gets Schema * * @return \PayPal\Api\HyperSchema */ public function getSchema() { return $this->schema; } } rest-api-sdk-php/lib/PayPal/Api/RelatedResources.php 0000644 00000004674 15007532371 0016303 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class RelatedResources * * Each one representing a financial transaction (Sale, Authorization, Capture, Refund) related to the payment. * * @package PayPal\Api * * @property \PayPal\Api\Sale sale * @property \PayPal\Api\Authorization authorization * @property \PayPal\Api\Order order * @property \PayPal\Api\Capture capture * @property \PayPal\Api\Refund refund */ class RelatedResources extends PayPalModel { /** * Sale transaction * * @param \PayPal\Api\Sale $sale * * @return $this */ public function setSale($sale) { $this->sale = $sale; return $this; } /** * Sale transaction * * @return \PayPal\Api\Sale */ public function getSale() { return $this->sale; } /** * Authorization transaction * * @param \PayPal\Api\Authorization $authorization * * @return $this */ public function setAuthorization($authorization) { $this->authorization = $authorization; return $this; } /** * Authorization transaction * * @return \PayPal\Api\Authorization */ public function getAuthorization() { return $this->authorization; } /** * Order transaction * * @param \PayPal\Api\Order $order * * @return $this */ public function setOrder($order) { $this->order = $order; return $this; } /** * Order transaction * * @return \PayPal\Api\Order */ public function getOrder() { return $this->order; } /** * Capture transaction * * @param \PayPal\Api\Capture $capture * * @return $this */ public function setCapture($capture) { $this->capture = $capture; return $this; } /** * Capture transaction * * @return \PayPal\Api\Capture */ public function getCapture() { return $this->capture; } /** * Refund transaction * * @param \PayPal\Api\Refund $refund * * @return $this */ public function setRefund($refund) { $this->refund = $refund; return $this; } /** * Refund transaction * * @return \PayPal\Api\Refund */ public function getRefund() { return $this->refund; } } rest-api-sdk-php/lib/PayPal/Api/HyperSchema.php 0000644 00000006464 15007532371 0015237 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class HyperSchema * * * * @package PayPal\Api * * @property \PayPal\Api\Links[] links * @property string fragmentResolution * @property bool readonly * @property string contentEncoding * @property string pathStart * @property string mediaType */ class HyperSchema extends PayPalModel { /** * Sets Links * * @param \PayPal\Api\Links[] $links * * @return $this */ public function setLinks($links) { $this->links = $links; return $this; } /** * Gets Links * * @return \PayPal\Api\Links[] */ public function getLinks() { return $this->links; } /** * Append Links to the list. * * @param \PayPal\Api\Links $links * @return $this */ public function addLink($links) { if (!$this->getLinks()) { return $this->setLinks(array($links)); } else { return $this->setLinks( array_merge($this->getLinks(), array($links)) ); } } /** * Remove Links from the list. * * @param \PayPal\Api\Links $links * @return $this */ public function removeLink($links) { return $this->setLinks( array_diff($this->getLinks(), array($links)) ); } /** * Sets FragmentResolution * * @param string $fragmentResolution * * @return $this */ public function setFragmentResolution($fragmentResolution) { $this->fragmentResolution = $fragmentResolution; return $this; } /** * Gets FragmentResolution * * @return string */ public function getFragmentResolution() { return $this->fragmentResolution; } /** * Sets Readonly * * @param bool $readonly * * @return $this */ public function setReadonly($readonly) { $this->readonly = $readonly; return $this; } /** * Gets Readonly * * @return bool */ public function getReadonly() { return $this->readonly; } /** * Sets ContentEncoding * * @param string $contentEncoding * * @return $this */ public function setContentEncoding($contentEncoding) { $this->contentEncoding = $contentEncoding; return $this; } /** * Gets ContentEncoding * * @return string */ public function getContentEncoding() { return $this->contentEncoding; } /** * Sets PathStart * * @param string $pathStart * * @return $this */ public function setPathStart($pathStart) { $this->pathStart = $pathStart; return $this; } /** * Gets PathStart * * @return string */ public function getPathStart() { return $this->pathStart; } /** * Sets MediaType * * @param string $mediaType * * @return $this */ public function setMediaType($mediaType) { $this->mediaType = $mediaType; return $this; } /** * Gets MediaType * * @return string */ public function getMediaType() { return $this->mediaType; } } rest-api-sdk-php/lib/PayPal/Api/RedirectUrls.php 0000644 00000003203 15007532371 0015422 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; use PayPal\Validation\UrlValidator; /** * Class RedirectUrls * * Set of redirect URLs you provide only for PayPal-based payments. * * @package PayPal\Api * * @property string return_url * @property string cancel_url */ class RedirectUrls extends PayPalModel { /** * Url where the payer would be redirected to after approving the payment. **Required for PayPal account payments.** * * @param string $return_url * @throws \InvalidArgumentException * @return $this */ public function setReturnUrl($return_url) { UrlValidator::validate($return_url, "ReturnUrl"); $this->return_url = $return_url; return $this; } /** * Url where the payer would be redirected to after approving the payment. **Required for PayPal account payments.** * * @return string */ public function getReturnUrl() { return $this->return_url; } /** * Url where the payer would be redirected to after canceling the payment. **Required for PayPal account payments.** * * @param string $cancel_url * @throws \InvalidArgumentException * @return $this */ public function setCancelUrl($cancel_url) { UrlValidator::validate($cancel_url, "CancelUrl"); $this->cancel_url = $cancel_url; return $this; } /** * Url where the payer would be redirected to after canceling the payment. **Required for PayPal account payments.** * * @return string */ public function getCancelUrl() { return $this->cancel_url; } } rest-api-sdk-php/lib/PayPal/Api/InvoiceAddress.php 0000644 00000001234 15007532371 0015717 0 ustar 00 <?php namespace PayPal\Api; /** * Class InvoiceAddress * * Base Address object used as billing address in a payment or extended for Shipping Address. * * @package PayPal\Api * * @property \PayPal\Api\Phone phone */ class InvoiceAddress extends BaseAddress { /** * Phone number in E.123 format. * * @param \PayPal\Api\Phone $phone * * @return $this */ public function setPhone($phone) { $this->phone = $phone; return $this; } /** * Phone number in E.123 format. * * @return \PayPal\Api\Phone */ public function getPhone() { return $this->phone; } } rest-api-sdk-php/lib/PayPal/Api/Credit.php 0000644 00000002077 15007532371 0014235 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class Credit * * A resource representing a credit instrument. * * @package PayPal\Api * * @property string id * @property string type */ class Credit extends PayPalModel { /** * Unique identifier of credit resource. * * @param string $id * * @return $this */ public function setId($id) { $this->id = $id; return $this; } /** * Unique identifier of credit resource. * * @return string */ public function getId() { return $this->id; } /** * specifies type of credit * Valid Values: ["BILL_ME_LATER", "PAYPAL_EXTRAS_MASTERCARD", "EBAY_MASTERCARD", "PAYPAL_SMART_CONNECT"] * * @param string $type * * @return $this */ public function setType($type) { $this->type = $type; return $this; } /** * specifies type of credit * * @return string */ public function getType() { return $this->type; } } rest-api-sdk-php/lib/PayPal/Api/Notification.php 0000644 00000003023 15007532371 0015441 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class Notification * * Email/SMS notification. * * @package PayPal\Api * * @property string subject * @property string note * @property bool send_to_merchant */ class Notification extends PayPalModel { /** * Subject of the notification. * * @param string $subject * * @return $this */ public function setSubject($subject) { $this->subject = $subject; return $this; } /** * Subject of the notification. * * @return string */ public function getSubject() { return $this->subject; } /** * Note to the payer. * * @param string $note * * @return $this */ public function setNote($note) { $this->note = $note; return $this; } /** * 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 bool $send_to_merchant * * @return $this */ 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 bool */ public function getSendToMerchant() { return $this->send_to_merchant; } } rest-api-sdk-php/lib/PayPal/Api/PayoutItem.php 0000644 00000012674 15007532371 0015127 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalResourceModel; use PayPal\Rest\ApiContext; use PayPal\Transport\PayPalRestCall; use PayPal\Validation\ArgumentValidator; /** * Class PayoutItem * * Sender-created description of a payout to a single recipient. * * @package PayPal\Api * * @property string recipient_type * @property \PayPal\Api\Currency amount * @property string note * @property string receiver * @property string sender_item_id */ class PayoutItem extends PayPalResourceModel { /** * The type of identification for the payment receiver. If this field is provided, the payout items without a `recipient_type` will use the provided value. If this field is not provided, each payout item must include a value for the `recipient_type`. * * @param string $recipient_type * * @return $this */ public function setRecipientType($recipient_type) { $this->recipient_type = $recipient_type; return $this; } /** * The type of identification for the payment receiver. If this field is provided, the payout items without a `recipient_type` will use the provided value. If this field is not provided, each payout item must include a value for the `recipient_type`. * * @return string */ public function getRecipientType() { return $this->recipient_type; } /** * The amount of money to pay a receiver. * * @param \PayPal\Api\Currency $amount * * @return $this */ public function setAmount($amount) { $this->amount = $amount; return $this; } /** * The amount of money to pay a receiver. * * @return \PayPal\Api\Currency */ public function getAmount() { return $this->amount; } /** * Note for notifications. The note is provided by the payment sender. This note can be any string. 4000 characters max. * * @param string $note * * @return $this */ public function setNote($note) { $this->note = $note; return $this; } /** * Note for notifications. The note is provided by the payment sender. This note can be any string. 4000 characters max. * * @return string */ public function getNote() { return $this->note; } /** * The receiver of the payment. In a call response, the format of this value corresponds to the `recipient_type` specified in the request. 127 characters max. * * @param string $receiver * * @return $this */ public function setReceiver($receiver) { $this->receiver = $receiver; return $this; } /** * The receiver of the payment. In a call response, the format of this value corresponds to the `recipient_type` specified in the request. 127 characters max. * * @return string */ public function getReceiver() { return $this->receiver; } /** * A sender-specific ID number, used in an accounting system for tracking purposes. 30 characters max. * * @param string $sender_item_id * * @return $this */ public function setSenderItemId($sender_item_id) { $this->sender_item_id = $sender_item_id; return $this; } /** * A sender-specific ID number, used in an accounting system for tracking purposes. 30 characters max. * * @return string */ public function getSenderItemId() { return $this->sender_item_id; } /** * Obtain the status of a payout item by passing the item ID to the request URI. * * @param string $payoutItemId * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return PayoutItemDetails */ public static function get($payoutItemId, $apiContext = null, $restCall = null) { ArgumentValidator::validate($payoutItemId, 'payoutItemId'); $payLoad = ""; $json = self::executeCall( "/v1/payments/payouts-item/$payoutItemId", "GET", $payLoad, null, $apiContext, $restCall ); $ret = new PayoutItemDetails(); $ret->fromJson($json); return $ret; } /** * Cancels the unclaimed payment using the items id passed in the request URI. If an unclaimed item is not claimed within 30 days, the funds will be automatically returned to the sender. This call can be used to cancel the unclaimed item prior to the automatic 30-day return. * * @param string $payoutItemId * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return PayoutItemDetails */ public static function cancel($payoutItemId, $apiContext = null, $restCall = null) { ArgumentValidator::validate($payoutItemId, 'payoutItemId'); $payLoad = ""; $json = self::executeCall( "/v1/payments/payouts-item/$payoutItemId/cancel", "POST", $payLoad, null, $apiContext, $restCall ); $ret = new PayoutItemDetails(); $ret->fromJson($json); return $ret; } } rest-api-sdk-php/lib/PayPal/Api/TransactionBase.php 0000644 00000001655 15007532371 0016104 0 ustar 00 <?php namespace PayPal\Api; /** * Class TransactionBase * * A transaction defines the contract of a payment - what is the payment for and who is fulfilling it. * * @package PayPal\Api * * @property \PayPal\Api\RelatedResources related_resources */ class TransactionBase extends CartBase { /** * List of financial transactions (Sale, Authorization, Capture, Refund) related to the payment. * * * @param \PayPal\Api\RelatedResources $related_resources * * @return $this */ public function setRelatedResources($related_resources) { $this->related_resources = $related_resources; return $this; } /** * List of financial transactions (Sale, Authorization, Capture, Refund) related to the payment. * * @return \PayPal\Api\RelatedResources[] */ public function getRelatedResources() { return $this->related_resources; } } rest-api-sdk-php/lib/PayPal/Api/Details.php 0000644 00000013262 15007532371 0014406 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; use PayPal\Converter\FormatConverter; use PayPal\Validation\NumericValidator; /** * Class Details * * Additional details of the payment amount. * * @package PayPal\Api * * @property string subtotal * @property string shipping * @property string tax * @property string handling_fee * @property string shipping_discount * @property string insurance * @property string gift_wrap * @property string fee */ class Details extends PayPalModel { /** * Amount of the subtotal of the items. **Required** if line items are specified. 10 characters max, with support for 2 decimal places. * * @param string|double $subtotal * * @return $this */ public function setSubtotal($subtotal) { NumericValidator::validate($subtotal, "Subtotal"); $subtotal = FormatConverter::formatToPrice($subtotal); $this->subtotal = $subtotal; return $this; } /** * Amount of the subtotal of the items. **Required** if line items are specified. 10 characters max, with support for 2 decimal places. * * @return string */ public function getSubtotal() { return $this->subtotal; } /** * Amount charged for shipping. 10 characters max with support for 2 decimal places. * * @param string|double $shipping * * @return $this */ public function setShipping($shipping) { NumericValidator::validate($shipping, "Shipping"); $shipping = FormatConverter::formatToPrice($shipping); $this->shipping = $shipping; return $this; } /** * Amount charged for shipping. 10 characters max with support for 2 decimal places. * * @return string */ public function getShipping() { return $this->shipping; } /** * Amount charged for tax. 10 characters max with support for 2 decimal places. * * @param string|double $tax * * @return $this */ public function setTax($tax) { NumericValidator::validate($tax, "Tax"); $tax = FormatConverter::formatToPrice($tax); $this->tax = $tax; return $this; } /** * Amount charged for tax. 10 characters max with support for 2 decimal places. * * @return string */ public function getTax() { return $this->tax; } /** * Amount being charged for the handling fee. Only supported when the `payment_method` is set to `paypal`. * * @param string|double $handling_fee * * @return $this */ public function setHandlingFee($handling_fee) { NumericValidator::validate($handling_fee, "Handling Fee"); $handling_fee = FormatConverter::formatToPrice($handling_fee); $this->handling_fee = $handling_fee; return $this; } /** * Amount being charged for the handling fee. Only supported when the `payment_method` is set to `paypal`. * * @return string */ public function getHandlingFee() { return $this->handling_fee; } /** * Amount being discounted for the shipping fee. Only supported when the `payment_method` is set to `paypal`. * * @param string|double $shipping_discount * * @return $this */ public function setShippingDiscount($shipping_discount) { NumericValidator::validate($shipping_discount, "Shipping Discount"); $shipping_discount = FormatConverter::formatToPrice($shipping_discount); $this->shipping_discount = $shipping_discount; return $this; } /** * Amount being discounted for the shipping fee. Only supported when the `payment_method` is set to `paypal`. * * @return string */ public function getShippingDiscount() { return $this->shipping_discount; } /** * Amount being charged for the insurance fee. Only supported when the `payment_method` is set to `paypal`. * * @param string|double $insurance * * @return $this */ public function setInsurance($insurance) { NumericValidator::validate($insurance, "Insurance"); $insurance = FormatConverter::formatToPrice($insurance); $this->insurance = $insurance; return $this; } /** * Amount being charged for the insurance fee. Only supported when the `payment_method` is set to `paypal`. * * @return string */ public function getInsurance() { return $this->insurance; } /** * Amount being charged as gift wrap fee. * * @param string|double $gift_wrap * * @return $this */ public function setGiftWrap($gift_wrap) { NumericValidator::validate($gift_wrap, "Gift Wrap"); $gift_wrap = FormatConverter::formatToPrice($gift_wrap); $this->gift_wrap = $gift_wrap; return $this; } /** * Amount being charged as gift wrap fee. * * @return string */ public function getGiftWrap() { return $this->gift_wrap; } /** * Fee charged by PayPal. In case of a refund, this is the fee amount refunded to the original receipient of the payment. * * @param string|double $fee * * @return $this */ public function setFee($fee) { NumericValidator::validate($fee, "Fee"); $fee = FormatConverter::formatToPrice($fee); $this->fee = $fee; return $this; } /** * Fee charged by PayPal. In case of a refund, this is the fee amount refunded to the original receipient of the payment. * * @return string */ public function getFee() { return $this->fee; } } rest-api-sdk-php/lib/PayPal/Api/PayoutSenderBatchHeader.php 0000644 00000005063 15007532371 0017516 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class PayoutSenderBatchHeader * * This object represents sender-provided data about a batch header. The data is provided in a POST request. All batch submissions must have a batch header. * * @package PayPal\Api * * @property string sender_batch_id * @property string email_subject * @property string recipient_type */ class PayoutSenderBatchHeader extends PayPalModel { /** * Sender-created ID for tracking the batch payout in an accounting system. 30 characters max. * * @param string $sender_batch_id * * @return $this */ public function setSenderBatchId($sender_batch_id) { $this->sender_batch_id = $sender_batch_id; return $this; } /** * Sender-created ID for tracking the batch payout in an accounting system. 30 characters max. * * @return string */ public function getSenderBatchId() { return $this->sender_batch_id; } /** * The subject line text for the email that PayPal sends when a payout item is completed. (The subject line is the same for all recipients.) Maximum of 255 single-byte alphanumeric characters. * * @param string $email_subject * * @return $this */ public function setEmailSubject($email_subject) { $this->email_subject = $email_subject; return $this; } /** * The subject line text for the email that PayPal sends when a payout item is completed. (The subject line is the same for all recipients.) Maximum of 255 single-byte alphanumeric characters. * * @return string */ public function getEmailSubject() { return $this->email_subject; } /** * The type of ID for a payment receiver. If this field is provided, the payout items without a `recipient_type` will use the provided value. If this field is not provided, each payout item must include a value for the `recipient_type`. * * @param string $recipient_type * * @return $this */ public function setRecipientType($recipient_type) { $this->recipient_type = $recipient_type; return $this; } /** * The type of ID for a payment receiver. If this field is provided, the payout items without a `recipient_type` will use the provided value. If this field is not provided, each payout item must include a value for the `recipient_type`. * * @return string */ public function getRecipientType() { return $this->recipient_type; } } rest-api-sdk-php/lib/PayPal/Api/Payment.php 0000644 00000046040 15007532371 0014436 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalResourceModel; use PayPal\Core\PayPalConstants; use PayPal\Rest\ApiContext; use PayPal\Transport\PayPalRestCall; use PayPal\Validation\ArgumentValidator; /** * Class Payment * * Lets you create, process and manage payments. * * @package PayPal\Api * * @property string id * @property string intent * @property \PayPal\Api\Payer payer * @property \PayPal\Api\PotentialPayerInfo potential_payer_info * @property \PayPal\Api\Payee payee * @property \PayPal\Api\Transaction[] transactions * @property string[] billing_agreement_tokens * @property \PayPal\Api\PaymentInstruction payment_instruction * @property string state * @property string experience_profile_id * @property string note_to_payer * @property \PayPal\Api\RedirectUrls redirect_urls * @property string failure_reason * @property string create_time * @property string update_time * @property \PayPal\Api\Links[] links */ class Payment extends PayPalResourceModel { /** * ID of the created payment, the 'transaction ID' * * @param string $id * * @return $this */ public function setId($id) { $this->id = $id; return $this; } /** * ID of the created payment, the 'transaction ID' * * @return string */ public function getId() { return $this->id; } /** * Payment intent. * Valid Values: ["sale", "authorize", "order"] * * @param string $intent * * @return $this */ public function setIntent($intent) { $this->intent = $intent; return $this; } /** * Payment intent. * * @return string */ public function getIntent() { return $this->intent; } /** * Source of the funds for this payment represented by a PayPal account or a direct credit card. * * @param \PayPal\Api\Payer $payer * * @return $this */ public function setPayer($payer) { $this->payer = $payer; return $this; } /** * Source of the funds for this payment represented by a PayPal account or a direct credit card. * * @return \PayPal\Api\Payer */ public function getPayer() { return $this->payer; } /** * Information that the merchant knows about the payer. This information is not definitive and only serves as a hint to the UI or any pre-processing logic. * * @param \PayPal\Api\PotentialPayerInfo $potential_payer_info * * @return $this */ public function setPotentialPayerInfo($potential_payer_info) { $this->potential_payer_info = $potential_payer_info; return $this; } /** * Information that the merchant knows about the payer. This information is not definitive and only serves as a hint to the UI or any pre-processing logic. * * @return \PayPal\Api\PotentialPayerInfo */ public function getPotentialPayerInfo() { return $this->potential_payer_info; } /** * Receiver of funds for this payment. **Readonly for PayPal external REST payments.** * * @param \PayPal\Api\Payee $payee * * @return $this */ public function setPayee($payee) { $this->payee = $payee; return $this; } /** * Receiver of funds for this payment. **Readonly for PayPal external REST payments.** * * @return \PayPal\Api\Payee */ public function getPayee() { return $this->payee; } /** * ID of the cart to execute the payment. * * @deprecated Not publicly available * @param string $cart * * @return $this */ public function setCart($cart) { $this->cart = $cart; return $this; } /** * ID of the cart to execute the payment. * * @deprecated Not publicly available * @return string */ public function getCart() { return $this->cart; } /** * Transactional details including the amount and item details. * * @param \PayPal\Api\Transaction[] $transactions * * @return $this */ public function setTransactions($transactions) { $this->transactions = $transactions; return $this; } /** * Transactional details including the amount and item details. * * @return \PayPal\Api\Transaction[] */ public function getTransactions() { return $this->transactions; } /** * Append Transactions to the list. * * @param \PayPal\Api\Transaction $transaction * @return $this */ public function addTransaction($transaction) { if (!$this->getTransactions()) { return $this->setTransactions(array($transaction)); } else { return $this->setTransactions( array_merge($this->getTransactions(), array($transaction)) ); } } /** * Remove Transactions from the list. * * @param \PayPal\Api\Transaction $transaction * @return $this */ public function removeTransaction($transaction) { return $this->setTransactions( array_diff($this->getTransactions(), array($transaction)) ); } /** * Applicable for advanced payments like multi seller payment (MSP) to support partial failures * * @deprecated Not publicly available * @param \PayPal\Api\Error[] $failed_transactions * * @return $this */ public function setFailedTransactions($failed_transactions) { $this->failed_transactions = $failed_transactions; return $this; } /** * Applicable for advanced payments like multi seller payment (MSP) to support partial failures * * @deprecated Not publicly available * @return \PayPal\Api\Error[] */ public function getFailedTransactions() { return $this->failed_transactions; } /** * Append FailedTransactions to the list. * * @deprecated Not publicly available * @param \PayPal\Api\Error $error * @return $this */ public function addFailedTransaction($error) { if (!$this->getFailedTransactions()) { return $this->setFailedTransactions(array($error)); } else { return $this->setFailedTransactions( array_merge($this->getFailedTransactions(), array($error)) ); } } /** * Remove FailedTransactions from the list. * * @deprecated Not publicly available * @param \PayPal\Api\Error $error * @return $this */ public function removeFailedTransaction($error) { return $this->setFailedTransactions( array_diff($this->getFailedTransactions(), array($error)) ); } /** * Collection of PayPal generated billing agreement tokens. * * @param string[] $billing_agreement_tokens * * @return $this */ public function setBillingAgreementTokens($billing_agreement_tokens) { $this->billing_agreement_tokens = $billing_agreement_tokens; return $this; } /** * Collection of PayPal generated billing agreement tokens. * * @return string[] */ public function getBillingAgreementTokens() { return $this->billing_agreement_tokens; } /** * Append BillingAgreementTokens to the list. * * @param string $billingAgreementToken * @return $this */ public function addBillingAgreementToken($billingAgreementToken) { if (!$this->getBillingAgreementTokens()) { return $this->setBillingAgreementTokens(array($billingAgreementToken)); } else { return $this->setBillingAgreementTokens( array_merge($this->getBillingAgreementTokens(), array($billingAgreementToken)) ); } } /** * Remove BillingAgreementTokens from the list. * * @param string $billingAgreementToken * @return $this */ public function removeBillingAgreementToken($billingAgreementToken) { return $this->setBillingAgreementTokens( array_diff($this->getBillingAgreementTokens(), array($billingAgreementToken)) ); } /** * Credit financing offered to payer on PayPal side. Returned in payment after payer opts-in * * @deprecated Not publicly available * @param \PayPal\Api\CreditFinancingOffered $credit_financing_offered * * @return $this */ public function setCreditFinancingOffered($credit_financing_offered) { $this->credit_financing_offered = $credit_financing_offered; return $this; } /** * Credit financing offered to payer on PayPal side. Returned in payment after payer opts-in * * @deprecated Not publicly available * @return \PayPal\Api\CreditFinancingOffered */ public function getCreditFinancingOffered() { return $this->credit_financing_offered; } /** * Instructions for the payer to complete this payment. * * @param \PayPal\Api\PaymentInstruction $payment_instruction * * @return $this */ public function setPaymentInstruction($payment_instruction) { $this->payment_instruction = $payment_instruction; return $this; } /** * Instructions for the payer to complete this payment. * * @return \PayPal\Api\PaymentInstruction */ public function getPaymentInstruction() { return $this->payment_instruction; } /** * Payment state. * Valid Values: ["created", "approved", "failed", "partially_completed", "in_progress"] * * @param string $state * * @return $this */ public function setState($state) { $this->state = $state; return $this; } /** * Payment state. * * @return string */ public function getState() { return $this->state; } /** * PayPal generated identifier for the merchant's payment experience profile. Refer to [this](https://developer.paypal.com/webapps/developer/docs/api/#payment-experience) link to create experience profile ID. * * @param string $experience_profile_id * * @return $this */ public function setExperienceProfileId($experience_profile_id) { $this->experience_profile_id = $experience_profile_id; return $this; } /** * PayPal generated identifier for the merchant's payment experience profile. Refer to [this](https://developer.paypal.com/webapps/developer/docs/api/#payment-experience) link to create experience profile ID. * * @return string */ public function getExperienceProfileId() { return $this->experience_profile_id; } /** * free-form field for the use of clients to pass in a message to the payer * * @param string $note_to_payer * * @return $this */ public function setNoteToPayer($note_to_payer) { $this->note_to_payer = $note_to_payer; return $this; } /** * free-form field for the use of clients to pass in a message to the payer * * @return string */ public function getNoteToPayer() { return $this->note_to_payer; } /** * Set of redirect URLs you provide only for PayPal-based payments. * * @param \PayPal\Api\RedirectUrls $redirect_urls * * @return $this */ public function setRedirectUrls($redirect_urls) { $this->redirect_urls = $redirect_urls; return $this; } /** * Set of redirect URLs you provide only for PayPal-based payments. * * @return \PayPal\Api\RedirectUrls */ public function getRedirectUrls() { return $this->redirect_urls; } /** * Failure reason code returned when the payment failed for some valid reasons. * Valid Values: ["UNABLE_TO_COMPLETE_TRANSACTION", "INVALID_PAYMENT_METHOD", "PAYER_CANNOT_PAY", "CANNOT_PAY_THIS_PAYEE", "REDIRECT_REQUIRED", "PAYEE_FILTER_RESTRICTIONS"] * * @param string $failure_reason * * @return $this */ public function setFailureReason($failure_reason) { $this->failure_reason = $failure_reason; return $this; } /** * Failure reason code returned when the payment failed for some valid reasons. * * @return string */ public function getFailureReason() { return $this->failure_reason; } /** * Payment creation time as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6). * * @param string $create_time * * @return $this */ public function setCreateTime($create_time) { $this->create_time = $create_time; return $this; } /** * Payment creation time as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6). * * @return string */ public function getCreateTime() { return $this->create_time; } /** * Payment update time as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6). * * @param string $update_time * * @return $this */ public function setUpdateTime($update_time) { $this->update_time = $update_time; return $this; } /** * Payment update time as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6). * * @return string */ public function getUpdateTime() { return $this->update_time; } /** * Get Approval Link * * @return null|string */ public function getApprovalLink() { return $this->getLink(PayPalConstants::APPROVAL_URL); } /** * Create and process a payment by passing a payment object that includes the intent, payer, and transactions in the body of the request JSON. For PayPal payments, include redirect URLs in the payment object. * * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return Payment */ public function create($apiContext = null, $restCall = null) { $payLoad = $this->toJSON(); $json = self::executeCall( "/v1/payments/payment", "POST", $payLoad, null, $apiContext, $restCall ); $this->fromJson($json); return $this; } /** * Look up a particular payment resource by passing the payment_id in the request URI. * * @param string $paymentId * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return Payment */ public static function get($paymentId, $apiContext = null, $restCall = null) { ArgumentValidator::validate($paymentId, 'paymentId'); $payLoad = ""; $json = self::executeCall( "/v1/payments/payment/$paymentId", "GET", $payLoad, null, $apiContext, $restCall ); $ret = new Payment(); $ret->fromJson($json); return $ret; } /** * Use this call to partially update the payment resource for the given identifier. Allowed objects are amount, shipping_address, invoice_id and custom. Please note that it is not possible to use patch after execute has been called. * * @param PatchRequest $patchRequest * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return boolean */ public function update($patchRequest, $apiContext = null, $restCall = null) { ArgumentValidator::validate($this->getId(), "Id"); ArgumentValidator::validate($patchRequest, 'patchRequest'); $payLoad = $patchRequest->toJSON(); self::executeCall( "/v1/payments/payment/{$this->getId()}", "PATCH", $payLoad, null, $apiContext, $restCall ); return true; } /** * Execute (complete) a PayPal payment that has been approved by the payer. Optionally update selective payment information when executing the payment. * * @param PaymentExecution $paymentExecution * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return Payment */ public function execute($paymentExecution, $apiContext = null, $restCall = null) { ArgumentValidator::validate($this->getId(), "Id"); ArgumentValidator::validate($paymentExecution, 'paymentExecution'); $payLoad = $paymentExecution->toJSON(); $json = self::executeCall( "/v1/payments/payment/{$this->getId()}/execute", "POST", $payLoad, null, $apiContext, $restCall ); $this->fromJson($json); return $this; } /** * List payments in any state (created, approved, failed, etc.). Payments returned are the payments made to the merchant issuing the request. * * @param array $params * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return PaymentHistory */ public static function all($params, $apiContext = null, $restCall = null) { ArgumentValidator::validate($params, 'params'); $payLoad = ""; $allowedParams = array( 'count' => 1, 'start_id' => 1, 'start_index' => 1, 'start_time' => 1, 'end_time' => 1, 'payee_id' => 1, 'sort_by' => 1, 'sort_order' => 1, ); $json = self::executeCall( "/v1/payments/payment?" . http_build_query(array_intersect_key($params, $allowedParams)), "GET", $payLoad, null, $apiContext, $restCall ); $ret = new PaymentHistory(); $ret->fromJson($json); return $ret; } } rest-api-sdk-php/lib/PayPal/Api/Metadata.php 0000644 00000012247 15007532371 0014543 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; use PayPal\Validation\UrlValidator; /** * Class Metadata * * Audit information of the resource. * * @package PayPal\Api * * @property string created_date * @property string created_by * @property string cancelled_date * @property string cancelled_by * @property string last_updated_date * @property string last_updated_by * @property string first_sent_date * @property string last_sent_date * @property string last_sent_by * @property string payer_view_url */ class Metadata extends PayPalModel { /** * Date when the resource was created. * * @param string $created_date * * @return $this */ 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; } /** * Email address of the account that created the resource. * * @param string $created_by * * @return $this */ public function setCreatedBy($created_by) { $this->created_by = $created_by; return $this; } /** * 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 * * @return $this */ public function setCancelledDate($cancelled_date) { $this->cancelled_date = $cancelled_date; return $this; } /** * Date when the resource was cancelled. * * @return string */ public function getCancelledDate() { return $this->cancelled_date; } /** * Actor who cancelled the resource. * * @param string $cancelled_by * * @return $this */ public function setCancelledBy($cancelled_by) { $this->cancelled_by = $cancelled_by; return $this; } /** * 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 * * @return $this */ public function setLastUpdatedDate($last_updated_date) { $this->last_updated_date = $last_updated_date; return $this; } /** * Date when the resource was last edited. * * @return string */ public function getLastUpdatedDate() { return $this->last_updated_date; } /** * Email address of the account that last edited the resource. * * @param string $last_updated_by * * @return $this */ public function setLastUpdatedBy($last_updated_by) { $this->last_updated_by = $last_updated_by; 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 first sent. * * @param string $first_sent_date * * @return $this */ public function setFirstSentDate($first_sent_date) { $this->first_sent_date = $first_sent_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 sent. * * @param string $last_sent_date * * @return $this */ 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; } /** * Email address of the account that last sent the resource. * * @param string $last_sent_by * * @return $this */ 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; } /** * URL representing the payer's view of the invoice. * * @param string $payer_view_url * @throws \InvalidArgumentException * @return $this */ public function setPayerViewUrl($payer_view_url) { UrlValidator::validate($payer_view_url, "PayerViewUrl"); $this->payer_view_url = $payer_view_url; return $this; } /** * URL representing the payer's view of the invoice. * * @return string */ public function getPayerViewUrl() { return $this->payer_view_url; } } rest-api-sdk-php/lib/PayPal/Api/WebhookList.php 0000644 00000002475 15007532371 0015257 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class WebhookList * * List of Webhooks * * @package PayPal\Api * * @property \PayPal\Api\Webhook[] webhooks */ class WebhookList extends PayPalModel { /** * A list of Webhooks * * @param \PayPal\Api\Webhook[] $webhooks * * @return $this */ public function setWebhooks($webhooks) { $this->webhooks = $webhooks; return $this; } /** * A list of Webhooks * * @return \PayPal\Api\Webhook[] */ public function getWebhooks() { return $this->webhooks; } /** * Append Webhooks to the list. * * @param \PayPal\Api\Webhook $webhook * @return $this */ public function addWebhook($webhook) { if (!$this->getWebhooks()) { return $this->setWebhooks(array($webhook)); } else { return $this->setWebhooks( array_merge($this->getWebhooks(), array($webhook)) ); } } /** * Remove Webhooks from the list. * * @param \PayPal\Api\Webhook $webhook * @return $this */ public function removeWebhook($webhook) { return $this->setWebhooks( array_diff($this->getWebhooks(), array($webhook)) ); } } rest-api-sdk-php/lib/PayPal/Api/PlanList.php 0000644 00000006261 15007532371 0014550 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class PlanList * * Resource representing a list of billing plans with basic information and get link. * * @package PayPal\Api * * @property \PayPal\Api\Plan[] plans * @property string total_items * @property string total_pages * @property \PayPal\Api\Links[] links */ class PlanList extends PayPalModel { /** * Array of billing plans. * * @param \PayPal\Api\Plan[] $plans * * @return $this */ public function setPlans($plans) { $this->plans = $plans; return $this; } /** * Array of billing plans. * * @return \PayPal\Api\Plan[] */ public function getPlans() { return $this->plans; } /** * Append Plans to the list. * * @param \PayPal\Api\Plan $plan * @return $this */ public function addPlan($plan) { if (!$this->getPlans()) { return $this->setPlans(array($plan)); } else { return $this->setPlans( array_merge($this->getPlans(), array($plan)) ); } } /** * Remove Plans from the list. * * @param \PayPal\Api\Plan $plan * @return $this */ public function removePlan($plan) { return $this->setPlans( array_diff($this->getPlans(), array($plan)) ); } /** * Total number of items. * * @param string $total_items * * @return $this */ public function setTotalItems($total_items) { $this->total_items = $total_items; return $this; } /** * Total number of items. * * @return string */ public function getTotalItems() { return $this->total_items; } /** * Total number of pages. * * @param string $total_pages * * @return $this */ public function setTotalPages($total_pages) { $this->total_pages = $total_pages; return $this; } /** * Total number of pages. * * @return string */ public function getTotalPages() { return $this->total_pages; } /** * Sets Links * * @param \PayPal\Api\Links[] $links * * @return $this */ public function setLinks($links) { $this->links = $links; return $this; } /** * Gets Links * * @return \PayPal\Api\Links[] */ public function getLinks() { return $this->links; } /** * Append Links to the list. * * @param \PayPal\Api\Links $links * @return $this */ public function addLink($links) { if (!$this->getLinks()) { return $this->setLinks(array($links)); } else { return $this->setLinks( array_merge($this->getLinks(), array($links)) ); } } /** * Remove Links from the list. * * @param \PayPal\Api\Links $links * @return $this */ public function removeLink($links) { return $this->setLinks( array_diff($this->getLinks(), array($links)) ); } } rest-api-sdk-php/lib/PayPal/Api/PaymentCardToken.php 0000644 00000006502 15007532371 0016230 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class PaymentCardToken * * A resource representing a payment card that can be used to fund a payment. * * @package PayPal\Api * * @property string payment_card_id * @property string external_customer_id * @property string last4 * @property string type * @property int expire_month * @property int expire_year */ class PaymentCardToken extends PayPalModel { /** * ID of a previously saved Payment Card resource. * * @param string $payment_card_id * * @return $this */ public function setPaymentCardId($payment_card_id) { $this->payment_card_id = $payment_card_id; return $this; } /** * ID of a previously saved Payment Card resource. * * @return string */ public function getPaymentCardId() { return $this->payment_card_id; } /** * The unique identifier of the payer used when saving this payment card. * * @param string $external_customer_id * * @return $this */ public function setExternalCustomerId($external_customer_id) { $this->external_customer_id = $external_customer_id; return $this; } /** * The unique identifier of the payer used when saving this payment card. * * @return string */ public function getExternalCustomerId() { return $this->external_customer_id; } /** * Last 4 digits of the card number from the saved card. * * @param string $last4 * * @return $this */ public function setLast4($last4) { $this->last4 = $last4; return $this; } /** * Last 4 digits of the card number from the saved card. * * @return string */ public function getLast4() { return $this->last4; } /** * Type of the Card. * Valid Values: ["VISA", "AMEX", "SOLO", "JCB", "STAR", "DELTA", "DISCOVER", "SWITCH", "MAESTRO", "CB_NATIONALE", "CONFINOGA", "COFIDIS", "ELECTRON", "CETELEM", "CHINA_UNION_PAY", "MASTERCARD"] * * @param string $type * * @return $this */ public function setType($type) { $this->type = $type; return $this; } /** * Type of the Card. * * @return string */ public function getType() { return $this->type; } /** * Expiry month from the saved card with value 1 - 12. * * @param int $expire_month * * @return $this */ public function setExpireMonth($expire_month) { $this->expire_month = $expire_month; return $this; } /** * Expiry month from the saved card with value 1 - 12. * * @return int */ public function getExpireMonth() { return $this->expire_month; } /** * Four digit expiry year from the saved card, represented as YYYY format. * * @param int $expire_year * * @return $this */ public function setExpireYear($expire_year) { $this->expire_year = $expire_year; return $this; } /** * Four digit expiry year from the saved card, represented as YYYY format. * * @return int */ public function getExpireYear() { return $this->expire_year; } } rest-api-sdk-php/lib/PayPal/Api/CartBase.php 0000644 00000022265 15007532371 0014510 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; use PayPal\Validation\UrlValidator; /** * Class CartBase * * Base properties of a cart resource * * @package PayPal\Api * * @property string reference_id * @property \PayPal\Api\Amount amount * @property string description * @property string note_to_payee * @property string custom * @property string invoice_number * @property string soft_descriptor * @property \PayPal\Api\PaymentOptions payment_options * @property \PayPal\Api\ItemList item_list * @property string notify_url * @property string order_url */ class CartBase extends PayPalModel { /** * Merchant identifier to the purchase unit. Optional parameter * * @param string $reference_id * * @return $this */ public function setReferenceId($reference_id) { $this->reference_id = $reference_id; return $this; } /** * Merchant identifier to the purchase unit. Optional parameter * * @return string */ public function getReferenceId() { return $this->reference_id; } /** * Amount being collected. * * @param \PayPal\Api\Amount $amount * * @return $this */ public function setAmount($amount) { $this->amount = $amount; return $this; } /** * Amount being collected. * * @return \PayPal\Api\Amount */ public function getAmount() { return $this->amount; } /** * Recipient of the funds in this transaction. * * @deprecated Not publicly available * @param \PayPal\Api\Payee $payee * * @return $this */ public function setPayee($payee) { $this->payee = $payee; return $this; } /** * Recipient of the funds in this transaction. * * @deprecated Not publicly available * @return \PayPal\Api\Payee */ public function getPayee() { return $this->payee; } /** * Description of transaction. * * @param string $description * * @return $this */ public function setDescription($description) { $this->description = $description; return $this; } /** * Description of transaction. * * @return string */ public function getDescription() { return $this->description; } /** * Note to the recipient of the funds in this transaction. * * @param string $note_to_payee * * @return $this */ public function setNoteToPayee($note_to_payee) { $this->note_to_payee = $note_to_payee; return $this; } /** * Note to the recipient of the funds in this transaction. * * @return string */ public function getNoteToPayee() { return $this->note_to_payee; } /** * Free-form field for the use of clients. Only supported when the `payment_method` is set to `paypal`. * * @param string $custom * * @return $this */ public function setCustom($custom) { $this->custom = $custom; return $this; } /** * Free-form field for the use of clients. Only supported when the `payment_method` is set to `paypal`. * * @return string */ public function getCustom() { return $this->custom; } /** * Invoice number used to track the payment. Only supported when the `payment_method` is set to `paypal`. * * @param string $invoice_number * * @return $this */ public function setInvoiceNumber($invoice_number) { $this->invoice_number = $invoice_number; return $this; } /** * Invoice number used to track the payment. Only supported when the `payment_method` is set to `paypal`. * * @return string */ public function getInvoiceNumber() { return $this->invoice_number; } /** * Soft descriptor used when charging this funding source. If length exceeds max length, the value will be truncated * * @param string $soft_descriptor * * @return $this */ public function setSoftDescriptor($soft_descriptor) { $this->soft_descriptor = $soft_descriptor; return $this; } /** * Soft descriptor used when charging this funding source. If length exceeds max length, the value will be truncated * * @return string */ public function getSoftDescriptor() { return $this->soft_descriptor; } /** * Soft descriptor city used when charging this funding source. If length exceeds max length, the value will be truncated. Only supported when the `payment_method` is set to `credit_card` * * @deprecated Not publicly available * @param string $soft_descriptor_city * * @return $this */ public function setSoftDescriptorCity($soft_descriptor_city) { $this->soft_descriptor_city = $soft_descriptor_city; return $this; } /** * Soft descriptor city used when charging this funding source. If length exceeds max length, the value will be truncated. Only supported when the `payment_method` is set to `credit_card` * * @deprecated Not publicly available * @return string */ public function getSoftDescriptorCity() { return $this->soft_descriptor_city; } /** * Payment options requested for this purchase unit * * @param \PayPal\Api\PaymentOptions $payment_options * * @return $this */ public function setPaymentOptions($payment_options) { $this->payment_options = $payment_options; return $this; } /** * Payment options requested for this purchase unit * * @return \PayPal\Api\PaymentOptions */ public function getPaymentOptions() { return $this->payment_options; } /** * Items and related shipping address within a transaction. * * @param \PayPal\Api\ItemList $item_list * * @return $this */ public function setItemList($item_list) { $this->item_list = $item_list; return $this; } /** * Items and related shipping address within a transaction. * * @return \PayPal\Api\ItemList */ public function getItemList() { return $this->item_list; } /** * URL to send payment notifications * * @param string $notify_url * @throws \InvalidArgumentException * @return $this */ public function setNotifyUrl($notify_url) { UrlValidator::validate($notify_url, "NotifyUrl"); $this->notify_url = $notify_url; return $this; } /** * URL to send payment notifications * * @return string */ public function getNotifyUrl() { return $this->notify_url; } /** * Url on merchant site pertaining to this payment. * * @param string $order_url * @throws \InvalidArgumentException * @return $this */ public function setOrderUrl($order_url) { UrlValidator::validate($order_url, "OrderUrl"); $this->order_url = $order_url; return $this; } /** * Url on merchant site pertaining to this payment. * * @return string */ public function getOrderUrl() { return $this->order_url; } /** * List of external funding being applied to the purchase unit. Each external_funding unit should have a unique reference_id * * @deprecated Not publicly available * @param \PayPal\Api\ExternalFunding[] $external_funding * * @return $this */ public function setExternalFunding($external_funding) { $this->external_funding = $external_funding; return $this; } /** * List of external funding being applied to the purchase unit. Each external_funding unit should have a unique reference_id * * @deprecated Not publicly available * @return \PayPal\Api\ExternalFunding[] */ public function getExternalFunding() { return $this->external_funding; } /** * Append ExternalFunding to the list. * * @deprecated Not publicly available * @param \PayPal\Api\ExternalFunding $externalFunding * @return $this */ public function addExternalFunding($externalFunding) { if (!$this->getExternalFunding()) { return $this->setExternalFunding(array($externalFunding)); } else { return $this->setExternalFunding( array_merge($this->getExternalFunding(), array($externalFunding)) ); } } /** * Remove ExternalFunding from the list. * * @deprecated Not publicly available * @param \PayPal\Api\ExternalFunding $externalFunding * @return $this */ public function removeExternalFunding($externalFunding) { return $this->setExternalFunding( array_diff($this->getExternalFunding(), array($externalFunding)) ); } } rest-api-sdk-php/lib/PayPal/Api/OpenIdSession.php 0000644 00000007261 15007532371 0015545 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Core\PayPalConstants; use PayPal\Rest\ApiContext; class OpenIdSession { /** * Returns the PayPal URL to which the user must be redirected to * start the authentication / authorization process. * * @param string $redirectUri Uri on merchant website to where * the user must be redirected to post paypal login * @param array $scope The access privilges that you are requesting for * from the user. Pass empty array for all scopes. * @param string $clientId client id from developer portal * See https://developer.paypal.com/webapps/developer/docs/integration/direct/log-in-with-paypal/detailed/#attributes for more * @param null $nonce * @param null $state * @param ApiContext $apiContext Optional API Context * @return string Authorization URL */ public static function getAuthorizationUrl($redirectUri, $scope, $clientId, $nonce = null, $state = null, $apiContext = null) { $apiContext = $apiContext ? $apiContext : new ApiContext(); $config = $apiContext->getConfig(); if ($apiContext->get($clientId)) { $clientId = $apiContext->get($clientId); } $clientId = $clientId ? $clientId : $apiContext->getCredential()->getClientId(); $scope = count($scope) != 0 ? $scope : array('openid', 'profile', 'address', 'email', 'phone', 'https://uri.paypal.com/services/paypalattributes', 'https://uri.paypal.com/services/expresscheckout'); if (!in_array('openid', $scope)) { $scope[] = 'openid'; } $params = array( 'client_id' => $clientId, 'response_type' => 'code', 'scope' => implode(" ", $scope), 'redirect_uri' => $redirectUri ); if ($nonce) { $params['nonce'] = $nonce; } if ($state) { $params['state'] = $state; } return sprintf("%s/v1/authorize?%s", self::getBaseUrl($config), http_build_query($params)); } /** * Returns the URL to which the user must be redirected to * logout from the OpenID provider (i.e. PayPal) * * @param string $redirectUri Uri on merchant website to where * the user must be redirected to post logout * @param string $idToken id_token from the TokenInfo object * @param ApiContext $apiContext Optional API Context * @return string logout URL */ public static function getLogoutUrl($redirectUri, $idToken, $apiContext = null) { if (is_null($apiContext)) { $apiContext = new ApiContext(); } $config = $apiContext->getConfig(); $params = array( 'id_token' => $idToken, 'redirect_uri' => $redirectUri, 'logout' => 'true' ); return sprintf("%s/v1/endsession?%s", self::getBaseUrl($config), http_build_query($params)); } /** * Gets the base URL for the Redirect URI * * @param $config * @return null|string */ private static function getBaseUrl($config) { if (array_key_exists('openid.RedirectUri', $config)) { return $config['openid.RedirectUri']; } else if (array_key_exists('mode', $config)) { switch (strtoupper($config['mode'])) { case 'SANDBOX': return PayPalConstants::OPENID_REDIRECT_SANDBOX_URL; case 'LIVE': return PayPalConstants::OPENID_REDIRECT_LIVE_URL; } } return null; } } rest-api-sdk-php/lib/PayPal/Api/ShippingCost.php 0000644 00000002137 15007532371 0015432 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class ShippingCost * * Shipping cost in percent or amount. * * @package PayPal\Api * * @property \PayPal\Api\Currency amount * @property \PayPal\Api\Tax tax */ class ShippingCost extends PayPalModel { /** * Shipping cost in amount. Range of 0 to 999999.99. * * @param \PayPal\Api\Currency $amount * * @return $this */ 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; } /** * Tax percentage on shipping amount. * * @param \PayPal\Api\Tax $tax * * @return $this */ public function setTax($tax) { $this->tax = $tax; return $this; } /** * Tax percentage on shipping amount. * * @return \PayPal\Api\Tax */ public function getTax() { return $this->tax; } } rest-api-sdk-php/lib/PayPal/Api/PayoutBatchHeader.php 0000644 00000012602 15007532371 0016352 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class PayoutBatchHeader * * This object enables you to get payout header information for an entire batch request. This object represents payout header data, and can be the response to a batch header request. * * @package PayPal\Api * * @property string payout_batch_id * @property string batch_status * @property string time_created * @property string time_completed * @property \PayPal\Api\PayoutSenderBatchHeader sender_batch_header * @property \PayPal\Api\Currency amount * @property \PayPal\Api\Currency fees * @property \PayPal\Api\Error errors * @property \PayPal\Api\Links[] links */ class PayoutBatchHeader extends PayPalModel { /** * An ID for the batch payout. Generated by PayPal. 30 characters max. * * @param string $payout_batch_id * * @return $this */ public function setPayoutBatchId($payout_batch_id) { $this->payout_batch_id = $payout_batch_id; return $this; } /** * An ID for the batch payout. Generated by PayPal. 30 characters max. * * @return string */ public function getPayoutBatchId() { return $this->payout_batch_id; } /** * Generated batch status. * * @param string $batch_status * * @return $this */ public function setBatchStatus($batch_status) { $this->batch_status = $batch_status; return $this; } /** * Generated batch status. * * @return string */ public function getBatchStatus() { return $this->batch_status; } /** * The time the batch entered processing. * * @param string $time_created * * @return $this */ public function setTimeCreated($time_created) { $this->time_created = $time_created; return $this; } /** * The time the batch entered processing. * * @return string */ public function getTimeCreated() { return $this->time_created; } /** * The time that processing for the batch was completed. * * @param string $time_completed * * @return $this */ public function setTimeCompleted($time_completed) { $this->time_completed = $time_completed; return $this; } /** * The time that processing for the batch was completed. * * @return string */ public function getTimeCompleted() { return $this->time_completed; } /** * The original batch header as provided by the payment sender. * * @param \PayPal\Api\PayoutSenderBatchHeader $sender_batch_header * * @return $this */ public function setSenderBatchHeader($sender_batch_header) { $this->sender_batch_header = $sender_batch_header; return $this; } /** * The original batch header as provided by the payment sender. * * @return \PayPal\Api\PayoutSenderBatchHeader */ public function getSenderBatchHeader() { return $this->sender_batch_header; } /** * Total amount, in U.S. dollars, requested for the applicable payouts. * * @param \PayPal\Api\Currency $amount * * @return $this */ public function setAmount($amount) { $this->amount = $amount; return $this; } /** * Total amount, in U.S. dollars, requested for the applicable payouts. * * @return \PayPal\Api\Currency */ public function getAmount() { return $this->amount; } /** * Total estimate in U.S. dollars for the applicable payouts fees. * * @param \PayPal\Api\Currency $fees * * @return $this */ public function setFees($fees) { $this->fees = $fees; return $this; } /** * Total estimate in U.S. dollars for the applicable payouts fees. * * @return \PayPal\Api\Currency */ public function getFees() { return $this->fees; } /** * Sets Errors * * @param \PayPal\Api\Error $errors * * @return $this */ public function setErrors($errors) { $this->errors = $errors; return $this; } /** * Gets Errors * * @return \PayPal\Api\Error */ public function getErrors() { return $this->errors; } /** * Sets Links * * @param \PayPal\Api\Links[] $links * * @return $this */ public function setLinks($links) { $this->links = $links; return $this; } /** * Gets Links * * @return \PayPal\Api\Links[] */ public function getLinks() { return $this->links; } /** * Append Links to the list. * * @param \PayPal\Api\Links $links * @return $this */ public function addLink($links) { if (!$this->getLinks()) { return $this->setLinks(array($links)); } else { return $this->setLinks( array_merge($this->getLinks(), array($links)) ); } } /** * Remove Links from the list. * * @param \PayPal\Api\Links $links * @return $this */ public function removeLink($links) { return $this->setLinks( array_diff($this->getLinks(), array($links)) ); } } rest-api-sdk-php/lib/PayPal/Api/Payer.php 0000644 00000015354 15007532371 0014105 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class Payer * * A resource representing a Payer that funds a payment. * * @package PayPal\Api * * @property string payment_method * @property string status * @property \PayPal\Api\FundingInstrument[] funding_instruments * @property string funding_option_id * @property \PayPal\Api\PayerInfo payer_info */ class Payer extends PayPalModel { /** * Payment method being used - PayPal Wallet payment, Bank Direct Debit or Direct Credit card. * Valid Values: ["credit_card", "bank", "paypal", "pay_upon_invoice", "carrier", "alternate_payment"] * * @param string $payment_method * * @return $this */ public function setPaymentMethod($payment_method) { $this->payment_method = $payment_method; return $this; } /** * Payment method being used - PayPal Wallet payment, Bank Direct Debit or Direct Credit card. * * @return string */ public function getPaymentMethod() { return $this->payment_method; } /** * Status of payer's PayPal Account. * Valid Values: ["VERIFIED", "UNVERIFIED"] * * @param string $status * * @return $this */ public function setStatus($status) { $this->status = $status; return $this; } /** * Status of payer's PayPal Account. * * @return string */ public function getStatus() { return $this->status; } /** * Type of account relationship payer has with PayPal. * Valid Values: ["BUSINESS", "PERSONAL", "PREMIER"] * * @deprecated Not publicly available * @param string $account_type * * @return $this */ public function setAccountType($account_type) { $this->account_type = $account_type; return $this; } /** * Type of account relationship payer has with PayPal. * * @deprecated Not publicly available * @return string */ public function getAccountType() { return $this->account_type; } /** * Duration since the payer established account relationship with PayPal in days. * * @deprecated Not publicly available * @param string $account_age * * @return $this */ public function setAccountAge($account_age) { $this->account_age = $account_age; return $this; } /** * Duration since the payer established account relationship with PayPal in days. * * @deprecated Not publicly available * @return string */ public function getAccountAge() { return $this->account_age; } /** * List of funding instruments to fund the payment. 'OneOf' funding_instruments,funding_option_id to be used to identify the specifics of payment method passed. * * @param \PayPal\Api\FundingInstrument[] $funding_instruments * * @return $this */ public function setFundingInstruments($funding_instruments) { $this->funding_instruments = $funding_instruments; return $this; } /** * List of funding instruments to fund the payment. 'OneOf' funding_instruments,funding_option_id to be used to identify the specifics of payment method passed. * * @return \PayPal\Api\FundingInstrument[] */ public function getFundingInstruments() { return $this->funding_instruments; } /** * Append FundingInstruments to the list. * * @param \PayPal\Api\FundingInstrument $fundingInstrument * @return $this */ public function addFundingInstrument($fundingInstrument) { if (!$this->getFundingInstruments()) { return $this->setFundingInstruments(array($fundingInstrument)); } else { return $this->setFundingInstruments( array_merge($this->getFundingInstruments(), array($fundingInstrument)) ); } } /** * Remove FundingInstruments from the list. * * @param \PayPal\Api\FundingInstrument $fundingInstrument * @return $this */ public function removeFundingInstrument($fundingInstrument) { return $this->setFundingInstruments( array_diff($this->getFundingInstruments(), array($fundingInstrument)) ); } /** * Id of user selected funding option for the payment.'OneOf' funding_instruments,funding_option_id to be used to identify the specifics of payment method passed. * * @param string $funding_option_id * * @return $this */ public function setFundingOptionId($funding_option_id) { $this->funding_option_id = $funding_option_id; return $this; } /** * Id of user selected funding option for the payment.'OneOf' funding_instruments,funding_option_id to be used to identify the specifics of payment method passed. * * @return string */ public function getFundingOptionId() { return $this->funding_option_id; } /** * Default funding option available for the payment * * @deprecated Not publicly available * @param \PayPal\Api\FundingOption $funding_option * * @return $this */ public function setFundingOption($funding_option) { $this->funding_option = $funding_option; return $this; } /** * Default funding option available for the payment * * @deprecated Not publicly available * @return \PayPal\Api\FundingOption */ public function getFundingOption() { return $this->funding_option; } /** * Funding option related to default funding option. * * @deprecated Not publicly available * @param \PayPal\Api\FundingOption $related_funding_option * * @return $this */ public function setRelatedFundingOption($related_funding_option) { $this->related_funding_option = $related_funding_option; return $this; } /** * Funding option related to default funding option. * * @deprecated Not publicly available * @return \PayPal\Api\FundingOption */ public function getRelatedFundingOption() { return $this->related_funding_option; } /** * Information related to the Payer. * * @param \PayPal\Api\PayerInfo $payer_info * * @return $this */ public function setPayerInfo($payer_info) { $this->payer_info = $payer_info; return $this; } /** * Information related to the Payer. * * @return \PayPal\Api\PayerInfo */ public function getPayerInfo() { return $this->payer_info; } } rest-api-sdk-php/lib/PayPal/Api/BankToken.php 0000644 00000003764 15007532371 0014703 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class BankToken * * A resource representing a bank that can be used to fund a payment. * * @package PayPal\Api * * @property string bank_id * @property string external_customer_id * @property string mandate_reference_number */ class BankToken extends PayPalModel { /** * ID of a previously saved Bank resource using /vault/bank API. * * @param string $bank_id * * @return $this */ public function setBankId($bank_id) { $this->bank_id = $bank_id; return $this; } /** * ID of a previously saved Bank resource using /vault/bank API. * * @return string */ public function getBankId() { return $this->bank_id; } /** * The unique identifier of the payer used when saving this bank using /vault/bank API. * * @param string $external_customer_id * * @return $this */ public function setExternalCustomerId($external_customer_id) { $this->external_customer_id = $external_customer_id; return $this; } /** * The unique identifier of the payer used when saving this bank using /vault/bank API. * * @return string */ public function getExternalCustomerId() { return $this->external_customer_id; } /** * Identifier of the direct debit mandate to validate. Currently supported only for EU bank accounts(SEPA). * * @param string $mandate_reference_number * * @return $this */ public function setMandateReferenceNumber($mandate_reference_number) { $this->mandate_reference_number = $mandate_reference_number; return $this; } /** * Identifier of the direct debit mandate to validate. Currently supported only for EU bank accounts(SEPA). * * @return string */ public function getMandateReferenceNumber() { return $this->mandate_reference_number; } } rest-api-sdk-php/lib/PayPal/Api/ExternalFunding.php 0000644 00000005163 15007532371 0016117 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class ExternalFunding * * A resource representing an external funding object. * * @package PayPal\Api * * @property string reference_id * @property string code * @property string funding_account_id * @property string display_text * @property \PayPal\Api\Amount amount */ class ExternalFunding extends PayPalModel { /** * Unique identifier for the external funding * * @param string $reference_id * * @return $this */ public function setReferenceId($reference_id) { $this->reference_id = $reference_id; return $this; } /** * Unique identifier for the external funding * * @return string */ public function getReferenceId() { return $this->reference_id; } /** * Generic identifier for the external funding * * @param string $code * * @return $this */ public function setCode($code) { $this->code = $code; return $this; } /** * Generic identifier for the external funding * * @return string */ public function getCode() { return $this->code; } /** * Encrypted PayPal Account identifier for the funding account * * @param string $funding_account_id * * @return $this */ public function setFundingAccountId($funding_account_id) { $this->funding_account_id = $funding_account_id; return $this; } /** * Encrypted PayPal Account identifier for the funding account * * @return string */ public function getFundingAccountId() { return $this->funding_account_id; } /** * Description of the external funding being applied * * @param string $display_text * * @return $this */ public function setDisplayText($display_text) { $this->display_text = $display_text; return $this; } /** * Description of the external funding being applied * * @return string */ public function getDisplayText() { return $this->display_text; } /** * Amount being funded by the external funding account * * @param \PayPal\Api\Amount $amount * * @return $this */ public function setAmount($amount) { $this->amount = $amount; return $this; } /** * Amount being funded by the external funding account * * @return \PayPal\Api\Amount */ public function getAmount() { return $this->amount; } } rest-api-sdk-php/lib/PayPal/Api/BaseAddress.php 0000644 00000010173 15007532371 0015177 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class BaseAddress * * Base Address object used as billing address in a payment or extended for Shipping Address. * * @package PayPal\Api * * @property string line1 * @property string line2 * @property string city * @property string country_code * @property string postal_code * @property string state * @property string normalization_status * @property string status */ class BaseAddress extends PayPalModel { /** * Line 1 of the Address (eg. number, street, etc). * * @param string $line1 * * @return $this */ public function setLine1($line1) { $this->line1 = $line1; return $this; } /** * Line 1 of the Address (eg. number, street, etc). * * @return string */ public function getLine1() { return $this->line1; } /** * Optional line 2 of the Address (eg. suite, apt #, etc.). * * @param string $line2 * * @return $this */ public function setLine2($line2) { $this->line2 = $line2; return $this; } /** * Optional line 2 of the Address (eg. suite, apt #, etc.). * * @return string */ public function getLine2() { return $this->line2; } /** * City name. * * @param string $city * * @return $this */ public function setCity($city) { $this->city = $city; return $this; } /** * City name. * * @return string */ public function getCity() { return $this->city; } /** * 2 letter country code. * * @param string $country_code * * @return $this */ public function setCountryCode($country_code) { $this->country_code = $country_code; return $this; } /** * 2 letter country code. * * @return string */ public function getCountryCode() { return $this->country_code; } /** * Zip code or equivalent is usually required for countries that have them. For list of countries that do not have postal codes please refer to http://en.wikipedia.org/wiki/Postal_code. * * @param string $postal_code * * @return $this */ public function setPostalCode($postal_code) { $this->postal_code = $postal_code; return $this; } /** * Zip code or equivalent is usually required for countries that have them. For list of countries that do not have postal codes please refer to http://en.wikipedia.org/wiki/Postal_code. * * @return string */ public function getPostalCode() { return $this->postal_code; } /** * 2 letter code for US states, and the equivalent for other countries. * * @param string $state * * @return $this */ public function setState($state) { $this->state = $state; return $this; } /** * 2 letter code for US states, and the equivalent for other countries. * * @return string */ public function getState() { return $this->state; } /** * Address normalization status * Valid Values: ["UNKNOWN", "UNNORMALIZED_USER_PREFERRED", "NORMALIZED", "UNNORMALIZED"] * * @param string $normalization_status * * @return $this */ public function setNormalizationStatus($normalization_status) { $this->normalization_status = $normalization_status; return $this; } /** * Address normalization status * * @return string */ public function getNormalizationStatus() { return $this->normalization_status; } /** * Address status * Valid Values: ["CONFIRMED", "UNCONFIRMED"] * * @param string $status * * @return $this */ public function setStatus($status) { $this->status = $status; return $this; } /** * Address status * * @return string */ public function getStatus() { return $this->status; } } rest-api-sdk-php/lib/PayPal/Api/PaymentTerm.php 0000644 00000002743 15007532371 0015270 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class PaymentTerm * * Payment term of the invoice. If term_type is present, due_date must not be present and vice versa. * * @package PayPal\Api * * @property string term_type * @property string due_date */ class PaymentTerm extends PayPalModel { /** * Terms by which the invoice payment is due. * Valid Values: ["DUE_ON_RECEIPT", "NET_10", "NET_15", "NET_30", "NET_45"] * * @param string $term_type * * @return $this */ 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; } /** * Date on which invoice payment is due. It must be always a future date. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). * * @param string $due_date * * @return $this */ 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, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). * * @return string */ public function getDueDate() { return $this->due_date; } } rest-api-sdk-php/lib/PayPal/Api/Error.php 0000644 00000015512 15007532371 0014112 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class Error * * Details of an Error * * @package PayPal\Api * * @property string name * @property string message * @property \PayPal\Api\ErrorDetails[] details * @property string information_link * @property string debug_id * @property \PayPal\Api\Links[] links */ class Error extends PayPalModel { /** * Human readable, unique name of the error. * * @param string $name * * @return $this */ public function setName($name) { $this->name = $name; return $this; } /** * Human readable, unique name of the error. * * @return string */ public function getName() { return $this->name; } /** * Reference ID of the purchase_unit associated with this error * * @deprecated Not publicly available * @param string $purchase_unit_reference_id * * @return $this */ public function setPurchaseUnitReferenceId($purchase_unit_reference_id) { $this->purchase_unit_reference_id = $purchase_unit_reference_id; return $this; } /** * Reference ID of the purchase_unit associated with this error * * @deprecated Not publicly available * @return string */ public function getPurchaseUnitReferenceId() { return $this->purchase_unit_reference_id; } /** * Message describing the error. * * @param string $message * * @return $this */ public function setMessage($message) { $this->message = $message; return $this; } /** * Message describing the error. * * @return string */ public function getMessage() { return $this->message; } /** * PayPal internal error code. * * @deprecated Not publicly available * @param string $code * * @return $this */ public function setCode($code) { $this->code = $code; return $this; } /** * PayPal internal error code. * * @deprecated Not publicly available * @return string */ public function getCode() { return $this->code; } /** * Additional details of the error * * @param \PayPal\Api\ErrorDetails[] $details * * @return $this */ public function setDetails($details) { $this->details = $details; return $this; } /** * Additional details of the error * * @return \PayPal\Api\ErrorDetails[] */ public function getDetails() { return $this->details; } /** * Append Details to the list. * * @param \PayPal\Api\ErrorDetails $errorDetails * @return $this */ public function addDetail($errorDetails) { if (!$this->getDetails()) { return $this->setDetails(array($errorDetails)); } else { return $this->setDetails( array_merge($this->getDetails(), array($errorDetails)) ); } } /** * Remove Details from the list. * * @param \PayPal\Api\ErrorDetails $errorDetails * @return $this */ public function removeDetail($errorDetails) { return $this->setDetails( array_diff($this->getDetails(), array($errorDetails)) ); } /** * response codes returned from a payment processor such as avs, cvv, etc. Only supported when the `payment_method` is set to `credit_card`. * * @deprecated Not publicly available * @param \PayPal\Api\ProcessorResponse $processor_response * * @return $this */ public function setProcessorResponse($processor_response) { $this->processor_response = $processor_response; return $this; } /** * response codes returned from a payment processor such as avs, cvv, etc. Only supported when the `payment_method` is set to `credit_card`. * * @deprecated Not publicly available * @return \PayPal\Api\ProcessorResponse */ public function getProcessorResponse() { return $this->processor_response; } /** * Fraud filter details. Only supported when the `payment_method` is set to `credit_card` * * @deprecated Not publicly available * @param \PayPal\Api\FmfDetails $fmf_details * * @return $this */ public function setFmfDetails($fmf_details) { $this->fmf_details = $fmf_details; return $this; } /** * Fraud filter details. Only supported when the `payment_method` is set to `credit_card` * * @deprecated Not publicly available * @return \PayPal\Api\FmfDetails */ public function getFmfDetails() { return $this->fmf_details; } /** * URI for detailed information related to this error for the developer. * * @param string $information_link * * @return $this */ 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; } /** * PayPal internal identifier used for correlation purposes. * * @param string $debug_id * * @return $this */ 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; } /** * Sets Links * * @param \PayPal\Api\Links[] $links * * @return $this */ public function setLinks($links) { $this->links = $links; return $this; } /** * Gets Links * * @return \PayPal\Api\Links[] */ public function getLinks() { return $this->links; } /** * Append Links to the list. * * @param \PayPal\Api\Links $links * @return $this */ public function addLink($links) { if (!$this->getLinks()) { return $this->setLinks(array($links)); } else { return $this->setLinks( array_merge($this->getLinks(), array($links)) ); } } /** * Remove Links from the list. * * @param \PayPal\Api\Links $links * @return $this */ public function removeLink($links) { return $this->setLinks( array_diff($this->getLinks(), array($links)) ); } } rest-api-sdk-php/lib/PayPal/Api/FundingDetail.php 0000644 00000004472 15007532371 0015541 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class FundingDetail * * Additional detail of the funding. * * @package PayPal\Api * * @property string clearing_time * @property string payment_hold_date * @property string payment_debit_date * @property string processing_type */ class FundingDetail extends PayPalModel { /** * Expected clearing time * * @param string $clearing_time * * @return $this */ public function setClearingTime($clearing_time) { $this->clearing_time = $clearing_time; return $this; } /** * Expected clearing time * * @return string */ public function getClearingTime() { return $this->clearing_time; } /** * [DEPRECATED] Hold-off duration of the payment. payment_debit_date should be used instead. * * @param string $payment_hold_date * * @return $this */ public function setPaymentHoldDate($payment_hold_date) { $this->payment_hold_date = $payment_hold_date; return $this; } /** * @deprecated [DEPRECATED] Hold-off duration of the payment. payment_debit_date should be used instead. * * @return string */ public function getPaymentHoldDate() { return $this->payment_hold_date; } /** * Date when funds will be debited from the payer's account * * @param string $payment_debit_date * * @return $this */ public function setPaymentDebitDate($payment_debit_date) { $this->payment_debit_date = $payment_debit_date; return $this; } /** * Date when funds will be debited from the payer's account * * @return string */ public function getPaymentDebitDate() { return $this->payment_debit_date; } /** * Processing type of the payment card * Valid Values: ["PINLESS_DEBIT"] * * @param string $processing_type * * @return $this */ public function setProcessingType($processing_type) { $this->processing_type = $processing_type; return $this; } /** * Processing type of the payment card * * @return string */ public function getProcessingType() { return $this->processing_type; } } rest-api-sdk-php/lib/PayPal/Api/InvoiceItem.php 0000644 00000007344 15007532371 0015240 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; use PayPal\Converter\FormatConverter; use PayPal\Validation\NumericValidator; /** * Class InvoiceItem * * Information about a single line item. * * @package PayPal\Api * * @property string name * @property string description * @property \PayPal\Api\number quantity * @property \PayPal\Api\Currency unit_price * @property \PayPal\Api\Tax tax * @property string date * @property \PayPal\Api\Cost discount */ class InvoiceItem extends PayPalModel { /** * Name of the item. 60 characters max. * * @param string $name * * @return $this */ public function setName($name) { $this->name = $name; return $this; } /** * 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 * * @return $this */ public function setDescription($description) { $this->description = $description; return $this; } /** * 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 string|double $quantity * * @return $this */ public function setQuantity($quantity) { NumericValidator::validate($quantity, "Percent"); $quantity = FormatConverter::formatToPrice($quantity); $this->quantity = $quantity; return $this; } /** * Quantity of the item. Range of 0 to 9999.999. * * @return string */ public function getQuantity() { return $this->quantity; } /** * Unit price of the item. Range of -999999.99 to 999999.99. * * @param \PayPal\Api\Currency $unit_price * * @return $this */ 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; } /** * Tax associated with the item. * * @param \PayPal\Api\Tax $tax * * @return $this */ 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, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). * * @param string $date * * @return $this */ public function setDate($date) { $this->date = $date; return $this; } /** * Date on which the item or service was provided. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). * * @return string */ public function getDate() { return $this->date; } /** * Item discount in percent or amount. * * @param \PayPal\Api\Cost $discount * * @return $this */ 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; } } rest-api-sdk-php/lib/PayPal/Api/BankAccount.php 0000644 00000034256 15007532371 0015217 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class BankAccount * * A resource representing a bank account that can be used to fund a payment. * * @package PayPal\Api * * @property string account_number * @property string account_number_type * @property string routing_number * @property string account_type * @property string account_name * @property string check_type * @property string auth_type * @property string auth_capture_timestamp * @property string bank_name * @property string country_code * @property string first_name * @property string last_name * @property string birth_date * @property \PayPal\Api\Address billing_address * @property string state * @property string confirmation_status * @property string payer_id * @property string external_customer_id * @property string merchant_id * @property string create_time * @property string update_time * @property string valid_until * @property \PayPal\Api\Links[] links */ class BankAccount extends PayPalModel { /** * ID of the bank account being saved for later use. * * @deprecated Not publicly available * @param string $id * * @return $this */ public function setId($id) { $this->id = $id; return $this; } /** * ID of the bank account being saved for later use. * * @deprecated Not publicly available * @return string */ public function getId() { return $this->id; } /** * Account number in either IBAN (max length 34) or BBAN (max length 17) format. * * @param string $account_number * * @return $this */ public function setAccountNumber($account_number) { $this->account_number = $account_number; return $this; } /** * Account number in either IBAN (max length 34) or BBAN (max length 17) format. * * @return string */ public function getAccountNumber() { return $this->account_number; } /** * Type of the bank account number (International or Basic Bank Account Number). For more information refer to http://en.wikipedia.org/wiki/International_Bank_Account_Number. * Valid Values: ["BBAN", "IBAN"] * * @param string $account_number_type * * @return $this */ public function setAccountNumberType($account_number_type) { $this->account_number_type = $account_number_type; return $this; } /** * Type of the bank account number (International or Basic Bank Account Number). For more information refer to http://en.wikipedia.org/wiki/International_Bank_Account_Number. * * @return string */ public function getAccountNumberType() { return $this->account_number_type; } /** * Routing transit number (aka Bank Code) of the bank (typically for domestic use only - for international use, IBAN includes bank code). For more information refer to http://en.wikipedia.org/wiki/Bank_code. * * @param string $routing_number * * @return $this */ public function setRoutingNumber($routing_number) { $this->routing_number = $routing_number; return $this; } /** * Routing transit number (aka Bank Code) of the bank (typically for domestic use only - for international use, IBAN includes bank code). For more information refer to http://en.wikipedia.org/wiki/Bank_code. * * @return string */ public function getRoutingNumber() { return $this->routing_number; } /** * Type of the bank account. * Valid Values: ["CHECKING", "SAVINGS"] * * @param string $account_type * * @return $this */ public function setAccountType($account_type) { $this->account_type = $account_type; return $this; } /** * Type of the bank account. * * @return string */ public function getAccountType() { return $this->account_type; } /** * A customer designated name. * * @param string $account_name * * @return $this */ public function setAccountName($account_name) { $this->account_name = $account_name; return $this; } /** * A customer designated name. * * @return string */ public function getAccountName() { return $this->account_name; } /** * Type of the check when this information was obtained through a check by the facilitator or merchant. * Valid Values: ["PERSONAL", "COMPANY"] * * @param string $check_type * * @return $this */ public function setCheckType($check_type) { $this->check_type = $check_type; return $this; } /** * Type of the check when this information was obtained through a check by the facilitator or merchant. * * @return string */ public function getCheckType() { return $this->check_type; } /** * How the check was obtained from the customer, if check was the source of the information provided. * Valid Values: ["CCD", "PPD", "TEL", "POP", "ARC", "RCK", "WEB"] * * @param string $auth_type * * @return $this */ public function setAuthType($auth_type) { $this->auth_type = $auth_type; return $this; } /** * How the check was obtained from the customer, if check was the source of the information provided. * * @return string */ public function getAuthType() { return $this->auth_type; } /** * Time at which the authorization (or check) was captured. Use this field if the user authorization needs to be captured due to any privacy requirements. * * @param string $auth_capture_timestamp * * @return $this */ public function setAuthCaptureTimestamp($auth_capture_timestamp) { $this->auth_capture_timestamp = $auth_capture_timestamp; return $this; } /** * Time at which the authorization (or check) was captured. Use this field if the user authorization needs to be captured due to any privacy requirements. * * @return string */ public function getAuthCaptureTimestamp() { return $this->auth_capture_timestamp; } /** * Name of the bank. * * @param string $bank_name * * @return $this */ public function setBankName($bank_name) { $this->bank_name = $bank_name; return $this; } /** * Name of the bank. * * @return string */ public function getBankName() { return $this->bank_name; } /** * 2 letter country code of the Bank. * * @param string $country_code * * @return $this */ public function setCountryCode($country_code) { $this->country_code = $country_code; return $this; } /** * 2 letter country code of the Bank. * * @return string */ public function getCountryCode() { return $this->country_code; } /** * Account holder's first name. * * @param string $first_name * * @return $this */ public function setFirstName($first_name) { $this->first_name = $first_name; return $this; } /** * Account holder's first name. * * @return string */ public function getFirstName() { return $this->first_name; } /** * Account holder's last name. * * @param string $last_name * * @return $this */ public function setLastName($last_name) { $this->last_name = $last_name; return $this; } /** * Account holder's last name. * * @return string */ public function getLastName() { return $this->last_name; } /** * Birth date of the bank account holder. * * @param string $birth_date * * @return $this */ public function setBirthDate($birth_date) { $this->birth_date = $birth_date; return $this; } /** * Birth date of the bank account holder. * * @return string */ public function getBirthDate() { return $this->birth_date; } /** * Billing address. * * @param \PayPal\Api\Address $billing_address * * @return $this */ public function setBillingAddress($billing_address) { $this->billing_address = $billing_address; return $this; } /** * Billing address. * * @return \PayPal\Api\Address */ public function getBillingAddress() { return $this->billing_address; } /** * State of this funding instrument. * Valid Values: ["ACTIVE", "INACTIVE", "DELETED"] * * @param string $state * * @return $this */ public function setState($state) { $this->state = $state; return $this; } /** * State of this funding instrument. * * @return string */ public function getState() { return $this->state; } /** * Confirmation status of a bank account. * Valid Values: ["UNCONFIRMED", "CONFIRMED"] * * @param string $confirmation_status * * @return $this */ public function setConfirmationStatus($confirmation_status) { $this->confirmation_status = $confirmation_status; return $this; } /** * Confirmation status of a bank account. * * @return string */ public function getConfirmationStatus() { return $this->confirmation_status; } /** * [DEPRECATED] Use external_customer_id instead. * * @param string $payer_id * * @return $this */ public function setPayerId($payer_id) { $this->payer_id = $payer_id; return $this; } /** * @deprecated [DEPRECATED] Use external_customer_id instead. * * @return string */ public function getPayerId() { return $this->payer_id; } /** * A unique identifier of the customer to whom this bank account belongs to. Generated and provided by the facilitator. This is required when creating or using a stored funding instrument in vault. * * @param string $external_customer_id * * @return $this */ public function setExternalCustomerId($external_customer_id) { $this->external_customer_id = $external_customer_id; return $this; } /** * A unique identifier of the customer to whom this bank account belongs to. Generated and provided by the facilitator. This is required when creating or using a stored funding instrument in vault. * * @return string */ public function getExternalCustomerId() { return $this->external_customer_id; } /** * A unique identifier of the merchant for which this bank account has been stored for. Generated and provided by the facilitator so it can be used to restrict the usage of the bank account to the specific merchnt. * * @param string $merchant_id * * @return $this */ public function setMerchantId($merchant_id) { $this->merchant_id = $merchant_id; return $this; } /** * A unique identifier of the merchant for which this bank account has been stored for. Generated and provided by the facilitator so it can be used to restrict the usage of the bank account to the specific merchnt. * * @return string */ public function getMerchantId() { return $this->merchant_id; } /** * Time the resource was created. * * @param string $create_time * * @return $this */ public function setCreateTime($create_time) { $this->create_time = $create_time; return $this; } /** * Time the resource was created. * * @return string */ public function getCreateTime() { return $this->create_time; } /** * Time the resource was last updated. * * @param string $update_time * * @return $this */ public function setUpdateTime($update_time) { $this->update_time = $update_time; return $this; } /** * Time the resource was last updated. * * @return string */ public function getUpdateTime() { return $this->update_time; } /** * Date/Time until this resource can be used to fund a payment. * * @param string $valid_until * * @return $this */ public function setValidUntil($valid_until) { $this->valid_until = $valid_until; return $this; } /** * Date/Time until this resource can be used to fund a payment. * * @return string */ public function getValidUntil() { return $this->valid_until; } /** * Sets Links * * @param \PayPal\Api\Links[] $links * * @return $this */ public function setLinks($links) { $this->links = $links; return $this; } /** * Gets Links * * @return \PayPal\Api\Links[] */ public function getLinks() { return $this->links; } /** * Append Links to the list. * * @param \PayPal\Api\Links $links * @return $this */ public function addLink($links) { if (!$this->getLinks()) { return $this->setLinks(array($links)); } else { return $this->setLinks( array_merge($this->getLinks(), array($links)) ); } } /** * Remove Links from the list. * * @param \PayPal\Api\Links $links * @return $this */ public function removeLink($links) { return $this->setLinks( array_diff($this->getLinks(), array($links)) ); } } rest-api-sdk-php/lib/PayPal/Api/InvoiceSearchResponse.php 0000644 00000003435 15007532371 0017263 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class InvoiceSearchResponse * * * * @package PayPal\Api * * @property int total_count * @property \PayPal\Api\Invoice[] invoices */ class InvoiceSearchResponse extends PayPalModel { /** * Total number of invoices. * * @param int $total_count * * @return $this */ public function setTotalCount($total_count) { $this->total_count = $total_count; return $this; } /** * Total number of invoices. * * @return int */ public function getTotalCount() { return $this->total_count; } /** * List of invoices belonging to a merchant. * * @param \PayPal\Api\Invoice[] $invoices * * @return $this */ 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; } /** * Append Invoices to the list. * * @param \PayPal\Api\Invoice $invoice * @return $this */ public function addInvoice($invoice) { if (!$this->getInvoices()) { return $this->setInvoices(array($invoice)); } else { return $this->setInvoices( array_merge($this->getInvoices(), array($invoice)) ); } } /** * Remove Invoices from the list. * * @param \PayPal\Api\Invoice $invoice * @return $this */ public function removeInvoice($invoice) { return $this->setInvoices( array_diff($this->getInvoices(), array($invoice)) ); } } rest-api-sdk-php/lib/PayPal/Api/FundingOption.php 0000644 00000011606 15007532371 0015604 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class FundingOption * * specifies the funding option details. * * @package PayPal\Api * * @property string id * @property \PayPal\Api\FundingSource[] funding_sources * @property \PayPal\Api\FundingInstrument backup_funding_instrument * @property \PayPal\Api\CurrencyConversion currency_conversion * @property \PayPal\Api\InstallmentInfo installment_info * @property \PayPal\Api\Links[] links */ class FundingOption extends PayPalModel { /** * id of the funding option. * * @param string $id * * @return $this */ public function setId($id) { $this->id = $id; return $this; } /** * id of the funding option. * * @return string */ public function getId() { return $this->id; } /** * List of funding sources that contributes to a payment. * * @param \PayPal\Api\FundingSource[] $funding_sources * * @return $this */ public function setFundingSources($funding_sources) { $this->funding_sources = $funding_sources; return $this; } /** * List of funding sources that contributes to a payment. * * @return \PayPal\Api\FundingSource[] */ public function getFundingSources() { return $this->funding_sources; } /** * Append FundingSources to the list. * * @param \PayPal\Api\FundingSource $fundingSource * @return $this */ public function addFundingSource($fundingSource) { if (!$this->getFundingSources()) { return $this->setFundingSources(array($fundingSource)); } else { return $this->setFundingSources( array_merge($this->getFundingSources(), array($fundingSource)) ); } } /** * Remove FundingSources from the list. * * @param \PayPal\Api\FundingSource $fundingSource * @return $this */ public function removeFundingSource($fundingSource) { return $this->setFundingSources( array_diff($this->getFundingSources(), array($fundingSource)) ); } /** * Backup funding instrument which will be used for payment if primary fails. * * @param \PayPal\Api\FundingInstrument $backup_funding_instrument * * @return $this */ public function setBackupFundingInstrument($backup_funding_instrument) { $this->backup_funding_instrument = $backup_funding_instrument; return $this; } /** * Backup funding instrument which will be used for payment if primary fails. * * @return \PayPal\Api\FundingInstrument */ public function getBackupFundingInstrument() { return $this->backup_funding_instrument; } /** * Currency conversion applicable to this funding option. * * @param \PayPal\Api\CurrencyConversion $currency_conversion * * @return $this */ public function setCurrencyConversion($currency_conversion) { $this->currency_conversion = $currency_conversion; return $this; } /** * Currency conversion applicable to this funding option. * * @return \PayPal\Api\CurrencyConversion */ public function getCurrencyConversion() { return $this->currency_conversion; } /** * Installment options available for a funding option. * * @param \PayPal\Api\InstallmentInfo $installment_info * * @return $this */ public function setInstallmentInfo($installment_info) { $this->installment_info = $installment_info; return $this; } /** * Installment options available for a funding option. * * @return \PayPal\Api\InstallmentInfo */ public function getInstallmentInfo() { return $this->installment_info; } /** * Sets Links * * @param \PayPal\Api\Links[] $links * * @return $this */ public function setLinks($links) { $this->links = $links; return $this; } /** * Gets Links * * @return \PayPal\Api\Links[] */ public function getLinks() { return $this->links; } /** * Append Links to the list. * * @param \PayPal\Api\Links $links * @return $this */ public function addLink($links) { if (!$this->getLinks()) { return $this->setLinks(array($links)); } else { return $this->setLinks( array_merge($this->getLinks(), array($links)) ); } } /** * Remove Links from the list. * * @param \PayPal\Api\Links $links * @return $this */ public function removeLink($links) { return $this->setLinks( array_diff($this->getLinks(), array($links)) ); } } rest-api-sdk-php/lib/PayPal/Api/OverrideChargeModel.php 0000644 00000002250 15007532371 0016666 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class OverrideChargeModel * * A resource representing an override_charge_model to be used during creation of the agreement. * * @package PayPal\Api * * @property string charge_id * @property \PayPal\Api\Currency amount */ class OverrideChargeModel extends PayPalModel { /** * ID of charge model. * * @param string $charge_id * * @return $this */ public function setChargeId($charge_id) { $this->charge_id = $charge_id; return $this; } /** * ID of charge model. * * @return string */ public function getChargeId() { return $this->charge_id; } /** * Updated Amount to be associated with this charge model. * * @param \PayPal\Api\Currency $amount * * @return $this */ public function setAmount($amount) { $this->amount = $amount; return $this; } /** * Updated Amount to be associated with this charge model. * * @return \PayPal\Api\Currency */ public function getAmount() { return $this->amount; } } rest-api-sdk-php/lib/PayPal/Api/InstallmentOption.php 0000644 00000004240 15007532371 0016500 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class InstallmentOption * * A resource describing an installment * * @package PayPal\Api * * @property int term * @property \PayPal\Api\Currency monthly_payment * @property \PayPal\Api\Currency discount_amount * @property string discount_percentage */ class InstallmentOption extends PayPalModel { /** * Number of installments * * @param int $term * * @return $this */ public function setTerm($term) { $this->term = $term; return $this; } /** * Number of installments * * @return int */ public function getTerm() { return $this->term; } /** * Monthly payment * * @param \PayPal\Api\Currency $monthly_payment * * @return $this */ public function setMonthlyPayment($monthly_payment) { $this->monthly_payment = $monthly_payment; return $this; } /** * Monthly payment * * @return \PayPal\Api\Currency */ public function getMonthlyPayment() { return $this->monthly_payment; } /** * Discount amount applied to the payment, if any * * @param \PayPal\Api\Currency $discount_amount * * @return $this */ public function setDiscountAmount($discount_amount) { $this->discount_amount = $discount_amount; return $this; } /** * Discount amount applied to the payment, if any * * @return \PayPal\Api\Currency */ public function getDiscountAmount() { return $this->discount_amount; } /** * Discount percentage applied to the payment, if any * * @param string $discount_percentage * * @return $this */ public function setDiscountPercentage($discount_percentage) { $this->discount_percentage = $discount_percentage; return $this; } /** * Discount percentage applied to the payment, if any * * @return string */ public function getDiscountPercentage() { return $this->discount_percentage; } } rest-api-sdk-php/lib/PayPal/Api/ProcessorResponse.php 0000644 00000007416 15007532371 0016523 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class ProcessorResponse * * Collection of payment response related fields returned from a payment request * * @package PayPal\Api * * @property string response_code * @property string avs_code * @property string cvv_code * @property string advice_code * @property string eci_submitted * @property string vpas */ class ProcessorResponse extends PayPalModel { /** * Paypal normalized response code, generated from the processor's specific response code * * @param string $response_code * * @return $this */ public function setResponseCode($response_code) { $this->response_code = $response_code; return $this; } /** * Paypal normalized response code, generated from the processor's specific response code * * @return string */ public function getResponseCode() { return $this->response_code; } /** * Address Verification System response code. https://developer.paypal.com/webapps/developer/docs/classic/api/AVSResponseCodes/ * * @param string $avs_code * * @return $this */ public function setAvsCode($avs_code) { $this->avs_code = $avs_code; return $this; } /** * Address Verification System response code. https://developer.paypal.com/webapps/developer/docs/classic/api/AVSResponseCodes/ * * @return string */ public function getAvsCode() { return $this->avs_code; } /** * CVV System response code. https://developer.paypal.com/webapps/developer/docs/classic/api/AVSResponseCodes/ * * @param string $cvv_code * * @return $this */ public function setCvvCode($cvv_code) { $this->cvv_code = $cvv_code; return $this; } /** * CVV System response code. https://developer.paypal.com/webapps/developer/docs/classic/api/AVSResponseCodes/ * * @return string */ public function getCvvCode() { return $this->cvv_code; } /** * Provides merchant advice on how to handle declines related to recurring payments * Valid Values: ["01_NEW_ACCOUNT_INFORMATION", "02_TRY_AGAIN_LATER", "02_STOP_SPECIFIC_PAYMENT", "03_DO_NOT_TRY_AGAIN", "03_REVOKE_AUTHORIZATION_FOR_FUTURE_PAYMENT", "21_DO_NOT_TRY_AGAIN_CARD_HOLDER_CANCELLED_RECURRRING_CHARGE", "21_CANCEL_ALL_RECURRING_PAYMENTS"] * * @param string $advice_code * * @return $this */ public function setAdviceCode($advice_code) { $this->advice_code = $advice_code; return $this; } /** * Provides merchant advice on how to handle declines related to recurring payments * * @return string */ public function getAdviceCode() { return $this->advice_code; } /** * Response back from the authorization. Provided by the processor * * @param string $eci_submitted * * @return $this */ public function setEciSubmitted($eci_submitted) { $this->eci_submitted = $eci_submitted; return $this; } /** * Response back from the authorization. Provided by the processor * * @return string */ public function getEciSubmitted() { return $this->eci_submitted; } /** * Visa Payer Authentication Service status. Will be return from processor * * @param string $vpas * * @return $this */ public function setVpas($vpas) { $this->vpas = $vpas; return $this; } /** * Visa Payer Authentication Service status. Will be return from processor * * @return string */ public function getVpas() { return $this->vpas; } } rest-api-sdk-php/lib/PayPal/Api/ErrorDetails.php 0000644 00000004104 15007532371 0015413 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class ErrorDetails * * Details about a specific error. * * @package PayPal\Api * * @property string field * @property string issue */ class ErrorDetails extends PayPalModel { /** * Name of the field that caused the error. * * @param string $field * * @return $this */ 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; } /** * Reason for the error. * * @param string $issue * * @return $this */ public function setIssue($issue) { $this->issue = $issue; return $this; } /** * Reason for the error. * * @return string */ public function getIssue() { return $this->issue; } /** * Reference ID of the purchase_unit associated with this error * * @deprecated Not publicly available * @param string $purchase_unit_reference_id * * @return $this */ public function setPurchaseUnitReferenceId($purchase_unit_reference_id) { $this->purchase_unit_reference_id = $purchase_unit_reference_id; return $this; } /** * Reference ID of the purchase_unit associated with this error * * @deprecated Not publicly available * @return string */ public function getPurchaseUnitReferenceId() { return $this->purchase_unit_reference_id; } /** * PayPal internal error code. * * @deprecated Not publicly available * @param string $code * * @return $this */ public function setCode($code) { $this->code = $code; return $this; } /** * PayPal internal error code. * * @deprecated Not publicly available * @return string */ public function getCode() { return $this->code; } } rest-api-sdk-php/lib/PayPal/Api/PaymentOptions.php 0000644 00000005024 15007532371 0016007 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class PaymentOptions * * Payment options requested for this purchase unit * * @package PayPal\Api * * @property string allowed_payment_method */ class PaymentOptions extends PayPalModel { /** * Optional payment method type. If specified, the transaction will go through for only instant payment. Only for use with the paypal payment_method, not relevant for the credit_card payment_method. * Valid Values: ["UNRESTRICTED", "INSTANT_FUNDING_SOURCE", "IMMEDIATE_PAY"] * * @param string $allowed_payment_method * * @return $this */ public function setAllowedPaymentMethod($allowed_payment_method) { $this->allowed_payment_method = $allowed_payment_method; return $this; } /** * Optional payment method type. If specified, the transaction will go through for only instant payment. Only for use with the paypal payment_method, not relevant for the credit_card payment_method. * * @return string */ public function getAllowedPaymentMethod() { return $this->allowed_payment_method; } /** * Indicator if this payment request is a recurring payment. Only supported when the `payment_method` is set to `credit_card` * * @deprecated Not publicly available * @param bool $recurring_flag * * @return $this */ public function setRecurringFlag($recurring_flag) { $this->recurring_flag = $recurring_flag; return $this; } /** * Indicator if this payment request is a recurring payment. Only supported when the `payment_method` is set to `credit_card` * * @deprecated Not publicly available * @return bool */ public function getRecurringFlag() { return $this->recurring_flag; } /** * Indicator if fraud management filters (fmf) should be skipped for this transaction. Only supported when the `payment_method` is set to `credit_card` * * @deprecated Not publicly available * @param bool $skip_fmf * * @return $this */ public function setSkipFmf($skip_fmf) { $this->skip_fmf = $skip_fmf; return $this; } /** * Indicator if fraud management filters (fmf) should be skipped for this transaction. Only supported when the `payment_method` is set to `credit_card` * * @deprecated Not publicly available * @return bool */ public function getSkipFmf() { return $this->skip_fmf; } } rest-api-sdk-php/lib/PayPal/Api/Order.php 0000644 00000031272 15007532371 0014075 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalResourceModel; use PayPal\Rest\ApiContext; use PayPal\Validation\ArgumentValidator; /** * Class Order * * An order transaction. * * @package PayPal\Api * * @property string id * @property string purchase_unit_reference_id * @property \PayPal\Api\Amount amount * @property string payment_mode * @property string state * @property string reason_code * @property string pending_reason * @property string protection_eligibility * @property string protection_eligibility_type * @property string parent_payment * @property \PayPal\Api\FmfDetails fmf_details * @property string create_time * @property string update_time * @property \PayPal\Api\Links[] links */ class Order extends PayPalResourceModel { /** * Identifier of the order transaction. * * @param string $id * * @return $this */ public function setId($id) { $this->id = $id; return $this; } /** * Identifier of the order transaction. * * @return string */ public function getId() { return $this->id; } /** * Identifier to the purchase unit associated with this object. Obsolete. Use one in cart_base. * * @param string $purchase_unit_reference_id * * @return $this */ public function setPurchaseUnitReferenceId($purchase_unit_reference_id) { $this->purchase_unit_reference_id = $purchase_unit_reference_id; return $this; } /** * Identifier to the purchase unit associated with this object. Obsolete. Use one in cart_base. * * @return string */ public function getPurchaseUnitReferenceId() { return $this->purchase_unit_reference_id; } /** * Amount being collected. * * @param \PayPal\Api\Amount $amount * * @return $this */ public function setAmount($amount) { $this->amount = $amount; return $this; } /** * Amount being collected. * * @return \PayPal\Api\Amount */ public function getAmount() { return $this->amount; } /** * specifies payment mode of the transaction * Valid Values: ["INSTANT_TRANSFER", "MANUAL_BANK_TRANSFER", "DELAYED_TRANSFER", "ECHECK"] * * @param string $payment_mode * * @return $this */ public function setPaymentMode($payment_mode) { $this->payment_mode = $payment_mode; return $this; } /** * specifies payment mode of the transaction * * @return string */ public function getPaymentMode() { return $this->payment_mode; } /** * State of the order transaction. * Valid Values: ["pending", "completed", "refunded", "partially_refunded", "voided"] * * @param string $state * * @return $this */ public function setState($state) { $this->state = $state; return $this; } /** * State of the order transaction. * * @return string */ public function getState() { return $this->state; } /** * Reason code for the transaction state being Pending or Reversed. Only supported when the `payment_method` is set to `paypal`. * Valid Values: ["PAYER_SHIPPING_UNCONFIRMED", "MULTI_CURRENCY", "RISK_REVIEW", "REGULATORY_REVIEW", "VERIFICATION_REQUIRED", "ORDER", "OTHER"] * * @param string $reason_code * * @return $this */ public function setReasonCode($reason_code) { $this->reason_code = $reason_code; return $this; } /** * Reason code for the transaction state being Pending or Reversed. Only supported when the `payment_method` is set to `paypal`. * * @return string */ public function getReasonCode() { return $this->reason_code; } /** * [DEPRECATED] Reason the transaction is in pending state. Use reason_code field above instead. * Valid Values: ["payer_shipping_unconfirmed", "multi_currency", "risk_review", "regulatory_review", "verification_required", "order", "other"] * * @param string $pending_reason * * @return $this */ public function setPendingReason($pending_reason) { $this->pending_reason = $pending_reason; return $this; } /** * @deprecated [DEPRECATED] Reason the transaction is in pending state. Use reason_code field above instead. * * @return string */ public function getPendingReason() { return $this->pending_reason; } /** * The level of seller protection in force for the transaction. * Valid Values: ["ELIGIBLE", "PARTIALLY_ELIGIBLE", "INELIGIBLE"] * * @param string $protection_eligibility * * @return $this */ public function setProtectionEligibility($protection_eligibility) { $this->protection_eligibility = $protection_eligibility; return $this; } /** * The level of seller protection in force for the transaction. * * @return string */ public function getProtectionEligibility() { return $this->protection_eligibility; } /** * The kind of seller protection in force for the transaction. This property is returned only when the `protection_eligibility` property is set to `ELIGIBLE`or `PARTIALLY_ELIGIBLE`. Only supported when the `payment_method` is set to `paypal`. Allowed values:<br> `ITEM_NOT_RECEIVED_ELIGIBLE`- Sellers are protected against claims for items not received.<br> `UNAUTHORIZED_PAYMENT_ELIGIBLE`- Sellers are protected against claims for unauthorized payments.<br> One or both of the allowed values can be returned. * Valid Values: ["ITEM_NOT_RECEIVED_ELIGIBLE", "UNAUTHORIZED_PAYMENT_ELIGIBLE", "ITEM_NOT_RECEIVED_ELIGIBLE,UNAUTHORIZED_PAYMENT_ELIGIBLE"] * * @param string $protection_eligibility_type * * @return $this */ public function setProtectionEligibilityType($protection_eligibility_type) { $this->protection_eligibility_type = $protection_eligibility_type; return $this; } /** * The kind of seller protection in force for the transaction. This property is returned only when the `protection_eligibility` property is set to `ELIGIBLE`or `PARTIALLY_ELIGIBLE`. Only supported when the `payment_method` is set to `paypal`. Allowed values:<br> `ITEM_NOT_RECEIVED_ELIGIBLE`- Sellers are protected against claims for items not received.<br> `UNAUTHORIZED_PAYMENT_ELIGIBLE`- Sellers are protected against claims for unauthorized payments.<br> One or both of the allowed values can be returned. * * @return string */ public function getProtectionEligibilityType() { return $this->protection_eligibility_type; } /** * ID of the Payment resource that this transaction is based on. * * @param string $parent_payment * * @return $this */ public function setParentPayment($parent_payment) { $this->parent_payment = $parent_payment; return $this; } /** * ID of the Payment resource that this transaction is based on. * * @return string */ public function getParentPayment() { return $this->parent_payment; } /** * Fraud Management Filter (FMF) details applied for the payment that could result in accept/deny/pending action. * * @param \PayPal\Api\FmfDetails $fmf_details * * @return $this */ public function setFmfDetails($fmf_details) { $this->fmf_details = $fmf_details; return $this; } /** * Fraud Management Filter (FMF) details applied for the payment that could result in accept/deny/pending action. * * @return \PayPal\Api\FmfDetails */ public function getFmfDetails() { return $this->fmf_details; } /** * Time the resource was created in UTC ISO8601 format. * * @param string $create_time * * @return $this */ public function setCreateTime($create_time) { $this->create_time = $create_time; return $this; } /** * Time the resource was created in UTC ISO8601 format. * * @return string */ public function getCreateTime() { return $this->create_time; } /** * Time the resource was last updated in UTC ISO8601 format. * * @param string $update_time * * @return $this */ public function setUpdateTime($update_time) { $this->update_time = $update_time; return $this; } /** * Time the resource was last updated in UTC ISO8601 format. * * @return string */ public function getUpdateTime() { return $this->update_time; } /** * Retrieve details about an order by passing the order_id in the request URI. * * @param string $orderId * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return Order */ public static function get($orderId, $apiContext = null, $restCall = null) { ArgumentValidator::validate($orderId, 'orderId'); $payLoad = ""; $json = self::executeCall( "/v1/payments/orders/$orderId", "GET", $payLoad, null, $apiContext, $restCall ); $ret = new Order(); $ret->fromJson($json); return $ret; } /** * Capture a payment. In addition, include the amount of the payment and indicate whether this is a final capture for the given authorization in the body of the request JSON. * * @param Capture $capture * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return Capture */ public function capture($capture, $apiContext = null, $restCall = null) { ArgumentValidator::validate($this->getId(), "Id"); ArgumentValidator::validate($capture, 'capture'); $payLoad = $capture->toJSON(); $json = self::executeCall( "/v1/payments/orders/{$this->getId()}/capture", "POST", $payLoad, null, $apiContext, $restCall ); $ret = new Capture(); $ret->fromJson($json); return $ret; } /** * Void (cancel) an order by passing the order_id in the request URI. Note that an order cannot be voided if payment has already been partially or fully captured. * * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return Order */ public function void($apiContext = null, $restCall = null) { ArgumentValidator::validate($this->getId(), "Id"); $payLoad = ""; $json = self::executeCall( "/v1/payments/orders/{$this->getId()}/do-void", "POST", $payLoad, null, $apiContext, $restCall ); $this->fromJson($json); return $this; } /** * Authorize an order by passing the order_id in the request URI. In addition, include an amount object in the body of the request JSON. * * @param Authorization $authorization Authorization Object with Amount value to be authorized * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return Authorization */ public function authorize($authorization, $apiContext = null, $restCall = null) { ArgumentValidator::validate($this->getId(), "Id"); ArgumentValidator::validate($authorization, 'Authorization'); $payLoad = $authorization->toJSON(); $json = self::executeCall( "/v1/payments/orders/{$this->getId()}/authorize", "POST", $payLoad, null, $apiContext, $restCall ); $ret = new Authorization(); $ret->fromJson($json); return $ret; } } rest-api-sdk-php/lib/PayPal/Api/Transactions.php 0000644 00000001144 15007532371 0015465 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class Transactions * * * * @package PayPal\Api * * @property \PayPal\Api\Amount amount */ class Transactions extends PayPalModel { /** * Amount being collected. * * * @param \PayPal\Api\Amount $amount * * @return $this */ public function setAmount($amount) { $this->amount = $amount; return $this; } /** * Amount being collected. * * @return \PayPal\Api\Amount */ public function getAmount() { return $this->amount; } } rest-api-sdk-php/lib/PayPal/Api/BankAccountsList.php 0000644 00000005110 15007532371 0016221 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class BankAccountsList * * A list of Bank Account Resources * * @package PayPal\Api * * @property \PayPal\Api\BankAccount[] bank_accounts * @property int count * @property string next_id */ class BankAccountsList extends PayPalModel { /** * A list of bank account resources * * @param \PayPal\Api\BankAccount[] $bank_accounts * * @return $this */ public function setBankAccounts($bank_accounts) { $this->{"bank-accounts"} = $bank_accounts; return $this; } /** * A list of bank account resources * * @return \PayPal\Api\BankAccount[] */ public function getBankAccounts() { return $this->{"bank-accounts"}; } /** * Append BankAccounts to the list. * * @param \PayPal\Api\BankAccount $bankAccount * @return $this */ public function addBankAccount($bankAccount) { if (!$this->getBankAccounts()) { return $this->setBankAccounts(array($bankAccount)); } else { return $this->setBankAccounts( array_merge($this->getBankAccounts(), array($bankAccount)) ); } } /** * Remove BankAccounts from the list. * * @param \PayPal\Api\BankAccount $bankAccount * @return $this */ public function removeBankAccount($bankAccount) { return $this->setBankAccounts( array_diff($this->getBankAccounts(), array($bankAccount)) ); } /** * Number of items returned in each range of results. Note that the last results range could have fewer items than the requested number of items. * * @param int $count * * @return $this */ public function setCount($count) { $this->count = $count; return $this; } /** * Number of items returned in each range of results. Note that the last results range could have fewer items than the requested number of items. * * @return int */ public function getCount() { return $this->count; } /** * Identifier of the next element to get the next range of results. * * @param string $next_id * * @return $this */ public function setNextId($next_id) { $this->next_id = $next_id; return $this; } /** * Identifier of the next element to get the next range of results. * * @return string */ public function getNextId() { return $this->next_id; } } rest-api-sdk-php/lib/PayPal/Api/ShippingInfo.php 0000644 00000005507 15007532371 0015421 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class ShippingInfo * * Shipping information for the invoice recipient. * * @package PayPal\Api * * @property string first_name * @property string last_name * @property string business_name * @property \PayPal\Api\Phone phone * @property \PayPal\Api\InvoiceAddress address */ class ShippingInfo extends PayPalModel { /** * First name of the invoice recipient. 30 characters max. * * @param string $first_name * * @return $this */ 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; } /** * Last name of the invoice recipient. 30 characters max. * * @param string $last_name * * @return $this */ public function setLastName($last_name) { $this->last_name = $last_name; return $this; } /** * 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 * * @return $this */ public function setBusinessName($business_name) { $this->business_name = $business_name; return $this; } /** * Company business name of the invoice recipient. 100 characters max. * * @return string */ public function getBusinessName() { return $this->business_name; } /** * * * @param \PayPal\Api\Phone $phone * @return $this */ public function setPhone($phone) { $this->phone = $phone; return $this; } /** * * * @return \PayPal\Api\Phone */ public function getPhone() { return $this->phone; } /** * * * @param string $email * @return $this */ public function setEmail($email) { $this->email = $email; return $this; } /** * * * @return string */ public function getEmail() { return $this->email; } /** * Address of the invoice recipient. * * @param \PayPal\Api\InvoiceAddress $address * * @return $this */ public function setAddress($address) { $this->address = $address; return $this; } /** * Address of the invoice recipient. * * @return \PayPal\Api\InvoiceAddress */ public function getAddress() { return $this->address; } } rest-api-sdk-php/lib/PayPal/Api/Measurement.php 0000644 00000002064 15007532371 0015304 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class Measurement * * Measurement to represent item dimensions like length, width, height and weight etc. * * @package PayPal\Api * * @property string value * @property string unit */ class Measurement extends PayPalModel { /** * Value this measurement represents. * * @param string $value * * @return $this */ public function setValue($value) { $this->value = $value; return $this; } /** * Value this measurement represents. * * @return string */ public function getValue() { return $this->value; } /** * Unit in which the value is represented. * * @param string $unit * * @return $this */ public function setUnit($unit) { $this->unit = $unit; return $this; } /** * Unit in which the value is represented. * * @return string */ public function getUnit() { return $this->unit; } } rest-api-sdk-php/lib/PayPal/Api/ChargeModel.php 0000644 00000003042 15007532371 0015166 0 ustar 00 <?php namespace PayPal\Api; use PayPal\Common\PayPalModel; /** * Class ChargeModel * * A resource representing a charge model for a payment definition. * * @package PayPal\Api * * @property string id * @property string type * @property \PayPal\Api\Currency amount */ class ChargeModel extends PayPalModel { /** * Identifier of the charge model. 128 characters max. * * @param string $id * * @return $this */ public function setId($id) { $this->id = $id; return $this; } /** * Identifier of the charge model. 128 characters max. * * @return string */ public function getId() { return $this->id; } /** * Type of charge model. Allowed values: `SHIPPING`, `TAX`. * * @param string $type * * @return $this */ public function setType($type) { $this->type = $type; return $this; } /** * Type of charge model. Allowed values: `SHIPPING`, `TAX`. * * @return string */ public function getType() { return $this->type; } /** * Specific amount for this charge model. * * @param \PayPal\Api\Currency $amount * * @return $this */ public function setAmount($amount) { $this->amount = $amount; return $this; } /** * Specific amount for this charge model. * * @return \PayPal\Api\Currency */ public function getAmount() { return $this->amount; } } rest-api-sdk-php/lib/PayPal/Exception/PayPalInvalidCredentialException.php 0000644 00000001267 15007532371 0022617 0 ustar 00 <?php namespace PayPal\Exception; /** * Class PayPalInvalidCredentialException * * @package PayPal\Exception */ class PayPalInvalidCredentialException 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; } } rest-api-sdk-php/lib/PayPal/Exception/PayPalConfigurationException.php 0000644 00000000621 15007532371 0022036 0 ustar 00 <?php namespace PayPal\Exception; /** * Class PayPalConfigurationException * * @package PayPal\Exception */ class PayPalConfigurationException extends \Exception { /** * Default Constructor * * @param string|null $message * @param int $code */ public function __construct($message = null, $code = 0) { parent::__construct($message, $code); } } rest-api-sdk-php/lib/PayPal/Exception/PayPalMissingCredentialException.php 0000644 00000001263 15007532371 0022636 0 ustar 00 <?php namespace PayPal\Exception; /** * Class PayPalMissingCredentialException * * @package PayPal\Exception */ class PayPalMissingCredentialException 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; } } rest-api-sdk-php/lib/PayPal/Exception/PayPalConnectionException.php 0000644 00000002110 15007532371 0021321 0 ustar 00 <?php namespace PayPal\Exception; /** * Class PayPalConnectionException * * @package PayPal\Exception */ class PayPalConnectionException 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; } } rest-api-sdk-php/lib/PayPal/Transport/PayPalRestCall.php 0000644 00000004066 15007532371 0017126 0 ustar 00 <?php namespace PayPal\Transport; use PayPal\Core\PayPalHttpConfig; use PayPal\Core\PayPalHttpConnection; use PayPal\Core\PayPalLoggingManager; use PayPal\Rest\ApiContext; /** * Class PayPalRestCall * * @package PayPal\Transport */ class PayPalRestCall { /** * Paypal Logger * * @var PayPalLoggingManager logger interface */ private $logger; /** * API Context * * @var ApiContext */ private $apiContext; /** * Default Constructor * * @param ApiContext $apiContext */ public function __construct(ApiContext $apiContext) { $this->apiContext = $apiContext; $this->logger = PayPalLoggingManager::getInstance(__CLASS__); } /** * @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\PayPalConnectionException */ public function execute($handlers = array(), $path, $method, $data = '', $headers = array()) { $config = $this->apiContext->getConfig(); $httpConfig = new PayPalHttpConfig(null, $method, $config); $headers = $headers ? $headers : array(); $httpConfig->setHeaders($headers + array( 'Content-Type' => 'application/json' ) ); /** @var \Paypal\Handler\IPayPalHandler $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 PayPalHttpConnection($httpConfig, $config); $response = $connection->execute($data); return $response; } } rest-api-sdk-php/lib/PayPal/Cache/AuthorizationCache.php 0000644 00000007512 15007532371 0017100 0 ustar 00 <?php namespace PayPal\Cache; use PayPal\Core\PayPalConfigManager; use PayPal\Validation\JsonValidator; abstract class AuthorizationCache { public static $CACHE_PATH = '/../../../var/auth.cache'; /** * A pull method which would read the persisted data based on clientId. * If clientId is not provided, an array with all the tokens would be passed. * * @param array|null $config * @param string $clientId * @return mixed|null */ public static function pull($config = null, $clientId = null) { // Return if not enabled if (!self::isEnabled($config)) { return null; } $tokens = null; $cachePath = self::cachePath($config); if (file_exists($cachePath)) { // Read from the file $cachedToken = file_get_contents($cachePath); if ($cachedToken && JsonValidator::validate($cachedToken, true)) { $tokens = json_decode($cachedToken, true); if ($clientId && is_array($tokens) && array_key_exists($clientId, $tokens)) { // If client Id is found, just send in that data only return $tokens[$clientId]; } else if ($clientId) { // If client Id is provided, but no key in persisted data found matching it. return null; } } } return $tokens; } /** * Persists the data into a cache file provided in $CACHE_PATH * * @param array|null $config * @param $clientId * @param $accessToken * @param $tokenCreateTime * @param $tokenExpiresIn * @throws \Exception */ public static function push($config = null, $clientId, $accessToken, $tokenCreateTime, $tokenExpiresIn) { // Return if not enabled if (!self::isEnabled($config)) { return; } $cachePath = self::cachePath($config); if (!is_dir(dirname($cachePath))) { if (mkdir(dirname($cachePath), 0755, true) == false) { throw new \Exception("Failed to create directory at $cachePath"); } } // Reads all the existing persisted data $tokens = self::pull(); $tokens = $tokens ? $tokens : array(); if (is_array($tokens)) { $tokens[$clientId] = array( 'clientId' => $clientId, 'accessTokenEncrypted' => $accessToken, 'tokenCreateTime' => $tokenCreateTime, 'tokenExpiresIn' => $tokenExpiresIn ); } if(!file_put_contents($cachePath, json_encode($tokens))) { throw new \Exception("Failed to write cache"); }; } /** * Determines from the Configuration if caching is currently enabled/disabled * * @param $config * @return bool */ public static function isEnabled($config) { $value = self::getConfigValue('cache.enabled', $config); return empty($value) ? false : ((trim($value) == true || trim($value) == 'true')); } /** * Returns the cache file path * * @param $config * @return string */ public static function cachePath($config) { $cachePath = self::getConfigValue('cache.FileName', $config); return empty($cachePath) ? __DIR__ . self::$CACHE_PATH : $cachePath; } /** * Returns the Value of the key if found in given config, or from PayPal Config Manager * Returns null if not found * * @param $key * @param $config * @return null|string */ private static function getConfigValue($key, $config) { $config = ($config && is_array($config)) ? $config : PayPalConfigManager::getInstance()->getConfigHashmap(); return (array_key_exists($key, $config)) ? trim($config[$key]) : null; } } rest-api-sdk-php/lib/PayPal/Common/PayPalUserAgent.php 0000644 00000002730 15007532371 0016542 0 ustar 00 <?php namespace PayPal\Common; /** * Class PayPalUserAgent * PayPalUserAgent generates User Agent for curl requests * * @package PayPal\Common */ class PayPalUserAgent { /** * 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( 'platform-ver=' . 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[] = 'crypto-lib-ver=' . $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; } } } rest-api-sdk-php/lib/PayPal/Common/PayPalResourceModel.php 0000644 00000004715 15007532371 0017422 0 ustar 00 <?php namespace PayPal\Common; use PayPal\Rest\ApiContext; use PayPal\Rest\IResource; use PayPal\Transport\PayPalRestCall; /** * Class PayPalResourceModel * An Executable PayPalModel Class * * @property \PayPal\Api\Links[] links * @package PayPal\Common */ class PayPalResourceModel extends PayPalModel implements IResource { /** * Sets Links * * @param \PayPal\Api\Links[] $links * * @return $this */ public function setLinks($links) { $this->links = $links; return $this; } /** * Gets Links * * @return \PayPal\Api\Links[] */ public function getLinks() { return $this->links; } public function getLink($rel) { foreach ($this->links as $link) { if ($link->getRel() == $rel) { return $link->getHref(); } } return null; } /** * Append Links to the list. * * @param \PayPal\Api\Links $links * @return $this */ public function addLink($links) { if (!$this->getLinks()) { return $this->setLinks(array($links)); } else { return $this->setLinks( array_merge($this->getLinks(), array($links)) ); } } /** * Remove Links from the list. * * @param \PayPal\Api\Links $links * @return $this */ public function removeLink($links) { return $this->setLinks( array_diff($this->getLinks(), array($links)) ); } /** * Execute SDK Call to Paypal services * * @param string $url * @param string $method * @param string $payLoad * @param array $headers * @param ApiContext $apiContext * @param PayPalRestCall $restCall * @param array $handlers * @return string json response of the object */ protected static function executeCall($url, $method, $payLoad, $headers = array(), $apiContext = null, $restCall = null, $handlers = array('PayPal\Handler\RestHandler')) { //Initialize the context and rest call object if not provided explicitly $apiContext = $apiContext ? $apiContext : new ApiContext(self::$credential); $restCall = $restCall ? $restCall : new PayPalRestCall($apiContext); //Make the execution call $json = $restCall->execute($handlers, $url, $method, $payLoad, $headers); return $json; } } rest-api-sdk-php/lib/PayPal/Common/PayPalModel.php 0000644 00000020763 15007532371 0015713 0 ustar 00 <?php namespace PayPal\Common; use PayPal\Validation\JsonValidator; use PayPal\Validation\ModelAccessorValidator; /** * Generic Model class that all API domain classes extend * Stores all member data in a Hashmap that enables easy * JSON encoding/decoding */ class PayPalModel { private $_propMap = array(); /** * OAuth Credentials to use for this call * * @var \PayPal\Auth\OAuthTokenCredential $credential */ protected static $credential; /** * Sets Credential * * @deprecated Pass ApiContext to create/get methods instead * @param \PayPal\Auth\OAuthTokenCredential $credential */ public static function setCredential($credential) { self::$credential = $credential; } /** * Default Constructor * * You can pass data as a json representation or array object. This argument eliminates the need * to do $obj->fromJson($data) later after creating the object. * * @param null $data * @throws \InvalidArgumentException */ public function __construct($data = null) { switch (gettype($data)) { case "NULL": break; case "string": JsonValidator::validate($data); $this->fromJson($data); break; case "array": $this->fromArray($data); break; default: } } /** * Returns a list of Object from Array or Json String. It is generally used when your json * contains an array of this object * * @param mixed $data Array object or json string representation * @return array */ public static function getList($data) { // Return Null if Null if ($data === null) { return null; } if (is_a($data, get_class(new \stdClass()))) { //This means, root element is object return new static(json_encode($data)); } $list = array(); if (is_array($data)) { $data = json_encode($data); } if (JsonValidator::validate($data)) { // It is valid JSON $decoded = json_decode($data); if ($decoded === null) { return $list; } if (is_array($decoded)) { foreach ($decoded as $k => $v) { $list[] = self::getList($v); } } if (is_a($decoded, get_class(new \stdClass()))) { //This means, root element is object $list[] = new static(json_encode($decoded)); } } return $list; } /** * Magic Get Method * * @param $key * @return mixed */ public function __get($key) { if ($this->__isset($key)) { return $this->_propMap[$key]; } return null; } /** * Magic Set Method * * @param $key * @param $value */ public function __set($key, $value) { if (!is_array($value) && $value === null) { $this->__unset($key); } else { $this->_propMap[$key] = $value; } } /** * Converts the input key into a valid Setter Method Name * * @param $key * @return mixed */ private function convertToCamelCase($key) { return str_replace(' ', '', ucwords(str_replace(array('_', '-'), ' ', $key))); } /** * 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 PayPalModel) { $ret[$k] = $v->toArray(); } else if (sizeof($v) <= 0 && is_array($v)) { $ret[$k] = array(); } else if (is_array($v)) { $ret[$k] = $this->_convertToArray($v); } else { $ret[$k] = $v; } } // If the array is empty, which means an empty object, // we need to convert array to StdClass object to properly // represent JSON String if (sizeof($ret) <= 0) { $ret = new PayPalModel(); } return $ret; } /** * Fills object value from Array list * * @param $arr * @return $this */ public function fromArray($arr) { if (!empty($arr)) { // Iterate over each element in array foreach ($arr as $k => $v) { // If the value is an array, it means, it is an object after conversion if (is_array($v)) { // Determine the class of the object if (($clazz = ReflectionUtil::getPropertyClass(get_class($this), $k)) != null){ // If the value is an associative array, it means, its an object. Just make recursive call to it. if (empty($v)){ if (ReflectionUtil::isPropertyClassArray(get_class($this), $k)) { // It means, it is an array of objects. $this->assignValue($k, array()); continue; } $o = new $clazz(); //$arr = array(); $this->assignValue($k, $o); } elseif (ArrayUtil::isAssocArray($v)) { /** @var self $o */ $o = new $clazz(); $o->fromArray($v); $this->assignValue($k, $o); } else { // Else, value is an array of object/data $arr = array(); // Iterate through each element in that array. foreach ($v as $nk => $nv) { if (is_array($nv)) { $o = new $clazz(); $o->fromArray($nv); $arr[$nk] = $o; } else { $arr[$nk] = $nv; } } $this->assignValue($k, $arr); } } else { $this->assignValue($k, $v); } } else { $this->assignValue($k, $v); } } } return $this; } private function assignValue($key, $value) { $setter = 'set'. $this->convertToCamelCase($key); // If we find the setter, use that, otherwise use magic method. if (method_exists($this, $setter)) { $this->$setter($value); } else { $this->__set($key, $value); } } /** * 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) { // Because of PHP Version 5.3, we cannot use JSON_UNESCAPED_SLASHES option // Instead we would use the str_replace command for now. // TODO: Replace this code with return json_encode($this->toArray(), $options | 64); once we support PHP >= 5.4 if (version_compare(phpversion(), '5.4.0', '>=') === true) { return json_encode($this->toArray(), $options | 64); } return str_replace('\\/', '/', json_encode($this->toArray(), $options)); } /** * Magic Method for toString * * @return string */ public function __toString() { return $this->toJSON(128); } } rest-api-sdk-php/lib/PayPal/Common/ArrayUtil.php 0000644 00000000670 15007532371 0015453 0 ustar 00 <?php namespace PayPal\Common; /** * Class ArrayUtil * Util Class for Arrays * * @package PayPal\Common */ class ArrayUtil { /** * * @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; } } rest-api-sdk-php/lib/PayPal/Common/ReflectionUtil.php 0000644 00000011133 15007532371 0016463 0 ustar 00 <?php namespace PayPal\Common; use PayPal\Exception\PayPalConfigurationException; /** * Class ReflectionUtil * * @package PayPal\Common */ class ReflectionUtil { /** * Reflection Methods * * @var \ReflectionMethod[] */ private static $propertiesRefl = array(); /** * Properties Type * * @var string[] */ private static $propertiesType = array(); /** * Gets Property Class of the given property. * If the class is null, it returns null. * If the property is not found, it returns null. * * @param $class * @param $propertyName * @return null|string * @throws PayPalConfigurationException */ public static function getPropertyClass($class, $propertyName) { if ($class == get_class(new PayPalModel())) { // Make it generic if PayPalModel is used for generating this return get_class(new PayPalModel()); } // If the class doesn't exist, or the method doesn't exist, return null. if (!class_exists($class) || !method_exists($class, self::getter($class, $propertyName))) { return null; } if (($annotations = self::propertyAnnotations($class, $propertyName)) && isset($annotations['return'])) { $param = $annotations['return']; } if (isset($param)) { $anno = preg_split("/[\s\[\]]+/", $param); return $anno[0]; } else { throw new PayPalConfigurationException("Getter function for '$propertyName' in '$class' class should have a proper return type."); } } /** * Checks if the Property is of type array or an object * * @param $class * @param $propertyName * @return null|boolean * @throws PayPalConfigurationException */ public static function isPropertyClassArray($class, $propertyName) { // If the class doesn't exist, or the method doesn't exist, return null. if (!class_exists($class) || !method_exists($class, self::getter($class, $propertyName))) { return null; } if (($annotations = self::propertyAnnotations($class, $propertyName)) && isset($annotations['return'])) { $param = $annotations['return']; } if (isset($param)) { return substr($param, -strlen('[]'))==='[]'; } else { throw new PayPalConfigurationException("Getter function for '$propertyName' in '$class' class should have a proper return type."); } } /** * 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 = self::getter($class, $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]); } /** * Returns the properly formatted getter function name based on class name and property * Formats the property name to a standard getter function * * @param string $class * @param string $propertyName * @return string getter function name */ public static function getter($class, $propertyName) { return method_exists($class, "get" . ucfirst($propertyName)) ? "get" . ucfirst($propertyName) : "get" . preg_replace_callback("/([_\-\s]?([a-z0-9]+))/", "self::replace_callback", $propertyName); } } rest-api-sdk-php/lib/PayPal/Rest/ApiContext.php 0000644 00000007752 15007532371 0015312 0 ustar 00 <?php namespace PayPal\Rest; use PayPal\Core\PayPalConfigManager; use PayPal\Core\PayPalCredentialManager; /** * Class ApiContext * * Call level parameters such as request id, credentials etc * * @package PayPal\Rest */ class ApiContext { /** * Unique request id to be used for this call * The user can either generate one as per application * needs or let the SDK generate one * * @var null|string $requestId */ 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\PayPalCredentialManager * * @var \Paypal\Auth\OAuthTokenCredential */ private $credential; /** * Construct * * @param \PayPal\Auth\OAuthTokenCredential $credential * @param string|null $requestId */ public function __construct($credential = null, $requestId = null) { $this->requestId = $requestId; $this->credential = $credential; } /** * Get Credential * * @return \PayPal\Auth\OAuthTokenCredential */ public function getCredential() { if ($this->credential == null) { return PayPalCredentialManager::getInstance()->getCredentialObject(); } return $this->credential; } public function getRequestHeaders() { $result = PayPalConfigManager::getInstance()->get('http.headers'); $headers = array(); foreach ($result as $header => $value) { $headerName = ltrim($header, 'http.headers'); $headers[$headerName] = $value; } return $headers; } public function addRequestHeader($name, $value) { // Determine if the name already has a 'http.headers' prefix. If not, add one. if (!(substr($name, 0, strlen('http.headers')) === 'http.headers')) { $name = 'http.headers.' . $name; } PayPalConfigManager::getInstance()->addConfigs(array($name => $value)); } /** * Get Request ID * * @return string */ public function getRequestId() { if ($this->requestId == null) { $this->requestId = $this->generateRequestId(); } return $this->requestId; } /** * Resets the requestId that can be used to set the PayPal-request-id * header used for idempotency. In cases where you need to make multiple create calls * using the same ApiContext object, you need to reset request Id. * * @return string */ public function resetRequestId() { $this->requestId = $this->generateRequestId(); return $this->getRequestId(); } /** * Sets Config * * @param array $config SDK configuration parameters */ public function setConfig(array $config) { PayPalConfigManager::getInstance()->addConfigs($config); } /** * Gets Configurations * * @return array */ public function getConfig() { return PayPalConfigManager::getInstance()->getConfigHashmap(); } /** * Gets a specific configuration from key * * @param $searchKey * @return mixed */ public function get($searchKey) { return PayPalConfigManager::getInstance()->get($searchKey); } /** * Generates a unique per request id that * can be used to set the PayPal-Request-Id header * that is used for idempotency * * @return string */ private function generateRequestId() { static $pid = -1; static $addr = -1; if ($pid == -1) { $pid = getmypid(); } if ($addr == -1) { if (array_key_exists('SERVER_ADDR', $_SERVER)) { $addr = ip2long($_SERVER['SERVER_ADDR']); } else { $addr = php_uname('n'); } } return $addr . $pid . $_SERVER['REQUEST_TIME'] . mt_rand(0, 0xffff); } } rest-api-sdk-php/lib/PayPal/Rest/IResource.php 0000644 00000000161 15007532371 0015117 0 ustar 00 <?php namespace PayPal\Rest; /** * Interface IResource * * @package PayPal\Rest */ interface IResource { } rest-api-sdk-php/lib/PayPal/Validation/ArgumentValidator.php 0000644 00000001675 15007532371 0020037 0 ustar 00 <?php namespace PayPal\Validation; /** * Class ArgumentValidator * * @package PayPal\Validation */ class ArgumentValidator { /** * Helper method for validating an argument that will be used by this API in any requests. * * @param $argument mixed The object to be validated * @param $argumentName string|null The name of the argument. * This will be placed in the exception message for easy reference * @return bool */ public static function validate($argument, $argumentName = null) { if ($argument === null) { // Error if Object Null throw new \InvalidArgumentException("$argumentName cannot be null"); } else if (gettype($argument) == 'string' && trim($argument) == ''){ // Error if String Empty throw new \InvalidArgumentException("$argumentName string cannot be empty"); } return true; } } rest-api-sdk-php/lib/PayPal/Validation/NumericValidator.php 0000644 00000001113 15007532371 0017642 0 ustar 00 <?php namespace PayPal\Validation; /** * Class NumericValidator * * @package PayPal\Validation */ class NumericValidator { /** * Helper method for validating an argument if it is numeric * * @param mixed $argument * @param string|null $argumentName * @return bool */ public static function validate($argument, $argumentName = null) { if (trim($argument) != null && !is_numeric($argument)) { throw new \InvalidArgumentException("$argumentName is not a valid numeric value"); } return true; } } rest-api-sdk-php/lib/PayPal/Validation/UrlValidator.php 0000644 00000001070 15007532371 0017004 0 ustar 00 <?php namespace PayPal\Validation; /** * Class UrlValidator * * @package PayPal\Validation */ class UrlValidator { /** * Helper method for validating URLs that will be used by this API in any requests. * * @param $url * @param string|null $urlName * @throws \InvalidArgumentException */ public static function validate($url, $urlName = null) { if (filter_var($url, FILTER_VALIDATE_URL) === false) { throw new \InvalidArgumentException("$urlName is not a fully qualified URL"); } } } rest-api-sdk-php/lib/PayPal/Validation/JsonValidator.php 0000644 00000001551 15007532371 0017157 0 ustar 00 <?php namespace PayPal\Validation; /** * Class JsonValidator * * @package PayPal\Validation */ class JsonValidator { /** * Helper method for validating if string provided is a valid json. * * @param string $string String representation of Json object * @param bool $silent Flag to not throw \InvalidArgumentException * @return bool */ public static function validate($string, $silent = false) { @json_decode($string); if (json_last_error() != JSON_ERROR_NONE) { if ($string === '' || $string === null) { return true; } if ($silent == false) { //Throw an Exception for string or array throw new \InvalidArgumentException("Invalid JSON String"); } return false; } return true; } } rest-api-sdk-php/lib/PayPal/Security/Cipher.php 0000644 00000002442 15007532371 0015327 0 ustar 00 <?php namespace PayPal\Security; /** * Class Cipher * * Helper class to encrypt/decrypt data with secret key * * @package PayPal\Security */ class Cipher { private $secretKey; /** * Fixed IV Size */ const IV_SIZE = 16; function __construct($secretKey) { $this->secretKey = $secretKey; } /** * Encrypts the input text using the cipher key * * @param $input * @return string */ function encrypt($input) { // Create a random IV. Not using mcrypt to generate one, as to not have a dependency on it. $iv = substr(uniqid("", true), 0, Cipher::IV_SIZE); // Encrypt the data $encrypted = openssl_encrypt($input, "AES-256-CBC", $this->secretKey, 0, $iv); // Encode the data with IV as prefix return base64_encode($iv . $encrypted); } /** * Decrypts the input text from the cipher key * * @param $input * @return string */ function decrypt($input) { // Decode the IV + data $input = base64_decode($input); // Remove the IV $iv = substr($input, 0, Cipher::IV_SIZE); // Return Decrypted Data return openssl_decrypt(substr($input, Cipher::IV_SIZE), "AES-256-CBC", $this->secretKey, 0, $iv); } } rest-api-sdk-php/lib/PayPal/Core/PayPalLoggingManager.php 0000644 00000010147 15007532371 0017167 0 ustar 00 <?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 PayPalLoggingManager { /** * 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; /** * Returns the singleton object * * @param string $loggerName * @return $this */ public static function getInstance($loggerName = __CLASS__) { $instance = new self(); $instance->setLoggerName($loggerName); return $instance; } /** * Sets Logger Name. Generally defaulted to Logging Class * * @param string $loggerName */ public function setLoggerName($loggerName = __CLASS__) { $this->loggerName = $loggerName; } /** * Default Constructor */ public function __construct() { $config = PayPalConfigManager::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__ . "\\PayPalLoggingLevel::$loggingLevel")) ? constant(__NAMESPACE__ . "\\PayPalLoggingLevel::$loggingLevel") : PayPalLoggingManager::DEFAULT_LOGGING_LEVEL; } } /** * Default Logger * * @param string $message * @param int $level */ private function log($message, $level = PayPalLoggingLevel::INFO) { if ($this->isLoggingEnabled) { $config = PayPalConfigManager::getInstance()->getConfigHashmap(); // Check if logging in live if (array_key_exists('mode', $config) && $config['mode'] == 'live') { // Live should not have logging level above INFO. if ($this->loggingLevel >= PayPalLoggingLevel::INFO) { // If it is at Debug Level, throw an warning in the log. if ($this->loggingLevel == PayPalLoggingLevel::DEBUG) { error_log("[" . date('d-m-Y h:i:s') . "] " . $this->loggerName . ": ERROR\t: Not allowed to keep 'Debug' level for Live Environments. Reduced to 'INFO'\n", 3, $this->loggerFile); } // Reducing it to info level $this->loggingLevel = PayPalLoggingLevel::INFO; } } if ($level <= $this->loggingLevel) { error_log("[" . date('d-m-Y h:i:s') . "] " . $this->loggerName . ": $message\n", 3, $this->loggerFile); } } } /** * Log Error * * @param string $message */ public function error($message) { $this->log("ERROR\t: " . $message, PayPalLoggingLevel::ERROR); } /** * Log Warning * * @param string $message */ public function warning($message) { $this->log("WARNING\t: " . $message, PayPalLoggingLevel::WARN); } /** * Log Info * * @param string $message */ public function info($message) { $this->log("INFO\t: " . $message, PayPalLoggingLevel::INFO); } /** * Log Fine * * @param string $message */ public function fine($message) { $this->log("FINE\t: " . $message, PayPalLoggingLevel::FINE); } /** * Log Fine * * @param string $message */ public function debug($message) { $this->log("DEBUG\t: " . $message, PayPalLoggingLevel::DEBUG); } } rest-api-sdk-php/lib/PayPal/Core/PayPalConstants.php 0000644 00000001216 15007532371 0016257 0 ustar 00 <?php namespace PayPal\Core; /** * Class PayPalConstants * Placeholder for Paypal Constants * * @package PayPal\Core */ class PayPalConstants { const SDK_NAME = 'PayPal-PHP-SDK'; const SDK_VERSION = '1.6.4'; /** * Approval URL for Payment */ const APPROVAL_URL = 'approval_url'; const REST_SANDBOX_ENDPOINT = "https://api.sandbox.paypal.com/"; const OPENID_REDIRECT_SANDBOX_URL = "https://www.sandbox.paypal.com/webapps/auth/protocol/openidconnect"; const REST_LIVE_ENDPOINT = "https://api.paypal.com/"; const OPENID_REDIRECT_LIVE_URL = "https://www.paypal.com/webapps/auth/protocol/openidconnect"; } rest-api-sdk-php/lib/PayPal/Core/PayPalHttpConfig.php 0000644 00000015750 15007532371 0016360 0 ustar 00 <?php namespace PayPal\Core; use PayPal\Exception\PayPalConfigurationException; /** * Class PayPalHttpConfig * Http Configuration Class * * @package PayPal\Core */ class PayPalHttpConfig { /** * Some default options for curl * These are typically overridden by PayPalConnectionManager * * @var array */ public static $defaultCurlOptions = array( CURLOPT_SSLVERSION => 6, 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, CURLOPT_SSL_CIPHER_LIST => 'TLSv1' //Allowing TLSv1 cipher list. //Adding it like this for backward compatibility with older versions of curl ); 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 * @param array $configs All Configurations */ public function __construct($url = null, $method = self::HTTP_POST, $configs = array()) { $this->url = $url; $this->method = $method; $this->curlOptions = $this->getHttpConstantsFromConfigs($configs, 'http.') + self::$defaultCurlOptions; // Update the Cipher List based on OpenSSL or NSS settings $curl = curl_version(); $sslVersion = isset($curl['ssl_version']) ? $curl['ssl_version'] : ''; if (substr_compare($sslVersion, "NSS/", 0, strlen("NSS/")) === 0) { //Remove the Cipher List for NSS $this->removeCurlOption(CURLOPT_SSL_CIPHER_LIST); } } /** * 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 = array()) { $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; } /** * Removes a curl option from the list * * @param $name */ public function removeCurlOption($name) { unset($this->curlOptions[$name]); } /** * 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 PayPalConfigurationException */ public function setHttpProxy($proxy) { $urlParts = parse_url($proxy); if ($urlParts == false || !array_key_exists("host", $urlParts)) { throw new PayPalConfigurationException("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; } /** * Retrieves an array of constant key, and value based on Prefix * * @param array $configs * @param $prefix * @return array */ public function getHttpConstantsFromConfigs($configs = array(), $prefix) { $arr = array(); if ($prefix != null && is_array($configs)) { foreach ($configs as $k => $v) { // Check if it startsWith if (substr($k, 0, strlen($prefix)) === $prefix) { $newKey = ltrim($k, $prefix); if (defined($newKey)) { $arr[constant($newKey)] = $v; } } } } return $arr; } } rest-api-sdk-php/lib/PayPal/Core/cacert.pem 0000644 00000026145 15007532371 0014437 0 ustar 00 Verisign Class 3 Public Primary Certification Authority ======================================================= -----BEGIN CERTIFICATE----- MIICPDCCAaUCEHC65B0Q2Sk0tjjKewPMur8wDQYJKoZIhvcNAQECBQAwXzELMAkGA1UEBhMCVVMx FzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAzIFB1YmxpYyBQcmltYXJ5 IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk2MDEyOTAwMDAwMFoXDTI4MDgwMTIzNTk1OVow XzELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAz IFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGfMA0GCSqGSIb3DQEBAQUA A4GNADCBiQKBgQDJXFme8huKARS0EN8EQNvjV69qRUCPhAwL0TPZ2RHP7gJYHyX3KqhEBarsAx94 f56TuZoAqiN91qyFomNFx3InzPRMxnVx0jnvT0Lwdd8KkMaOIG+YD/isI19wKTakyYbnsZogy1Ol hec9vn2a/iRFM9x2Fe0PonFkTGUugWhFpwIDAQABMA0GCSqGSIb3DQEBAgUAA4GBALtMEivPLCYA TxQT3ab7/AoRhIzzKBxnki98tsX63/Dolbwdj2wsqFHMc9ikwFPwTtYmwHYBV4GSXiHx0bH/59Ah WM1pF+NEHJwZRDmJXNycAA9WjQKZ7aKQRUzkuxCkPfAyAw7xzvjoyVGM5mKf5p/AfbdynMk2Omuf Tqj/ZA1k -----END CERTIFICATE----- Verisign Class 3 Public Primary Certification Authority - G2 ============================================================ -----BEGIN CERTIFICATE----- MIIDAjCCAmsCEH3Z/gfPqB63EHln+6eJNMYwDQYJKoZIhvcNAQEFBQAwgcExCzAJBgNVBAYTAlVT MRcwFQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE8MDoGA1UECxMzQ2xhc3MgMyBQdWJsaWMgUHJpbWFy eSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcyMTowOAYDVQQLEzEoYykgMTk5OCBWZXJpU2ln biwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MR8wHQYDVQQLExZWZXJpU2lnbiBUcnVz dCBOZXR3b3JrMB4XDTk4MDUxODAwMDAwMFoXDTI4MDgwMTIzNTk1OVowgcExCzAJBgNVBAYTAlVT MRcwFQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE8MDoGA1UECxMzQ2xhc3MgMyBQdWJsaWMgUHJpbWFy eSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcyMTowOAYDVQQLEzEoYykgMTk5OCBWZXJpU2ln biwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MR8wHQYDVQQLExZWZXJpU2lnbiBUcnVz dCBOZXR3b3JrMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDMXtERXVxp0KvTuWpMmR9ZmDCO FoUgRm1HP9SFIIThbbP4pO0M8RcPO/mn+SXXwc+EY/J8Y8+iR/LGWzOOZEAEaMGAuWQcRXfH2G71 lSk8UOg013gfqLptQ5GVj0VXXn7F+8qkBOvqlzdUMG+7AUcyM83cV5tkaWH4mx0ciU9cZwIDAQAB MA0GCSqGSIb3DQEBBQUAA4GBAFFNzb5cy5gZnBWyATl4Lk0PZ3BwmcYQWpSkU01UbSuvDV1Ai2TT 1+7eVmGSX6bEHRBhNtMsJzzoKQm5EWR0zLVznxxIqbxhAe7iF6YM40AIOw7n60RzKprxaZLvcRTD Oaxxp5EJb+RxBrO6WVcmeQD2+A2iMzAo1KpYoJ2daZH9 -----END CERTIFICATE----- Verisign Class 3 Public Primary Certification Authority - G3 ============================================================ -----BEGIN CERTIFICATE----- MIIEGjCCAwICEQCbfgZJoz5iudXukEhxKe9XMA0GCSqGSIb3DQEBBQUAMIHKMQswCQYDVQQGEwJV UzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRydXN0IE5ldHdv cmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNl IG9ubHkxRTBDBgNVBAMTPFZlcmlTaWduIENsYXNzIDMgUHVibGljIFByaW1hcnkgQ2VydGlmaWNh dGlvbiBBdXRob3JpdHkgLSBHMzAeFw05OTEwMDEwMDAwMDBaFw0zNjA3MTYyMzU5NTlaMIHKMQsw CQYDVQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRy dXN0IE5ldHdvcmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1dGhv cml6ZWQgdXNlIG9ubHkxRTBDBgNVBAMTPFZlcmlTaWduIENsYXNzIDMgUHVibGljIFByaW1hcnkg Q2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBHMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC ggEBAMu6nFL8eB8aHm8bN3O9+MlrlBIwT/A2R/XQkQr1F8ilYcEWQE37imGQ5XYgwREGfassbqb1 EUGO+i2tKmFZpGcmTNDovFJbcCAEWNF6yaRpvIMXZK0Fi7zQWM6NjPXr8EJJC52XJ2cybuGukxUc cLwgTS8Y3pKI6GyFVxEa6X7jJhFUokWWVYPKMIno3Nij7SqAP395ZVc+FSBmCC+Vk7+qRy+oRpfw EuL+wgorUeZ25rdGt+INpsyow0xZVYnm6FNcHOqd8GIWC6fJXwzw3sJ2zq/3avL6QaaiMxTJ5Xpj 055iN9WFZZ4O5lMkdBteHRJTW8cs54NJOxWuimi5V5cCAwEAATANBgkqhkiG9w0BAQUFAAOCAQEA ERSWwauSCPc/L8my/uRan2Te2yFPhpk0djZX3dAVL8WtfxUfN2JzPtTnX84XA9s1+ivbrmAJXx5f j267Cz3qWhMeDGBvtcC1IyIuBwvLqXTLR7sdwdela8wv0kL9Sd2nic9TutoAWii/gt/4uhMdUIaC /Y4wjylGsB49Ndo4YhYYSq3mtlFs3q9i6wHQHiT+eo8SGhJouPtmmRQURVyu565pF4ErWjfJXir0 xuKhXFSbplQAz/DxwceYMBo7Nhbbo27q/a2ywtrvAkcTisDxszGtTxzhT5yvDwyd93gN2PQ1VoDa t20Xj50egWTh/sVFuq1ruQp6Tk9LhO5L8X3dEQ== -----END CERTIFICATE----- Verisign Class 4 Public Primary Certification Authority - G3 ============================================================ -----BEGIN CERTIFICATE----- MIIEGjCCAwICEQDsoKeLbnVqAc/EfMwvlF7XMA0GCSqGSIb3DQEBBQUAMIHKMQswCQYDVQQGEwJV UzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRydXN0IE5ldHdv cmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNl IG9ubHkxRTBDBgNVBAMTPFZlcmlTaWduIENsYXNzIDQgUHVibGljIFByaW1hcnkgQ2VydGlmaWNh dGlvbiBBdXRob3JpdHkgLSBHMzAeFw05OTEwMDEwMDAwMDBaFw0zNjA3MTYyMzU5NTlaMIHKMQsw CQYDVQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRy dXN0IE5ldHdvcmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1dGhv cml6ZWQgdXNlIG9ubHkxRTBDBgNVBAMTPFZlcmlTaWduIENsYXNzIDQgUHVibGljIFByaW1hcnkg Q2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBHMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC ggEBAK3LpRFpxlmr8Y+1GQ9Wzsy1HyDkniYlS+BzZYlZ3tCD5PUPtbut8XzoIfzk6AzufEUiGXaS tBO3IFsJ+mGuqPKljYXCKtbeZjbSmwL0qJJgfJxptI8kHtCGUvYynEFYHiK9zUVilQhu0GbdU6LM 8BDcVHOLBKFGMzNcF0C5nk3T875Vg+ixiY5afJqWIpA7iCXy0lOIAgwLePLmNxdLMEYH5IBtptiW Lugs+BGzOA1mppvqySNb247i8xOOGlktqgLw7KSHZtzBP/XYufTsgsbSPZUd5cBPhMnZo0QoBmrX Razwa2rvTl/4EYIeOGM0ZlDUPpNz+jDDZq3/ky2X7wMCAwEAATANBgkqhkiG9w0BAQUFAAOCAQEA j/ola09b5KROJ1WrIhVZPMq1CtRK26vdoV9TxaBXOcLORyu+OshWv8LZJxA6sQU8wHcxuzrTBXtt mhwwjIDLk5Mqg6sFUYICABFna/OIYUdfA5PVWw3g8dShMjWFsjrbsIKr0csKvE+MW8VLADsfKoKm fjaF3H48ZwC15DtS4KjrXRX5xm3wrR0OhbepmnMUWluPQSjA1egtTaRezarZ7c7c2NU8Qh0XwRJd RTjDOPP8hS6DRkiy1yBfkjaP53kPmF6Z6PDQpLv1U70qzlmwr25/bLvSHgCwIe34QWKCudiyxLtG UPMxxY8BqHTr9Xgn2uf3ZkPznoM+IKrDNWCRzg== -----END CERTIFICATE----- VeriSign Class 3 Public Primary Certification Authority - G5 ============================================================ -----BEGIN CERTIFICATE----- MIIE0zCCA7ugAwIBAgIQGNrRniZ96LtKIVjNzGs7SjANBgkqhkiG9w0BAQUFADCByjELMAkGA1UE BhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBO ZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVk IHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRp ZmljYXRpb24gQXV0aG9yaXR5IC0gRzUwHhcNMDYxMTA4MDAwMDAwWhcNMzYwNzE2MjM1OTU5WjCB yjELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2ln biBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJpU2lnbiwgSW5jLiAtIEZvciBh dXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmlt YXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw ggEKAoIBAQCvJAgIKXo1nmAMqudLO07cfLw8RRy7K+D+KQL5VwijZIUVJ/XxrcgxiV0i6CqqpkKz j/i5Vbext0uz/o9+B1fs70PbZmIVYc9gDaTY3vjgw2IIPVQT60nKWVSFJuUrjxuf6/WhkcIzSdhD Y2pSS9KP6HBRTdGJaXvHcPaz3BJ023tdS1bTlr8Vd6Gw9KIl8q8ckmcY5fQGBO+QueQA5N06tRn/ Arr0PO7gi+s3i+z016zy9vA9r911kTMZHRxAy3QkGSGT2RT+rCpSx4/VBEnkjWNHiDxpg8v+R70r fk/Fla4OndTRQ8Bnc+MUCH7lP59zuDMKz10/NIeWiu5T6CUVAgMBAAGjgbIwga8wDwYDVR0TAQH/ BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwbQYIKwYBBQUHAQwEYTBfoV2gWzBZMFcwVRYJaW1hZ2Uv Z2lmMCEwHzAHBgUrDgMCGgQUj+XTGoasjY5rw8+AatRIGCx7GS4wJRYjaHR0cDovL2xvZ28udmVy aXNpZ24uY29tL3ZzbG9nby5naWYwHQYDVR0OBBYEFH/TZafC3ey78DAJ80M5+gKvMzEzMA0GCSqG SIb3DQEBBQUAA4IBAQCTJEowX2LP2BqYLz3q3JktvXf2pXkiOOzEp6B4Eq1iDkVwZMXnl2YtmAl+ X6/WzChl8gGqCBpH3vn5fJJaCGkgDdk+bW48DW7Y5gaRQBi5+MHt39tBquCWIMnNZBU4gcmU7qKE KQsTb47bDN0lAtukixlE0kF6BWlKWE9gyn6CagsCqiUXObXbf+eEZSqVir2G3l6BFoMtEMze/aiC Km0oHw0LxOXnGiYZ4fQRbxC1lfznQgUy286dUV4otp6F01vvpX1FQHKOtw5rDgb7MzVIcbidJ4vE ZV8NhnacRHr2lVz2XTIIM6RUthg/aFzyQkqFOFSDX9HoLPKsEdao7WNq -----END CERTIFICATE----- VeriSign Universal Root Certification Authority =============================================== -----BEGIN CERTIFICATE----- MIIEuTCCA6GgAwIBAgIQQBrEZCGzEyEDDrvkEhrFHTANBgkqhkiG9w0BAQsFADCBvTELMAkGA1UE BhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBO ZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwOCBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVk IHVzZSBvbmx5MTgwNgYDVQQDEy9WZXJpU2lnbiBVbml2ZXJzYWwgUm9vdCBDZXJ0aWZpY2F0aW9u IEF1dGhvcml0eTAeFw0wODA0MDIwMDAwMDBaFw0zNzEyMDEyMzU5NTlaMIG9MQswCQYDVQQGEwJV UzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRydXN0IE5ldHdv cmsxOjA4BgNVBAsTMShjKSAyMDA4IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNl IG9ubHkxODA2BgNVBAMTL1ZlcmlTaWduIFVuaXZlcnNhbCBSb290IENlcnRpZmljYXRpb24gQXV0 aG9yaXR5MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAx2E3XrEBNNti1xWb/1hajCMj 1mCOkdeQmIN65lgZOIzF9uVkhbSicfvtvbnazU0AtMgtc6XHaXGVHzk8skQHnOgO+k1KxCHfKWGP MiJhgsWHH26MfF8WIFFE0XBPV+rjHOPMee5Y2A7Cs0WTwCznmhcrewA3ekEzeOEz4vMQGn+HLL72 9fdC4uW/h2KJXwBL38Xd5HVEMkE6HnFuacsLdUYI0crSK5XQz/u5QGtkjFdN/BMReYTtXlT2NJ8I AfMQJQYXStrxHXpma5hgZqTZ79IugvHw7wnqRMkVauIDbjPTrJ9VAMf2CGqUuV/c4DPxhGD5WycR tPwW8rtWaoAljQIDAQABo4GyMIGvMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMG0G CCsGAQUFBwEMBGEwX6FdoFswWTBXMFUWCWltYWdlL2dpZjAhMB8wBwYFKw4DAhoEFI/l0xqGrI2O a8PPgGrUSBgsexkuMCUWI2h0dHA6Ly9sb2dvLnZlcmlzaWduLmNvbS92c2xvZ28uZ2lmMB0GA1Ud DgQWBBS2d/ppSEefUxLVwuoHMnYH0ZcHGTANBgkqhkiG9w0BAQsFAAOCAQEASvj4sAPmLGd75JR3 Y8xuTPl9Dg3cyLk1uXBPY/ok+myDjEedO2Pzmvl2MpWRsXe8rJq+seQxIcaBlVZaDrHC1LGmWazx Y8u4TB1ZkErvkBYoH1quEPuBUDgMbMzxPcP1Y+Oz4yHJJDnp/RVmRvQbEdBNc6N9Rvk97ahfYtTx P/jgdFcrGJ2BtMQo2pSXpXDrrB2+BxHw1dvd5Yzw1TKwg+ZX4o+/vqGqvz0dtdQ46tewXDpPaj+P wGZsY6rp2aQW9IHRlRQOfc2VNNnSj3BzgXucfr2YYdhFh5iQxeuGMMY1v/D/w1WIg0vvBZIGcfK4 mJO37M2CYfE45k+XmCpajQ== -----END CERTIFICATE----- VeriSign Class 3 Public Primary Certification Authority - G4 ============================================================ -----BEGIN CERTIFICATE----- MIIDhDCCAwqgAwIBAgIQL4D+I4wOIg9IZxIokYesszAKBggqhkjOPQQDAzCByjELMAkGA1UEBhMC VVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBOZXR3 b3JrMTowOAYDVQQLEzEoYykgMjAwNyBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVz ZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmlj YXRpb24gQXV0aG9yaXR5IC0gRzQwHhcNMDcxMTA1MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCByjEL MAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBU cnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNyBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRo b3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5 IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzQwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAASnVnp8 Utpkmw4tXNherJI9/gHmGUo9FANL+mAnINmDiWn6VMaaGF5VKmTeBvaNSjutEDxlPZCIBIngMGGz rl0Bp3vefLK+ymVhAIau2o970ImtTR1ZmkGxvEeA3J5iw/mjgbIwga8wDwYDVR0TAQH/BAUwAwEB /zAOBgNVHQ8BAf8EBAMCAQYwbQYIKwYBBQUHAQwEYTBfoV2gWzBZMFcwVRYJaW1hZ2UvZ2lmMCEw HzAHBgUrDgMCGgQUj+XTGoasjY5rw8+AatRIGCx7GS4wJRYjaHR0cDovL2xvZ28udmVyaXNpZ24u Y29tL3ZzbG9nby5naWYwHQYDVR0OBBYEFLMWkf3upm7ktS5Jj4d4gYDs5bG1MAoGCCqGSM49BAMD A2gAMGUCMGYhDBgmYFo4e1ZC4Kf8NoRRkSAsdk1DPcQdhCPQrNZ8NQbOzWm9kA3bbEhCHQ6qQgIx AJw9SDkjOVgaFRJZap7v1VmyHVIsmXHNxynfGyphe3HR3vPA5Q06Sqotp9iGKt0uEA== -----END CERTIFICATE----- Verisign Class 3 Public Primary Certification Authority ======================================================= -----BEGIN CERTIFICATE----- MIICPDCCAaUCEDyRMcsf9tAbDpq40ES/Er4wDQYJKoZIhvcNAQEFBQAwXzELMAkGA1UEBhMCVVMx FzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAzIFB1YmxpYyBQcmltYXJ5 IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk2MDEyOTAwMDAwMFoXDTI4MDgwMjIzNTk1OVow XzELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAz IFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGfMA0GCSqGSIb3DQEBAQUA A4GNADCBiQKBgQDJXFme8huKARS0EN8EQNvjV69qRUCPhAwL0TPZ2RHP7gJYHyX3KqhEBarsAx94 f56TuZoAqiN91qyFomNFx3InzPRMxnVx0jnvT0Lwdd8KkMaOIG+YD/isI19wKTakyYbnsZogy1Ol hec9vn2a/iRFM9x2Fe0PonFkTGUugWhFpwIDAQABMA0GCSqGSIb3DQEBBQUAA4GBABByUqkFFBky CEHwxWsKzH4PIRnN5GfcX6kb5sroc50i2JhucwNhkcV8sEVAbkSdjbCxlnRhLQ2pRdKkkirWmnWX bj9T/UWZYB2oK0z5XqcJ2HUw19JlYD1n1khVdWk/kfVIC0dpImmClr7JyDiGSnoscxlIaU5rfGW/ D/xwzoiQ -----END CERTIFICATE----- rest-api-sdk-php/lib/PayPal/Core/PayPalCredentialManager.php 0000644 00000011214 15007532371 0017647 0 ustar 00 <?php namespace PayPal\Core; use PayPal\Auth\OAuthTokenCredential; use PayPal\Exception\PayPalInvalidCredentialException; /** * Class PayPalCredentialManager * * PayPalCredentialManager holds all the credential information in one place. * * @package PayPal\Core */ class PayPalCredentialManager { /** * Singleton Object * * @var PayPalCredentialManager */ 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 PayPalCredentialManager */ public static function getInstance($config = null) { if (!self::$instance) { self::$instance = new self($config == null ? PayPalConfigManager::getInstance()->getConfigHashmap() : $config); } return self::$instance; } /** * Load credentials for multiple accounts, with priority given to Signature credential. * * @param array $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 PayPalInvalidCredentialException */ public function getCredentialObject($userId = null) { if ($userId == null && array_key_exists($this->defaultAccountName, $this->credentialHashmap)) { $credObj = $this->credentialHashmap[$this->defaultAccountName]; } else if (array_key_exists($userId, $this->credentialHashmap)) { $credObj = $this->credentialHashmap[$userId]; } if (empty($credObj)) { throw new PayPalInvalidCredentialException("Credential not found for " . ($userId ? $userId : " default user") . ". Please make sure your configuration/APIContext has credential information"); } return $credObj; } /** * Disabling __clone call */ public function __clone() { trigger_error('Clone is not allowed.', E_USER_ERROR); } } rest-api-sdk-php/lib/PayPal/Core/PayPalLoggingLevel.php 0000644 00000000600 15007532371 0016655 0 ustar 00 <?php namespace PayPal\Core; /** * Logging Levels. * Class containing all the constants for Logging Levels. */ class PayPalLoggingLevel { // DEBUG Logging Level const DEBUG = 4; // FINE Logging Level const FINE = 3; // INFO Logging Level const INFO = 2; // WARN Logging Level const WARN = 1; // ERROR Logging Level const ERROR = 0; } rest-api-sdk-php/lib/PayPal/Core/PayPalConfigManager.php 0000644 00000007165 15007532371 0017014 0 ustar 00 <?php namespace PayPal\Core; /** * Class PayPalConfigManager * * PayPalConfigManager loads the SDK configuration file and * hands out appropriate config params to other classes * * @package PayPal\Core */ class PayPalConfigManager { /** * Configuration Options * * @var array */ private $configs = array( ); /** * 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")); } if (file_exists($configFile)) { $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 array $configs * @return $this */ public function addConfigs($configs = array()) { $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); } } rest-api-sdk-php/lib/PayPal/Core/PayPalHttpConnection.php 0000644 00000015617 15007532371 0017254 0 ustar 00 <?php namespace PayPal\Core; use PayPal\Exception\PayPalConfigurationException; use PayPal\Exception\PayPalConnectionException; /** * 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 PayPalHttpConnection { /** * @var PayPalHttpConfig */ 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 PayPalLoggingManager */ private $logger; /** * Default Constructor * * @param PayPalHttpConfig $httpConfig * @param array $config * @throws PayPalConfigurationException */ public function __construct(PayPalHttpConfig $httpConfig, array $config) { if (!function_exists("curl_init")) { throw new PayPalConfigurationException("Curl module is not available on this system"); } $this->httpConfig = $httpConfig; $this->logger = PayPalLoggingManager::getInstance(__CLASS__); } /** * 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 * @return mixed * @throws PayPalConnectionException */ public function execute($data) { //Initialize the logger $this->logger->info($this->httpConfig->getMethod() . ' ' . $this->httpConfig->getUrl()); //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, true); curl_setopt($ch, CURLINFO_HEADER_OUT, true); 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); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); break; case 'PUT': case 'PATCH': case 'DELETE': 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->debug($header); } //Execute Curl Request $result = curl_exec($ch); //Retrieve Response Status $httpStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE); //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); //Retrieve Response Status $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 PayPalConnectionException( $this->httpConfig->getUrl(), curl_error($ch), curl_errno($ch) ); curl_close($ch); throw $ex; } // Get Request and Response Headers $requestHeaders = curl_getinfo($ch, CURLINFO_HEADER_OUT); //Using alternative solution to CURLINFO_HEADER_SIZE as it throws invalid number when called using PROXY. $responseHeaderSize = strlen($result) - curl_getinfo($ch, CURLINFO_SIZE_DOWNLOAD); $responseHeaders = substr($result, 0, $responseHeaderSize); $result = substr($result, $responseHeaderSize); $this->logger->debug("Request Headers \t: " . str_replace("\r\n", ", ", $requestHeaders)); $this->logger->debug(($data && $data != '' ? "Request Data\t\t: " . $data : "No Request Payload") . "\n" . str_repeat('-', 128) . "\n"); $this->logger->info("Response Status \t: " . $httpStatus); $this->logger->debug("Response Headers\t: " . str_replace("\r\n", ", ", $responseHeaders)); //Close the curl request curl_close($ch); //More Exceptions based on HttpStatus Code if (in_array($httpStatus, self::$retryCodes)) { $ex = new PayPalConnectionException( $this->httpConfig->getUrl(), "Got Http response code $httpStatus when accessing {$this->httpConfig->getUrl()}. " . "Retried $retries times." ); $ex->setData($result); $this->logger->error("Got Http response code $httpStatus when accessing {$this->httpConfig->getUrl()}. " . "Retried $retries times." . $result); $this->logger->debug("\n\n" . str_repeat('=', 128) . "\n"); throw $ex; } else if ($httpStatus < 200 || $httpStatus >= 300) { $ex = new PayPalConnectionException( $this->httpConfig->getUrl(), "Got Http response code $httpStatus when accessing {$this->httpConfig->getUrl()}.", $httpStatus ); $ex->setData($result); $this->logger->error("Got Http response code $httpStatus when accessing {$this->httpConfig->getUrl()}. " . $result ); $this->logger->debug("\n\n" . str_repeat('=', 128) . "\n"); throw $ex; } $this->logger->debug(($result && $result != '' ? "Response Data \t: " . $result : "No Response Body") . "\n\n" . str_repeat('=', 128) . "\n"); //Return result object return $result; } } rest-api-sdk-php/lib/PayPal/Converter/FormatConverter.php 0000644 00000003602 15007532371 0017374 0 ustar 00 <?php namespace PayPal\Converter; class FormatConverter { /** * Format the data based on the input formatter value * * @param $value * @param $formatter * @return string */ public static function format($value, $formatter) { return sprintf($formatter, $value); } /** * Format the input data with decimal places * * Defaults to 2 decimal places * * @param $value * @param int $decimals * @return null|string */ public static function formatToNumber($value, $decimals = 2) { if (trim($value) != null) { return number_format($value, $decimals, '.', ''); } return null; } /** * Helper method to format price values with associated currency information. * * It covers the cases where certain currencies does not accept decimal values. We will be adding * any specific currency level rules as required here. * * @param $value * @param null $currency * @return null|string */ public static function formatToPrice($value, $currency = null) { $decimals = 2; $currencyDecimals = array('JPY' => 0, 'TWD' => 0); if ($currency && array_key_exists($currency, $currencyDecimals)) { if (strpos($value, ".") !== false && (floor($value) != $value)) { //throw exception if it has decimal values for JPY and TWD which does not ends with .00 throw new \InvalidArgumentException("value cannot have decimals for $currency currency"); } $decimals = $currencyDecimals[$currency]; } else if (strpos($value, ".") === false) { // Check if value has decimal values. If not no need to assign 2 decimals with .00 at the end $decimals = 0; } return self::formatToNumber($value, $decimals); } } rest-api-sdk-php/lib/PayPal/Handler/RestHandler.php 0000644 00000010052 15007532371 0016072 0 ustar 00 <?php /** * API handler for all REST API calls */ namespace PayPal\Handler; use PayPal\Auth\OAuthTokenCredential; use PayPal\Common\PayPalUserAgent; use PayPal\Core\PayPalConstants; use PayPal\Core\PayPalCredentialManager; use PayPal\Core\PayPalHttpConfig; use PayPal\Exception\PayPalConfigurationException; use PayPal\Exception\PayPalInvalidCredentialException; use PayPal\Exception\PayPalMissingCredentialException; /** * Class RestHandler */ class RestHandler implements IPayPalHandler { /** * Private Variable * * @var \Paypal\Rest\ApiContext $apiContext */ private $apiContext; /** * Construct * * @param \Paypal\Rest\ApiContext $apiContext */ public function __construct($apiContext) { $this->apiContext = $apiContext; } /** * @param PayPalHttpConfig $httpConfig * @param string $request * @param mixed $options * @return mixed|void * @throws PayPalConfigurationException * @throws PayPalInvalidCredentialException * @throws PayPalMissingCredentialException */ public function handle($httpConfig, $request, $options) { $credential = $this->apiContext->getCredential(); $config = $this->apiContext->getConfig(); if ($credential == null) { // Try picking credentials from the config file $credMgr = PayPalCredentialManager::getInstance($config); $credValues = $credMgr->getCredentialObject(); if (!is_array($credValues)) { throw new PayPalMissingCredentialException("Empty or invalid credentials passed"); } $credential = new OAuthTokenCredential($credValues['clientId'], $credValues['clientSecret']); } if ($credential == null || !($credential instanceof OAuthTokenCredential)) { throw new PayPalInvalidCredentialException("Invalid credentials passed"); } $httpConfig->setUrl( rtrim(trim($this->_getEndpoint($config)), '/') . (isset($options['path']) ? $options['path'] : '') ); // Overwrite Expect Header to disable 100 Continue Issue $httpConfig->addHeader("Expect", null); if (!array_key_exists("User-Agent", $httpConfig->getHeaders())) { $httpConfig->addHeader("User-Agent", PayPalUserAgent::getValue(PayPalConstants::SDK_NAME, PayPalConstants::SDK_VERSION)); } if (!is_null($credential) && $credential instanceof OAuthTokenCredential && is_null($httpConfig->getHeader('Authorization'))) { $httpConfig->addHeader('Authorization', "Bearer " . $credential->getAccessToken($config), false); } if ($httpConfig->getMethod() == 'POST' || $httpConfig->getMethod() == 'PUT') { $httpConfig->addHeader('PayPal-Request-Id', $this->apiContext->getRequestId()); } // Add any additional Headers that they may have provided $headers = $this->apiContext->getRequestHeaders(); foreach ($headers as $key => $value) { $httpConfig->addHeader($key, $value); } } /** * End Point * * @param array $config * * @return string * @throws \PayPal\Exception\PayPalConfigurationException */ private function _getEndpoint($config) { if (isset($config['service.EndPoint'])) { return $config['service.EndPoint']; } else if (isset($config['mode'])) { switch (strtoupper($config['mode'])) { case 'SANDBOX': return PayPalConstants::REST_SANDBOX_ENDPOINT; break; case 'LIVE': return PayPalConstants::REST_LIVE_ENDPOINT; break; default: throw new PayPalConfigurationException('The mode config parameter must be set to either sandbox/live'); break; } } else { // Defaulting to Sandbox return PayPalConstants::REST_SANDBOX_ENDPOINT; } } } rest-api-sdk-php/lib/PayPal/Handler/IPayPalHandler.php 0000644 00000000535 15007532371 0016461 0 ustar 00 <?php namespace PayPal\Handler; /** * Interface IPayPalHandler * * @package PayPal\Handler */ interface IPayPalHandler { /** * * @param \Paypal\Core\PayPalHttpConfig $httpConfig * @param string $request * @param mixed $options * @return mixed */ public function handle($httpConfig, $request, $options); } rest-api-sdk-php/lib/PayPal/Handler/OauthHandler.php 0000644 00000006157 15007532371 0016250 0 ustar 00 <?php /** * API handler for OAuth Token Request REST API calls */ namespace PayPal\Handler; use PayPal\Common\PayPalUserAgent; use PayPal\Core\PayPalConstants; use PayPal\Core\PayPalHttpConfig; use PayPal\Exception\PayPalConfigurationException; use PayPal\Exception\PayPalInvalidCredentialException; use PayPal\Exception\PayPalMissingCredentialException; /** * Class OauthHandler */ class OauthHandler implements IPayPalHandler { /** * Private Variable * * @var \Paypal\Rest\ApiContext $apiContext */ private $apiContext; /** * Construct * * @param \Paypal\Rest\ApiContext $apiContext */ public function __construct($apiContext) { $this->apiContext = $apiContext; } /** * @param PayPalHttpConfig $httpConfig * @param string $request * @param mixed $options * @return mixed|void * @throws PayPalConfigurationException * @throws PayPalInvalidCredentialException * @throws PayPalMissingCredentialException */ public function handle($httpConfig, $request, $options) { $config = $this->apiContext->getConfig(); $httpConfig->setUrl( rtrim(trim($this->_getEndpoint($config)), '/') . (isset($options['path']) ? $options['path'] : '') ); $headers = array( "User-Agent" => PayPalUserAgent::getValue(PayPalConstants::SDK_NAME, PayPalConstants::SDK_VERSION), "Authorization" => "Basic " . base64_encode($options['clientId'] . ":" . $options['clientSecret']), "Accept" => "*/*" ); $httpConfig->setHeaders($headers); // Add any additional Headers that they may have provided $headers = $this->apiContext->getRequestHeaders(); foreach ($headers as $key => $value) { $httpConfig->addHeader($key, $value); } } /** * Get HttpConfiguration object for OAuth API * * @param array $config * * @return PayPalHttpConfig * @throws \PayPal\Exception\PayPalConfigurationException */ private static function _getEndpoint($config) { if (isset($config['oauth.EndPoint'])) { $baseEndpoint = $config['oauth.EndPoint']; } else if (isset($config['service.EndPoint'])) { $baseEndpoint = $config['service.EndPoint']; } else if (isset($config['mode'])) { switch (strtoupper($config['mode'])) { case 'SANDBOX': $baseEndpoint = PayPalConstants::REST_SANDBOX_ENDPOINT; break; case 'LIVE': $baseEndpoint = PayPalConstants::REST_LIVE_ENDPOINT; break; default: throw new PayPalConfigurationException('The mode config parameter must be set to either sandbox/live'); } } else { // Defaulting to Sandbox $baseEndpoint = PayPalConstants::REST_SANDBOX_ENDPOINT; } $baseEndpoint = rtrim(trim($baseEndpoint), '/') . "/v1/oauth2/token"; return $baseEndpoint; } } rest-api-sdk-php/lib/PayPal/Auth/OAuthTokenCredential.php 0000644 00000022003 15007532371 0017216 0 ustar 00 <?php namespace PayPal\Auth; use PayPal\Cache\AuthorizationCache; use PayPal\Common\PayPalResourceModel; use PayPal\Core\PayPalHttpConfig; use PayPal\Core\PayPalHttpConnection; use PayPal\Core\PayPalLoggingManager; use PayPal\Exception\PayPalConfigurationException; use PayPal\Exception\PayPalConnectionException; use PayPal\Handler\IPayPalHandler; use PayPal\Rest\ApiContext; use PayPal\Security\Cipher; /** * Class OAuthTokenCredential */ class OAuthTokenCredential extends PayPalResourceModel { public static $CACHE_PATH = '/../../../var/auth.cache'; /** * @var string Default Auth Handler */ public static $AUTH_HANDLER = 'PayPal\Handler\OauthHandler'; /** * Private Variable * * @var int $expiryBufferTime */ private static $expiryBufferTime = 120; /** * Private Variable * * @var \PayPal\Core\PayPalLoggingManager $logger */ private $logger; /** * Client ID as obtained from the developer portal * * @var string $clientId */ private $clientId; /** * Client secret as obtained from the developer portal * * @var string $clientSecret */ private $clientSecret; /** * Generated Access Token * * @var string $accessToken */ private $accessToken; /** * Seconds for with access token is valid * * @var $tokenExpiresIn */ private $tokenExpiresIn; /** * Last time (in milliseconds) when access token was generated * * @var $tokenCreateTime */ private $tokenCreateTime; /** * Instance of cipher used to encrypt/decrypt data while storing in cache. * * @var Cipher */ private $cipher; /** * Construct * * @param string $clientId client id obtained from the developer portal * @param string $clientSecret client secret obtained from the developer portal */ public function __construct($clientId, $clientSecret) { $this->clientId = $clientId; $this->clientSecret = $clientSecret; $this->cipher = new Cipher($this->clientSecret); $this->logger = PayPalLoggingManager::getInstance(__CLASS__); } /** * Get Client ID * * @return string */ public function getClientId() { return $this->clientId; } /** * Get Client Secret * * @return string */ public function getClientSecret() { return $this->clientSecret; } /** * Get AccessToken * * @param $config * * @return null|string */ public function getAccessToken($config) { // Check if we already have accessToken in Cache if ($this->accessToken && (time() - $this->tokenCreateTime) < ($this->tokenExpiresIn - self::$expiryBufferTime)) { return $this->accessToken; } // Check for persisted data first $token = AuthorizationCache::pull($config, $this->clientId); if ($token) { // We found it // This code block is for backward compatibility only. if (array_key_exists('accessToken', $token)) { $this->accessToken = $token['accessToken']; } $this->tokenCreateTime = $token['tokenCreateTime']; $this->tokenExpiresIn = $token['tokenExpiresIn']; // Case where we have an old unencrypted cache file if (!array_key_exists('accessTokenEncrypted', $token)) { AuthorizationCache::push($config, $this->clientId, $this->encrypt($this->accessToken), $this->tokenCreateTime, $this->tokenExpiresIn); } else { $this->accessToken = $this->decrypt($token['accessTokenEncrypted']); } } // Check if Access Token is not null and has not expired. // The API returns expiry time as a relative time unit // We use a buffer time when checking for token expiry to account // for API call delays and any delay between the time the token is // retrieved and subsequently used if ( $this->accessToken != null && (time() - $this->tokenCreateTime) > ($this->tokenExpiresIn - self::$expiryBufferTime) ) { $this->accessToken = null; } // If accessToken is Null, obtain a new token if ($this->accessToken == null) { // Get a new one by making calls to API $this->updateAccessToken($config); AuthorizationCache::push($config, $this->clientId, $this->encrypt($this->accessToken), $this->tokenCreateTime, $this->tokenExpiresIn); } return $this->accessToken; } /** * Get a Refresh Token from Authorization Code * * @param $config * @param $authorizationCode * @param array $params optional arrays to override defaults * @return string|null */ public function getRefreshToken($config, $authorizationCode = null, $params = array()) { static $allowedParams = array( 'grant_type' => 'authorization_code', 'code' => 1, 'redirect_uri' => 'urn:ietf:wg:oauth:2.0:oob', 'response_type' => 'token' ); $params = is_array($params) ? $params : array(); if ($authorizationCode) { //Override the authorizationCode if value is explicitly set $params['code'] = $authorizationCode; } $payload = http_build_query(array_merge($allowedParams, array_intersect_key($params, $allowedParams))); $response = $this->getToken($config, $this->clientId, $this->clientSecret, $payload); if ($response != null && isset($response["refresh_token"])) { return $response['refresh_token']; } return null; } /** * Updates Access Token based on given input * * @param array $config * @param string|null $refreshToken * @return string */ public function updateAccessToken($config, $refreshToken = null) { $this->generateAccessToken($config, $refreshToken); return $this->accessToken; } /** * Retrieves the token based on the input configuration * * @param array $config * @param string $clientId * @param string $clientSecret * @param string $payload * @return mixed * @throws PayPalConfigurationException * @throws \PayPal\Exception\PayPalConnectionException */ protected function getToken($config, $clientId, $clientSecret, $payload) { $httpConfig = new PayPalHttpConfig(null, 'POST', $config); $handlers = array(self::$AUTH_HANDLER); /** @var IPayPalHandler $handler */ foreach ($handlers as $handler) { if (!is_object($handler)) { $fullHandler = "\\" . (string)$handler; $handler = new $fullHandler(new ApiContext($this)); } $handler->handle($httpConfig, $payload, array('clientId' => $clientId, 'clientSecret' => $clientSecret)); } $connection = new PayPalHttpConnection($httpConfig, $config); $res = $connection->execute($payload); $response = json_decode($res, true); return $response; } /** * Generates a new access token * * @param array $config * @param null|string $refreshToken * @return null * @throws PayPalConnectionException */ private function generateAccessToken($config, $refreshToken = null) { $params = array('grant_type' => 'client_credentials'); if ($refreshToken != null) { // If the refresh token is provided, it would get access token using refresh token // Used for Future Payments $params['grant_type'] = 'refresh_token'; $params['refresh_token'] = $refreshToken; } $payload = http_build_query($params); $response = $this->getToken($config, $this->clientId, $this->clientSecret, $payload); if ($response == null || !isset($response["access_token"]) || !isset($response["expires_in"])) { $this->accessToken = null; $this->tokenExpiresIn = null; $this->logger->warning( "Could not generate new Access token. Invalid response from server: " ); throw new PayPalConnectionException(null, "Could not generate new Access token. Invalid response from server: "); } else { $this->accessToken = $response["access_token"]; $this->tokenExpiresIn = $response["expires_in"]; } $this->tokenCreateTime = time(); return $this->accessToken; } /** * Helper method to encrypt data using clientSecret as key * * @param $data * @return string */ public function encrypt($data) { return $this->cipher->encrypt($data); } /** * Helper method to decrypt data using clientSecret as key * * @param $data * @return string */ public function decrypt($data) { return $this->cipher->decrypt($data); } } rest-api-sdk-php/composer.json 0000644 00000001256 15007532371 0012365 0 ustar 00 { "name": "paypal/rest-api-sdk-php", "description": "PayPal's PHP SDK for REST APIs", "keywords": ["paypal", "payments", "rest", "sdk"], "type": "library", "license": "Apache2", "homepage": "http://paypal.github.io/PayPal-PHP-SDK/", "authors": [ { "name": "PayPal", "homepage": "https://github.com/paypal/rest-api-sdk-php/contributors" } ], "require": { "php": ">=5.3.0", "ext-curl": "*", "ext-json": "*" }, "require-dev": { "phpunit/phpunit": "3.7.*" }, "autoload": { "psr-0": { "PayPal": "lib/" } } } rest-api-sdk-php/release_notes.md 0000644 00000014361 15007532371 0013016 0 ustar 00 PayPal PHP SDK release notes ============================ v1.6.4 ---- * SSL Connect Error Fix * Fixes #474 v1.6.3 ---- * Fixes Continue 100 Header * Minor Bug Fixes #452 v1.6.2 ---- * TLS Check Sample Added * Updated README v1.6.1 ---- * User Agent Changes * SDK Version Fix v1.6.0 ---- * Updated Payments API to latest version * Removed ModelAccessValidator * Minor Bug Fixes #399 v1.5.1 ---- * Fixed a bug #343 in Future Payment * Minor Improvements * Updates to Sample Docs v1.5.0 ---- * Enabled Vault List API * Added More Fields to Vault Credit Card Object * Minor Fixes v1.4.0 ---- * Ability to validate Webhook * Fixes to Logging Manager to skip if mode is not set * SDK updates and fixes v1.3.2 ---- * Minor Fix for Agreement Details v1.3.1 ---- * PayPalModel to differentiate between empty objects and array * Fixed CURLINFO_HEADER_SIZE miscalculations if Proxy Enabled v1.3.0 ---- * Updated Payment APIs * Updating ModelAccessValidator to be disabled if not set explicitly v1.2.1 ---- * Ability to handle missing accesors for unknown objects in json v1.2.0 ---- * Order API Support * Introduced DEBUG mode in Logging. Deprecated FINE. * Ability to not Log on DEBUG, while on live environment * Vault APIs Update API Support * Transaction Fee Added in Sale Object * Fixed #237, #234, #233, #215 v1.1.1 ---- * Fix to Cipher Encryption (Critical) v1.1.0 ---- * Enabled Payouts Cancel API Support for Unclaimed Payouts * Encrypting Access Token in Cached Storage * Updated Billing Agreement Search Transaction code to pass start_date and end_date * Updated OAuthToken to throw proper error on not receiving access token * Minor Bug Fixes and Documentation Updates v1.0.0 ---- * Enabled Payouts API Support * Authorization Cache Custom Path Directory Configuration * Helper Functions to retrieve specific HATEOS Links * Default Mode set to Sandbox * Enabled Rest SDK to work nicely with Classic SDKs. * If missing annotation of return type in Getters, it throws a proper exception * `echo` on PayPalModel Objects will print nice looking JSON * Updated Invoice Object to retrieve payments and refunds > ## Breaking Changes * Removed Deprecated Getter Setters from all Model Classes * All Camelcase getters and setters are removed. Please use first letter uppercase syntax * E.g. instead of using get_notify_url(), use getNotifyUrl() instead * Renamed Classes * PayPal\Common\PPModel => PayPal\Common\PayPalModel * PayPal\Common\ResourceModel => PayPal\Common\PayPalResourceModel * PayPal\Common\PPUserAgent => PayPal\Common\PayPalUserAgent * PayPal\Core\PPConfigManager => PayPal\Core\PayPalConfigManager * PayPal\Core\PPConstants => PayPal\Core\PayPalConstants * PayPal\Core\PPCredentialManager => PayPal\Core\PayPalCredentialManager * PayPal\Core\PPHttpConfig => PayPal\Core\PayPalHttpConfig * PayPal\Core\PPHttpConnection => PayPal\Core\PayPalHttpConnection * PayPal\Core\PPLoggingLevel => PayPal\Core\PayPalLoggingLevel * PayPal\Core\PPLoggingManager => PayPal\Core\PayPalLoggingManager * PayPal\Exception\PPConfigurationException => PayPal\Exception\PayPalConfigurationException * PayPal\Exception\PPConnectionException => PayPal\Exception\PayPalConnectionException * PayPal\Exception\PPInvalidCredentialException => PayPal\Exception\PayPalInvalidCredentialException * PayPal\Exception\PPMissingCredentialException => PayPal\Exception\PayPalMissingCredentialException * PayPal\Handler\IPPHandler => PayPal\Handler\IPayPalHandler * PayPal\Transport\PPRestCall => PayPal\Transport\PayPalRestCall * Namespace Changes and Class Naming Convention * PayPal\Common\FormatConverter => PayPal\Converter\FormatConverter * PayPal\Rest\RestHandler => PayPal\Handler\RestHandler * PayPal\Rest\OauthHandler => PayPal\Handler\OauthHandler * Fixes to Methods * PayPal\Api\Invoice->getPaymentDetails() was renamed to getPayments() * PayPal\Api\Invoice->getRefundDetails() was renamed to getRefunds() v1.0.0-beta ---- * Namespace Changes and Class Naming Convention * Helper Functions to retrieve specific HATEOS Links * Default Mode set to Sandbox v0.16.1 ---- * Configurable Headers for all requests to PayPal * Allows adding additional headers to every call to PayPal APIs * SDK Config to add headers with http.headers.* syntax v0.16.0 ---- * Enabled Webhook Management Capabilities * Enabled Caching Abilities for Access Tokens v0.15.1 ---- * Enabled Deleting Billing Plans * Updated Samples v0.15.0 ---- * Extended Invoicing Capabilities * Allows QR Code Generation for Invoices * Updated Formatter to work with multiple locales * Removed Future Payments mandate on Correlation Id v0.14.2 ---- * Quick Patch to Unset Cipher List for NSS v0.14.1 ---- * Updated HttpConfig to use TLSv1 as Cipher List * Added resetRequestId in ApiContext to enable multiple create calls in succession * Sanitize Input for Price Variables * Made samples look better and work best v0.14.0 ---- * Enabled Billing Plans and Agreements APIs * Renamed SDK name to PayPal-PHP-SDK v0.13.2 ---- * Updated Future Payments and LIPP Support * Updated Logging Syntax v0.13.1 ---- * Enabled TLS version 1.x for SSL Negotiation * Updated Identity Support from SDK Core * Fixed Backward Compatibility changes v0.13.0 ---- * Enabled Payment Experience v0.12.0 ---- * Enabled EC Parameters Support for Payment APIs * Enabled Validation for Missing Accessors v0.11.1 ---- * Removed Dependency from SDK Core Project * Enabled Future Payments v0.11.0 ---- * Ability for PUT and PATCH requests * Invoice number, custom and soft descriptor * Order API and tests, more Authorization tests * remove references to sdk-packages * patch for retrieving paid invoices * Shipping address docs patch * Remove @array annotation * Validate return cancel url * type hinting, comment cleaning, and getters and setters for Shipping v0.8.0 ----- * Invoicing API support added v0.7.1 ----- * Added support for Reauthorization 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 v0.6.0 ----- * Adding support for dynamic configuration of SDK (Upgrading sdk-core-php dependency to V1.4.0) * Deprecating the setCredential method and changing resource class methods to take an ApiContext argument instead of a OauthTokenCredential argument. v0.5.0 ----- * Initial Release rest-api-sdk-php/tests/bootstrap.php 0000644 00000000701 15007532371 0013525 0 ustar 00 <?php error_reporting(E_ALL); ini_set('display_errors', '1'); // To suppress the warning during the date() invocation in logs, we would default the timezone to GMT. if (!ini_get('date.timezone')) { date_default_timezone_set('GMT'); } // Include the composer autoloader $loader = require dirname(__DIR__) . '/vendor/autoload.php'; $loader->add('PayPal\\Test', __DIR__); if (!defined("PP_CONFIG_PATH")) { define("PP_CONFIG_PATH", __DIR__); } rest-api-sdk-php/tests/PayPal/Test/Api/ExtendedBankAccountTest.php 0000644 00000002423 15007532371 0021042 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\ExtendedBankAccount; /** * Class ExtendedBankAccount * * @package PayPal\Test\Api */ class ExtendedBankAccountTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object ExtendedBankAccount * * @return string */ public static function getJson() { return '{"mandate_reference_number":"TestSample"}'; } /** * Gets Object Instance with Json data filled in * * @return ExtendedBankAccount */ public static function getObject() { return new ExtendedBankAccount(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * * @return ExtendedBankAccount */ public function testSerializationDeserialization() { $obj = new ExtendedBankAccount(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getMandateReferenceNumber()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param ExtendedBankAccount $obj */ public function testGetters($obj) { $this->assertEquals($obj->getMandateReferenceNumber(), "TestSample"); } } rest-api-sdk-php/tests/PayPal/Test/Api/ErrorDetailsTest.php 0000644 00000003133 15007532371 0017567 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\ErrorDetails; /** * Class ErrorDetails * * @package PayPal\Test\Api */ class ErrorDetailsTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object ErrorDetails * * @return string */ public static function getJson() { return '{"field":"TestSample","issue":"TestSample","purchase_unit_reference_id":"TestSample","code":"TestSample"}'; } /** * Gets Object Instance with Json data filled in * * @return ErrorDetails */ public static function getObject() { return new ErrorDetails(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * * @return ErrorDetails */ public function testSerializationDeserialization() { $obj = new ErrorDetails(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getField()); $this->assertNotNull($obj->getIssue()); $this->assertNotNull($obj->getPurchaseUnitReferenceId()); $this->assertNotNull($obj->getCode()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param ErrorDetails $obj */ public function testGetters($obj) { $this->assertEquals($obj->getField(), "TestSample"); $this->assertEquals($obj->getIssue(), "TestSample"); $this->assertEquals($obj->getPurchaseUnitReferenceId(), "TestSample"); $this->assertEquals($obj->getCode(), "TestSample"); } } rest-api-sdk-php/tests/PayPal/Test/Api/ErrorTest.php 0000644 00000005044 15007532371 0016264 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\Error; /** * Class Error * * @package PayPal\Test\Api */ class ErrorTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object Error * * @return string */ public static function getJson() { return '{"name":"TestSample","purchase_unit_reference_id":"TestSample","message":"TestSample","code":"TestSample","details":' . ErrorDetailsTest::getJson() . ',"processor_response":' . ProcessorResponseTest::getJson() . ',"fmf_details":' . FmfDetailsTest::getJson() . ',"information_link":"TestSample","debug_id":"TestSample","links":' . LinksTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * * @return Error */ public static function getObject() { return new Error(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * * @return Error */ public function testSerializationDeserialization() { $obj = new Error(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getName()); $this->assertNotNull($obj->getPurchaseUnitReferenceId()); $this->assertNotNull($obj->getMessage()); $this->assertNotNull($obj->getCode()); $this->assertNotNull($obj->getDetails()); $this->assertNotNull($obj->getProcessorResponse()); $this->assertNotNull($obj->getFmfDetails()); $this->assertNotNull($obj->getInformationLink()); $this->assertNotNull($obj->getDebugId()); $this->assertNotNull($obj->getLinks()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param Error $obj */ public function testGetters($obj) { $this->assertEquals($obj->getName(), "TestSample"); $this->assertEquals($obj->getPurchaseUnitReferenceId(), "TestSample"); $this->assertEquals($obj->getMessage(), "TestSample"); $this->assertEquals($obj->getCode(), "TestSample"); $this->assertEquals($obj->getDetails(), ErrorDetailsTest::getObject()); $this->assertEquals($obj->getProcessorResponse(), ProcessorResponseTest::getObject()); $this->assertEquals($obj->getFmfDetails(), FmfDetailsTest::getObject()); $this->assertEquals($obj->getInformationLink(), "TestSample"); $this->assertEquals($obj->getDebugId(), "TestSample"); $this->assertEquals($obj->getLinks(), LinksTest::getObject()); } } rest-api-sdk-php/tests/PayPal/Test/Api/NameValuePairTest.php 0000644 00000002447 15007532371 0017670 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\NameValuePair; /** * Class NameValuePair * * @package PayPal\Test\Api */ class NameValuePairTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object NameValuePair * * @return string */ public static function getJson() { return '{"name":"TestSample","value":"TestSample"}'; } /** * Gets Object Instance with Json data filled in * * @return NameValuePair */ public static function getObject() { return new NameValuePair(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * * @return NameValuePair */ public function testSerializationDeserialization() { $obj = new NameValuePair(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getName()); $this->assertNotNull($obj->getValue()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param NameValuePair $obj */ public function testGetters($obj) { $this->assertEquals($obj->getName(), "TestSample"); $this->assertEquals($obj->getValue(), "TestSample"); } } rest-api-sdk-php/tests/PayPal/Test/Api/PlanTest.php 0000644 00000012476 15007532371 0016074 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\Plan; /** * Class Plan * * @package PayPal\Test\Api */ class PlanTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object Plan * @return string */ public static function getJson() { return '{"id":"TestSample","name":"TestSample","description":"TestSample","type":"TestSample","state":"TestSample","create_time":"TestSample","update_time":"TestSample","payment_definitions":' .PaymentDefinitionTest::getJson() . ',"terms":' .TermsTest::getJson() . ',"merchant_preferences":' .MerchantPreferencesTest::getJson() . ',"links":' .LinksTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * @return Plan */ public static function getObject() { return new Plan(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return Plan */ public function testSerializationDeserialization() { $obj = new Plan(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getId()); $this->assertNotNull($obj->getName()); $this->assertNotNull($obj->getDescription()); $this->assertNotNull($obj->getType()); $this->assertNotNull($obj->getState()); $this->assertNotNull($obj->getCreateTime()); $this->assertNotNull($obj->getUpdateTime()); $this->assertNotNull($obj->getPaymentDefinitions()); $this->assertNotNull($obj->getTerms()); $this->assertNotNull($obj->getMerchantPreferences()); $this->assertNotNull($obj->getLinks()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param Plan $obj */ public function testGetters($obj) { $this->assertEquals($obj->getId(), "TestSample"); $this->assertEquals($obj->getName(), "TestSample"); $this->assertEquals($obj->getDescription(), "TestSample"); $this->assertEquals($obj->getType(), "TestSample"); $this->assertEquals($obj->getState(), "TestSample"); $this->assertEquals($obj->getCreateTime(), "TestSample"); $this->assertEquals($obj->getUpdateTime(), "TestSample"); $this->assertEquals($obj->getPaymentDefinitions(), PaymentDefinitionTest::getObject()); $this->assertEquals($obj->getTerms(), TermsTest::getObject()); $this->assertEquals($obj->getMerchantPreferences(), MerchantPreferencesTest::getObject()); $this->assertEquals($obj->getLinks(), LinksTest::getObject()); } /** * @dataProvider mockProvider * @param Plan $obj */ public function testGet($obj, $mockApiContext) { $mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPayPalRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( PlanTest::getJson() )); $result = $obj->get("planId", $mockApiContext, $mockPayPalRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param Plan $obj */ public function testCreate($obj, $mockApiContext) { $mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPayPalRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( self::getJson() )); $result = $obj->create($mockApiContext, $mockPayPalRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param Plan $obj */ public function testUpdate($obj, $mockApiContext) { $mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPayPalRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( true )); $patchRequest = PatchRequestTest::getObject(); $result = $obj->update($patchRequest, $mockApiContext, $mockPayPalRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param Plan $obj */ public function testList($obj, $mockApiContext) { $mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPayPalRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( PlanListTest::getJson() )); $params = ParamsTest::getObject(); $result = $obj->all($params, $mockApiContext, $mockPayPalRestCall); $this->assertNotNull($result); } public function mockProvider() { $obj = self::getObject(); $mockApiContext = $this->getMockBuilder('ApiContext') ->disableOriginalConstructor() ->getMock(); return array( array($obj, $mockApiContext), array($obj, null) ); } } rest-api-sdk-php/tests/PayPal/Test/Api/AlternatePaymentTest.php 0000644 00000003134 15007532371 0020446 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\AlternatePayment; /** * Class AlternatePayment * * @package PayPal\Test\Api */ class AlternatePaymentTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object AlternatePayment * @return string */ public static function getJson() { return '{"alternate_payment_account_id":"TestSample","external_customer_id":"TestSample","alternate_payment_provider_id":"TestSample"}'; } /** * Gets Object Instance with Json data filled in * @return AlternatePayment */ public static function getObject() { return new AlternatePayment(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return AlternatePayment */ public function testSerializationDeserialization() { $obj = new AlternatePayment(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getAlternatePaymentAccountId()); $this->assertNotNull($obj->getExternalCustomerId()); $this->assertNotNull($obj->getAlternatePaymentProviderId()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param AlternatePayment $obj */ public function testGetters($obj) { $this->assertEquals($obj->getAlternatePaymentAccountId(), "TestSample"); $this->assertEquals($obj->getExternalCustomerId(), "TestSample"); $this->assertEquals($obj->getAlternatePaymentProviderId(), "TestSample"); } } rest-api-sdk-php/tests/PayPal/Test/Api/AgreementTest.php 0000644 00000024005 15007532371 0017100 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\Agreement; /** * Class Agreement * * @package PayPal\Test\Api */ class AgreementTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object Agreement * @return string */ public static function getJson() { return '{"id":"TestSample","state":"TestSample","name":"TestSample","description":"TestSample","start_date":"TestSample","payer":' .PayerTest::getJson() . ',"shipping_address":' .AddressTest::getJson() . ',"override_merchant_preferences":' .MerchantPreferencesTest::getJson() . ',"override_charge_models":' .OverrideChargeModelTest::getJson() . ',"plan":' .PlanTest::getJson() . ',"create_time":"TestSample","agreement_details":{"outstanding_balance":{"currency":"USD","value":"0.00"},"cycles_remaining":"12","cycles_completed":"0","next_billing_date":"2015-06-17T10:00:00Z","last_payment_date":"2015-03-18T20:20:17Z","last_payment_amount":{"currency":"USD","value":"1.00"},"final_payment_date":"2017-04-17T10:00:00Z","failed_payment_count":"0"},"update_time":"TestSample","links":' .LinksTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * @return Agreement */ public static function getObject() { return new Agreement(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return Agreement */ public function testSerializationDeserialization() { $obj = new Agreement(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getId()); $this->assertNotNull($obj->getState()); $this->assertNotNull($obj->getName()); $this->assertNotNull($obj->getDescription()); $this->assertNotNull($obj->getStartDate()); $this->assertNotNull($obj->getPayer()); $this->assertNotNull($obj->getShippingAddress()); $this->assertNotNull($obj->getOverrideMerchantPreferences()); $this->assertNotNull($obj->getOverrideChargeModels()); $this->assertNotNull($obj->getPlan()); $this->assertNotNull($obj->getCreateTime()); $this->assertNotNull($obj->getUpdateTime()); $this->assertNotNull($obj->getLinks()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param Agreement $obj */ public function testGetters($obj) { $this->assertEquals($obj->getId(), "TestSample"); $this->assertEquals($obj->getState(), "TestSample"); $this->assertEquals($obj->getName(), "TestSample"); $this->assertEquals($obj->getDescription(), "TestSample"); $this->assertEquals($obj->getStartDate(), "TestSample"); $this->assertEquals($obj->getPayer(), PayerTest::getObject()); $this->assertEquals($obj->getShippingAddress(), AddressTest::getObject()); $this->assertEquals($obj->getOverrideMerchantPreferences(), MerchantPreferencesTest::getObject()); $this->assertEquals($obj->getOverrideChargeModels(), OverrideChargeModelTest::getObject()); $this->assertEquals($obj->getPlan(), PlanTest::getObject()); $this->assertEquals($obj->getCreateTime(), "TestSample"); $this->assertEquals($obj->getUpdateTime(), "TestSample"); $this->assertEquals($obj->getLinks(), LinksTest::getObject()); } /** * @dataProvider mockProvider * @param Agreement $obj */ public function testCreate($obj, $mockApiContext) { $mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPayPalRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( self::getJson() )); $result = $obj->create($mockApiContext, $mockPayPalRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param Agreement $obj */ public function testExecute($obj, $mockApiContext) { $mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPayPalRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( self::getJson() )); $result = $obj->execute("123123", $mockApiContext, $mockPayPalRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param Agreement $obj */ public function testGet($obj, $mockApiContext) { $mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPayPalRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( AgreementTest::getJson() )); $result = $obj->get("agreementId", $mockApiContext, $mockPayPalRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param Agreement $obj */ public function testUpdate($obj, $mockApiContext) { $mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPayPalRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( self::getJson() )); $patchRequest = PatchRequestTest::getObject(); $result = $obj->update($patchRequest, $mockApiContext, $mockPayPalRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param Agreement $obj */ public function testSuspend($obj, $mockApiContext) { $mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPayPalRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( true )); $agreementStateDescriptor = AgreementStateDescriptorTest::getObject(); $result = $obj->suspend($agreementStateDescriptor, $mockApiContext, $mockPayPalRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param Agreement $obj */ public function testReActivate($obj, $mockApiContext) { $mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPayPalRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( true )); $agreementStateDescriptor = AgreementStateDescriptorTest::getObject(); $result = $obj->reActivate($agreementStateDescriptor, $mockApiContext, $mockPayPalRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param Agreement $obj */ public function testCancel($obj, $mockApiContext) { $mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPayPalRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( true )); $agreementStateDescriptor = AgreementStateDescriptorTest::getObject(); $result = $obj->cancel($agreementStateDescriptor, $mockApiContext, $mockPayPalRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param Agreement $obj */ public function testBillBalance($obj, $mockApiContext) { $mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPayPalRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( true )); $agreementStateDescriptor = AgreementStateDescriptorTest::getObject(); $result = $obj->billBalance($agreementStateDescriptor, $mockApiContext, $mockPayPalRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param Agreement $obj */ public function testSetBalance($obj, $mockApiContext) { $mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPayPalRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( true )); $currency = CurrencyTest::getObject(); $result = $obj->setBalance($currency, $mockApiContext, $mockPayPalRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param Agreement $obj */ public function testTransactions($obj, $mockApiContext) { $mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPayPalRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( AgreementTransactionsTest::getJson() )); $result = $obj->searchTransactions("agreementId", array(), $mockApiContext, $mockPayPalRestCall); $this->assertNotNull($result); } public function mockProvider() { $obj = self::getObject(); $mockApiContext = $this->getMockBuilder('ApiContext') ->disableOriginalConstructor() ->getMock(); return array( array($obj, $mockApiContext), array($obj, null) ); } } rest-api-sdk-php/tests/PayPal/Test/Api/WebhookListTest.php 0000644 00000002246 15007532371 0017426 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\WebhookList; /** * Class WebhookList * * @package PayPal\Test\Api */ class WebhookListTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object WebhookList * @return string */ public static function getJson() { return '{"webhooks":' .WebhookTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * @return WebhookList */ public static function getObject() { return new WebhookList(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return WebhookList */ public function testSerializationDeserialization() { $obj = new WebhookList(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getWebhooks()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param WebhookList $obj */ public function testGetters($obj) { $this->assertEquals($obj->getWebhooks(), WebhookTest::getObject()); } } rest-api-sdk-php/tests/PayPal/Test/Api/MerchantInfoTest.php 0000644 00000004672 15007532371 0017556 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\MerchantInfo; /** * Class MerchantInfo * * @package PayPal\Test\Api */ class MerchantInfoTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object MerchantInfo * @return string */ public static function getJson() { return '{"email":"TestSample","first_name":"TestSample","last_name":"TestSample","address":' .AddressTest::getJson() . ',"business_name":"TestSample","phone":' .PhoneTest::getJson() . ',"fax":' .PhoneTest::getJson() . ',"website":"TestSample","tax_id":"TestSample","additional_info":"TestSample"}'; } /** * Gets Object Instance with Json data filled in * @return MerchantInfo */ public static function getObject() { return new MerchantInfo(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return MerchantInfo */ public function testSerializationDeserialization() { $obj = new MerchantInfo(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getEmail()); $this->assertNotNull($obj->getFirstName()); $this->assertNotNull($obj->getLastName()); $this->assertNotNull($obj->getAddress()); $this->assertNotNull($obj->getBusinessName()); $this->assertNotNull($obj->getPhone()); $this->assertNotNull($obj->getFax()); $this->assertNotNull($obj->getWebsite()); $this->assertNotNull($obj->getTaxId()); $this->assertNotNull($obj->getAdditionalInfo()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param MerchantInfo $obj */ public function testGetters($obj) { $this->assertEquals($obj->getEmail(), "TestSample"); $this->assertEquals($obj->getFirstName(), "TestSample"); $this->assertEquals($obj->getLastName(), "TestSample"); $this->assertEquals($obj->getAddress(), AddressTest::getObject()); $this->assertEquals($obj->getBusinessName(), "TestSample"); $this->assertEquals($obj->getPhone(), PhoneTest::getObject()); $this->assertEquals($obj->getFax(), PhoneTest::getObject()); $this->assertEquals($obj->getWebsite(), "TestSample"); $this->assertEquals($obj->getTaxId(), "TestSample"); $this->assertEquals($obj->getAdditionalInfo(), "TestSample"); } } rest-api-sdk-php/tests/PayPal/Test/Api/AgreementTransactionsTest.php 0000644 00000002514 15007532371 0021472 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\AgreementTransactions; /** * Class AgreementTransactions * * @package PayPal\Test\Api */ class AgreementTransactionsTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object AgreementTransactions * @return string */ public static function getJson() { return '{"agreement_transaction_list":' .AgreementTransactionTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * @return AgreementTransactions */ public static function getObject() { return new AgreementTransactions(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return AgreementTransactions */ public function testSerializationDeserialization() { $obj = new AgreementTransactions(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getAgreementTransactionList()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param AgreementTransactions $obj */ public function testGetters($obj) { $this->assertEquals($obj->getAgreementTransactionList(), AgreementTransactionTest::getObject()); } } rest-api-sdk-php/tests/PayPal/Test/Api/WebhookEventTypeListTest.php 0000644 00000002420 15007532371 0021264 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\WebhookEventTypeList; /** * Class WebhookEventTypeList * * @package PayPal\Test\Api */ class WebhookEventTypeListTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object WebhookEventTypeList * @return string */ public static function getJson() { return '{"event_types":' .WebhookEventTypeTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * @return WebhookEventTypeList */ public static function getObject() { return new WebhookEventTypeList(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return WebhookEventTypeList */ public function testSerializationDeserialization() { $obj = new WebhookEventTypeList(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getEventTypes()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param WebhookEventTypeList $obj */ public function testGetters($obj) { $this->assertEquals($obj->getEventTypes(), WebhookEventTypeTest::getObject()); } } rest-api-sdk-php/tests/PayPal/Test/Api/AmountTest.php 0000644 00000002620 15007532371 0016433 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\Amount; /** * Class Amount * * @package PayPal\Test\Api */ class AmountTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object Amount * * @return string */ public static function getJson() { return '{"currency":"TestSample","total":"12.34","details":' . DetailsTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * * @return Amount */ public static function getObject() { return new Amount(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * * @return Amount */ public function testSerializationDeserialization() { $obj = new Amount(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getCurrency()); $this->assertNotNull($obj->getTotal()); $this->assertNotNull($obj->getDetails()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param Amount $obj */ public function testGetters($obj) { $this->assertEquals($obj->getCurrency(), "TestSample"); $this->assertEquals($obj->getTotal(), "12.34"); $this->assertEquals($obj->getDetails(), DetailsTest::getObject()); } } rest-api-sdk-php/tests/PayPal/Test/Api/PaymentDefinitionTest.php 0000644 00000004306 15007532371 0020621 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\PaymentDefinition; /** * Class PaymentDefinition * * @package PayPal\Test\Api */ class PaymentDefinitionTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object PaymentDefinition * @return string */ public static function getJson() { return '{"id":"TestSample","name":"TestSample","type":"TestSample","frequency_interval":"TestSample","frequency":"TestSample","cycles":"TestSample","amount":' .CurrencyTest::getJson() . ',"charge_models":' .ChargeModelTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * @return PaymentDefinition */ public static function getObject() { return new PaymentDefinition(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return PaymentDefinition */ public function testSerializationDeserialization() { $obj = new PaymentDefinition(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getId()); $this->assertNotNull($obj->getName()); $this->assertNotNull($obj->getType()); $this->assertNotNull($obj->getFrequencyInterval()); $this->assertNotNull($obj->getFrequency()); $this->assertNotNull($obj->getCycles()); $this->assertNotNull($obj->getAmount()); $this->assertNotNull($obj->getChargeModels()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param PaymentDefinition $obj */ public function testGetters($obj) { $this->assertEquals($obj->getId(), "TestSample"); $this->assertEquals($obj->getName(), "TestSample"); $this->assertEquals($obj->getType(), "TestSample"); $this->assertEquals($obj->getFrequencyInterval(), "TestSample"); $this->assertEquals($obj->getFrequency(), "TestSample"); $this->assertEquals($obj->getCycles(), "TestSample"); $this->assertEquals($obj->getAmount(), CurrencyTest::getObject()); $this->assertEquals($obj->getChargeModels(), ChargeModelTest::getObject()); } } rest-api-sdk-php/tests/PayPal/Test/Api/NotificationTest.php 0000644 00000002636 15007532371 0017625 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\Notification; /** * Class Notification * * @package PayPal\Test\Api */ class NotificationTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object Notification * @return string */ public static function getJson() { return '{"subject":"TestSample","note":"TestSample","send_to_merchant":true}'; } /** * Gets Object Instance with Json data filled in * @return Notification */ public static function getObject() { return new Notification(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return Notification */ public function testSerializationDeserialization() { $obj = new Notification(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getSubject()); $this->assertNotNull($obj->getNote()); $this->assertNotNull($obj->getSendToMerchant()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param Notification $obj */ public function testGetters($obj) { $this->assertEquals($obj->getSubject(), "TestSample"); $this->assertEquals($obj->getNote(), "TestSample"); $this->assertEquals($obj->getSendToMerchant(), true); } } rest-api-sdk-php/tests/PayPal/Test/Api/TermsTest.php 0000644 00000003547 15007532371 0016273 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\Terms; /** * Class Terms * * @package PayPal\Test\Api */ class TermsTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object Terms * @return string */ public static function getJson() { return '{"id":"TestSample","type":"TestSample","max_billing_amount":' .CurrencyTest::getJson() . ',"occurrences":"TestSample","amount_range":' .CurrencyTest::getJson() . ',"buyer_editable":"TestSample"}'; } /** * Gets Object Instance with Json data filled in * @return Terms */ public static function getObject() { return new Terms(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return Terms */ public function testSerializationDeserialization() { $obj = new Terms(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getId()); $this->assertNotNull($obj->getType()); $this->assertNotNull($obj->getMaxBillingAmount()); $this->assertNotNull($obj->getOccurrences()); $this->assertNotNull($obj->getAmountRange()); $this->assertNotNull($obj->getBuyerEditable()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param Terms $obj */ public function testGetters($obj) { $this->assertEquals($obj->getId(), "TestSample"); $this->assertEquals($obj->getType(), "TestSample"); $this->assertEquals($obj->getMaxBillingAmount(), CurrencyTest::getObject()); $this->assertEquals($obj->getOccurrences(), "TestSample"); $this->assertEquals($obj->getAmountRange(), CurrencyTest::getObject()); $this->assertEquals($obj->getBuyerEditable(), "TestSample"); } } rest-api-sdk-php/tests/PayPal/Test/Api/RefundTest.php 0000644 00000006613 15007532371 0016421 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\Refund; /** * Class Refund * * @package PayPal\Test\Api */ class RefundTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object Refund * * @return string */ public static function getJson() { return '{"id":"TestSample","amount":' . AmountTest::getJson() . ',"state":"TestSample","reason":"TestSample","sale_id":"TestSample","capture_id":"TestSample","parent_payment":"TestSample","description":"TestSample","create_time":"TestSample","update_time":"TestSample","links":' . LinksTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * * @return Refund */ public static function getObject() { return new Refund(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * * @return Refund */ public function testSerializationDeserialization() { $obj = new Refund(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getId()); $this->assertNotNull($obj->getAmount()); $this->assertNotNull($obj->getState()); $this->assertNotNull($obj->getReason()); $this->assertNotNull($obj->getSaleId()); $this->assertNotNull($obj->getCaptureId()); $this->assertNotNull($obj->getParentPayment()); $this->assertNotNull($obj->getDescription()); $this->assertNotNull($obj->getCreateTime()); $this->assertNotNull($obj->getUpdateTime()); $this->assertNotNull($obj->getLinks()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param Refund $obj */ public function testGetters($obj) { $this->assertEquals($obj->getId(), "TestSample"); $this->assertEquals($obj->getAmount(), AmountTest::getObject()); $this->assertEquals($obj->getState(), "TestSample"); $this->assertEquals($obj->getReason(), "TestSample"); $this->assertEquals($obj->getSaleId(), "TestSample"); $this->assertEquals($obj->getCaptureId(), "TestSample"); $this->assertEquals($obj->getParentPayment(), "TestSample"); $this->assertEquals($obj->getDescription(), "TestSample"); $this->assertEquals($obj->getCreateTime(), "TestSample"); $this->assertEquals($obj->getUpdateTime(), "TestSample"); $this->assertEquals($obj->getLinks(), LinksTest::getObject()); } /** * @dataProvider mockProvider * @param Refund $obj */ public function testGet($obj, $mockApiContext) { $mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPPRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( RefundTest::getJson() )); $result = $obj->get("refundId", $mockApiContext, $mockPPRestCall); $this->assertNotNull($result); } public function mockProvider() { $obj = self::getObject(); $mockApiContext = $this->getMockBuilder('ApiContext') ->disableOriginalConstructor() ->getMock(); return array( array($obj, $mockApiContext), array($obj, null) ); } } rest-api-sdk-php/tests/PayPal/Test/Api/PaymentInstructionTest.php 0000644 00000006265 15007532371 0021060 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\PaymentInstruction; use PayPal\Transport\PPRestCall; /** * Class PaymentInstruction * * @package PayPal\Test\Api */ class PaymentInstructionTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object PaymentInstruction * @return string */ public static function getJson() { return '{"reference_number":"TestSample","instruction_type":"TestSample","recipient_banking_instruction":' .RecipientBankingInstructionTest::getJson() . ',"amount":' .CurrencyTest::getJson() . ',"payment_due_date":"TestSample","note":"TestSample","links":' .LinksTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * @return PaymentInstruction */ public static function getObject() { return new PaymentInstruction(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return PaymentInstruction */ public function testSerializationDeserialization() { $obj = new PaymentInstruction(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getReferenceNumber()); $this->assertNotNull($obj->getInstructionType()); $this->assertNotNull($obj->getRecipientBankingInstruction()); $this->assertNotNull($obj->getAmount()); $this->assertNotNull($obj->getPaymentDueDate()); $this->assertNotNull($obj->getNote()); $this->assertNotNull($obj->getLinks()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param PaymentInstruction $obj */ public function testGetters($obj) { $this->assertEquals($obj->getReferenceNumber(), "TestSample"); $this->assertEquals($obj->getInstructionType(), "TestSample"); $this->assertEquals($obj->getRecipientBankingInstruction(), RecipientBankingInstructionTest::getObject()); $this->assertEquals($obj->getAmount(), CurrencyTest::getObject()); $this->assertEquals($obj->getPaymentDueDate(), "TestSample"); $this->assertEquals($obj->getNote(), "TestSample"); $this->assertEquals($obj->getLinks(), LinksTest::getObject()); } /** * @dataProvider mockProvider * @param PaymentInstruction $obj */ public function testGet($obj, $mockApiContext) { $mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPPRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( PaymentInstructionTest::getJson() )); $result = $obj->get("paymentId", $mockApiContext, $mockPPRestCall); $this->assertNotNull($result); } public function mockProvider() { $obj = self::getObject(); $mockApiContext = $this->getMockBuilder('ApiContext') ->disableOriginalConstructor() ->getMock(); return array( array($obj, $mockApiContext), array($obj, null) ); } } rest-api-sdk-php/tests/PayPal/Test/Api/PrivateLabelCardTest.php 0000644 00000003341 15007532371 0020335 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\PrivateLabelCard; /** * Class PrivateLabelCard * * @package PayPal\Test\Api */ class PrivateLabelCardTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object PrivateLabelCard * @return string */ public static function getJson() { return '{"id":"TestSample","card_number":"TestSample","issuer_id":"TestSample","issuer_name":"TestSample","image_key":"TestSample"}'; } /** * Gets Object Instance with Json data filled in * @return PrivateLabelCard */ public static function getObject() { return new PrivateLabelCard(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return PrivateLabelCard */ public function testSerializationDeserialization() { $obj = new PrivateLabelCard(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getId()); $this->assertNotNull($obj->getCardNumber()); $this->assertNotNull($obj->getIssuerId()); $this->assertNotNull($obj->getIssuerName()); $this->assertNotNull($obj->getImageKey()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param PrivateLabelCard $obj */ public function testGetters($obj) { $this->assertEquals($obj->getId(), "TestSample"); $this->assertEquals($obj->getCardNumber(), "TestSample"); $this->assertEquals($obj->getIssuerId(), "TestSample"); $this->assertEquals($obj->getIssuerName(), "TestSample"); $this->assertEquals($obj->getImageKey(), "TestSample"); } } rest-api-sdk-php/tests/PayPal/Test/Api/FundingDetailTest.php 0000644 00000003243 15007532371 0017707 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\FundingDetail; /** * Class FundingDetail * * @package PayPal\Test\Api */ class FundingDetailTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object FundingDetail * * @return string */ public static function getJson() { return '{"clearing_time":"TestSample","payment_hold_date":"TestSample","payment_debit_date":"TestSample","processing_type":"TestSample"}'; } /** * Gets Object Instance with Json data filled in * * @return FundingDetail */ public static function getObject() { return new FundingDetail(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * * @return FundingDetail */ public function testSerializationDeserialization() { $obj = new FundingDetail(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getClearingTime()); $this->assertNotNull($obj->getPaymentHoldDate()); $this->assertNotNull($obj->getPaymentDebitDate()); $this->assertNotNull($obj->getProcessingType()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param FundingDetail $obj */ public function testGetters($obj) { $this->assertEquals($obj->getClearingTime(), "TestSample"); $this->assertEquals($obj->getPaymentHoldDate(), "TestSample"); $this->assertEquals($obj->getPaymentDebitDate(), "TestSample"); $this->assertEquals($obj->getProcessingType(), "TestSample"); } } rest-api-sdk-php/tests/PayPal/Test/Api/RecipientBankingInstructionTest.php 0000644 00000004211 15007532371 0022644 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\RecipientBankingInstruction; /** * Class RecipientBankingInstruction * * @package PayPal\Test\Api */ class RecipientBankingInstructionTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object RecipientBankingInstruction * * @return string */ public static function getJson() { return '{"bank_name":"TestSample","account_holder_name":"TestSample","account_number":"TestSample","routing_number":"TestSample","international_bank_account_number":"TestSample","bank_identifier_code":"TestSample"}'; } /** * Gets Object Instance with Json data filled in * * @return RecipientBankingInstruction */ public static function getObject() { return new RecipientBankingInstruction(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * * @return RecipientBankingInstruction */ public function testSerializationDeserialization() { $obj = new RecipientBankingInstruction(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getBankName()); $this->assertNotNull($obj->getAccountHolderName()); $this->assertNotNull($obj->getAccountNumber()); $this->assertNotNull($obj->getRoutingNumber()); $this->assertNotNull($obj->getInternationalBankAccountNumber()); $this->assertNotNull($obj->getBankIdentifierCode()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param RecipientBankingInstruction $obj */ public function testGetters($obj) { $this->assertEquals($obj->getBankName(), "TestSample"); $this->assertEquals($obj->getAccountHolderName(), "TestSample"); $this->assertEquals($obj->getAccountNumber(), "TestSample"); $this->assertEquals($obj->getRoutingNumber(), "TestSample"); $this->assertEquals($obj->getInternationalBankAccountNumber(), "TestSample"); $this->assertEquals($obj->getBankIdentifierCode(), "TestSample"); } } rest-api-sdk-php/tests/PayPal/Test/Api/SaleTest.php 0000644 00000013730 15007532371 0016060 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\Sale; /** * Class Sale * * @package PayPal\Test\Api */ class SaleTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object Sale * * @return string */ public static function getJson() { return '{"id":"TestSample","purchase_unit_reference_id":"TestSample","amount":' . AmountTest::getJson() . ',"payment_mode":"TestSample","state":"TestSample","reason_code":"TestSample","protection_eligibility":"TestSample","protection_eligibility_type":"TestSample","clearing_time":"TestSample","payment_hold_status":"TestSample","payment_hold_reasons":"TestSample","transaction_fee":' . CurrencyTest::getJson() . ',"receivable_amount":' . CurrencyTest::getJson() . ',"exchange_rate":"TestSample","fmf_details":' . FmfDetailsTest::getJson() . ',"receipt_id":"TestSample","parent_payment":"TestSample","processor_response":' . ProcessorResponseTest::getJson() . ',"billing_agreement_id":"TestSample","create_time":"TestSample","update_time":"TestSample","links":' . LinksTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * * @return Sale */ public static function getObject() { return new Sale(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * * @return Sale */ public function testSerializationDeserialization() { $obj = new Sale(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getId()); $this->assertNotNull($obj->getPurchaseUnitReferenceId()); $this->assertNotNull($obj->getAmount()); $this->assertNotNull($obj->getPaymentMode()); $this->assertNotNull($obj->getState()); $this->assertNotNull($obj->getReasonCode()); $this->assertNotNull($obj->getProtectionEligibility()); $this->assertNotNull($obj->getProtectionEligibilityType()); $this->assertNotNull($obj->getClearingTime()); $this->assertNotNull($obj->getPaymentHoldStatus()); $this->assertNotNull($obj->getPaymentHoldReasons()); $this->assertNotNull($obj->getTransactionFee()); $this->assertNotNull($obj->getReceivableAmount()); $this->assertNotNull($obj->getExchangeRate()); $this->assertNotNull($obj->getFmfDetails()); $this->assertNotNull($obj->getReceiptId()); $this->assertNotNull($obj->getParentPayment()); $this->assertNotNull($obj->getProcessorResponse()); $this->assertNotNull($obj->getBillingAgreementId()); $this->assertNotNull($obj->getCreateTime()); $this->assertNotNull($obj->getUpdateTime()); $this->assertNotNull($obj->getLinks()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param Sale $obj */ public function testGetters($obj) { $this->assertEquals($obj->getId(), "TestSample"); $this->assertEquals($obj->getPurchaseUnitReferenceId(), "TestSample"); $this->assertEquals($obj->getAmount(), AmountTest::getObject()); $this->assertEquals($obj->getPaymentMode(), "TestSample"); $this->assertEquals($obj->getState(), "TestSample"); $this->assertEquals($obj->getReasonCode(), "TestSample"); $this->assertEquals($obj->getProtectionEligibility(), "TestSample"); $this->assertEquals($obj->getProtectionEligibilityType(), "TestSample"); $this->assertEquals($obj->getClearingTime(), "TestSample"); $this->assertEquals($obj->getPaymentHoldStatus(), "TestSample"); $this->assertEquals($obj->getPaymentHoldReasons(), "TestSample"); $this->assertEquals($obj->getTransactionFee(), CurrencyTest::getObject()); $this->assertEquals($obj->getReceivableAmount(), CurrencyTest::getObject()); $this->assertEquals($obj->getExchangeRate(), "TestSample"); $this->assertEquals($obj->getFmfDetails(), FmfDetailsTest::getObject()); $this->assertEquals($obj->getReceiptId(), "TestSample"); $this->assertEquals($obj->getParentPayment(), "TestSample"); $this->assertEquals($obj->getProcessorResponse(), ProcessorResponseTest::getObject()); $this->assertEquals($obj->getBillingAgreementId(), "TestSample"); $this->assertEquals($obj->getCreateTime(), "TestSample"); $this->assertEquals($obj->getUpdateTime(), "TestSample"); $this->assertEquals($obj->getLinks(), LinksTest::getObject()); } /** * @dataProvider mockProvider * @param Sale $obj */ public function testGet($obj, $mockApiContext) { $mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPPRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( SaleTest::getJson() )); $result = $obj->get("saleId", $mockApiContext, $mockPPRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param Sale $obj */ public function testRefund($obj, $mockApiContext) { $mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPPRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( RefundTest::getJson() )); $refund = RefundTest::getObject(); $result = $obj->refund($refund, $mockApiContext, $mockPPRestCall); $this->assertNotNull($result); } public function mockProvider() { $obj = self::getObject(); $mockApiContext = $this->getMockBuilder('ApiContext') ->disableOriginalConstructor() ->getMock(); return array( array($obj, $mockApiContext), array($obj, null) ); } } rest-api-sdk-php/tests/PayPal/Test/Api/MetadataTest.php 0000644 00000005715 15007532371 0016720 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\Metadata; /** * Class Metadata * * @package PayPal\Test\Api */ class MetadataTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object Metadata * @return string */ public static function getJson() { return '{"created_date":"TestSample","created_by":"TestSample","cancelled_date":"TestSample","cancelled_by":"TestSample","last_updated_date":"TestSample","last_updated_by":"TestSample","first_sent_date":"TestSample","last_sent_date":"TestSample","last_sent_by":"TestSample","payer_view_url":"http://www.google.com"}'; } /** * Gets Object Instance with Json data filled in * @return Metadata */ public static function getObject() { return new Metadata(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return Metadata */ public function testSerializationDeserialization() { $obj = new Metadata(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getCreatedDate()); $this->assertNotNull($obj->getCreatedBy()); $this->assertNotNull($obj->getCancelledDate()); $this->assertNotNull($obj->getCancelledBy()); $this->assertNotNull($obj->getLastUpdatedDate()); $this->assertNotNull($obj->getLastUpdatedBy()); $this->assertNotNull($obj->getFirstSentDate()); $this->assertNotNull($obj->getLastSentDate()); $this->assertNotNull($obj->getLastSentBy()); $this->assertNotNull($obj->getPayerViewUrl()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param Metadata $obj */ public function testGetters($obj) { $this->assertEquals($obj->getCreatedDate(), "TestSample"); $this->assertEquals($obj->getCreatedBy(), "TestSample"); $this->assertEquals($obj->getCancelledDate(), "TestSample"); $this->assertEquals($obj->getCancelledBy(), "TestSample"); $this->assertEquals($obj->getLastUpdatedDate(), "TestSample"); $this->assertEquals($obj->getLastUpdatedBy(), "TestSample"); $this->assertEquals($obj->getFirstSentDate(), "TestSample"); $this->assertEquals($obj->getLastSentDate(), "TestSample"); $this->assertEquals($obj->getLastSentBy(), "TestSample"); $this->assertEquals($obj->getPayerViewUrl(), "http://www.google.com"); } /** * @expectedException \InvalidArgumentException * @expectedExceptionMessage PayerViewUrl is not a fully qualified URL */ public function testUrlValidationForPayerViewUrl() { $obj = new Metadata(); $obj->setPayerViewUrl(null); } public function testUrlValidationForPayerViewUrlDeprecated() { $obj = new Metadata(); $obj->setPayer_view_url(null); $this->assertNull($obj->getPayer_view_url()); } } rest-api-sdk-php/tests/PayPal/Test/Api/ExternalFundingTest.php 0000644 00000003421 15007532371 0020265 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\ExternalFunding; /** * Class ExternalFunding * * @package PayPal\Test\Api */ class ExternalFundingTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object ExternalFunding * @return string */ public static function getJson() { return '{"reference_id":"TestSample","code":"TestSample","funding_account_id":"TestSample","display_text":"TestSample","amount":' .AmountTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * @return ExternalFunding */ public static function getObject() { return new ExternalFunding(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return ExternalFunding */ public function testSerializationDeserialization() { $obj = new ExternalFunding(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getReferenceId()); $this->assertNotNull($obj->getCode()); $this->assertNotNull($obj->getFundingAccountId()); $this->assertNotNull($obj->getDisplayText()); $this->assertNotNull($obj->getAmount()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param ExternalFunding $obj */ public function testGetters($obj) { $this->assertEquals($obj->getReferenceId(), "TestSample"); $this->assertEquals($obj->getCode(), "TestSample"); $this->assertEquals($obj->getFundingAccountId(), "TestSample"); $this->assertEquals($obj->getDisplayText(), "TestSample"); $this->assertEquals($obj->getAmount(), AmountTest::getObject()); } } rest-api-sdk-php/tests/PayPal/Test/Api/PhoneTest.php 0000644 00000002637 15007532371 0016251 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\Phone; /** * Class Phone * * @package PayPal\Test\Api */ class PhoneTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object Phone * * @return string */ public static function getJson() { return '{"country_code":"TestSample","national_number":"TestSample","extension":"TestSample"}'; } /** * Gets Object Instance with Json data filled in * * @return Phone */ public static function getObject() { return new Phone(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * * @return Phone */ public function testSerializationDeserialization() { $obj = new Phone(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getCountryCode()); $this->assertNotNull($obj->getNationalNumber()); $this->assertNotNull($obj->getExtension()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param Phone $obj */ public function testGetters($obj) { $this->assertEquals($obj->getCountryCode(), "TestSample"); $this->assertEquals($obj->getNationalNumber(), "TestSample"); $this->assertEquals($obj->getExtension(), "TestSample"); } } rest-api-sdk-php/tests/PayPal/Test/Api/WebhookEventListTest.php 0000644 00000002742 15007532371 0020431 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\WebhookEventList; /** * Class WebhookEventList * * @package PayPal\Test\Api */ class WebhookEventListTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object WebhookEventList * @return string */ public static function getJson() { return '{"events":' .WebhookEventTest::getJson() . ',"count":123,"links":' .LinksTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * @return WebhookEventList */ public static function getObject() { return new WebhookEventList(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return WebhookEventList */ public function testSerializationDeserialization() { $obj = new WebhookEventList(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getEvents()); $this->assertNotNull($obj->getCount()); $this->assertNotNull($obj->getLinks()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param WebhookEventList $obj */ public function testGetters($obj) { $this->assertEquals($obj->getEvents(), WebhookEventTest::getObject()); $this->assertEquals($obj->getCount(), 123); $this->assertEquals($obj->getLinks(), LinksTest::getObject()); } } rest-api-sdk-php/tests/PayPal/Test/Api/InvoiceItemTest.php 0000644 00000003762 15007532371 0017413 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\InvoiceItem; /** * Class InvoiceItem * * @package PayPal\Test\Api */ class InvoiceItemTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object InvoiceItem * @return string */ public static function getJson() { return '{"name":"TestSample","description":"TestSample","quantity":"12.34","unit_price":' .CurrencyTest::getJson() . ',"tax":' .TaxTest::getJson() . ',"date":"TestSample","discount":' .CostTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * @return InvoiceItem */ public static function getObject() { return new InvoiceItem(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return InvoiceItem */ public function testSerializationDeserialization() { $obj = new InvoiceItem(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getName()); $this->assertNotNull($obj->getDescription()); $this->assertNotNull($obj->getQuantity()); $this->assertNotNull($obj->getUnitPrice()); $this->assertNotNull($obj->getTax()); $this->assertNotNull($obj->getDate()); $this->assertNotNull($obj->getDiscount()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param InvoiceItem $obj */ public function testGetters($obj) { $this->assertEquals($obj->getName(), "TestSample"); $this->assertEquals($obj->getDescription(), "TestSample"); $this->assertEquals($obj->getQuantity(), "12.34"); $this->assertEquals($obj->getUnitPrice(), CurrencyTest::getObject()); $this->assertEquals($obj->getTax(), TaxTest::getObject()); $this->assertEquals($obj->getDate(), "TestSample"); $this->assertEquals($obj->getDiscount(), CostTest::getObject()); } } rest-api-sdk-php/tests/PayPal/Test/Api/PayeeTest.php 0000644 00000003504 15007532371 0016235 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\Payee; /** * Class Payee * * @package PayPal\Test\Api */ class PayeeTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object Payee * * @return string */ public static function getJson() { return '{"email":"TestSample","merchant_id":"TestSample","first_name":"TestSample","last_name":"TestSample","account_number":"TestSample","phone":' . PhoneTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * * @return Payee */ public static function getObject() { return new Payee(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * * @return Payee */ public function testSerializationDeserialization() { $obj = new Payee(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getEmail()); $this->assertNotNull($obj->getMerchantId()); $this->assertNotNull($obj->getFirstName()); $this->assertNotNull($obj->getLastName()); $this->assertNotNull($obj->getAccountNumber()); $this->assertNotNull($obj->getPhone()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param Payee $obj */ public function testGetters($obj) { $this->assertEquals($obj->getEmail(), "TestSample"); $this->assertEquals($obj->getMerchantId(), "TestSample"); $this->assertEquals($obj->getFirstName(), "TestSample"); $this->assertEquals($obj->getLastName(), "TestSample"); $this->assertEquals($obj->getAccountNumber(), "TestSample"); $this->assertEquals($obj->getPhone(), PhoneTest::getObject()); } } rest-api-sdk-php/tests/PayPal/Test/Api/PaymentExecutionTest.php 0000644 00000003065 15007532371 0020475 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\PaymentExecution; /** * Class PaymentExecution * * @package PayPal\Test\Api */ class PaymentExecutionTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object PaymentExecution * * @return string */ public static function getJson() { return '{"payer_id":"TestSample","carrier_account_id":"TestSample","transactions":[' . TransactionTest::getJson() . ']}'; } /** * Gets Object Instance with Json data filled in * * @return PaymentExecution */ public static function getObject() { return new PaymentExecution(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * * @return PaymentExecution */ public function testSerializationDeserialization() { $obj = new PaymentExecution(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getPayerId()); $this->assertNotNull($obj->getCarrierAccountId()); $this->assertNotNull($obj->getTransactions()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param PaymentExecution $obj */ public function testGetters($obj) { $this->assertEquals($obj->getPayerId(), "TestSample"); $this->assertEquals($obj->getCarrierAccountId(), "TestSample"); $this->assertEquals($obj->getTransactions(), array(TransactionTest::getObject())); } } rest-api-sdk-php/tests/PayPal/Test/Api/PaymentTest.php 0000644 00000016675 15007532371 0016624 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\object; use PayPal\Api\Payment; /** * Class Payment * * @package PayPal\Test\Api */ class PaymentTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object Payment * * @return string */ public static function getJson() { return '{"id":"TestSample","intent":"TestSample","payer":' . PayerTest::getJson() . ',"potential_payer_info":' . PotentialPayerInfoTest::getJson() . ',"payee":' . PayeeTest::getJson() . ',"cart":"TestSample","transactions":[' . TransactionTest::getJson() . '],"failed_transactions":' . ErrorTest::getJson() . ',"billing_agreement_tokens":["TestSample"],"credit_financing_offered":' . CreditFinancingOfferedTest::getJson() . ',"payment_instruction":' . PaymentInstructionTest::getJson() . ',"state":"TestSample","experience_profile_id":"TestSample","note_to_payer":"TestSample","redirect_urls":' . RedirectUrlsTest::getJson() . ',"failure_reason":"TestSample","create_time":"TestSample","update_time":"TestSample","links":' . LinksTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * * @return Payment */ public static function getObject() { return new Payment(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * * @return Payment */ public function testSerializationDeserialization() { $obj = new Payment(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getId()); $this->assertNotNull($obj->getIntent()); $this->assertNotNull($obj->getPayer()); $this->assertNotNull($obj->getPotentialPayerInfo()); $this->assertNotNull($obj->getPayee()); $this->assertNotNull($obj->getCart()); $this->assertNotNull($obj->getTransactions()); $this->assertNotNull($obj->getFailedTransactions()); $this->assertNotNull($obj->getBillingAgreementTokens()); $this->assertNotNull($obj->getCreditFinancingOffered()); $this->assertNotNull($obj->getPaymentInstruction()); $this->assertNotNull($obj->getState()); $this->assertNotNull($obj->getExperienceProfileId()); $this->assertNotNull($obj->getNoteToPayer()); $this->assertNotNull($obj->getRedirectUrls()); $this->assertNotNull($obj->getFailureReason()); $this->assertNotNull($obj->getCreateTime()); $this->assertNotNull($obj->getUpdateTime()); $this->assertNotNull($obj->getLinks()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param Payment $obj */ public function testGetters($obj) { $this->assertEquals($obj->getId(), "TestSample"); $this->assertEquals($obj->getIntent(), "TestSample"); $this->assertEquals($obj->getPayer(), PayerTest::getObject()); $this->assertEquals($obj->getPotentialPayerInfo(), PotentialPayerInfoTest::getObject()); $this->assertEquals($obj->getPayee(), PayeeTest::getObject()); $this->assertEquals($obj->getCart(), "TestSample"); $this->assertEquals($obj->getTransactions(), array(TransactionTest::getObject())); $this->assertEquals($obj->getFailedTransactions(), ErrorTest::getObject()); $this->assertEquals($obj->getBillingAgreementTokens(), array("TestSample")); $this->assertEquals($obj->getCreditFinancingOffered(), CreditFinancingOfferedTest::getObject()); $this->assertEquals($obj->getPaymentInstruction(), PaymentInstructionTest::getObject()); $this->assertEquals($obj->getState(), "TestSample"); $this->assertEquals($obj->getExperienceProfileId(), "TestSample"); $this->assertEquals($obj->getNoteToPayer(), "TestSample"); $this->assertEquals($obj->getRedirectUrls(), RedirectUrlsTest::getObject()); $this->assertEquals($obj->getFailureReason(), "TestSample"); $this->assertEquals($obj->getCreateTime(), "TestSample"); $this->assertEquals($obj->getUpdateTime(), "TestSample"); $this->assertEquals($obj->getLinks(), LinksTest::getObject()); } /** * @dataProvider mockProvider * @param Payment $obj */ public function testCreate($obj, $mockApiContext) { $mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPPRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( self::getJson() )); $result = $obj->create($mockApiContext, $mockPPRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param Payment $obj */ public function testGet($obj, $mockApiContext) { $mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPPRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( PaymentTest::getJson() )); $result = $obj->get("paymentId", $mockApiContext, $mockPPRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param Payment $obj */ public function testUpdate($obj, $mockApiContext) { $mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPPRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( true )); $patchRequest = PatchRequestTest::getObject(); $result = $obj->update($patchRequest, $mockApiContext, $mockPPRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param Payment $obj */ public function testExecute($obj, $mockApiContext) { $mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPPRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( self::getJson() )); $paymentExecution = PaymentExecutionTest::getObject(); $result = $obj->execute($paymentExecution, $mockApiContext, $mockPPRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param Payment $obj */ public function testList($obj, $mockApiContext) { $mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPPRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( PaymentHistoryTest::getJson() )); $params = array(); $result = $obj->all($params, $mockApiContext, $mockPPRestCall); $this->assertNotNull($result); } public function mockProvider() { $obj = self::getObject(); $mockApiContext = $this->getMockBuilder('ApiContext') ->disableOriginalConstructor() ->getMock(); return array( array($obj, $mockApiContext), array($obj, null) ); } } rest-api-sdk-php/tests/PayPal/Test/Api/CaptureTest.php 0000644 00000007512 15007532371 0016600 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\Capture; use PayPal\Transport\PPRestCall; /** * Class Capture * * @package PayPal\Test\Api */ class CaptureTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object Capture * * @return string */ public static function getJson() { return '{"id":"TestSample","amount":' . AmountTest::getJson() . ',"is_final_capture":true,"state":"TestSample","parent_payment":"TestSample","transaction_fee":' . CurrencyTest::getJson() . ',"create_time":"TestSample","update_time":"TestSample","links":' . LinksTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * * @return Capture */ public static function getObject() { return new Capture(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * * @return Capture */ public function testSerializationDeserialization() { $obj = new Capture(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getId()); $this->assertNotNull($obj->getAmount()); $this->assertNotNull($obj->getIsFinalCapture()); $this->assertNotNull($obj->getState()); $this->assertNotNull($obj->getParentPayment()); $this->assertNotNull($obj->getTransactionFee()); $this->assertNotNull($obj->getCreateTime()); $this->assertNotNull($obj->getUpdateTime()); $this->assertNotNull($obj->getLinks()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param Capture $obj */ public function testGetters($obj) { $this->assertEquals($obj->getId(), "TestSample"); $this->assertEquals($obj->getAmount(), AmountTest::getObject()); $this->assertEquals($obj->getIsFinalCapture(), true); $this->assertEquals($obj->getState(), "TestSample"); $this->assertEquals($obj->getParentPayment(), "TestSample"); $this->assertEquals($obj->getTransactionFee(), CurrencyTest::getObject()); $this->assertEquals($obj->getCreateTime(), "TestSample"); $this->assertEquals($obj->getUpdateTime(), "TestSample"); $this->assertEquals($obj->getLinks(), LinksTest::getObject()); } /** * @dataProvider mockProvider * @param Capture $obj */ public function testGet($obj, $mockApiContext) { $mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPPRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( CaptureTest::getJson() )); $result = $obj->get("captureId", $mockApiContext, $mockPPRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param Capture $obj */ public function testRefund($obj, $mockApiContext) { $mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPPRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( RefundTest::getJson() )); $refund = RefundTest::getObject(); $result = $obj->refund($refund, $mockApiContext, $mockPPRestCall); $this->assertNotNull($result); } public function mockProvider() { $obj = self::getObject(); $mockApiContext = $this->getMockBuilder('ApiContext') ->disableOriginalConstructor() ->getMock(); return array( array($obj, $mockApiContext), array($obj, null) ); } } rest-api-sdk-php/tests/PayPal/Test/Api/ProcessorResponseTest.php 0000644 00000003610 15007532371 0020666 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\ProcessorResponse; /** * Class ProcessorResponse * * @package PayPal\Test\Api */ class ProcessorResponseTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object ProcessorResponse * @return string */ public static function getJson() { return '{"response_code":"TestSample","avs_code":"TestSample","cvv_code":"TestSample","advice_code":"TestSample","eci_submitted":"TestSample","vpas":"TestSample"}'; } /** * Gets Object Instance with Json data filled in * @return ProcessorResponse */ public static function getObject() { return new ProcessorResponse(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return ProcessorResponse */ public function testSerializationDeserialization() { $obj = new ProcessorResponse(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getResponseCode()); $this->assertNotNull($obj->getAvsCode()); $this->assertNotNull($obj->getCvvCode()); $this->assertNotNull($obj->getAdviceCode()); $this->assertNotNull($obj->getEciSubmitted()); $this->assertNotNull($obj->getVpas()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param ProcessorResponse $obj */ public function testGetters($obj) { $this->assertEquals($obj->getResponseCode(), "TestSample"); $this->assertEquals($obj->getAvsCode(), "TestSample"); $this->assertEquals($obj->getCvvCode(), "TestSample"); $this->assertEquals($obj->getAdviceCode(), "TestSample"); $this->assertEquals($obj->getEciSubmitted(), "TestSample"); $this->assertEquals($obj->getVpas(), "TestSample"); } } rest-api-sdk-php/tests/PayPal/Test/Api/CancelNotificationTest.php 0000644 00000003131 15007532371 0020722 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\CancelNotification; /** * Class CancelNotification * * @package PayPal\Test\Api */ class CancelNotificationTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object CancelNotification * @return string */ public static function getJson() { return '{"subject":"TestSample","note":"TestSample","send_to_merchant":true,"send_to_payer":true}'; } /** * Gets Object Instance with Json data filled in * @return CancelNotification */ public static function getObject() { return new CancelNotification(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return CancelNotification */ public function testSerializationDeserialization() { $obj = new CancelNotification(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getSubject()); $this->assertNotNull($obj->getNote()); $this->assertNotNull($obj->getSendToMerchant()); $this->assertNotNull($obj->getSendToPayer()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param CancelNotification $obj */ public function testGetters($obj) { $this->assertEquals($obj->getSubject(), "TestSample"); $this->assertEquals($obj->getNote(), "TestSample"); $this->assertEquals($obj->getSendToMerchant(), true); $this->assertEquals($obj->getSendToPayer(), true); } } rest-api-sdk-php/tests/PayPal/Test/Api/BankAccountsListTest.php 0000644 00000002736 15007532371 0020407 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\BankAccountsList; /** * Class BankAccountsList * * @package PayPal\Test\Api */ class BankAccountsListTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object BankAccountsList * @return string */ public static function getJson() { return '{"bank-accounts":' .BankAccountTest::getJson() . ',"count":123,"next_id":"TestSample"}'; } /** * Gets Object Instance with Json data filled in * @return BankAccountsList */ public static function getObject() { return new BankAccountsList(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return BankAccountsList */ public function testSerializationDeserialization() { $obj = new BankAccountsList(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getBankAccounts()); $this->assertNotNull($obj->getCount()); $this->assertNotNull($obj->getNextId()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param BankAccountsList $obj */ public function testGetters($obj) { $this->assertEquals($obj->getBankAccounts(), BankAccountTest::getObject()); $this->assertEquals($obj->getCount(), 123); $this->assertEquals($obj->getNextId(), "TestSample"); } } rest-api-sdk-php/tests/PayPal/Test/Api/RefundDetailTest.php 0000644 00000002604 15007532371 0017540 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\RefundDetail; /** * Class RefundDetail * * @package PayPal\Test\Api */ class RefundDetailTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object RefundDetail * @return string */ public static function getJson() { return '{"type":"TestSample","date":"TestSample","note":"TestSample"}'; } /** * Gets Object Instance with Json data filled in * @return RefundDetail */ public static function getObject() { return new RefundDetail(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return RefundDetail */ public function testSerializationDeserialization() { $obj = new RefundDetail(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getType()); $this->assertNotNull($obj->getDate()); $this->assertNotNull($obj->getNote()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param RefundDetail $obj */ public function testGetters($obj) { $this->assertEquals($obj->getType(), "TestSample"); $this->assertEquals($obj->getDate(), "TestSample"); $this->assertEquals($obj->getNote(), "TestSample"); } } rest-api-sdk-php/tests/PayPal/Test/Api/BankAccountTest.php 0000644 00000011054 15007532371 0017361 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\BankAccount; /** * Class BankAccount * * @package PayPal\Test\Api */ class BankAccountTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object BankAccount * * @return string */ public static function getJson() { return '{"id":"TestSample","account_number":"TestSample","account_number_type":"TestSample","routing_number":"TestSample","account_type":"TestSample","account_name":"TestSample","check_type":"TestSample","auth_type":"TestSample","auth_capture_timestamp":"TestSample","bank_name":"TestSample","country_code":"TestSample","first_name":"TestSample","last_name":"TestSample","birth_date":"TestSample","billing_address":' . AddressTest::getJson() . ',"state":"TestSample","confirmation_status":"TestSample","payer_id":"TestSample","external_customer_id":"TestSample","merchant_id":"TestSample","create_time":"TestSample","update_time":"TestSample","valid_until":"TestSample","links":' . LinksTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * * @return BankAccount */ public static function getObject() { return new BankAccount(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * * @return BankAccount */ public function testSerializationDeserialization() { $obj = new BankAccount(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getId()); $this->assertNotNull($obj->getAccountNumber()); $this->assertNotNull($obj->getAccountNumberType()); $this->assertNotNull($obj->getRoutingNumber()); $this->assertNotNull($obj->getAccountType()); $this->assertNotNull($obj->getAccountName()); $this->assertNotNull($obj->getCheckType()); $this->assertNotNull($obj->getAuthType()); $this->assertNotNull($obj->getAuthCaptureTimestamp()); $this->assertNotNull($obj->getBankName()); $this->assertNotNull($obj->getCountryCode()); $this->assertNotNull($obj->getFirstName()); $this->assertNotNull($obj->getLastName()); $this->assertNotNull($obj->getBirthDate()); $this->assertNotNull($obj->getBillingAddress()); $this->assertNotNull($obj->getState()); $this->assertNotNull($obj->getConfirmationStatus()); $this->assertNotNull($obj->getPayerId()); $this->assertNotNull($obj->getExternalCustomerId()); $this->assertNotNull($obj->getMerchantId()); $this->assertNotNull($obj->getCreateTime()); $this->assertNotNull($obj->getUpdateTime()); $this->assertNotNull($obj->getValidUntil()); $this->assertNotNull($obj->getLinks()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param BankAccount $obj */ public function testGetters($obj) { $this->assertEquals($obj->getId(), "TestSample"); $this->assertEquals($obj->getAccountNumber(), "TestSample"); $this->assertEquals($obj->getAccountNumberType(), "TestSample"); $this->assertEquals($obj->getRoutingNumber(), "TestSample"); $this->assertEquals($obj->getAccountType(), "TestSample"); $this->assertEquals($obj->getAccountName(), "TestSample"); $this->assertEquals($obj->getCheckType(), "TestSample"); $this->assertEquals($obj->getAuthType(), "TestSample"); $this->assertEquals($obj->getAuthCaptureTimestamp(), "TestSample"); $this->assertEquals($obj->getBankName(), "TestSample"); $this->assertEquals($obj->getCountryCode(), "TestSample"); $this->assertEquals($obj->getFirstName(), "TestSample"); $this->assertEquals($obj->getLastName(), "TestSample"); $this->assertEquals($obj->getBirthDate(), "TestSample"); $this->assertEquals($obj->getBillingAddress(), AddressTest::getObject()); $this->assertEquals($obj->getState(), "TestSample"); $this->assertEquals($obj->getConfirmationStatus(), "TestSample"); $this->assertEquals($obj->getPayerId(), "TestSample"); $this->assertEquals($obj->getExternalCustomerId(), "TestSample"); $this->assertEquals($obj->getMerchantId(), "TestSample"); $this->assertEquals($obj->getCreateTime(), "TestSample"); $this->assertEquals($obj->getUpdateTime(), "TestSample"); $this->assertEquals($obj->getValidUntil(), "TestSample"); $this->assertEquals($obj->getLinks(), LinksTest::getObject()); } } rest-api-sdk-php/tests/PayPal/Test/Api/CostTest.php 0000644 00000002345 15007532371 0016104 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\Cost; /** * Class Cost * * @package PayPal\Test\Api */ class CostTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object Cost * @return string */ public static function getJson() { return '{"percent":"12.34","amount":' .CurrencyTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * @return Cost */ public static function getObject() { return new Cost(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return Cost */ public function testSerializationDeserialization() { $obj = new Cost(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getPercent()); $this->assertNotNull($obj->getAmount()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param Cost $obj */ public function testGetters($obj) { $this->assertEquals($obj->getPercent(), "12.34"); $this->assertEquals($obj->getAmount(), CurrencyTest::getObject()); } } rest-api-sdk-php/tests/PayPal/Test/Api/FlowConfigTest.php 0000644 00000003176 15007532371 0017234 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\FlowConfig; /** * Class FlowConfig * * @package PayPal\Test\Api */ class FlowConfigTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object FlowConfig * @return string */ public static function getJson() { return '{"landing_page_type":"TestSample","bank_txn_pending_url":"http://www.google.com"}'; } /** * Gets Object Instance with Json data filled in * @return FlowConfig */ public static function getObject() { return new FlowConfig(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return FlowConfig */ public function testSerializationDeserialization() { $obj = new FlowConfig(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getLandingPageType()); $this->assertNotNull($obj->getBankTxnPendingUrl()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param FlowConfig $obj */ public function testGetters($obj) { $this->assertEquals($obj->getLandingPageType(), "TestSample"); $this->assertEquals($obj->getBankTxnPendingUrl(), "http://www.google.com"); } /** * @expectedException \InvalidArgumentException * @expectedExceptionMessage BankTxnPendingUrl is not a fully qualified URL */ public function testUrlValidationForBankTxnPendingUrl() { $obj = new FlowConfig(); $obj->setBankTxnPendingUrl(null); } } rest-api-sdk-php/tests/PayPal/Test/Api/FundingSourceTest.php 0000644 00000004772 15007532371 0017755 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\FundingSource; /** * Class FundingSource * * @package PayPal\Test\Api */ class FundingSourceTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object FundingSource * * @return string */ public static function getJson() { return '{"funding_mode":"TestSample","funding_instrument_type":"TestSample","soft_descriptor":"TestSample","amount":' . CurrencyTest::getJson() . ',"legal_text":"TestSample","funding_detail":' . FundingDetailTest::getJson() . ',"additional_text":"TestSample","extends":' . FundingInstrumentTest::getJson() . ',"links":' . LinksTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * * @return FundingSource */ public static function getObject() { return new FundingSource(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * * @return FundingSource */ public function testSerializationDeserialization() { $obj = new FundingSource(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getFundingMode()); $this->assertNotNull($obj->getFundingInstrumentType()); $this->assertNotNull($obj->getSoftDescriptor()); $this->assertNotNull($obj->getAmount()); $this->assertNotNull($obj->getLegalText()); $this->assertNotNull($obj->getFundingDetail()); $this->assertNotNull($obj->getAdditionalText()); $this->assertNotNull($obj->getExtends()); $this->assertNotNull($obj->getLinks()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param FundingSource $obj */ public function testGetters($obj) { $this->assertEquals($obj->getFundingMode(), "TestSample"); $this->assertEquals($obj->getFundingInstrumentType(), "TestSample"); $this->assertEquals($obj->getSoftDescriptor(), "TestSample"); $this->assertEquals($obj->getAmount(), CurrencyTest::getObject()); $this->assertEquals($obj->getLegalText(), "TestSample"); $this->assertEquals($obj->getFundingDetail(), FundingDetailTest::getObject()); $this->assertEquals($obj->getAdditionalText(), "TestSample"); $this->assertEquals($obj->getExtends(), FundingInstrumentTest::getObject()); $this->assertEquals($obj->getLinks(), LinksTest::getObject()); } } rest-api-sdk-php/tests/PayPal/Test/Api/IncentiveTest.php 0000644 00000005072 15007532371 0017120 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\Incentive; /** * Class Incentive * * @package PayPal\Test\Api */ class IncentiveTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object Incentive * * @return string */ public static function getJson() { return '{"id":"TestSample","code":"TestSample","name":"TestSample","description":"TestSample","minimum_purchase_amount":' . CurrencyTest::getJson() . ',"logo_image_url":"http://www.google.com","expiry_date":"TestSample","type":"TestSample","terms":"TestSample"}'; } /** * Gets Object Instance with Json data filled in * * @return Incentive */ public static function getObject() { return new Incentive(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * * @return Incentive */ public function testSerializationDeserialization() { $obj = new Incentive(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getId()); $this->assertNotNull($obj->getCode()); $this->assertNotNull($obj->getName()); $this->assertNotNull($obj->getDescription()); $this->assertNotNull($obj->getMinimumPurchaseAmount()); $this->assertNotNull($obj->getLogoImageUrl()); $this->assertNotNull($obj->getExpiryDate()); $this->assertNotNull($obj->getType()); $this->assertNotNull($obj->getTerms()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param Incentive $obj */ public function testGetters($obj) { $this->assertEquals($obj->getId(), "TestSample"); $this->assertEquals($obj->getCode(), "TestSample"); $this->assertEquals($obj->getName(), "TestSample"); $this->assertEquals($obj->getDescription(), "TestSample"); $this->assertEquals($obj->getMinimumPurchaseAmount(), CurrencyTest::getObject()); $this->assertEquals($obj->getLogoImageUrl(), "http://www.google.com"); $this->assertEquals($obj->getExpiryDate(), "TestSample"); $this->assertEquals($obj->getType(), "TestSample"); $this->assertEquals($obj->getTerms(), "TestSample"); } /** * @expectedException \InvalidArgumentException * @expectedExceptionMessage LogoImageUrl is not a fully qualified URL */ public function testUrlValidationForLogoImageUrl() { $obj = new Incentive(); $obj->setLogoImageUrl(null); } } rest-api-sdk-php/tests/PayPal/Test/Api/OpenIdUserinfoTest.php 0000644 00000003330 15007532371 0020060 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\OpenIdUserinfo; /** * Test class for OpenIdUserinfo. * */ class OpenIdUserinfoTest extends \PHPUnit_Framework_TestCase { /** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { } /** * Tears down the fixture, for example, closes a network connection. * This method is called after a test is executed. */ protected function tearDown() { } /** * @test */ public function testSerializationDeserialization() { $user = new OpenIdUserinfo(); $user->setAccountType("PERSONAL")->setAgeRange("20-30")->setBirthday("1970-01-01") ->setEmail("me@email.com")->setEmailVerified(true) ->setFamilyName("Doe")->setMiddleName("A")->setGivenName("John") ->setLocale("en-US")->setGender("male")->setName("John A Doe") ->setPayerId("A-XZASASA")->setPhoneNumber("1-408-111-1111") ->setPicture("http://gravatar.com/me.jpg") ->setSub("me@email.com")->setUserId("userId") ->setVerified(true)->setVerifiedAccount(true) ->setZoneinfo("America/PST")->setLanguage('en_US') ->setAddress(OpenIdAddressTest::getTestData()); $userCopy = new OpenIdUserinfo(); $userCopy->fromJson($user->toJSON()); $this->assertEquals($user, $userCopy); } /** * @test */ public function testInvalidParamUserInfoCall() { $this->setExpectedException('PayPal\Exception\PayPalConnectionException'); OpenIdUserinfo::getUserinfo(array('access_token' => 'accessToken')); } } rest-api-sdk-php/tests/PayPal/Test/Api/RelatedResourcesTest.php 0000644 00000003577 15007532371 0020457 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\RelatedResources; /** * Class RelatedResources * * @package PayPal\Test\Api */ class RelatedResourcesTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object RelatedResources * * @return string */ public static function getJson() { return '{"sale":' . SaleTest::getJson() . ',"authorization":' . AuthorizationTest::getJson() . ',"order":' . OrderTest::getJson() . ',"capture":' . CaptureTest::getJson() . ',"refund":' . RefundTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * * @return RelatedResources */ public static function getObject() { return new RelatedResources(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * * @return RelatedResources */ public function testSerializationDeserialization() { $obj = new RelatedResources(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getSale()); $this->assertNotNull($obj->getAuthorization()); $this->assertNotNull($obj->getOrder()); $this->assertNotNull($obj->getCapture()); $this->assertNotNull($obj->getRefund()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param RelatedResources $obj */ public function testGetters($obj) { $this->assertEquals($obj->getSale(), SaleTest::getObject()); $this->assertEquals($obj->getAuthorization(), AuthorizationTest::getObject()); $this->assertEquals($obj->getOrder(), OrderTest::getObject()); $this->assertEquals($obj->getCapture(), CaptureTest::getObject()); $this->assertEquals($obj->getRefund(), RefundTest::getObject()); } } rest-api-sdk-php/tests/PayPal/Test/Api/PayoutBatchHeaderTest.php 0000644 00000004765 15007532371 0020540 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\PayoutBatchHeader; /** * Class PayoutBatchHeader * * @package PayPal\Test\Api */ class PayoutBatchHeaderTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object PayoutBatchHeader * @return string */ public static function getJson() { return '{"payout_batch_id":"TestSample","batch_status":"TestSample","time_created":"TestSample","time_completed":"TestSample","sender_batch_header":' .PayoutSenderBatchHeaderTest::getJson() . ',"amount":' .CurrencyTest::getJson() . ',"fees":' .CurrencyTest::getJson() . ',"errors":' .ErrorTest::getJson() . ',"links":' .LinksTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * @return PayoutBatchHeader */ public static function getObject() { return new PayoutBatchHeader(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return PayoutBatchHeader */ public function testSerializationDeserialization() { $obj = new PayoutBatchHeader(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getPayoutBatchId()); $this->assertNotNull($obj->getBatchStatus()); $this->assertNotNull($obj->getTimeCreated()); $this->assertNotNull($obj->getTimeCompleted()); $this->assertNotNull($obj->getSenderBatchHeader()); $this->assertNotNull($obj->getAmount()); $this->assertNotNull($obj->getFees()); $this->assertNotNull($obj->getErrors()); $this->assertNotNull($obj->getLinks()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param PayoutBatchHeader $obj */ public function testGetters($obj) { $this->assertEquals($obj->getPayoutBatchId(), "TestSample"); $this->assertEquals($obj->getBatchStatus(), "TestSample"); $this->assertEquals($obj->getTimeCreated(), "TestSample"); $this->assertEquals($obj->getTimeCompleted(), "TestSample"); $this->assertEquals($obj->getSenderBatchHeader(), PayoutSenderBatchHeaderTest::getObject()); $this->assertEquals($obj->getAmount(), CurrencyTest::getObject()); $this->assertEquals($obj->getFees(), CurrencyTest::getObject()); $this->assertEquals($obj->getErrors(), ErrorTest::getObject()); $this->assertEquals($obj->getLinks(), LinksTest::getObject()); } } rest-api-sdk-php/tests/PayPal/Test/Api/InvoiceAddressTest.php 0000644 00000003731 15007532371 0020076 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\InvoiceAddress; /** * Class InvoiceAddress * * @package PayPal\Test\Api */ class InvoiceAddressTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object Address * @return string */ public static function getJson() { return '{"line1":"TestSample","line2":"TestSample","city":"TestSample","country_code":"TestSample","postal_code":"TestSample","state":"TestSample","phone":'. PhoneTest::getJson() . "}"; } /** * Gets Object Instance with Json data filled in * @return InvoiceAddress */ public static function getObject() { return new InvoiceAddress(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return InvoiceAddress */ public function testSerializationDeserialization() { $obj = new InvoiceAddress(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getLine1()); $this->assertNotNull($obj->getLine2()); $this->assertNotNull($obj->getCity()); $this->assertNotNull($obj->getCountryCode()); $this->assertNotNull($obj->getPostalCode()); $this->assertNotNull($obj->getState()); $this->assertNotNull($obj->getPhone()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param InvoiceAddress $obj */ public function testGetters($obj) { $this->assertEquals($obj->getLine1(), "TestSample"); $this->assertEquals($obj->getLine2(), "TestSample"); $this->assertEquals($obj->getCity(), "TestSample"); $this->assertEquals($obj->getCountryCode(), "TestSample"); $this->assertEquals($obj->getPostalCode(), "TestSample"); $this->assertEquals($obj->getState(), "TestSample"); $this->assertEquals($obj->getPhone(), PhoneTest::getObject()); } } rest-api-sdk-php/tests/PayPal/Test/Api/PaymentTermTest.php 0000644 00000002427 15007532371 0017442 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\PaymentTerm; /** * Class PaymentTerm * * @package PayPal\Test\Api */ class PaymentTermTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object PaymentTerm * @return string */ public static function getJson() { return '{"term_type":"TestSample","due_date":"TestSample"}'; } /** * Gets Object Instance with Json data filled in * @return PaymentTerm */ public static function getObject() { return new PaymentTerm(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return PaymentTerm */ public function testSerializationDeserialization() { $obj = new PaymentTerm(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getTermType()); $this->assertNotNull($obj->getDueDate()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param PaymentTerm $obj */ public function testGetters($obj) { $this->assertEquals($obj->getTermType(), "TestSample"); $this->assertEquals($obj->getDueDate(), "TestSample"); } } rest-api-sdk-php/tests/PayPal/Test/Api/TransactionTest.php 0000644 00000002025 15007532371 0017454 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\Transaction; /** * Class Transaction * * @package PayPal\Test\Api */ class TransactionTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object Transaction * * @return string */ public static function getJson() { return '{}'; } /** * Gets Object Instance with Json data filled in * * @return Transaction */ public static function getObject() { return new Transaction(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * * @return Transaction */ public function testSerializationDeserialization() { $obj = new Transaction(self::getJson()); $this->assertNotNull($obj); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param Transaction $obj */ public function testGetters($obj) { } } rest-api-sdk-php/tests/PayPal/Test/Api/CartBaseTest.php 0000644 00000007402 15007532371 0016657 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\CartBase; /** * Class CartBase * * @package PayPal\Test\Api */ class CartBaseTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object CartBase * * @return string */ public static function getJson() { return '{"reference_id":"TestSample","amount":' . AmountTest::getJson() . ',"payee":' . PayeeTest::getJson() . ',"description":"TestSample","note_to_payee":"TestSample","custom":"TestSample","invoice_number":"TestSample","soft_descriptor":"TestSample","soft_descriptor_city":"TestSample","payment_options":' . PaymentOptionsTest::getJson() . ',"item_list":' . ItemListTest::getJson() . ',"notify_url":"http://www.google.com","order_url":"http://www.google.com","external_funding":' . ExternalFundingTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * * @return CartBase */ public static function getObject() { return new CartBase(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * * @return CartBase */ public function testSerializationDeserialization() { $obj = new CartBase(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getReferenceId()); $this->assertNotNull($obj->getAmount()); $this->assertNotNull($obj->getPayee()); $this->assertNotNull($obj->getDescription()); $this->assertNotNull($obj->getNoteToPayee()); $this->assertNotNull($obj->getCustom()); $this->assertNotNull($obj->getInvoiceNumber()); $this->assertNotNull($obj->getSoftDescriptor()); $this->assertNotNull($obj->getSoftDescriptorCity()); $this->assertNotNull($obj->getPaymentOptions()); $this->assertNotNull($obj->getItemList()); $this->assertNotNull($obj->getNotifyUrl()); $this->assertNotNull($obj->getOrderUrl()); $this->assertNotNull($obj->getExternalFunding()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param CartBase $obj */ public function testGetters($obj) { $this->assertEquals($obj->getReferenceId(), "TestSample"); $this->assertEquals($obj->getAmount(), AmountTest::getObject()); $this->assertEquals($obj->getPayee(), PayeeTest::getObject()); $this->assertEquals($obj->getDescription(), "TestSample"); $this->assertEquals($obj->getNoteToPayee(), "TestSample"); $this->assertEquals($obj->getCustom(), "TestSample"); $this->assertEquals($obj->getInvoiceNumber(), "TestSample"); $this->assertEquals($obj->getSoftDescriptor(), "TestSample"); $this->assertEquals($obj->getSoftDescriptorCity(), "TestSample"); $this->assertEquals($obj->getPaymentOptions(), PaymentOptionsTest::getObject()); $this->assertEquals($obj->getItemList(), ItemListTest::getObject()); $this->assertEquals($obj->getNotifyUrl(), "http://www.google.com"); $this->assertEquals($obj->getOrderUrl(), "http://www.google.com"); $this->assertEquals($obj->getExternalFunding(), ExternalFundingTest::getObject()); } /** * @expectedException \InvalidArgumentException * @expectedExceptionMessage NotifyUrl is not a fully qualified URL */ public function testUrlValidationForNotifyUrl() { $obj = new CartBase(); $obj->setNotifyUrl(null); } /** * @expectedException \InvalidArgumentException * @expectedExceptionMessage OrderUrl is not a fully qualified URL */ public function testUrlValidationForOrderUrl() { $obj = new CartBase(); $obj->setOrderUrl(null); } } rest-api-sdk-php/tests/PayPal/Test/Api/PayoutItemDetailsTest.php 0000644 00000005213 15007532371 0020577 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\PayoutItemDetails; /** * Class PayoutItemDetails * * @package PayPal\Test\Api */ class PayoutItemDetailsTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object PayoutItemDetails * @return string */ public static function getJson() { return '{"payout_item_id":"TestSample","transaction_id":"TestSample","transaction_status":"TestSample","payout_item_fee":' .CurrencyTest::getJson() . ',"payout_batch_id":"TestSample","sender_batch_id":"TestSample","payout_item":' .PayoutItemTest::getJson() . ',"time_processed":"TestSample","errors":' .ErrorTest::getJson() . ',"links":' .LinksTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * @return PayoutItemDetails */ public static function getObject() { return new PayoutItemDetails(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return PayoutItemDetails */ public function testSerializationDeserialization() { $obj = new PayoutItemDetails(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getPayoutItemId()); $this->assertNotNull($obj->getTransactionId()); $this->assertNotNull($obj->getTransactionStatus()); $this->assertNotNull($obj->getPayoutItemFee()); $this->assertNotNull($obj->getPayoutBatchId()); $this->assertNotNull($obj->getSenderBatchId()); $this->assertNotNull($obj->getPayoutItem()); $this->assertNotNull($obj->getTimeProcessed()); $this->assertNotNull($obj->getErrors()); $this->assertNotNull($obj->getLinks()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param PayoutItemDetails $obj */ public function testGetters($obj) { $this->assertEquals($obj->getPayoutItemId(), "TestSample"); $this->assertEquals($obj->getTransactionId(), "TestSample"); $this->assertEquals($obj->getTransactionStatus(), "TestSample"); $this->assertEquals($obj->getPayoutItemFee(), CurrencyTest::getObject()); $this->assertEquals($obj->getPayoutBatchId(), "TestSample"); $this->assertEquals($obj->getSenderBatchId(), "TestSample"); $this->assertEquals($obj->getPayoutItem(), PayoutItemTest::getObject()); $this->assertEquals($obj->getTimeProcessed(), "TestSample"); $this->assertEquals($obj->getErrors(), ErrorTest::getObject()); $this->assertEquals($obj->getLinks(), LinksTest::getObject()); } } rest-api-sdk-php/tests/PayPal/Test/Api/PatchTest.php 0000644 00000002743 15007532371 0016235 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\Patch; /** * Class Patch * * @package PayPal\Test\Api */ class PatchTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object Patch * * @return string */ public static function getJson() { return '{"op":"TestSample","path":"TestSample","value":"TestSampleObject","from":"TestSample"}'; } /** * Gets Object Instance with Json data filled in * * @return Patch */ public static function getObject() { return new Patch(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * * @return Patch */ public function testSerializationDeserialization() { $obj = new Patch(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getOp()); $this->assertNotNull($obj->getPath()); $this->assertNotNull($obj->getValue()); $this->assertNotNull($obj->getFrom()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param Patch $obj */ public function testGetters($obj) { $this->assertEquals($obj->getOp(), "TestSample"); $this->assertEquals($obj->getPath(), "TestSample"); $this->assertEquals($obj->getValue(), "TestSampleObject"); $this->assertEquals($obj->getFrom(), "TestSample"); } } rest-api-sdk-php/tests/PayPal/Test/Api/FmfDetailsTest.php 0000644 00000003074 15007532371 0017212 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\FmfDetails; /** * Class FmfDetails * * @package PayPal\Test\Api */ class FmfDetailsTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object FmfDetails * * @return string */ public static function getJson() { return '{"filter_type":"TestSample","filter_id":"TestSample","name":"TestSample","description":"TestSample"}'; } /** * Gets Object Instance with Json data filled in * * @return FmfDetails */ public static function getObject() { return new FmfDetails(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * * @return FmfDetails */ public function testSerializationDeserialization() { $obj = new FmfDetails(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getFilterType()); $this->assertNotNull($obj->getFilterId()); $this->assertNotNull($obj->getName()); $this->assertNotNull($obj->getDescription()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param FmfDetails $obj */ public function testGetters($obj) { $this->assertEquals($obj->getFilterType(), "TestSample"); $this->assertEquals($obj->getFilterId(), "TestSample"); $this->assertEquals($obj->getName(), "TestSample"); $this->assertEquals($obj->getDescription(), "TestSample"); } } rest-api-sdk-php/tests/PayPal/Test/Api/RedirectUrlsTest.php 0000644 00000003612 15007532371 0017601 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\RedirectUrls; /** * Class RedirectUrls * * @package PayPal\Test\Api */ class RedirectUrlsTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object RedirectUrls * * @return string */ public static function getJson() { return '{"return_url":"http://www.google.com","cancel_url":"http://www.google.com"}'; } /** * Gets Object Instance with Json data filled in * * @return RedirectUrls */ public static function getObject() { return new RedirectUrls(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * * @return RedirectUrls */ public function testSerializationDeserialization() { $obj = new RedirectUrls(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getReturnUrl()); $this->assertNotNull($obj->getCancelUrl()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param RedirectUrls $obj */ public function testGetters($obj) { $this->assertEquals($obj->getReturnUrl(), "http://www.google.com"); $this->assertEquals($obj->getCancelUrl(), "http://www.google.com"); } /** * @expectedException \InvalidArgumentException * @expectedExceptionMessage ReturnUrl is not a fully qualified URL */ public function testUrlValidationForReturnUrl() { $obj = new RedirectUrls(); $obj->setReturnUrl(null); } /** * @expectedException \InvalidArgumentException * @expectedExceptionMessage CancelUrl is not a fully qualified URL */ public function testUrlValidationForCancelUrl() { $obj = new RedirectUrls(); $obj->setCancelUrl(null); } } rest-api-sdk-php/tests/PayPal/Test/Api/CurrencyConversionTest.php 0000644 00000005610 15007532371 0021032 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\CurrencyConversion; /** * Class CurrencyConversion * * @package PayPal\Test\Api */ class CurrencyConversionTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object CurrencyConversion * * @return string */ public static function getJson() { return '{"conversion_date":"TestSample","from_currency":"TestSample","from_amount":"TestSample","to_currency":"TestSample","to_amount":"TestSample","conversion_type":"TestSample","conversion_type_changeable":true,"web_url":"http://www.google.com","links":' . LinksTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * * @return CurrencyConversion */ public static function getObject() { return new CurrencyConversion(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * * @return CurrencyConversion */ public function testSerializationDeserialization() { $obj = new CurrencyConversion(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getConversionDate()); $this->assertNotNull($obj->getFromCurrency()); $this->assertNotNull($obj->getFromAmount()); $this->assertNotNull($obj->getToCurrency()); $this->assertNotNull($obj->getToAmount()); $this->assertNotNull($obj->getConversionType()); $this->assertNotNull($obj->getConversionTypeChangeable()); $this->assertNotNull($obj->getWebUrl()); $this->assertNotNull($obj->getLinks()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param CurrencyConversion $obj */ public function testGetters($obj) { $this->assertEquals($obj->getConversionDate(), "TestSample"); $this->assertEquals($obj->getFromCurrency(), "TestSample"); $this->assertEquals($obj->getFromAmount(), "TestSample"); $this->assertEquals($obj->getToCurrency(), "TestSample"); $this->assertEquals($obj->getToAmount(), "TestSample"); $this->assertEquals($obj->getConversionType(), "TestSample"); $this->assertEquals($obj->getConversionTypeChangeable(), true); $this->assertEquals($obj->getWebUrl(), "http://www.google.com"); $this->assertEquals($obj->getLinks(), LinksTest::getObject()); } /** * @expectedException \InvalidArgumentException * @expectedExceptionMessage WebUrl is not a fully qualified URL */ public function testUrlValidationForWebUrl() { $obj = new CurrencyConversion(); $obj->setWebUrl(null); } public function testUrlValidationForWebUrlDeprecated() { $obj = new CurrencyConversion(); $obj->setWebUrl(null); $this->assertNull($obj->getWebUrl()); } } rest-api-sdk-php/tests/PayPal/Test/Api/PlanListTest.php 0000644 00000003073 15007532371 0016721 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\PlanList; /** * Class PlanList * * @package PayPal\Test\Api */ class PlanListTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object PlanList * @return string */ public static function getJson() { return '{"plans":' .PlanTest::getJson() . ',"total_items":"TestSample","total_pages":"TestSample","links":' .LinksTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * @return PlanList */ public static function getObject() { return new PlanList(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return PlanList */ public function testSerializationDeserialization() { $obj = new PlanList(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getPlans()); $this->assertNotNull($obj->getTotalItems()); $this->assertNotNull($obj->getTotalPages()); $this->assertNotNull($obj->getLinks()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param PlanList $obj */ public function testGetters($obj) { $this->assertEquals($obj->getPlans(), PlanTest::getObject()); $this->assertEquals($obj->getTotalItems(), "TestSample"); $this->assertEquals($obj->getTotalPages(), "TestSample"); $this->assertEquals($obj->getLinks(), LinksTest::getObject()); } } rest-api-sdk-php/tests/PayPal/Test/Api/PotentialPayerInfoTest.php 0000644 00000003310 15007532371 0020741 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\PotentialPayerInfo; /** * Class PotentialPayerInfo * * @package PayPal\Test\Api */ class PotentialPayerInfoTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object PotentialPayerInfo * @return string */ public static function getJson() { return '{"email":"TestSample","external_remember_me_id":"TestSample","account_number":"TestSample","billing_address":' .AddressTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * @return PotentialPayerInfo */ public static function getObject() { return new PotentialPayerInfo(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return PotentialPayerInfo */ public function testSerializationDeserialization() { $obj = new PotentialPayerInfo(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getEmail()); $this->assertNotNull($obj->getExternalRememberMeId()); $this->assertNotNull($obj->getAccountNumber()); $this->assertNotNull($obj->getBillingAddress()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param PotentialPayerInfo $obj */ public function testGetters($obj) { $this->assertEquals($obj->getEmail(), "TestSample"); $this->assertEquals($obj->getExternalRememberMeId(), "TestSample"); $this->assertEquals($obj->getAccountNumber(), "TestSample"); $this->assertEquals($obj->getBillingAddress(), AddressTest::getObject()); } } rest-api-sdk-php/tests/PayPal/Test/Api/InstallmentOptionTest.php 0000644 00000003335 15007532371 0020657 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\InstallmentOption; /** * Class InstallmentOption * * @package PayPal\Test\Api */ class InstallmentOptionTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object InstallmentOption * * @return string */ public static function getJson() { return '{"term":123,"monthly_payment":' . CurrencyTest::getJson() . ',"discount_amount":' . CurrencyTest::getJson() . ',"discount_percentage":"TestSample"}'; } /** * Gets Object Instance with Json data filled in * * @return InstallmentOption */ public static function getObject() { return new InstallmentOption(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * * @return InstallmentOption */ public function testSerializationDeserialization() { $obj = new InstallmentOption(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getTerm()); $this->assertNotNull($obj->getMonthlyPayment()); $this->assertNotNull($obj->getDiscountAmount()); $this->assertNotNull($obj->getDiscountPercentage()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param InstallmentOption $obj */ public function testGetters($obj) { $this->assertEquals($obj->getTerm(), 123); $this->assertEquals($obj->getMonthlyPayment(), CurrencyTest::getObject()); $this->assertEquals($obj->getDiscountAmount(), CurrencyTest::getObject()); $this->assertEquals($obj->getDiscountPercentage(), "TestSample"); } } rest-api-sdk-php/tests/PayPal/Test/Api/DetailsTest.php 0000644 00000004001 15007532371 0016550 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\Details; /** * Class Details * * @package PayPal\Test\Api */ class DetailsTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object Details * * @return string */ public static function getJson() { return '{"subtotal":"12.34","shipping":"12.34","tax":"12.34","handling_fee":"12.34","shipping_discount":"12.34","insurance":"12.34","gift_wrap":"12.34","fee":"12.34"}'; } /** * Gets Object Instance with Json data filled in * * @return Details */ public static function getObject() { return new Details(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * * @return Details */ public function testSerializationDeserialization() { $obj = new Details(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getSubtotal()); $this->assertNotNull($obj->getShipping()); $this->assertNotNull($obj->getTax()); $this->assertNotNull($obj->getHandlingFee()); $this->assertNotNull($obj->getShippingDiscount()); $this->assertNotNull($obj->getInsurance()); $this->assertNotNull($obj->getGiftWrap()); $this->assertNotNull($obj->getFee()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param Details $obj */ public function testGetters($obj) { $this->assertEquals($obj->getSubtotal(), "12.34"); $this->assertEquals($obj->getShipping(), "12.34"); $this->assertEquals($obj->getTax(), "12.34"); $this->assertEquals($obj->getHandlingFee(), "12.34"); $this->assertEquals($obj->getShippingDiscount(), "12.34"); $this->assertEquals($obj->getInsurance(), "12.34"); $this->assertEquals($obj->getGiftWrap(), "12.34"); $this->assertEquals($obj->getFee(), "12.34"); } } rest-api-sdk-php/tests/PayPal/Test/Api/MeasurementTest.php 0000644 00000002425 15007532371 0017460 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\Measurement; /** * Class Measurement * * @package PayPal\Test\Api */ class MeasurementTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object Measurement * * @return string */ public static function getJson() { return '{"value":"TestSample","unit":"TestSample"}'; } /** * Gets Object Instance with Json data filled in * * @return Measurement */ public static function getObject() { return new Measurement(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * * @return Measurement */ public function testSerializationDeserialization() { $obj = new Measurement(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getValue()); $this->assertNotNull($obj->getUnit()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param Measurement $obj */ public function testGetters($obj) { $this->assertEquals($obj->getValue(), "TestSample"); $this->assertEquals($obj->getUnit(), "TestSample"); } } rest-api-sdk-php/tests/PayPal/Test/Api/CreditCardTokenTest.php 0000644 00000003536 15007532371 0020204 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\CreditCardToken; /** * Class CreditCardToken * * @package PayPal\Test\Api */ class CreditCardTokenTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object CreditCardToken * * @return string */ public static function getJson() { return '{"credit_card_id":"TestSample","payer_id":"TestSample","last4":"TestSample","type":"TestSample","expire_month":123,"expire_year":123}'; } /** * Gets Object Instance with Json data filled in * * @return CreditCardToken */ public static function getObject() { return new CreditCardToken(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * * @return CreditCardToken */ public function testSerializationDeserialization() { $obj = new CreditCardToken(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getCreditCardId()); $this->assertNotNull($obj->getPayerId()); $this->assertNotNull($obj->getLast4()); $this->assertNotNull($obj->getType()); $this->assertNotNull($obj->getExpireMonth()); $this->assertNotNull($obj->getExpireYear()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param CreditCardToken $obj */ public function testGetters($obj) { $this->assertEquals($obj->getCreditCardId(), "TestSample"); $this->assertEquals($obj->getPayerId(), "TestSample"); $this->assertEquals($obj->getLast4(), "TestSample"); $this->assertEquals($obj->getType(), "TestSample"); $this->assertEquals($obj->getExpireMonth(), 123); $this->assertEquals($obj->getExpireYear(), 123); } } rest-api-sdk-php/tests/PayPal/Test/Api/PayerInfoTest.php 0000644 00000006760 15007532371 0017075 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\PayerInfo; /** * Class PayerInfo * * @package PayPal\Test\Api */ class PayerInfoTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object PayerInfo * * @return string */ public static function getJson() { return '{"email":"TestSample","external_remember_me_id":"TestSample","account_number":"TestSample","salutation":"TestSample","first_name":"TestSample","middle_name":"TestSample","last_name":"TestSample","suffix":"TestSample","payer_id":"TestSample","phone":"TestSample","phone_type":"TestSample","birth_date":"TestSample","tax_id":"TestSample","tax_id_type":"TestSample","country_code":"TestSample","billing_address":' . AddressTest::getJson() . ',"shipping_address":' . ShippingAddressTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * * @return PayerInfo */ public static function getObject() { return new PayerInfo(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * * @return PayerInfo */ public function testSerializationDeserialization() { $obj = new PayerInfo(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getEmail()); $this->assertNotNull($obj->getExternalRememberMeId()); $this->assertNotNull($obj->getAccountNumber()); $this->assertNotNull($obj->getSalutation()); $this->assertNotNull($obj->getFirstName()); $this->assertNotNull($obj->getMiddleName()); $this->assertNotNull($obj->getLastName()); $this->assertNotNull($obj->getSuffix()); $this->assertNotNull($obj->getPayerId()); $this->assertNotNull($obj->getPhone()); $this->assertNotNull($obj->getPhoneType()); $this->assertNotNull($obj->getBirthDate()); $this->assertNotNull($obj->getTaxId()); $this->assertNotNull($obj->getTaxIdType()); $this->assertNotNull($obj->getCountryCode()); $this->assertNotNull($obj->getBillingAddress()); $this->assertNotNull($obj->getShippingAddress()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param PayerInfo $obj */ public function testGetters($obj) { $this->assertEquals($obj->getEmail(), "TestSample"); $this->assertEquals($obj->getExternalRememberMeId(), "TestSample"); $this->assertEquals($obj->getAccountNumber(), "TestSample"); $this->assertEquals($obj->getSalutation(), "TestSample"); $this->assertEquals($obj->getFirstName(), "TestSample"); $this->assertEquals($obj->getMiddleName(), "TestSample"); $this->assertEquals($obj->getLastName(), "TestSample"); $this->assertEquals($obj->getSuffix(), "TestSample"); $this->assertEquals($obj->getPayerId(), "TestSample"); $this->assertEquals($obj->getPhone(), "TestSample"); $this->assertEquals($obj->getPhoneType(), "TestSample"); $this->assertEquals($obj->getBirthDate(), "TestSample"); $this->assertEquals($obj->getTaxId(), "TestSample"); $this->assertEquals($obj->getTaxIdType(), "TestSample"); $this->assertEquals($obj->getCountryCode(), "TestSample"); $this->assertEquals($obj->getBillingAddress(), AddressTest::getObject()); $this->assertEquals($obj->getShippingAddress(), ShippingAddressTest::getObject()); } } rest-api-sdk-php/tests/PayPal/Test/Api/PaymentDetailTest.php 0000644 00000003516 15007532371 0017735 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\PaymentDetail; /** * Class PaymentDetail * * @package PayPal\Test\Api */ class PaymentDetailTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object PaymentDetail * @return string */ public static function getJson() { return '{"type":"TestSample","transaction_id":"TestSample","transaction_type":"TestSample","date":"TestSample","method":"TestSample","note":"TestSample"}'; } /** * Gets Object Instance with Json data filled in * @return PaymentDetail */ public static function getObject() { return new PaymentDetail(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return PaymentDetail */ public function testSerializationDeserialization() { $obj = new PaymentDetail(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getType()); $this->assertNotNull($obj->getTransactionId()); $this->assertNotNull($obj->getTransactionType()); $this->assertNotNull($obj->getDate()); $this->assertNotNull($obj->getMethod()); $this->assertNotNull($obj->getNote()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param PaymentDetail $obj */ public function testGetters($obj) { $this->assertEquals($obj->getType(), "TestSample"); $this->assertEquals($obj->getTransactionId(), "TestSample"); $this->assertEquals($obj->getTransactionType(), "TestSample"); $this->assertEquals($obj->getDate(), "TestSample"); $this->assertEquals($obj->getMethod(), "TestSample"); $this->assertEquals($obj->getNote(), "TestSample"); } } rest-api-sdk-php/tests/PayPal/Test/Api/InputFieldsTest.php 0000644 00000002646 15007532371 0017426 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\InputFields; /** * Class InputFields * * @package PayPal\Test\Api */ class InputFieldsTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object InputFields * @return string */ public static function getJson() { return json_encode(json_decode('{"allow_note":true,"no_shipping":123,"address_override":123}')); } /** * Gets Object Instance with Json data filled in * @return InputFields */ public static function getObject() { return new InputFields(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return InputFields */ public function testSerializationDeserialization() { $obj = new InputFields(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getAllowNote()); $this->assertNotNull($obj->getNoShipping()); $this->assertNotNull($obj->getAddressOverride()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param InputFields $obj */ public function testGetters($obj) { $this->assertEquals($obj->getAllowNote(), true); $this->assertEquals($obj->getNoShipping(), 123); $this->assertEquals($obj->getAddressOverride(), 123); } } rest-api-sdk-php/tests/PayPal/Test/Api/ShippingInfoTest.php 0000644 00000003137 15007532371 0017571 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\ShippingInfo; /** * Class ShippingInfo * * @package PayPal\Test\Api */ class ShippingInfoTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object ShippingInfo * @return string */ public static function getJson() { return '{"first_name":"TestSample","last_name":"TestSample","business_name":"TestSample","address":' .AddressTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * @return ShippingInfo */ public static function getObject() { return new ShippingInfo(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return ShippingInfo */ public function testSerializationDeserialization() { $obj = new ShippingInfo(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getFirstName()); $this->assertNotNull($obj->getLastName()); $this->assertNotNull($obj->getBusinessName()); $this->assertNotNull($obj->getAddress()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param ShippingInfo $obj */ public function testGetters($obj) { $this->assertEquals($obj->getFirstName(), "TestSample"); $this->assertEquals($obj->getLastName(), "TestSample"); $this->assertEquals($obj->getBusinessName(), "TestSample"); $this->assertEquals($obj->getAddress(), AddressTest::getObject()); } } rest-api-sdk-php/tests/PayPal/Test/Api/FundingOptionTest.php 0000644 00000004234 15007532371 0017756 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\FundingOption; /** * Class FundingOption * * @package PayPal\Test\Api */ class FundingOptionTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object FundingOption * * @return string */ public static function getJson() { return '{"id":"TestSample","funding_sources":' . FundingSourceTest::getJson() . ',"backup_funding_instrument":' . FundingInstrumentTest::getJson() . ',"currency_conversion":' . CurrencyConversionTest::getJson() . ',"installment_info":' . InstallmentInfoTest::getJson() . ',"links":' . LinksTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * * @return FundingOption */ public static function getObject() { return new FundingOption(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * * @return FundingOption */ public function testSerializationDeserialization() { $obj = new FundingOption(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getId()); $this->assertNotNull($obj->getFundingSources()); $this->assertNotNull($obj->getBackupFundingInstrument()); $this->assertNotNull($obj->getCurrencyConversion()); $this->assertNotNull($obj->getInstallmentInfo()); $this->assertNotNull($obj->getLinks()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param FundingOption $obj */ public function testGetters($obj) { $this->assertEquals($obj->getId(), "TestSample"); $this->assertEquals($obj->getFundingSources(), FundingSourceTest::getObject()); $this->assertEquals($obj->getBackupFundingInstrument(), FundingInstrumentTest::getObject()); $this->assertEquals($obj->getCurrencyConversion(), CurrencyConversionTest::getObject()); $this->assertEquals($obj->getInstallmentInfo(), InstallmentInfoTest::getObject()); $this->assertEquals($obj->getLinks(), LinksTest::getObject()); } } rest-api-sdk-php/tests/PayPal/Test/Api/CreditCardHistoryTest.php 0000644 00000004244 15007532371 0020562 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\CreditCard; use PayPal\Api\CreditCardHistory; class CreditCardHistoryTest extends \PHPUnit_Framework_TestCase { private $cards; public static $id = "id"; public static $validUntil = "2013-02-28T00:00:00Z"; public static $state = "created"; public static $payerId = "payer-id"; public static $cardType = "visa"; public static $cardNumber = "4417119669820331"; public static $expireMonth = 11; public static $expireYear = "2019"; public static $cvv = "012"; public static $firstName = "V"; public static $lastName = "C"; public static function createCreditCard() { $card = new CreditCard(); $card->setType(self::$cardType); $card->setNumber(self::$cardNumber); $card->setExpireMonth(self::$expireMonth); $card->setExpireYear(self::$expireYear); $card->setCvv2(self::$cvv); $card->setFirstName(self::$firstName); $card->setLastName(self::$lastName); $card->setId(self::$id); $card->setValidUntil(self::$validUntil); $card->setState(self::$state); return $card; } public function setup() { $card = self::createCreditCard(); $card->setBillingAddress(AddressTest::getObject()); $card->setLinks(array(LinksTest::getObject())); $this->cards['full'] = $card; $card = self::createCreditCard(); $this->cards['partial'] = $card; } public function testGetterSetters() { $cardHistory = new CreditCardHistory(); $cardHistory->setCreditCards(array($this->cards['partial'], $this->cards['full'])); $cardHistory->setCount(2); $this->assertEquals(2, count($cardHistory->getCreditCards())); } public function testSerializationDeserialization() { $cardHistory = new CreditCardHistory(); $cardHistory->setCreditCards(array($this->cards['partial'], $this->cards['full'])); $cardHistory->setCount(2); $cardHistoryCopy = new CreditCardHistory(); $cardHistoryCopy->fromJson($cardHistory->toJSON()); $this->assertEquals($cardHistory, $cardHistoryCopy); } } rest-api-sdk-php/tests/PayPal/Test/Api/BillingTest.php 0000644 00000002206 15007532371 0016550 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\Billing; /** * Class Billing * * @package PayPal\Test\Api */ class BillingTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object Billing * @return string */ public static function getJson() { return '{"billing_agreement_id":"TestSample"}'; } /** * Gets Object Instance with Json data filled in * @return Billing */ public static function getObject() { return new Billing(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return Billing */ public function testSerializationDeserialization() { $obj = new Billing(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getBillingAgreementId()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param Billing $obj */ public function testGetters($obj) { $this->assertEquals($obj->getBillingAgreementId(), "TestSample"); } } rest-api-sdk-php/tests/PayPal/Test/Api/PayerTest.php 0000644 00000004764 15007532371 0016263 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\Payer; /** * Class Payer * * @package PayPal\Test\Api */ class PayerTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object Payer * * @return string */ public static function getJson() { return '{"payment_method":"TestSample","status":"TestSample","account_type":"TestSample","account_age":"TestSample","funding_instruments":' . FundingInstrumentTest::getJson() . ',"funding_option_id":"TestSample","funding_option":' . FundingOptionTest::getJson() . ',"related_funding_option":' . FundingOptionTest::getJson() . ',"payer_info":' . PayerInfoTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * * @return Payer */ public static function getObject() { return new Payer(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * * @return Payer */ public function testSerializationDeserialization() { $obj = new Payer(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getPaymentMethod()); $this->assertNotNull($obj->getStatus()); $this->assertNotNull($obj->getAccountType()); $this->assertNotNull($obj->getAccountAge()); $this->assertNotNull($obj->getFundingInstruments()); $this->assertNotNull($obj->getFundingOptionId()); $this->assertNotNull($obj->getFundingOption()); $this->assertNotNull($obj->getRelatedFundingOption()); $this->assertNotNull($obj->getPayerInfo()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param Payer $obj */ public function testGetters($obj) { $this->assertEquals($obj->getPaymentMethod(), "TestSample"); $this->assertEquals($obj->getStatus(), "TestSample"); $this->assertEquals($obj->getAccountType(), "TestSample"); $this->assertEquals($obj->getAccountAge(), "TestSample"); $this->assertEquals($obj->getFundingInstruments(), FundingInstrumentTest::getObject()); $this->assertEquals($obj->getFundingOptionId(), "TestSample"); $this->assertEquals($obj->getFundingOption(), FundingOptionTest::getObject()); $this->assertEquals($obj->getRelatedFundingOption(), FundingOptionTest::getObject()); $this->assertEquals($obj->getPayerInfo(), PayerInfoTest::getObject()); } } rest-api-sdk-php/tests/PayPal/Test/Api/CreateProfileResponseTest.php 0000644 00000002353 15007532371 0021436 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\CreateProfileResponse; /** * Class CreateProfileResponse * * @package PayPal\Test\Api */ class CreateProfileResponseTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object CreateProfileResponse * @return string */ public static function getJson() { return json_encode(json_decode('{"id":"TestSample"}')); } /** * Gets Object Instance with Json data filled in * @return CreateProfileResponse */ public static function getObject() { return new CreateProfileResponse(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return CreateProfileResponse */ public function testSerializationDeserialization() { $obj = new CreateProfileResponse(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getId()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param CreateProfileResponse $obj */ public function testGetters($obj) { $this->assertEquals($obj->getId(), "TestSample"); } } rest-api-sdk-php/tests/PayPal/Test/Api/LinksTest.php 0000644 00000003466 15007532371 0016261 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\Links; /** * Class Links * * @package PayPal\Test\Api */ class LinksTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object Links * @return string */ public static function getJson() { return '{"href":"TestSample","rel":"TestSample","targetSchema":' .HyperSchemaTest::getJson() . ',"method":"TestSample","enctype":"TestSample","schema":' .HyperSchemaTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * @return Links */ public static function getObject() { return new Links(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return Links */ public function testSerializationDeserialization() { $obj = new Links(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getHref()); $this->assertNotNull($obj->getRel()); $this->assertNotNull($obj->getTargetSchema()); $this->assertNotNull($obj->getMethod()); $this->assertNotNull($obj->getEnctype()); $this->assertNotNull($obj->getSchema()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param Links $obj */ public function testGetters($obj) { $this->assertEquals($obj->getHref(), "TestSample"); $this->assertEquals($obj->getRel(), "TestSample"); $this->assertEquals($obj->getTargetSchema(), HyperSchemaTest::getObject()); $this->assertEquals($obj->getMethod(), "TestSample"); $this->assertEquals($obj->getEnctype(), "TestSample"); $this->assertEquals($obj->getSchema(), HyperSchemaTest::getObject()); } } rest-api-sdk-php/tests/PayPal/Test/Api/OpenIdErrorTest.php 0000644 00000002041 15007532371 0017355 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\OpenIdError; /** * Test class for OpenIdError. * */ class OpenIdErrorTest extends \PHPUnit_Framework_TestCase { /** @var OpenIdError */ private $error; /** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { $this->error = new OpenIdError(); $this->error->setErrorDescription('error description') ->setErrorUri('http://developer.paypal.com/api/error') ->setError('VALIDATION_ERROR'); } /** * Tears down the fixture, for example, closes a network connection. * This method is called after a test is executed. */ protected function tearDown() { } /** * @test */ public function testSerializationDeserialization() { $errorCopy = new OpenIdError(); $errorCopy->fromJson($this->error->toJson()); $this->assertEquals($this->error, $errorCopy); } } rest-api-sdk-php/tests/PayPal/Test/Api/PaymentCardTokenTest.php 0000644 00000003566 15007532371 0020412 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\PaymentCardToken; /** * Class PaymentCardToken * * @package PayPal\Test\Api */ class PaymentCardTokenTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object PaymentCardToken * @return string */ public static function getJson() { return '{"payment_card_id":"TestSample","external_customer_id":"TestSample","last4":"TestSample","type":"TestSample","expire_month":123,"expire_year":123}'; } /** * Gets Object Instance with Json data filled in * @return PaymentCardToken */ public static function getObject() { return new PaymentCardToken(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return PaymentCardToken */ public function testSerializationDeserialization() { $obj = new PaymentCardToken(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getPaymentCardId()); $this->assertNotNull($obj->getExternalCustomerId()); $this->assertNotNull($obj->getLast4()); $this->assertNotNull($obj->getType()); $this->assertNotNull($obj->getExpireMonth()); $this->assertNotNull($obj->getExpireYear()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param PaymentCardToken $obj */ public function testGetters($obj) { $this->assertEquals($obj->getPaymentCardId(), "TestSample"); $this->assertEquals($obj->getExternalCustomerId(), "TestSample"); $this->assertEquals($obj->getLast4(), "TestSample"); $this->assertEquals($obj->getType(), "TestSample"); $this->assertEquals($obj->getExpireMonth(), 123); $this->assertEquals($obj->getExpireYear(), 123); } } rest-api-sdk-php/tests/PayPal/Test/Api/SearchTest.php 0000644 00000007574 15007532371 0016412 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\Search; /** * Class Search * * @package PayPal\Test\Api */ class SearchTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object Search * @return string */ public static function getJson() { return '{"email":"TestSample","recipient_first_name":"TestSample","recipient_last_name":"TestSample","recipient_business_name":"TestSample","number":"TestSample","status":"TestSample","lower_total_amount":' .CurrencyTest::getJson() . ',"upper_total_amount":' .CurrencyTest::getJson() . ',"start_invoice_date":"TestSample","end_invoice_date":"TestSample","start_due_date":"TestSample","end_due_date":"TestSample","start_payment_date":"TestSample","end_payment_date":"TestSample","start_creation_date":"TestSample","end_creation_date":"TestSample","page":"12.34","page_size":"12.34","total_count_required":true}'; } /** * Gets Object Instance with Json data filled in * @return Search */ public static function getObject() { return new Search(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return Search */ public function testSerializationDeserialization() { $obj = new Search(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getEmail()); $this->assertNotNull($obj->getRecipientFirstName()); $this->assertNotNull($obj->getRecipientLastName()); $this->assertNotNull($obj->getRecipientBusinessName()); $this->assertNotNull($obj->getNumber()); $this->assertNotNull($obj->getStatus()); $this->assertNotNull($obj->getLowerTotalAmount()); $this->assertNotNull($obj->getUpperTotalAmount()); $this->assertNotNull($obj->getStartInvoiceDate()); $this->assertNotNull($obj->getEndInvoiceDate()); $this->assertNotNull($obj->getStartDueDate()); $this->assertNotNull($obj->getEndDueDate()); $this->assertNotNull($obj->getStartPaymentDate()); $this->assertNotNull($obj->getEndPaymentDate()); $this->assertNotNull($obj->getStartCreationDate()); $this->assertNotNull($obj->getEndCreationDate()); $this->assertNotNull($obj->getPage()); $this->assertNotNull($obj->getPageSize()); $this->assertNotNull($obj->getTotalCountRequired()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param Search $obj */ public function testGetters($obj) { $this->assertEquals($obj->getEmail(), "TestSample"); $this->assertEquals($obj->getRecipientFirstName(), "TestSample"); $this->assertEquals($obj->getRecipientLastName(), "TestSample"); $this->assertEquals($obj->getRecipientBusinessName(), "TestSample"); $this->assertEquals($obj->getNumber(), "TestSample"); $this->assertEquals($obj->getStatus(), "TestSample"); $this->assertEquals($obj->getLowerTotalAmount(), CurrencyTest::getObject()); $this->assertEquals($obj->getUpperTotalAmount(), CurrencyTest::getObject()); $this->assertEquals($obj->getStartInvoiceDate(), "TestSample"); $this->assertEquals($obj->getEndInvoiceDate(), "TestSample"); $this->assertEquals($obj->getStartDueDate(), "TestSample"); $this->assertEquals($obj->getEndDueDate(), "TestSample"); $this->assertEquals($obj->getStartPaymentDate(), "TestSample"); $this->assertEquals($obj->getEndPaymentDate(), "TestSample"); $this->assertEquals($obj->getStartCreationDate(), "TestSample"); $this->assertEquals($obj->getEndCreationDate(), "TestSample"); $this->assertEquals($obj->getPage(), "12.34"); $this->assertEquals($obj->getPageSize(), "12.34"); $this->assertEquals($obj->getTotalCountRequired(), true); } } rest-api-sdk-php/tests/PayPal/Test/Api/PayoutItemTest.php 0000644 00000006423 15007532371 0017275 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\ItemsArray; use PayPal\Api\PayoutItem; use PayPal\Transport\PPRestCall; /** * Class PayoutItem * * @package PayPal\Test\Api */ class PayoutItemTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object PayoutItem * @return string */ public static function getJson() { return '{"recipient_type":"TestSample","amount":' .CurrencyTest::getJson() . ',"note":"TestSample","receiver":"TestSample","sender_item_id":"TestSample"}'; } /** * Gets Object Instance with Json data filled in * @return PayoutItem */ public static function getObject() { return new PayoutItem(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return PayoutItem */ public function testSerializationDeserialization() { $obj = new PayoutItem(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getRecipientType()); $this->assertNotNull($obj->getAmount()); $this->assertNotNull($obj->getNote()); $this->assertNotNull($obj->getReceiver()); $this->assertNotNull($obj->getSenderItemId()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param PayoutItem $obj */ public function testGetters($obj) { $this->assertEquals($obj->getRecipientType(), "TestSample"); $this->assertEquals($obj->getAmount(), CurrencyTest::getObject()); $this->assertEquals($obj->getNote(), "TestSample"); $this->assertEquals($obj->getReceiver(), "TestSample"); $this->assertEquals($obj->getSenderItemId(), "TestSample"); } /** * @dataProvider mockProvider * @param PayoutItem $obj */ public function testGet($obj, $mockApiContext) { $mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPPRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( PayoutItemDetailsTest::getJson() )); $result = $obj->get("payoutItemId", $mockApiContext, $mockPPRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param PayoutItem $obj */ public function testCancel($obj, $mockApiContext) { $mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPPRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( PayoutItemDetailsTest::getJson() )); $result = $obj->cancel("payoutItemId", $mockApiContext, $mockPPRestCall); $this->assertNotNull($result); } public function mockProvider() { $obj = self::getObject(); $mockApiContext = $this->getMockBuilder('ApiContext') ->disableOriginalConstructor() ->getMock(); return array( array($obj, $mockApiContext), array($obj, null) ); } } rest-api-sdk-php/tests/PayPal/Test/Api/ItemListTest.php 0000644 00000003256 15007532371 0016730 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\ItemList; /** * Class ItemList * * @package PayPal\Test\Api */ class ItemListTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object ItemList * * @return string */ public static function getJson() { return '{"items":' . ItemTest::getJson() . ',"shipping_address":' . ShippingAddressTest::getJson() . ',"shipping_method":"TestSample","shipping_phone_number":"TestSample"}'; } /** * Gets Object Instance with Json data filled in * * @return ItemList */ public static function getObject() { return new ItemList(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * * @return ItemList */ public function testSerializationDeserialization() { $obj = new ItemList(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getItems()); $this->assertNotNull($obj->getShippingAddress()); $this->assertNotNull($obj->getShippingMethod()); $this->assertNotNull($obj->getShippingPhoneNumber()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param ItemList $obj */ public function testGetters($obj) { $this->assertEquals($obj->getItems(), ItemTest::getObject()); $this->assertEquals($obj->getShippingAddress(), ShippingAddressTest::getObject()); $this->assertEquals($obj->getShippingMethod(), "TestSample"); $this->assertEquals($obj->getShippingPhoneNumber(), "TestSample"); } } rest-api-sdk-php/tests/PayPal/Test/Api/CreditTest.php 0000644 00000002337 15007532371 0016407 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\Credit; /** * Class Credit * * @package PayPal\Test\Api */ class CreditTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object Credit * * @return string */ public static function getJson() { return '{"id":"TestSample","type":"TestSample"}'; } /** * Gets Object Instance with Json data filled in * * @return Credit */ public static function getObject() { return new Credit(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * * @return Credit */ public function testSerializationDeserialization() { $obj = new Credit(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getId()); $this->assertNotNull($obj->getType()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param Credit $obj */ public function testGetters($obj) { $this->assertEquals($obj->getId(), "TestSample"); $this->assertEquals($obj->getType(), "TestSample"); } } rest-api-sdk-php/tests/PayPal/Test/Api/InvoiceSearchResponseTest.php 0000644 00000002600 15007532371 0021427 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\InvoiceSearchResponse; /** * Class InvoiceSearchResponse * * @package PayPal\Test\Api */ class InvoiceSearchResponseTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object InvoiceSearchResponse * @return string */ public static function getJson() { return '{"total_count":123,"invoices":' .InvoiceTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * @return InvoiceSearchResponse */ public static function getObject() { return new InvoiceSearchResponse(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return InvoiceSearchResponse */ public function testSerializationDeserialization() { $obj = new InvoiceSearchResponse(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getTotalCount()); $this->assertNotNull($obj->getInvoices()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param InvoiceSearchResponse $obj */ public function testGetters($obj) { $this->assertEquals($obj->getTotalCount(), 123); $this->assertEquals($obj->getInvoices(), InvoiceTest::getObject()); } } rest-api-sdk-php/tests/PayPal/Test/Api/CountryCodeTest.php 0000644 00000002224 15007532371 0017426 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\CountryCode; /** * Class CountryCode * * @package PayPal\Test\Api */ class CountryCodeTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object CountryCode * @return string */ public static function getJson() { return '{"country_code":"TestSample"}'; } /** * Gets Object Instance with Json data filled in * @return CountryCode */ public static function getObject() { return new CountryCode(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return CountryCode */ public function testSerializationDeserialization() { $obj = new CountryCode(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getCountryCode()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param CountryCode $obj */ public function testGetters($obj) { $this->assertEquals($obj->getCountryCode(), "TestSample"); } } rest-api-sdk-php/tests/PayPal/Test/Api/OverrideChargeModelTest.php 0000644 00000002566 15007532371 0021053 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\OverrideChargeModel; /** * Class OverrideChargeModel * * @package PayPal\Test\Api */ class OverrideChargeModelTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object OverrideChargeModel * @return string */ public static function getJson() { return '{"charge_id":"TestSample","amount":' .CurrencyTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * @return OverrideChargeModel */ public static function getObject() { return new OverrideChargeModel(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return OverrideChargeModel */ public function testSerializationDeserialization() { $obj = new OverrideChargeModel(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getChargeId()); $this->assertNotNull($obj->getAmount()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param OverrideChargeModel $obj */ public function testGetters($obj) { $this->assertEquals($obj->getChargeId(), "TestSample"); $this->assertEquals($obj->getAmount(), CurrencyTest::getObject()); } } rest-api-sdk-php/tests/PayPal/Test/Api/MerchantPreferencesTest.php 0000644 00000010053 15007532371 0021112 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\MerchantPreferences; /** * Class MerchantPreferences * * @package PayPal\Test\Api */ class MerchantPreferencesTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object MerchantPreferences * @return string */ public static function getJson() { return '{"id":"TestSample","setup_fee":' .CurrencyTest::getJson() . ',"cancel_url":"http://www.google.com","return_url":"http://www.google.com","notify_url":"http://www.google.com","max_fail_attempts":"TestSample","auto_bill_amount":"TestSample","initial_fail_amount_action":"TestSample","accepted_payment_type":"TestSample","char_set":"TestSample"}'; } /** * Gets Object Instance with Json data filled in * @return MerchantPreferences */ public static function getObject() { return new MerchantPreferences(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return MerchantPreferences */ public function testSerializationDeserialization() { $obj = new MerchantPreferences(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getId()); $this->assertNotNull($obj->getSetupFee()); $this->assertNotNull($obj->getCancelUrl()); $this->assertNotNull($obj->getReturnUrl()); $this->assertNotNull($obj->getNotifyUrl()); $this->assertNotNull($obj->getMaxFailAttempts()); $this->assertNotNull($obj->getAutoBillAmount()); $this->assertNotNull($obj->getInitialFailAmountAction()); $this->assertNotNull($obj->getAcceptedPaymentType()); $this->assertNotNull($obj->getCharSet()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param MerchantPreferences $obj */ public function testGetters($obj) { $this->assertEquals($obj->getId(), "TestSample"); $this->assertEquals($obj->getSetupFee(), CurrencyTest::getObject()); $this->assertEquals($obj->getCancelUrl(), "http://www.google.com"); $this->assertEquals($obj->getReturnUrl(), "http://www.google.com"); $this->assertEquals($obj->getNotifyUrl(), "http://www.google.com"); $this->assertEquals($obj->getMaxFailAttempts(), "TestSample"); $this->assertEquals($obj->getAutoBillAmount(), "TestSample"); $this->assertEquals($obj->getInitialFailAmountAction(), "TestSample"); $this->assertEquals($obj->getAcceptedPaymentType(), "TestSample"); $this->assertEquals($obj->getCharSet(), "TestSample"); } /** * @expectedException \InvalidArgumentException * @expectedExceptionMessage CancelUrl is not a fully qualified URL */ public function testUrlValidationForCancelUrl() { $obj = new MerchantPreferences(); $obj->setCancelUrl(null); } /** * @expectedException \InvalidArgumentException * @expectedExceptionMessage ReturnUrl is not a fully qualified URL */ public function testUrlValidationForReturnUrl() { $obj = new MerchantPreferences(); $obj->setReturnUrl(null); } /** * @expectedException \InvalidArgumentException * @expectedExceptionMessage NotifyUrl is not a fully qualified URL */ public function testUrlValidationForNotifyUrl() { $obj = new MerchantPreferences(); $obj->setNotifyUrl(null); } public function testUrlValidationForCancelUrlDeprecated() { $obj = new MerchantPreferences(); $obj->setCancelUrl(null); $this->assertNull($obj->getCancelUrl()); } public function testUrlValidationForReturnUrlDeprecated() { $obj = new MerchantPreferences(); $obj->setReturnUrl(null); $this->assertNull($obj->getReturnUrl()); } public function testUrlValidationForNotifyUrlDeprecated() { $obj = new MerchantPreferences(); $obj->setNotifyUrl(null); $this->assertNull($obj->getNotifyUrl()); } } rest-api-sdk-php/tests/PayPal/Test/Api/PatchRequestTest.php 0000644 00000002152 15007532371 0017600 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\PatchRequest; /** * Class PatchRequest * * @package PayPal\Test\Api */ class PatchRequestTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object PatchRequest * @return string */ public static function getJson() { return '{"patches":' .PatchTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * @return PatchRequest */ public static function getObject() { return new PatchRequest(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return PatchRequest */ public function testSerializationDeserialization() { $obj = new PatchRequest(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getPatches()); return $obj; } /** * @depends testSerializationDeserialization * @param PatchRequest $obj */ public function testGetters($obj) { $this->assertEquals($obj->getPatches(), PatchTest::getObject()); } } rest-api-sdk-php/tests/PayPal/Test/Api/FundingInstrumentTest.php 0000644 00000007072 15007532371 0020661 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\FundingInstrument; /** * Class FundingInstrument * * @package PayPal\Test\Api */ class FundingInstrumentTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object FundingInstrument * * @return string */ public static function getJson() { return '{"credit_card":' . CreditCardTest::getJson() . ',"credit_card_token":' . CreditCardTokenTest::getJson() . ',"payment_card":' . PaymentCardTest::getJson() . ',"bank_account":' . ExtendedBankAccountTest::getJson() . ',"bank_account_token":' . BankTokenTest::getJson() . ',"credit":' . CreditTest::getJson() . ',"incentive":' . IncentiveTest::getJson() . ',"external_funding":' . ExternalFundingTest::getJson() . ',"carrier_account_token":' . CarrierAccountTokenTest::getJson() . ',"carrier_account":' . CarrierAccountTest::getJson() . ',"private_label_card":' . PrivateLabelCardTest::getJson() . ',"billing":' . BillingTest::getJson() . ',"alternate_payment":' . AlternatePaymentTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * * @return FundingInstrument */ public static function getObject() { return new FundingInstrument(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * * @return FundingInstrument */ public function testSerializationDeserialization() { $obj = new FundingInstrument(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getCreditCard()); $this->assertNotNull($obj->getCreditCardToken()); $this->assertNotNull($obj->getPaymentCard()); $this->assertNotNull($obj->getBankAccount()); $this->assertNotNull($obj->getBankAccountToken()); $this->assertNotNull($obj->getCredit()); $this->assertNotNull($obj->getIncentive()); $this->assertNotNull($obj->getExternalFunding()); $this->assertNotNull($obj->getCarrierAccountToken()); $this->assertNotNull($obj->getCarrierAccount()); $this->assertNotNull($obj->getPrivateLabelCard()); $this->assertNotNull($obj->getBilling()); $this->assertNotNull($obj->getAlternatePayment()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param FundingInstrument $obj */ public function testGetters($obj) { $this->assertEquals($obj->getCreditCard(), CreditCardTest::getObject()); $this->assertEquals($obj->getCreditCardToken(), CreditCardTokenTest::getObject()); $this->assertEquals($obj->getPaymentCard(), PaymentCardTest::getObject()); $this->assertEquals($obj->getBankAccount(), ExtendedBankAccountTest::getObject()); $this->assertEquals($obj->getBankAccountToken(), BankTokenTest::getObject()); $this->assertEquals($obj->getCredit(), CreditTest::getObject()); $this->assertEquals($obj->getIncentive(), IncentiveTest::getObject()); $this->assertEquals($obj->getExternalFunding(), ExternalFundingTest::getObject()); $this->assertEquals($obj->getCarrierAccountToken(), CarrierAccountTokenTest::getObject()); $this->assertEquals($obj->getCarrierAccount(), CarrierAccountTest::getObject()); $this->assertEquals($obj->getPrivateLabelCard(), PrivateLabelCardTest::getObject()); $this->assertEquals($obj->getBilling(), BillingTest::getObject()); $this->assertEquals($obj->getAlternatePayment(), AlternatePaymentTest::getObject()); } } rest-api-sdk-php/tests/PayPal/Test/Api/WebProfileTest.php 0000644 00000013243 15007532371 0017231 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\WebProfile; /** * Class WebProfile * * @package PayPal\Test\Api */ class WebProfileTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object WebProfile * @return string */ public static function getJson() { return '{"id":"TestSample","name":"TestSample","flow_config":' .FlowConfigTest::getJson() . ',"input_fields":' .InputFieldsTest::getJson() . ',"presentation":' .PresentationTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * @return WebProfile */ public static function getObject() { return new WebProfile(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return WebProfile */ public function testSerializationDeserialization() { $obj = new WebProfile(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getId()); $this->assertNotNull($obj->getName()); $this->assertNotNull($obj->getFlowConfig()); $this->assertNotNull($obj->getInputFields()); $this->assertNotNull($obj->getPresentation()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param WebProfile $obj */ public function testGetters($obj) { $this->assertEquals($obj->getId(), "TestSample"); $this->assertEquals($obj->getName(), "TestSample"); $this->assertEquals($obj->getFlowConfig(), FlowConfigTest::getObject()); $this->assertEquals($obj->getInputFields(), InputFieldsTest::getObject()); $this->assertEquals($obj->getPresentation(), PresentationTest::getObject()); } /** * @dataProvider mockProvider * @param WebProfile $obj */ public function testCreate($obj, $mockApiContext) { $mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPayPalRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( CreateProfileResponseTest::getJson() )); $result = $obj->create($mockApiContext, $mockPayPalRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param WebProfile $obj */ public function testUpdate($obj, $mockApiContext) { $mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPayPalRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( true )); $result = $obj->update($mockApiContext, $mockPayPalRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param WebProfile $obj */ public function testPartialUpdate($obj, $mockApiContext) { $mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPayPalRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( true )); $patch = array(PatchTest::getObject()); $result = $obj->partial_update($patch, $mockApiContext, $mockPayPalRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param WebProfile $obj */ public function testGet($obj, $mockApiContext) { $mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPayPalRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( WebProfileTest::getJson() )); $result = $obj->get("profileId", $mockApiContext, $mockPayPalRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param WebProfile $obj */ public function testGetList($obj, $mockApiContext) { $mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPayPalRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( json_encode(array(json_decode(WebProfileTest::getJson()))) )); $result = $obj->get_list($mockApiContext, $mockPayPalRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param WebProfile $obj */ public function testDelete($obj, $mockApiContext) { $mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPayPalRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( true )); $result = $obj->delete($mockApiContext, $mockPayPalRestCall); $this->assertNotNull($result); } public function mockProvider() { $obj = self::getObject(); $mockApiContext = $this->getMockBuilder('ApiContext') ->disableOriginalConstructor() ->getMock(); return array( array($obj, $mockApiContext), array($obj, null) ); } } rest-api-sdk-php/tests/PayPal/Test/Api/PresentationTest.php 0000644 00000002721 15007532371 0017645 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\Presentation; /** * Class Presentation * * @package PayPal\Test\Api */ class PresentationTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object Presentation * @return string */ public static function getJson() { return json_encode(json_decode('{"brand_name":"TestSample","logo_image":"TestSample","locale_code":"TestSample"}')); } /** * Gets Object Instance with Json data filled in * @return Presentation */ public static function getObject() { return new Presentation(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return Presentation */ public function testSerializationDeserialization() { $obj = new Presentation(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getBrandName()); $this->assertNotNull($obj->getLogoImage()); $this->assertNotNull($obj->getLocaleCode()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param Presentation $obj */ public function testGetters($obj) { $this->assertEquals($obj->getBrandName(), "TestSample"); $this->assertEquals($obj->getLogoImage(), "TestSample"); $this->assertEquals($obj->getLocaleCode(), "TestSample"); } } rest-api-sdk-php/tests/PayPal/Test/Api/CarrierAccountTokenTest.php 0000644 00000002654 15007532371 0021104 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\CarrierAccountToken; /** * Class CarrierAccountToken * * @package PayPal\Test\Api */ class CarrierAccountTokenTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object CarrierAccountToken * * @return string */ public static function getJson() { return '{"carrier_account_id":"TestSample","external_customer_id":"TestSample"}'; } /** * Gets Object Instance with Json data filled in * * @return CarrierAccountToken */ public static function getObject() { return new CarrierAccountToken(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * * @return CarrierAccountToken */ public function testSerializationDeserialization() { $obj = new CarrierAccountToken(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getCarrierAccountId()); $this->assertNotNull($obj->getExternalCustomerId()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param CarrierAccountToken $obj */ public function testGetters($obj) { $this->assertEquals($obj->getCarrierAccountId(), "TestSample"); $this->assertEquals($obj->getExternalCustomerId(), "TestSample"); } } rest-api-sdk-php/tests/PayPal/Test/Api/PayoutSenderBatchHeaderTest.php 0000644 00000003071 15007532371 0021666 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\PayoutSenderBatchHeader; /** * Class PayoutSenderBatchHeader * * @package PayPal\Test\Api */ class PayoutSenderBatchHeaderTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object PayoutSenderBatchHeader * @return string */ public static function getJson() { return '{"sender_batch_id":"TestSample","email_subject":"TestSample","recipient_type":"TestSample"}'; } /** * Gets Object Instance with Json data filled in * @return PayoutSenderBatchHeader */ public static function getObject() { return new PayoutSenderBatchHeader(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return PayoutSenderBatchHeader */ public function testSerializationDeserialization() { $obj = new PayoutSenderBatchHeader(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getSenderBatchId()); $this->assertNotNull($obj->getEmailSubject()); $this->assertNotNull($obj->getRecipientType()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param PayoutSenderBatchHeader $obj */ public function testGetters($obj) { $this->assertEquals($obj->getSenderBatchId(), "TestSample"); $this->assertEquals($obj->getEmailSubject(), "TestSample"); $this->assertEquals($obj->getRecipientType(), "TestSample"); } } rest-api-sdk-php/tests/PayPal/Test/Api/OpenIdSessionTest.php 0000644 00000006461 15007532371 0017721 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\OpenIdSession; use PayPal\Rest\ApiContext; /** * Test class for OpenIdSession. * */ class OpenIdSessionTest extends \PHPUnit_Framework_TestCase { private $context; /** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { $this->context = new ApiContext(); $this->context->setConfig( array( 'acct1.ClientId' => 'DummyId', 'acct1.ClientSecret' => 'A8VERY8SECRET8VALUE0', 'mode' => 'live' ) ); } /** * Tears down the fixture, for example, closes a network connection. * This method is called after a test is executed. */ protected function tearDown() { } /** * @test */ public function testLoginUrlForMultipleScopes() { $clientId = "AQkquBDf1zctJOWGKWUEtKXm6qVhueUEMvXO_-MCI4DQQ4-LWvkDLIN2fGsd"; $redirectUri = 'https://devtools-paypal.com/'; $scope = array('this', 'that', 'and more'); $expectedBaseUrl = "https://www.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize"; $this->assertEquals($expectedBaseUrl . "?client_id=$clientId&response_type=code&scope=this+that+and+more+openid&redirect_uri=" . urlencode($redirectUri), OpenIdSession::getAuthorizationUrl($redirectUri, $scope, $clientId), "Failed case - custom scope"); $scope = array(); $this->assertEquals($expectedBaseUrl . "?client_id=$clientId&response_type=code&scope=openid+profile+address+email+phone+" . urlencode("https://uri.paypal.com/services/paypalattributes") . "+" . urlencode('https://uri.paypal.com/services/expresscheckout') . "&redirect_uri=" . urlencode($redirectUri), OpenIdSession::getAuthorizationUrl($redirectUri, $scope, $clientId), "Failed case - default scope"); $scope = array('openid'); $this->assertEquals($expectedBaseUrl . "?client_id=$clientId&response_type=code&scope=openid&redirect_uri=" . urlencode($redirectUri), OpenIdSession::getAuthorizationUrl($redirectUri, $scope, $clientId), "Failed case - openid scope"); } /** * @test */ public function testLoginWithCustomConfig() { $redirectUri = 'http://mywebsite.com'; $scope = array('this', 'that', 'and more'); $expectedBaseUrl = "https://www.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize"; $this->assertEquals($expectedBaseUrl . "?client_id=DummyId&response_type=code&scope=this+that+and+more+openid&redirect_uri=" . urlencode($redirectUri), OpenIdSession::getAuthorizationUrl($redirectUri, $scope, "DummyId", null, null, $this->context), "Failed case - custom config"); } /** * @test */ public function testLogoutWithCustomConfig() { $redirectUri = 'http://mywebsite.com'; $idToken = 'abc'; $expectedBaseUrl = "https://www.paypal.com/webapps/auth/protocol/openidconnect/v1/endsession"; $this->assertEquals($expectedBaseUrl . "?id_token=$idToken&redirect_uri=" . urlencode($redirectUri) . "&logout=true", OpenIdSession::getLogoutUrl($redirectUri, $idToken, $this->context), "Failed case - custom config"); } } rest-api-sdk-php/tests/PayPal/Test/Api/ItemTest.php 0000644 00000006652 15007532371 0016077 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\Item; /** * Class Item * * @package PayPal\Test\Api */ class ItemTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object Item * * @return string */ public static function getJson() { return '{"sku":"TestSample","name":"TestSample","description":"TestSample","quantity":"12.34","price":"12.34","currency":"TestSample","tax":"12.34","url":"http://www.google.com","category":"TestSample","weight":' . MeasurementTest::getJson() . ',"length":' . MeasurementTest::getJson() . ',"height":' . MeasurementTest::getJson() . ',"width":' . MeasurementTest::getJson() . ',"supplementary_data":' . NameValuePairTest::getJson() . ',"postback_data":' . NameValuePairTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * * @return Item */ public static function getObject() { return new Item(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * * @return Item */ public function testSerializationDeserialization() { $obj = new Item(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getSku()); $this->assertNotNull($obj->getName()); $this->assertNotNull($obj->getDescription()); $this->assertNotNull($obj->getQuantity()); $this->assertNotNull($obj->getPrice()); $this->assertNotNull($obj->getCurrency()); $this->assertNotNull($obj->getTax()); $this->assertNotNull($obj->getUrl()); $this->assertNotNull($obj->getCategory()); $this->assertNotNull($obj->getWeight()); $this->assertNotNull($obj->getLength()); $this->assertNotNull($obj->getHeight()); $this->assertNotNull($obj->getWidth()); $this->assertNotNull($obj->getSupplementaryData()); $this->assertNotNull($obj->getPostbackData()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param Item $obj */ public function testGetters($obj) { $this->assertEquals($obj->getSku(), "TestSample"); $this->assertEquals($obj->getName(), "TestSample"); $this->assertEquals($obj->getDescription(), "TestSample"); $this->assertEquals($obj->getQuantity(), "12.34"); $this->assertEquals($obj->getPrice(), "12.34"); $this->assertEquals($obj->getCurrency(), "TestSample"); $this->assertEquals($obj->getTax(), "12.34"); $this->assertEquals($obj->getUrl(), "http://www.google.com"); $this->assertEquals($obj->getCategory(), "TestSample"); $this->assertEquals($obj->getWeight(), MeasurementTest::getObject()); $this->assertEquals($obj->getLength(), MeasurementTest::getObject()); $this->assertEquals($obj->getHeight(), MeasurementTest::getObject()); $this->assertEquals($obj->getWidth(), MeasurementTest::getObject()); $this->assertEquals($obj->getSupplementaryData(), NameValuePairTest::getObject()); $this->assertEquals($obj->getPostbackData(), NameValuePairTest::getObject()); } /** * @expectedException \InvalidArgumentException * @expectedExceptionMessage Url is not a fully qualified URL */ public function testUrlValidationForUrl() { $obj = new Item(); $obj->setUrl(null); } } rest-api-sdk-php/tests/PayPal/Test/Api/CreditCardListTest.php 0000644 00000003131 15007532371 0020026 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\CreditCardList; /** * Class CreditCardList * * @package PayPal\Test\Api */ class CreditCardListTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object CreditCardList * @return string */ public static function getJson() { return '{"items":' .CreditCardTest::getJson() . ',"links":' .LinksTest::getJson() . ',"total_items":123,"total_pages":123}'; } /** * Gets Object Instance with Json data filled in * @return CreditCardList */ public static function getObject() { return new CreditCardList(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return CreditCardList */ public function testSerializationDeserialization() { $obj = new CreditCardList(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getItems()); $this->assertNotNull($obj->getLinks()); $this->assertNotNull($obj->getTotalItems()); $this->assertNotNull($obj->getTotalPages()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param CreditCardList $obj */ public function testGetters($obj) { $this->assertEquals($obj->getItems(), CreditCardTest::getObject()); $this->assertEquals($obj->getLinks(), LinksTest::getObject()); $this->assertEquals($obj->getTotalItems(), 123); $this->assertEquals($obj->getTotalPages(), 123); } } rest-api-sdk-php/tests/PayPal/Test/Api/ImageTest.php 0000644 00000002112 15007532371 0016206 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\Image; /** * Class Image * * @package PayPal\Test\Api */ class ImageTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object Patch * @return string */ public static function getJson() { return '{"image":"TestSample"}'; } /** * Gets Object Instance with Json data filled in * @return Image */ public static function getObject() { return new Image(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return Image */ public function testSerializationDeserialization() { $obj = new Image(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getImage()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param Image $obj */ public function testGetters($obj) { $this->assertEquals($obj->getImage(), "TestSample"); } } rest-api-sdk-php/tests/PayPal/Test/Api/OpenIdTokeninfoTest.php 0000644 00000004050 15007532371 0020222 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\OpenIdTokeninfo; /** * Test class for OpenIdTokeninfo. * */ class OpenIdTokeninfoTest extends \PHPUnit_Framework_TestCase { /** @var OpenIdTokeninfo */ public $token; /** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { $this->token = new OpenIdTokeninfo(); $this->token->setAccessToken("Access token") ->setExpiresIn(900) ->setRefreshToken("Refresh token") ->setIdToken("id token") ->setScope("openid address") ->setTokenType("Bearer"); } /** * Tears down the fixture, for example, closes a network connection. * This method is called after a test is executed. */ protected function tearDown() { } /** * @test */ public function testSerializationDeserialization() { $tokenCopy = new OpenIdTokeninfo(); $tokenCopy->fromJson($this->token->toJson()); $this->assertEquals($this->token, $tokenCopy); } /** * @t1est * TODO: Fix Test. This test is disabled */ public function t1estOperations() { $clientId = 'AQkquBDf1zctJOWGKWUEtKXm6qVhueUEMvXO_-MCI4DQQ4-LWvkDLIN2fGsd'; $clientSecret = 'ELtVxAjhT7cJimnz5-Nsx9k2reTKSVfErNQF-CmrwJgxRtylkGTKlU4RvrX'; $params = array( 'code' => '<FILLME>', 'redirect_uri' => 'https://devtools-paypal.com/', 'client_id' => $clientId, 'client_secret' => $clientSecret ); $accessToken = OpenIdTokeninfo::createFromAuthorizationCode($params); $this->assertNotNull($accessToken); $params = array( 'refresh_token' => $accessToken->getRefreshToken(), 'client_id' => $clientId, 'client_secret' => $clientSecret ); $accessToken = $accessToken->createFromRefreshToken($params); $this->assertNotNull($accessToken); } } rest-api-sdk-php/tests/PayPal/Test/Api/ShippingCostTest.php 0000644 00000002474 15007532371 0017611 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\ShippingCost; /** * Class ShippingCost * * @package PayPal\Test\Api */ class ShippingCostTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object ShippingCost * @return string */ public static function getJson() { return '{"amount":' .CurrencyTest::getJson() . ',"tax":' .TaxTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * @return ShippingCost */ public static function getObject() { return new ShippingCost(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return ShippingCost */ public function testSerializationDeserialization() { $obj = new ShippingCost(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getAmount()); $this->assertNotNull($obj->getTax()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param ShippingCost $obj */ public function testGetters($obj) { $this->assertEquals($obj->getAmount(), CurrencyTest::getObject()); $this->assertEquals($obj->getTax(), TaxTest::getObject()); } } rest-api-sdk-php/tests/PayPal/Test/Api/PaymentOptionsTest.php 0000644 00000002744 15007532371 0020170 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\PaymentOptions; /** * Class PaymentOptions * * @package PayPal\Test\Api */ class PaymentOptionsTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object PaymentOptions * * @return string */ public static function getJson() { return '{"allowed_payment_method":"TestSample","recurring_flag":true,"skip_fmf":true}'; } /** * Gets Object Instance with Json data filled in * * @return PaymentOptions */ public static function getObject() { return new PaymentOptions(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * * @return PaymentOptions */ public function testSerializationDeserialization() { $obj = new PaymentOptions(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getAllowedPaymentMethod()); $this->assertNotNull($obj->getRecurringFlag()); $this->assertNotNull($obj->getSkipFmf()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param PaymentOptions $obj */ public function testGetters($obj) { $this->assertEquals($obj->getAllowedPaymentMethod(), "TestSample"); $this->assertEquals($obj->getRecurringFlag(), true); $this->assertEquals($obj->getSkipFmf(), true); } } rest-api-sdk-php/tests/PayPal/Test/Api/CreditFinancingOfferedTest.php 0000644 00000004053 15007532371 0021514 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\CreditFinancingOffered; /** * Class CreditFinancingOffered * * @package PayPal\Test\Api */ class CreditFinancingOfferedTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object CreditFinancingOffered * @return string */ public static function getJson() { return '{"total_cost":' .CurrencyTest::getJson() . ',"term":"12.34","monthly_payment":' .CurrencyTest::getJson() . ',"total_interest":' .CurrencyTest::getJson() . ',"payer_acceptance":true,"cart_amount_immutable":true}'; } /** * Gets Object Instance with Json data filled in * @return CreditFinancingOffered */ public static function getObject() { return new CreditFinancingOffered(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return CreditFinancingOffered */ public function testSerializationDeserialization() { $obj = new CreditFinancingOffered(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getTotalCost()); $this->assertNotNull($obj->getTerm()); $this->assertNotNull($obj->getMonthlyPayment()); $this->assertNotNull($obj->getTotalInterest()); $this->assertNotNull($obj->getPayerAcceptance()); $this->assertNotNull($obj->getCartAmountImmutable()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param CreditFinancingOffered $obj */ public function testGetters($obj) { $this->assertEquals($obj->getTotalCost(), CurrencyTest::getObject()); $this->assertEquals($obj->getTerm(), "12.34"); $this->assertEquals($obj->getMonthlyPayment(), CurrencyTest::getObject()); $this->assertEquals($obj->getTotalInterest(), CurrencyTest::getObject()); $this->assertEquals($obj->getPayerAcceptance(), true); $this->assertEquals($obj->getCartAmountImmutable(), true); } } rest-api-sdk-php/tests/PayPal/Test/Api/ChargeModelTest.php 0000644 00000002633 15007532371 0017346 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\ChargeModel; /** * Class ChargeModel * * @package PayPal\Test\Api */ class ChargeModelTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object ChargeModels * @return string */ public static function getJson() { return '{"id":"TestSample","type":"TestSample","amount":' .CurrencyTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * @return ChargeModel */ public static function getObject() { return new ChargeModel(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return ChargeModel */ public function testSerializationDeserialization() { $obj = new ChargeModel(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getId()); $this->assertNotNull($obj->getType()); $this->assertNotNull($obj->getAmount()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param ChargeModel $obj */ public function testGetters($obj) { $this->assertEquals($obj->getId(), "TestSample"); $this->assertEquals($obj->getType(), "TestSample"); $this->assertEquals($obj->getAmount(), CurrencyTest::getObject()); } } rest-api-sdk-php/tests/PayPal/Test/Api/PayoutTest.php 0000644 00000005776 15007532371 0016470 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\Payout; /** * Class Payout * * @package PayPal\Test\Api */ class PayoutTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object Payout * @return string */ public static function getJson() { return '{"sender_batch_header":' .PayoutSenderBatchHeaderTest::getJson() . ',"items":' .PayoutItemTest::getJson() . ',"links":' .LinksTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * @return Payout */ public static function getObject() { return new Payout(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return Payout */ public function testSerializationDeserialization() { $obj = new Payout(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getSenderBatchHeader()); $this->assertNotNull($obj->getItems()); $this->assertNotNull($obj->getLinks()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param Payout $obj */ public function testGetters($obj) { $this->assertEquals($obj->getSenderBatchHeader(), PayoutSenderBatchHeaderTest::getObject()); $this->assertEquals($obj->getItems(), PayoutItemTest::getObject()); $this->assertEquals($obj->getLinks(), LinksTest::getObject()); } /** * @dataProvider mockProvider * @param Payout $obj */ public function testCreate($obj, $mockApiContext) { $mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPPRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( PayoutBatchTest::getJson() )); $params = array(); $result = $obj->create($params, $mockApiContext, $mockPPRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param Payout $obj */ public function testGet($obj, $mockApiContext) { $mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPPRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( PayoutBatchTest::getJson() )); $result = $obj->get("payoutBatchId", $mockApiContext, $mockPPRestCall); $this->assertNotNull($result); } public function mockProvider() { $obj = self::getObject(); $mockApiContext = $this->getMockBuilder('ApiContext') ->disableOriginalConstructor() ->getMock(); return array( array($obj, $mockApiContext), array($obj, null) ); } } rest-api-sdk-php/tests/PayPal/Test/Api/HyperSchemaTest.php 0000644 00000003525 15007532371 0017405 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\HyperSchema; /** * Class HyperSchema * * @package PayPal\Test\Api */ class HyperSchemaTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object HyperSchema * @return string */ public static function getJson() { return '{"fragmentResolution":"TestSample","readonly":true,"contentEncoding":"TestSample","pathStart":"TestSample","mediaType":"TestSample"}'; } /** * Gets Object Instance with Json data filled in * @return HyperSchema */ public static function getObject() { return new HyperSchema(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return HyperSchema */ public function testSerializationDeserialization() { $obj = new HyperSchema(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getLinks()); $this->assertNotNull($obj->getFragmentResolution()); $this->assertNotNull($obj->getReadonly()); $this->assertNotNull($obj->getContentEncoding()); $this->assertNotNull($obj->getPathStart()); $this->assertNotNull($obj->getMediaType()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param HyperSchema $obj */ public function testGetters($obj) { $this->assertEquals($obj->getLinks(), LinksTest::getObject()); $this->assertEquals($obj->getFragmentResolution(), "TestSample"); $this->assertEquals($obj->getReadonly(), true); $this->assertEquals($obj->getContentEncoding(), "TestSample"); $this->assertEquals($obj->getPathStart(), "TestSample"); $this->assertEquals($obj->getMediaType(), "TestSample"); } } rest-api-sdk-php/tests/PayPal/Test/Api/InvoiceTest.php 0000644 00000031054 15007532371 0016567 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\Invoice; /** * Class Invoice * * @package PayPal\Test\Api */ class InvoiceTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object Invoice * @return string */ public static function getJson() { return '{"id":"TestSample","number":"TestSample","uri":"TestSample","status":"TestSample","merchant_info":' .MerchantInfoTest::getJson() . ',"billing_info":' .BillingInfoTest::getJson() . ',"shipping_info":' .ShippingInfoTest::getJson() . ',"items":' .InvoiceItemTest::getJson() . ',"invoice_date":"TestSample","payment_term":' .PaymentTermTest::getJson() . ',"discount":' .CostTest::getJson() . ',"shipping_cost":' .ShippingCostTest::getJson() . ',"custom":' .CustomAmountTest::getJson() . ',"tax_calculated_after_discount":true,"tax_inclusive":true,"terms":"TestSample","note":"TestSample","merchant_memo":"TestSample","logo_url":"http://www.google.com","total_amount":' .CurrencyTest::getJson() . ',"payments":' .PaymentDetailTest::getJson() . ',"refunds":' .RefundDetailTest::getJson() . ',"metadata":' .MetadataTest::getJson() . ',"additional_data":"TestSample"}'; } /** * Gets Object Instance with Json data filled in * @return Invoice */ public static function getObject() { return new Invoice(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return Invoice */ public function testSerializationDeserialization() { $obj = new Invoice(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getId()); $this->assertNotNull($obj->getNumber()); $this->assertNotNull($obj->getUri()); $this->assertNotNull($obj->getStatus()); $this->assertNotNull($obj->getMerchantInfo()); $this->assertNotNull($obj->getBillingInfo()); $this->assertNotNull($obj->getShippingInfo()); $this->assertNotNull($obj->getItems()); $this->assertNotNull($obj->getInvoiceDate()); $this->assertNotNull($obj->getPaymentTerm()); $this->assertNotNull($obj->getDiscount()); $this->assertNotNull($obj->getShippingCost()); $this->assertNotNull($obj->getCustom()); $this->assertNotNull($obj->getTaxCalculatedAfterDiscount()); $this->assertNotNull($obj->getTaxInclusive()); $this->assertNotNull($obj->getTerms()); $this->assertNotNull($obj->getNote()); $this->assertNotNull($obj->getMerchantMemo()); $this->assertNotNull($obj->getLogoUrl()); $this->assertNotNull($obj->getTotalAmount()); $this->assertNotNull($obj->getPayments()); $this->assertNotNull($obj->getRefunds()); $this->assertNotNull($obj->getMetadata()); $this->assertNotNull($obj->getAdditionalData()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param Invoice $obj */ public function testGetters($obj) { $this->assertEquals($obj->getId(), "TestSample"); $this->assertEquals($obj->getNumber(), "TestSample"); $this->assertEquals($obj->getUri(), "TestSample"); $this->assertEquals($obj->getStatus(), "TestSample"); $this->assertEquals($obj->getMerchantInfo(), MerchantInfoTest::getObject()); $this->assertEquals($obj->getBillingInfo(), BillingInfoTest::getObject()); $this->assertEquals($obj->getShippingInfo(), ShippingInfoTest::getObject()); $this->assertEquals($obj->getItems(), InvoiceItemTest::getObject()); $this->assertEquals($obj->getInvoiceDate(), "TestSample"); $this->assertEquals($obj->getPaymentTerm(), PaymentTermTest::getObject()); $this->assertEquals($obj->getDiscount(), CostTest::getObject()); $this->assertEquals($obj->getShippingCost(), ShippingCostTest::getObject()); $this->assertEquals($obj->getCustom(), CustomAmountTest::getObject()); $this->assertEquals($obj->getTaxCalculatedAfterDiscount(), true); $this->assertEquals($obj->getTaxInclusive(), true); $this->assertEquals($obj->getTerms(), "TestSample"); $this->assertEquals($obj->getNote(), "TestSample"); $this->assertEquals($obj->getMerchantMemo(), "TestSample"); $this->assertEquals($obj->getLogoUrl(), "http://www.google.com"); $this->assertEquals($obj->getTotalAmount(), CurrencyTest::getObject()); $this->assertEquals($obj->getPayments(), PaymentDetailTest::getObject()); $this->assertEquals($obj->getRefunds(), RefundDetailTest::getObject()); $this->assertEquals($obj->getMetadata(), MetadataTest::getObject()); $this->assertEquals($obj->getAdditionalData(), "TestSample"); } /** * @expectedException \InvalidArgumentException * @expectedExceptionMessage LogoUrl is not a fully qualified URL */ public function testUrlValidationForLogoUrl() { $obj = new Invoice(); $obj->setLogoUrl(null); } /** * @dataProvider mockProvider * @param Invoice $obj */ public function testCreate($obj, $mockApiContext) { $mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPayPalRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( self::getJson() )); $result = $obj->create($mockApiContext, $mockPayPalRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param Invoice $obj */ public function testSearch($obj, $mockApiContext) { $mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPayPalRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( InvoiceSearchResponseTest::getJson() )); $search = SearchTest::getObject(); $result = $obj->search($search, $mockApiContext, $mockPayPalRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param Invoice $obj */ public function testSend($obj, $mockApiContext) { $mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPayPalRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( true )); $result = $obj->send($mockApiContext, $mockPayPalRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param Invoice $obj */ public function testRemind($obj, $mockApiContext) { $mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPayPalRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( true )); $notification = NotificationTest::getObject(); $result = $obj->remind($notification, $mockApiContext, $mockPayPalRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param Invoice $obj */ public function testCancel($obj, $mockApiContext) { $mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPayPalRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( true )); $cancelNotification = CancelNotificationTest::getObject(); $result = $obj->cancel($cancelNotification, $mockApiContext, $mockPayPalRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param Invoice $obj */ public function testRecordPayment($obj, $mockApiContext) { $mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPayPalRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( true )); $paymentDetail = PaymentDetailTest::getObject(); $result = $obj->recordPayment($paymentDetail, $mockApiContext, $mockPayPalRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param Invoice $obj */ public function testRecordRefund($obj, $mockApiContext) { $mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPayPalRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( true )); $refundDetail = RefundDetailTest::getObject(); $result = $obj->recordRefund($refundDetail, $mockApiContext, $mockPayPalRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param Invoice $obj */ public function testGet($obj, $mockApiContext) { $mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPayPalRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( InvoiceTest::getJson() )); $result = $obj->get("invoiceId", $mockApiContext, $mockPayPalRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param Invoice $obj */ public function testGetAll($obj, $mockApiContext) { $mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPayPalRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( InvoiceSearchResponseTest::getJson() )); $result = $obj->getAll(array(), $mockApiContext, $mockPayPalRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param Invoice $obj */ public function testUpdate($obj, $mockApiContext) { $mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPayPalRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( self::getJson() )); $result = $obj->update($mockApiContext, $mockPayPalRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param Invoice $obj */ public function testDelete($obj, $mockApiContext) { $mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPayPalRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( true )); $result = $obj->delete($mockApiContext, $mockPayPalRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param Invoice $obj */ public function testQrCode($obj, $mockApiContext) { $mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPayPalRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( ImageTest::getJson() )); $result = $obj->qrCode("invoiceId", array(), $mockApiContext, $mockPayPalRestCall); $this->assertNotNull($result); } public function mockProvider() { $obj = self::getObject(); $mockApiContext = $this->getMockBuilder('ApiContext') ->disableOriginalConstructor() ->getMock(); return array( array($obj, $mockApiContext), array($obj, null) ); } } rest-api-sdk-php/tests/PayPal/Test/Api/BillingInfoTest.php 0000644 00000004527 15007532371 0017374 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\BillingInfo; /** * Class BillingInfo * * @package PayPal\Test\Api */ class BillingInfoTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object BillingInfo * @return string */ public static function getJson() { return '{"email":"TestSample","first_name":"TestSample","last_name":"TestSample","business_name":"TestSample","address":' .InvoiceAddressTest::getJson() . ',"language":"TestSample","additional_info":"TestSample","notification_channel":"TestSample","phone":' .PhoneTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * @return BillingInfo */ public static function getObject() { return new BillingInfo(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return BillingInfo */ public function testSerializationDeserialization() { $obj = new BillingInfo(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getEmail()); $this->assertNotNull($obj->getFirstName()); $this->assertNotNull($obj->getLastName()); $this->assertNotNull($obj->getBusinessName()); $this->assertNotNull($obj->getAddress()); $this->assertNotNull($obj->getLanguage()); $this->assertNotNull($obj->getAdditionalInfo()); $this->assertNotNull($obj->getNotificationChannel()); $this->assertNotNull($obj->getPhone()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param BillingInfo $obj */ public function testGetters($obj) { $this->assertEquals($obj->getEmail(), "TestSample"); $this->assertEquals($obj->getFirstName(), "TestSample"); $this->assertEquals($obj->getLastName(), "TestSample"); $this->assertEquals($obj->getBusinessName(), "TestSample"); $this->assertEquals($obj->getAddress(), InvoiceAddressTest::getObject()); $this->assertEquals($obj->getLanguage(), "TestSample"); $this->assertEquals($obj->getAdditionalInfo(), "TestSample"); $this->assertEquals($obj->getNotificationChannel(), "TestSample"); $this->assertEquals($obj->getPhone(), PhoneTest::getObject()); } } rest-api-sdk-php/tests/PayPal/Test/Api/PaymentCardTest.php 0000644 00000006634 15007532371 0017410 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\PaymentCard; /** * Class PaymentCard * * @package PayPal\Test\Api */ class PaymentCardTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object PaymentCard * * @return string */ public static function getJson() { return '{"id":"TestSample","number":"TestSample","type":"TestSample","expire_month":123,"expire_year":123,"start_month":"TestSample","start_year":"TestSample","cvv2":"TestSample","first_name":"TestSample","last_name":"TestSample","billing_country":"TestSample","billing_address":' . AddressTest::getJson() . ',"external_customer_id":"TestSample","status":"TestSample","valid_until":"TestSample","issue_number":"TestSample","links":' . LinksTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * * @return PaymentCard */ public static function getObject() { return new PaymentCard(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * * @return PaymentCard */ public function testSerializationDeserialization() { $obj = new PaymentCard(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getId()); $this->assertNotNull($obj->getNumber()); $this->assertNotNull($obj->getType()); $this->assertNotNull($obj->getExpireMonth()); $this->assertNotNull($obj->getExpireYear()); $this->assertNotNull($obj->getStartMonth()); $this->assertNotNull($obj->getStartYear()); $this->assertNotNull($obj->getCvv2()); $this->assertNotNull($obj->getFirstName()); $this->assertNotNull($obj->getLastName()); $this->assertNotNull($obj->getBillingCountry()); $this->assertNotNull($obj->getBillingAddress()); $this->assertNotNull($obj->getExternalCustomerId()); $this->assertNotNull($obj->getStatus()); $this->assertNotNull($obj->getValidUntil()); $this->assertNotNull($obj->getIssueNumber()); $this->assertNotNull($obj->getLinks()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param PaymentCard $obj */ public function testGetters($obj) { $this->assertEquals($obj->getId(), "TestSample"); $this->assertEquals($obj->getNumber(), "TestSample"); $this->assertEquals($obj->getType(), "TestSample"); $this->assertEquals($obj->getExpireMonth(), 123); $this->assertEquals($obj->getExpireYear(), 123); $this->assertEquals($obj->getStartMonth(), "TestSample"); $this->assertEquals($obj->getStartYear(), "TestSample"); $this->assertEquals($obj->getCvv2(), "TestSample"); $this->assertEquals($obj->getFirstName(), "TestSample"); $this->assertEquals($obj->getLastName(), "TestSample"); $this->assertEquals($obj->getBillingCountry(), "TestSample"); $this->assertEquals($obj->getBillingAddress(), AddressTest::getObject()); $this->assertEquals($obj->getExternalCustomerId(), "TestSample"); $this->assertEquals($obj->getStatus(), "TestSample"); $this->assertEquals($obj->getValidUntil(), "TestSample"); $this->assertEquals($obj->getIssueNumber(), "TestSample"); $this->assertEquals($obj->getLinks(), LinksTest::getObject()); } } rest-api-sdk-php/tests/PayPal/Test/Api/PayoutBatchTest.php 0000644 00000002567 15007532371 0017425 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\PayoutBatch; /** * Class PayoutBatch * * @package PayPal\Test\Api */ class PayoutBatchTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object PayoutBatch * @return string */ public static function getJson() { return '{"batch_header":' .PayoutBatchHeaderTest::getJson() . ',"items":' .PayoutItemDetailsTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * @return PayoutBatch */ public static function getObject() { return new PayoutBatch(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return PayoutBatch */ public function testSerializationDeserialization() { $obj = new PayoutBatch(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getBatchHeader()); $this->assertNotNull($obj->getItems()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param PayoutBatch $obj */ public function testGetters($obj) { $this->assertEquals($obj->getBatchHeader(), PayoutBatchHeaderTest::getObject()); $this->assertEquals($obj->getItems(), PayoutItemDetailsTest::getObject()); } } rest-api-sdk-php/tests/PayPal/Test/Api/CreditCardTest.php 0000644 00000005474 15007532371 0017206 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\CreditCard; /** * Class CreditCard * * @package PayPal\Test\Api */ class CreditCardTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object CreditCard * * @return string */ public static function getJson() { return '{"id":"TestSample","number":"TestSample","type":"TestSample","expire_month":123,"expire_year":123,"cvv2":"TestSample","first_name":"TestSample","last_name":"TestSample","billing_address":' . AddressTest::getJson() . ',"external_customer_id":"TestSample","state":"TestSample","valid_until":"TestSample","links":' . LinksTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * * @return CreditCard */ public static function getObject() { return new CreditCard(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * * @return CreditCard */ public function testSerializationDeserialization() { $obj = new CreditCard(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getId()); $this->assertNotNull($obj->getNumber()); $this->assertNotNull($obj->getType()); $this->assertNotNull($obj->getExpireMonth()); $this->assertNotNull($obj->getExpireYear()); $this->assertNotNull($obj->getCvv2()); $this->assertNotNull($obj->getFirstName()); $this->assertNotNull($obj->getLastName()); $this->assertNotNull($obj->getBillingAddress()); $this->assertNotNull($obj->getExternalCustomerId()); $this->assertNotNull($obj->getState()); $this->assertNotNull($obj->getValidUntil()); $this->assertNotNull($obj->getLinks()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param CreditCard $obj */ public function testGetters($obj) { $this->assertEquals($obj->getId(), "TestSample"); $this->assertEquals($obj->getNumber(), "TestSample"); $this->assertEquals($obj->getType(), "TestSample"); $this->assertEquals($obj->getExpireMonth(), 123); $this->assertEquals($obj->getExpireYear(), 123); $this->assertEquals($obj->getCvv2(), "TestSample"); $this->assertEquals($obj->getFirstName(), "TestSample"); $this->assertEquals($obj->getLastName(), "TestSample"); $this->assertEquals($obj->getBillingAddress(), AddressTest::getObject()); $this->assertEquals($obj->getExternalCustomerId(), "TestSample"); $this->assertEquals($obj->getState(), "TestSample"); $this->assertEquals($obj->getValidUntil(), "TestSample"); $this->assertEquals($obj->getLinks(), LinksTest::getObject()); } } rest-api-sdk-php/tests/PayPal/Test/Api/ShippingAddressTest.php 0000644 00000002732 15007532371 0020263 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\ShippingAddress; /** * Class ShippingAddress * * @package PayPal\Test\Api */ class ShippingAddressTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object ShippingAddress * * @return string */ public static function getJson() { return '{"id":"TestSample","recipient_name":"TestSample","default_address":true}'; } /** * Gets Object Instance with Json data filled in * * @return ShippingAddress */ public static function getObject() { return new ShippingAddress(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * * @return ShippingAddress */ public function testSerializationDeserialization() { $obj = new ShippingAddress(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getId()); $this->assertNotNull($obj->getRecipientName()); $this->assertNotNull($obj->getDefaultAddress()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param ShippingAddress $obj */ public function testGetters($obj) { $this->assertEquals($obj->getId(), "TestSample"); $this->assertEquals($obj->getRecipientName(), "TestSample"); $this->assertEquals($obj->getDefaultAddress(), true); } } rest-api-sdk-php/tests/PayPal/Test/Api/InstallmentInfoTest.php 0000644 00000003274 15007532371 0020304 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\InstallmentInfo; /** * Class InstallmentInfo * * @package PayPal\Test\Api */ class InstallmentInfoTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object InstallmentInfo * * @return string */ public static function getJson() { return '{"installment_id":"TestSample","network":"TestSample","issuer":"TestSample","installment_options":' . InstallmentOptionTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * * @return InstallmentInfo */ public static function getObject() { return new InstallmentInfo(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * * @return InstallmentInfo */ public function testSerializationDeserialization() { $obj = new InstallmentInfo(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getInstallmentId()); $this->assertNotNull($obj->getNetwork()); $this->assertNotNull($obj->getIssuer()); $this->assertNotNull($obj->getInstallmentOptions()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param InstallmentInfo $obj */ public function testGetters($obj) { $this->assertEquals($obj->getInstallmentId(), "TestSample"); $this->assertEquals($obj->getNetwork(), "TestSample"); $this->assertEquals($obj->getIssuer(), "TestSample"); $this->assertEquals($obj->getInstallmentOptions(), InstallmentOptionTest::getObject()); } } rest-api-sdk-php/tests/PayPal/Test/Api/TaxTest.php 0000644 00000002720 15007532371 0015725 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\Tax; /** * Class Tax * * @package PayPal\Test\Api */ class TaxTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object Tax * @return string */ public static function getJson() { return '{"id":"TestSample","name":"TestSample","percent":"12.34","amount":' .CurrencyTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * @return Tax */ public static function getObject() { return new Tax(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return Tax */ public function testSerializationDeserialization() { $obj = new Tax(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getId()); $this->assertNotNull($obj->getName()); $this->assertNotNull($obj->getPercent()); $this->assertNotNull($obj->getAmount()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param Tax $obj */ public function testGetters($obj) { $this->assertEquals($obj->getId(), "TestSample"); $this->assertEquals($obj->getName(), "TestSample"); $this->assertEquals($obj->getPercent(), "12.34"); $this->assertEquals($obj->getAmount(), CurrencyTest::getObject()); } } rest-api-sdk-php/tests/PayPal/Test/Api/WebhookEventTypeTest.php 0000644 00000005624 15007532371 0020441 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\WebhookEventType; /** * Class WebhookEventType * * @package PayPal\Test\Api */ class WebhookEventTypeTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object WebhookEventType * @return string */ public static function getJson() { return '{"name":"TestSample","description":"TestSample"}'; } /** * Gets Object Instance with Json data filled in * @return WebhookEventType */ public static function getObject() { return new WebhookEventType(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return WebhookEventType */ public function testSerializationDeserialization() { $obj = new WebhookEventType(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getName()); $this->assertNotNull($obj->getDescription()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param WebhookEventType $obj */ public function testGetters($obj) { $this->assertEquals($obj->getName(), "TestSample"); $this->assertEquals($obj->getDescription(), "TestSample"); } /** * @dataProvider mockProvider * @param WebhookEventType $obj */ public function testSubscribedEventTypes($obj, $mockApiContext) { $mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPayPalRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( WebhookEventTypeListTest::getJson() )); $result = $obj->subscribedEventTypes("webhookId", $mockApiContext, $mockPayPalRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param WebhookEventType $obj */ public function testAvailableEventTypes($obj, $mockApiContext) { $mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPayPalRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( WebhookEventTypeListTest::getJson() )); $result = $obj->availableEventTypes($mockApiContext, $mockPayPalRestCall); $this->assertNotNull($result); } public function mockProvider() { $obj = self::getObject(); $mockApiContext = $this->getMockBuilder('ApiContext') ->disableOriginalConstructor() ->getMock(); return array( array($obj, $mockApiContext), array($obj, null) ); } } rest-api-sdk-php/tests/PayPal/Test/Api/AgreementStateDescriptorTest.php 0000644 00000002626 15007532371 0022145 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\AgreementStateDescriptor; /** * Class AgreementStateDescriptor * * @package PayPal\Test\Api */ class AgreementStateDescriptorTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object AgreementStateDescriptor * @return string */ public static function getJson() { return '{"note":"TestSample","amount":' .CurrencyTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * @return AgreementStateDescriptor */ public static function getObject() { return new AgreementStateDescriptor(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return AgreementStateDescriptor */ public function testSerializationDeserialization() { $obj = new AgreementStateDescriptor(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getNote()); $this->assertNotNull($obj->getAmount()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param AgreementStateDescriptor $obj */ public function testGetters($obj) { $this->assertEquals($obj->getNote(), "TestSample"); $this->assertEquals($obj->getAmount(), CurrencyTest::getObject()); } } rest-api-sdk-php/tests/PayPal/Test/Api/AuthorizationTest.php 0000644 00000013522 15007532371 0020033 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\Authorization; use PayPal\Transport\PPRestCall; /** * Class Authorization * * @package PayPal\Test\Api */ class AuthorizationTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object Authorization * * @return string */ public static function getJson() { return '{"id":"TestSample","amount":' . AmountTest::getJson() . ',"payment_mode":"TestSample","state":"TestSample","reason_code":"TestSample","pending_reason":"TestSample","protection_eligibility":"TestSample","protection_eligibility_type":"TestSample","fmf_details":' . FmfDetailsTest::getJson() . ',"parent_payment":"TestSample","valid_until":"TestSample","create_time":"TestSample","update_time":"TestSample","links":' . LinksTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * * @return Authorization */ public static function getObject() { return new Authorization(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * * @return Authorization */ public function testSerializationDeserialization() { $obj = new Authorization(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getId()); $this->assertNotNull($obj->getAmount()); $this->assertNotNull($obj->getPaymentMode()); $this->assertNotNull($obj->getState()); $this->assertNotNull($obj->getReasonCode()); $this->assertNotNull($obj->getPendingReason()); $this->assertNotNull($obj->getProtectionEligibility()); $this->assertNotNull($obj->getProtectionEligibilityType()); $this->assertNotNull($obj->getFmfDetails()); $this->assertNotNull($obj->getParentPayment()); $this->assertNotNull($obj->getValidUntil()); $this->assertNotNull($obj->getCreateTime()); $this->assertNotNull($obj->getUpdateTime()); $this->assertNotNull($obj->getLinks()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param Authorization $obj */ public function testGetters($obj) { $this->assertEquals($obj->getId(), "TestSample"); $this->assertEquals($obj->getAmount(), AmountTest::getObject()); $this->assertEquals($obj->getPaymentMode(), "TestSample"); $this->assertEquals($obj->getState(), "TestSample"); $this->assertEquals($obj->getReasonCode(), "TestSample"); $this->assertEquals($obj->getPendingReason(), "TestSample"); $this->assertEquals($obj->getProtectionEligibility(), "TestSample"); $this->assertEquals($obj->getProtectionEligibilityType(), "TestSample"); $this->assertEquals($obj->getFmfDetails(), FmfDetailsTest::getObject()); $this->assertEquals($obj->getParentPayment(), "TestSample"); $this->assertEquals($obj->getValidUntil(), "TestSample"); $this->assertEquals($obj->getCreateTime(), "TestSample"); $this->assertEquals($obj->getUpdateTime(), "TestSample"); $this->assertEquals($obj->getLinks(), LinksTest::getObject()); } /** * @dataProvider mockProvider * @param Authorization $obj */ public function testGet($obj, $mockApiContext) { $mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPPRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( AuthorizationTest::getJson() )); $result = $obj->get("authorizationId", $mockApiContext, $mockPPRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param Authorization $obj */ public function testCapture($obj, $mockApiContext) { $mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPPRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( CaptureTest::getJson() )); $capture = CaptureTest::getObject(); $result = $obj->capture($capture, $mockApiContext, $mockPPRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param Authorization $obj */ public function testVoid($obj, $mockApiContext) { $mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPPRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( self::getJson() )); $result = $obj->void($mockApiContext, $mockPPRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param Authorization $obj */ public function testReauthorize($obj, $mockApiContext) { $mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPPRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( self::getJson() )); $result = $obj->reauthorize($mockApiContext, $mockPPRestCall); $this->assertNotNull($result); } public function mockProvider() { $obj = self::getObject(); $mockApiContext = $this->getMockBuilder('ApiContext') ->disableOriginalConstructor() ->getMock(); return array( array($obj, $mockApiContext), array($obj, null) ); } } rest-api-sdk-php/tests/PayPal/Test/Api/AddressTest.php 0000644 00000004320 15007532371 0016554 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\Address; /** * Class Address * * @package PayPal\Test\Api */ class AddressTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object Address * * @return string */ public static function getJson() { return '{"line1":"TestSample","line2":"TestSample","city":"TestSample","country_code":"TestSample","postal_code":"TestSample","state":"TestSample","phone":"TestSample","normalization_status":"TestSample","status":"TestSample"}'; } /** * Gets Object Instance with Json data filled in * * @return Address */ public static function getObject() { return new Address(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * * @return Address */ public function testSerializationDeserialization() { $obj = new Address(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getLine1()); $this->assertNotNull($obj->getLine2()); $this->assertNotNull($obj->getCity()); $this->assertNotNull($obj->getCountryCode()); $this->assertNotNull($obj->getPostalCode()); $this->assertNotNull($obj->getState()); $this->assertNotNull($obj->getPhone()); $this->assertNotNull($obj->getNormalizationStatus()); $this->assertNotNull($obj->getStatus()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param Address $obj */ public function testGetters($obj) { $this->assertEquals($obj->getLine1(), "TestSample"); $this->assertEquals($obj->getLine2(), "TestSample"); $this->assertEquals($obj->getCity(), "TestSample"); $this->assertEquals($obj->getCountryCode(), "TestSample"); $this->assertEquals($obj->getPostalCode(), "TestSample"); $this->assertEquals($obj->getState(), "TestSample"); $this->assertEquals($obj->getPhone(), "TestSample"); $this->assertEquals($obj->getNormalizationStatus(), "TestSample"); $this->assertEquals($obj->getStatus(), "TestSample"); } } rest-api-sdk-php/tests/PayPal/Test/Api/CustomAmountTest.php 0000644 00000002455 15007532371 0017634 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\CustomAmount; /** * Class CustomAmount * * @package PayPal\Test\Api */ class CustomAmountTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object CustomAmount * @return string */ public static function getJson() { return '{"label":"TestSample","amount":' .CurrencyTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * @return CustomAmount */ public static function getObject() { return new CustomAmount(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return CustomAmount */ public function testSerializationDeserialization() { $obj = new CustomAmount(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getLabel()); $this->assertNotNull($obj->getAmount()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param CustomAmount $obj */ public function testGetters($obj) { $this->assertEquals($obj->getLabel(), "TestSample"); $this->assertEquals($obj->getAmount(), CurrencyTest::getObject()); } } rest-api-sdk-php/tests/PayPal/Test/Api/CarrierAccountTest.php 0000644 00000003442 15007532371 0020077 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\CarrierAccount; /** * Class CarrierAccount * * @package PayPal\Test\Api */ class CarrierAccountTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object CarrierAccount * @return string */ public static function getJson() { return '{"id":"TestSample","phone_number":"TestSample","external_customer_id":"TestSample","phone_source":"TestSample","country_code":' .CountryCodeTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * @return CarrierAccount */ public static function getObject() { return new CarrierAccount(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return CarrierAccount */ public function testSerializationDeserialization() { $obj = new CarrierAccount(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getId()); $this->assertNotNull($obj->getPhoneNumber()); $this->assertNotNull($obj->getExternalCustomerId()); $this->assertNotNull($obj->getPhoneSource()); $this->assertNotNull($obj->getCountryCode()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param CarrierAccount $obj */ public function testGetters($obj) { $this->assertEquals($obj->getId(), "TestSample"); $this->assertEquals($obj->getPhoneNumber(), "TestSample"); $this->assertEquals($obj->getExternalCustomerId(), "TestSample"); $this->assertEquals($obj->getPhoneSource(), "TestSample"); $this->assertEquals($obj->getCountryCode(), CountryCodeTest::getObject()); } } rest-api-sdk-php/tests/PayPal/Test/Api/OrderTest.php 0000644 00000013507 15007532371 0016251 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\Authorization; use PayPal\Api\Order; /** * Class Order * * @package PayPal\Test\Api */ class OrderTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object Order * * @return string */ public static function getJson() { return '{"id":"TestSample","purchase_unit_reference_id":"TestSample","amount":' . AmountTest::getJson() . ',"payment_mode":"TestSample","state":"TestSample","reason_code":"TestSample","pending_reason":"TestSample","protection_eligibility":"TestSample","protection_eligibility_type":"TestSample","parent_payment":"TestSample","fmf_details":' . FmfDetailsTest::getJson() . ',"create_time":"TestSample","update_time":"TestSample","links":' . LinksTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * * @return Order */ public static function getObject() { return new Order(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * * @return Order */ public function testSerializationDeserialization() { $obj = new Order(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getId()); $this->assertNotNull($obj->getPurchaseUnitReferenceId()); $this->assertNotNull($obj->getAmount()); $this->assertNotNull($obj->getPaymentMode()); $this->assertNotNull($obj->getState()); $this->assertNotNull($obj->getReasonCode()); $this->assertNotNull($obj->getPendingReason()); $this->assertNotNull($obj->getProtectionEligibility()); $this->assertNotNull($obj->getProtectionEligibilityType()); $this->assertNotNull($obj->getParentPayment()); $this->assertNotNull($obj->getFmfDetails()); $this->assertNotNull($obj->getCreateTime()); $this->assertNotNull($obj->getUpdateTime()); $this->assertNotNull($obj->getLinks()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param Order $obj */ public function testGetters($obj) { $this->assertEquals($obj->getId(), "TestSample"); $this->assertEquals($obj->getPurchaseUnitReferenceId(), "TestSample"); $this->assertEquals($obj->getAmount(), AmountTest::getObject()); $this->assertEquals($obj->getPaymentMode(), "TestSample"); $this->assertEquals($obj->getState(), "TestSample"); $this->assertEquals($obj->getReasonCode(), "TestSample"); $this->assertEquals($obj->getPendingReason(), "TestSample"); $this->assertEquals($obj->getProtectionEligibility(), "TestSample"); $this->assertEquals($obj->getProtectionEligibilityType(), "TestSample"); $this->assertEquals($obj->getParentPayment(), "TestSample"); $this->assertEquals($obj->getFmfDetails(), FmfDetailsTest::getObject()); $this->assertEquals($obj->getCreateTime(), "TestSample"); $this->assertEquals($obj->getUpdateTime(), "TestSample"); $this->assertEquals($obj->getLinks(), LinksTest::getObject()); } /** * @dataProvider mockProvider * @param Order $obj */ public function testGet($obj, $mockApiContext) { $mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPPRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( OrderTest::getJson() )); $result = $obj->get("orderId", $mockApiContext, $mockPPRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param Order $obj */ public function testCapture($obj, $mockApiContext) { $mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPPRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( CaptureTest::getJson() )); $capture = CaptureTest::getObject(); $result = $obj->capture($capture, $mockApiContext, $mockPPRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param Order $obj */ public function testVoid($obj, $mockApiContext) { $mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPPRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( self::getJson() )); $result = $obj->void($mockApiContext, $mockPPRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param Order $obj */ public function testAuthorize($obj, $mockApiContext) { $mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPPRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( AuthorizationTest::getJson() )); $authorization = new Authorization(); $result = $obj->authorize($authorization, $mockApiContext, $mockPPRestCall); $this->assertNotNull($result); } public function mockProvider() { $obj = self::getObject(); $mockApiContext = $this->getMockBuilder('ApiContext') ->disableOriginalConstructor() ->getMock(); return array( array($obj, $mockApiContext), array($obj, null) ); } } rest-api-sdk-php/tests/PayPal/Test/Api/CurrencyTest.php 0000644 00000002374 15007532371 0016770 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\Currency; /** * Class Currency * * @package PayPal\Test\Api */ class CurrencyTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object Currency * * @return string */ public static function getJson() { return '{"currency":"TestSample","value":"12.34"}'; } /** * Gets Object Instance with Json data filled in * * @return Currency */ public static function getObject() { return new Currency(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * * @return Currency */ public function testSerializationDeserialization() { $obj = new Currency(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getCurrency()); $this->assertNotNull($obj->getValue()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param Currency $obj */ public function testGetters($obj) { $this->assertEquals($obj->getCurrency(), "TestSample"); $this->assertEquals($obj->getValue(), "12.34"); } } rest-api-sdk-php/tests/PayPal/Test/Api/BankTokenTest.php 0000644 00000002752 15007532371 0017052 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\BankToken; /** * Class BankToken * * @package PayPal\Test\Api */ class BankTokenTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object BankToken * * @return string */ public static function getJson() { return '{"bank_id":"TestSample","external_customer_id":"TestSample","mandate_reference_number":"TestSample"}'; } /** * Gets Object Instance with Json data filled in * * @return BankToken */ public static function getObject() { return new BankToken(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * * @return BankToken */ public function testSerializationDeserialization() { $obj = new BankToken(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getBankId()); $this->assertNotNull($obj->getExternalCustomerId()); $this->assertNotNull($obj->getMandateReferenceNumber()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param BankToken $obj */ public function testGetters($obj) { $this->assertEquals($obj->getBankId(), "TestSample"); $this->assertEquals($obj->getExternalCustomerId(), "TestSample"); $this->assertEquals($obj->getMandateReferenceNumber(), "TestSample"); } } rest-api-sdk-php/tests/PayPal/Test/Api/WebhookTest.php 0000644 00000012105 15007532371 0016565 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\Webhook; /** * Class Webhook * * @package PayPal\Test\Api */ class WebhookTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object Webhook * @return string */ public static function getJson() { return '{"id":"TestSample","url":"http://www.google.com","event_types":' .WebhookEventTypeTest::getJson() . ',"links":' .LinksTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * @return Webhook */ public static function getObject() { return new Webhook(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return Webhook */ public function testSerializationDeserialization() { $obj = new Webhook(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getId()); $this->assertNotNull($obj->getUrl()); $this->assertNotNull($obj->getEventTypes()); $this->assertNotNull($obj->getLinks()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param Webhook $obj */ public function testGetters($obj) { $this->assertEquals($obj->getId(), "TestSample"); $this->assertEquals($obj->getUrl(), "http://www.google.com"); $this->assertEquals($obj->getEventTypes(), WebhookEventTypeTest::getObject()); $this->assertEquals($obj->getLinks(), LinksTest::getObject()); } /** * @expectedException \InvalidArgumentException * @expectedExceptionMessage Url is not a fully qualified URL */ public function testUrlValidationForUrl() { $obj = new Webhook(); $obj->setUrl(null); } /** * @dataProvider mockProvider * @param Webhook $obj */ public function testCreate($obj, $mockApiContext) { $mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPayPalRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( self::getJson() )); $result = $obj->create($mockApiContext, $mockPayPalRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param Webhook $obj */ public function testGet($obj, $mockApiContext) { $mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPayPalRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( WebhookTest::getJson() )); $result = $obj->get("webhookId", $mockApiContext, $mockPayPalRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param Webhook $obj */ public function testGetAll($obj, $mockApiContext) { $mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPayPalRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( WebhookListTest::getJson() )); $result = $obj->getAll($mockApiContext, $mockPayPalRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param Webhook $obj */ public function testUpdate($obj, $mockApiContext) { $mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPayPalRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( self::getJson() )); $patchRequest = PatchRequestTest::getObject(); $result = $obj->update($patchRequest, $mockApiContext, $mockPayPalRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param Webhook $obj */ public function testDelete($obj, $mockApiContext) { $mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPayPalRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( true )); $result = $obj->delete($mockApiContext, $mockPayPalRestCall); $this->assertNotNull($result); } public function mockProvider() { $obj = self::getObject(); $mockApiContext = $this->getMockBuilder('ApiContext') ->disableOriginalConstructor() ->getMock(); return array( array($obj, $mockApiContext), array($obj, null) ); } } rest-api-sdk-php/tests/PayPal/Test/Api/AgreementTransactionTest.php 0000644 00000005114 15007532371 0021306 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\AgreementTransaction; /** * Class AgreementTransaction * * @package PayPal\Test\Api */ class AgreementTransactionTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object AgreementTransaction * @return string */ public static function getJson() { return '{"transaction_id":"TestSample","status":"TestSample","transaction_type":"TestSample","amount":' .CurrencyTest::getJson() . ',"fee_amount":' .CurrencyTest::getJson() . ',"net_amount":' .CurrencyTest::getJson() . ',"payer_email":"TestSample","payer_name":"TestSample","time_stamp":"TestSample","time_zone":"TestSample"}'; } /** * Gets Object Instance with Json data filled in * @return AgreementTransaction */ public static function getObject() { return new AgreementTransaction(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return AgreementTransaction */ public function testSerializationDeserialization() { $obj = new AgreementTransaction(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getTransactionId()); $this->assertNotNull($obj->getStatus()); $this->assertNotNull($obj->getTransactionType()); $this->assertNotNull($obj->getAmount()); $this->assertNotNull($obj->getFeeAmount()); $this->assertNotNull($obj->getNetAmount()); $this->assertNotNull($obj->getPayerEmail()); $this->assertNotNull($obj->getPayerName()); $this->assertNotNull($obj->getTimeStamp()); $this->assertNotNull($obj->getTimeZone()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param AgreementTransaction $obj */ public function testGetters($obj) { $this->assertEquals($obj->getTransactionId(), "TestSample"); $this->assertEquals($obj->getStatus(), "TestSample"); $this->assertEquals($obj->getTransactionType(), "TestSample"); $this->assertEquals($obj->getAmount(), CurrencyTest::getObject()); $this->assertEquals($obj->getFeeAmount(), CurrencyTest::getObject()); $this->assertEquals($obj->getNetAmount(), CurrencyTest::getObject()); $this->assertEquals($obj->getPayerEmail(), "TestSample"); $this->assertEquals($obj->getPayerName(), "TestSample"); $this->assertEquals($obj->getTimeStamp(), "TestSample"); $this->assertEquals($obj->getTimeZone(), "TestSample"); } } rest-api-sdk-php/tests/PayPal/Test/Api/WebhookEventTest.php 0000644 00000016231 15007532371 0017573 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\WebhookEvent; use PayPal\Exception\PayPalConnectionException; use PayPal\Rest\ApiContext; /** * Class WebhookEvent * * @package PayPal\Test\Api */ class WebhookEventTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object WebhookEvent * @return string */ public static function getJson() { return '{"id":"TestSample","create_time":"TestSample","resource_type":"TestSample","event_type":"TestSample","summary":"TestSample","resource":"TestSampleObject","links":' .LinksTest::getJson() . '}'; } /** * Gets Object Instance with Json data filled in * @return WebhookEvent */ public static function getObject() { return new WebhookEvent(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * @return WebhookEvent */ public function testSerializationDeserialization() { $obj = new WebhookEvent(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getId()); $this->assertNotNull($obj->getCreateTime()); $this->assertNotNull($obj->getResourceType()); $this->assertNotNull($obj->getEventType()); $this->assertNotNull($obj->getSummary()); $this->assertNotNull($obj->getResource()); $this->assertNotNull($obj->getLinks()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param WebhookEvent $obj */ public function testGetters($obj) { $this->assertEquals($obj->getId(), "TestSample"); $this->assertEquals($obj->getCreateTime(), "TestSample"); $this->assertEquals($obj->getResourceType(), "TestSample"); $this->assertEquals($obj->getEventType(), "TestSample"); $this->assertEquals($obj->getSummary(), "TestSample"); $this->assertEquals($obj->getResource(), "TestSampleObject"); $this->assertEquals($obj->getLinks(), LinksTest::getObject()); } /** * @dataProvider mockProvider * @param WebhookEvent $obj */ public function testGet($obj, $mockApiContext) { $mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPayPalRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( WebhookEventTest::getJson() )); $result = $obj->get("eventId", $mockApiContext, $mockPayPalRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param WebhookEvent $obj */ public function testResend($obj, $mockApiContext) { $mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPayPalRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( self::getJson() )); $result = $obj->resend($mockApiContext, $mockPayPalRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param WebhookEvent $obj */ public function testList($obj, $mockApiContext) { $mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPayPalRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( WebhookEventListTest::getJson() )); $params = array(); $result = $obj->all($params, $mockApiContext, $mockPayPalRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param WebhookEvent $obj */ public function testValidateWebhook($obj, $mockApiContext) { $mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPayPalRestCall->expects($this->any()) ->method('execute') ->will($this->returnValue( WebhookEventTest::getJson() )); $result = WebhookEvent::validateAndGetReceivedEvent('{"id":"123"}', $mockApiContext, $mockPayPalRestCall); //$result = $obj->get("eventId", $mockApiContext, $mockPayPalRestCall); $this->assertNotNull($result); } /** * @dataProvider mockProvider * @param WebhookEvent $obj * @param ApiContext $mockApiContext * @expectedException \InvalidArgumentException * @expectedExceptionMessage Webhook Event Id provided in the data is incorrect. This could happen if anyone other than PayPal is faking the incoming webhook data. */ public function testValidateWebhook404($obj, $mockApiContext) { $mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $mockPayPalRestCall->expects($this->any()) ->method('execute') ->will($this->throwException(new PayPalConnectionException(null, "404 not found", 404))); $result = WebhookEvent::validateAndGetReceivedEvent('{"id":"123"}', $mockApiContext, $mockPayPalRestCall); $this->assertNotNull($result); } public function mockProvider() { $obj = self::getObject(); $mockApiContext = $this->getMockBuilder('ApiContext') ->disableOriginalConstructor() ->getMock(); return array( array($obj, $mockApiContext), array($obj, null) ); } /** * @dataProvider mockProvider * @expectedException \InvalidArgumentException * @expectedExceptionMessage Body cannot be null or empty */ public function testValidateWebhookNull($mockApiContext) { WebhookEvent::validateAndGetReceivedEvent(null, $mockApiContext); } /** * @dataProvider mockProvider * @expectedException \InvalidArgumentException * @expectedExceptionMessage Body cannot be null or empty */ public function testValidateWebhookEmpty($mockApiContext) { WebhookEvent::validateAndGetReceivedEvent('', $mockApiContext); } /** * @dataProvider mockProvider * @expectedException \InvalidArgumentException * @expectedExceptionMessage Request Body is not a valid JSON. */ public function testValidateWebhookInvalid($mockApiContext) { WebhookEvent::validateAndGetReceivedEvent('something-invalid', $mockApiContext); } /** * @dataProvider mockProvider * @param $mockApiContext ApiContext * @expectedException \InvalidArgumentException * @expectedExceptionMessage Id attribute not found in JSON. Possible reason could be invalid JSON Object */ public function testValidateWebhookValidJSONWithoutId($obj, $mockApiContext) { WebhookEvent::validateAndGetReceivedEvent('{"summary":"json"}', $mockApiContext); } } rest-api-sdk-php/tests/PayPal/Test/Api/OpenIdAddressTest.php 0000644 00000002217 15007532371 0017656 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\OpenIdAddress; /** * Test class for OpenIdAddress. * */ class OpenIdAddressTest extends \PHPUnit_Framework_TestCase { /** @var OpenIdAddress */ private $addr; /** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { $this->addr = self::getTestData(); } /** * Tears down the fixture, for example, closes a network connection. * This method is called after a test is executed. */ protected function tearDown() { } public static function getTestData() { $addr = new OpenIdAddress(); $addr->setCountry("US")->setLocality("San Jose") ->setPostalCode("95112")->setRegion("CA") ->setStreetAddress("1, North 1'st street"); return $addr; } /** * @test */ public function testSerializationDeserialization() { $addrCopy = new OpenIdAddress(); $addrCopy->fromJson($this->addr->toJson()); $this->assertEquals($this->addr, $addrCopy); } } rest-api-sdk-php/tests/PayPal/Test/Api/PaymentHistoryTest.php 0000644 00000002716 15007532371 0020175 0 ustar 00 <?php namespace PayPal\Test\Api; use PayPal\Api\PaymentHistory; /** * Class PaymentHistory * * @package PayPal\Test\Api */ class PaymentHistoryTest extends \PHPUnit_Framework_TestCase { /** * Gets Json String of Object PaymentHistory * * @return string */ public static function getJson() { return '{"payments":' . PaymentTest::getJson() . ',"count":123,"next_id":"TestSample"}'; } /** * Gets Object Instance with Json data filled in * * @return PaymentHistory */ public static function getObject() { return new PaymentHistory(self::getJson()); } /** * Tests for Serialization and Deserialization Issues * * @return PaymentHistory */ public function testSerializationDeserialization() { $obj = new PaymentHistory(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getPayments()); $this->assertNotNull($obj->getCount()); $this->assertNotNull($obj->getNextId()); $this->assertEquals(self::getJson(), $obj->toJson()); return $obj; } /** * @depends testSerializationDeserialization * @param PaymentHistory $obj */ public function testGetters($obj) { $this->assertEquals($obj->getPayments(), PaymentTest::getObject()); $this->assertEquals($obj->getCount(), 123); $this->assertEquals($obj->getNextId(), "TestSample"); } } rest-api-sdk-php/tests/PayPal/Test/Exception/PayPalConfigurationExceptionTest.php 0000644 00000001616 15007532371 0024216 0 ustar 00 <?php use PayPal\Exception\PayPalConfigurationException; /** * Test class for PayPalConfigurationException. * */ class PayPalConfigurationExceptionTest extends \PHPUnit_Framework_TestCase { /** * @var PayPalConfigurationException */ protected $object; /** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { $this->object = new PayPalConfigurationException('Test PayPalConfigurationException'); } /** * Tears down the fixture, for example, closes a network connection. * This method is called after a test is executed. */ protected function tearDown() { } public function testPPConfigurationException() { $this->assertEquals('Test PayPalConfigurationException', $this->object->getMessage()); } } ?> rest-api-sdk-php/tests/PayPal/Test/Exception/PayPalMissingCredentialExceptionTest.php 0000644 00000001623 15007532371 0025011 0 ustar 00 <?php use PayPal\Exception\PayPalMissingCredentialException; /** * Test class for PayPalMissingCredentialException. * */ class PayPalMissingCredentialExceptionTest extends \PHPUnit_Framework_TestCase { /** * @var PayPalMissingCredentialException */ protected $object; /** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { $this->object = new PayPalMissingCredentialException; } /** * Tears down the fixture, for example, closes a network connection. * This method is called after a test is executed. */ protected function tearDown() { } /** * @test */ public function testErrorMessage() { $msg = $this->object->errorMessage(); $this->assertContains('Error on line', $msg); } } ?> rest-api-sdk-php/tests/PayPal/Test/Exception/PayPalInvalidCredentialExceptionTest.php 0000644 00000001623 15007532371 0024766 0 ustar 00 <?php use PayPal\Exception\PayPalInvalidCredentialException; /** * Test class for PayPalInvalidCredentialException. * */ class PayPalInvalidCredentialExceptionTest extends \PHPUnit_Framework_TestCase { /** * @var PayPalInvalidCredentialException */ protected $object; /** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { $this->object = new PayPalInvalidCredentialException; } /** * Tears down the fixture, for example, closes a network connection. * This method is called after a test is executed. */ protected function tearDown() { } /** * @test */ public function testErrorMessage() { $msg = $this->object->errorMessage(); $this->assertContains('Error on line', $msg); } } ?> rest-api-sdk-php/tests/PayPal/Test/Exception/PayPalConnectionExceptionTest.php 0000644 00000002131 15007532371 0023477 0 ustar 00 <?php use PayPal\Exception\PayPalConnectionException; /** * Test class for PayPalConnectionException. * */ class PayPalConnectionExceptionTest extends \PHPUnit_Framework_TestCase { /** * @var PayPalConnectionException */ protected $object; /** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { $this->object = new PayPalConnectionException('http://testURL', 'test message'); $this->object->setData('response payload for connection'); } /** * Tears down the fixture, for example, closes a network connection. * This method is called after a test is executed. */ protected function tearDown() { } /** * @test */ public function testGetUrl() { $this->assertEquals('http://testURL', $this->object->getUrl()); } /** * @test */ public function testGetData() { $this->assertEquals('response payload for connection', $this->object->getData()); } } ?> rest-api-sdk-php/tests/PayPal/Test/Constants.php 0000644 00000000302 15007532371 0015566 0 ustar 00 <?php namespace PayPal\Test; class Constants { const CLIENT_ID = 'EBWKjlELKMYqRNQ6sYvFo64FtaRLRR5BdHEESmha49TM'; const CLIENT_SECRET = 'EO422dn3gQLgDbuwqTjzrFgFtaRLRR5BdHEESmha49TM'; } rest-api-sdk-php/tests/PayPal/Test/Cache/AuthorizationCacheTest.php 0000644 00000006522 15007532371 0021253 0 ustar 00 <?php namespace PayPal\Test\Cache; use PayPal\Cache\AuthorizationCache; /** * Test class for AuthorizationCacheTest. * */ class AuthorizationCacheTest extends \PHPUnit_Framework_TestCase { const CACHE_FILE = 'tests/var/test.cache'; /** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { } /** * Tears down the fixture, for example, closes a network connection. * This method is called after a test is executed. */ protected function tearDown() { } public static function EnabledProvider() { return array( array(array('cache.enabled' => 'true'), true), array(array('cache.enabled' => true), true), ); } public static function CachePathProvider() { return array( array(array('cache.FileName' => 'temp.cache'), 'temp.cache') ); } /** * * @dataProvider EnabledProvider */ public function testIsEnabled($config, $expected) { $result = AuthorizationCache::isEnabled($config); $this->assertEquals($expected, $result); } /** * @dataProvider CachePathProvider */ public function testCachePath($config, $expected) { $result = AuthorizationCache::cachePath($config); $this->assertContains($expected, $result); } public function testCacheDisabled() { // 'cache.enabled' => true, AuthorizationCache::push(array('cache.enabled' => false), 'clientId', 'accessToken', 'tokenCreateTime', 'tokenExpiresIn'); AuthorizationCache::pull(array('cache.enabled' => false), 'clientId'); } public function testCachePush() { AuthorizationCache::push(array('cache.enabled' => true, 'cache.FileName' => AuthorizationCacheTest::CACHE_FILE), 'clientId', 'accessToken', 'tokenCreateTime', 'tokenExpiresIn'); $contents = file_get_contents(AuthorizationCacheTest::CACHE_FILE); $tokens = json_decode($contents, true); $this->assertNotNull($contents); $this->assertEquals('clientId', $tokens['clientId']['clientId']); $this->assertEquals('accessToken', $tokens['clientId']['accessTokenEncrypted']); $this->assertEquals('tokenCreateTime', $tokens['clientId']['tokenCreateTime']); $this->assertEquals('tokenExpiresIn', $tokens['clientId']['tokenExpiresIn']); } public function testCachePullNonExisting() { $result = AuthorizationCache::pull(array('cache.enabled' => true, 'cache.FileName' => AuthorizationCacheTest::CACHE_FILE), 'clientIdUndefined'); $this->assertNull($result); } /** * @depends testCachePush */ public function testCachePull() { $result = AuthorizationCache::pull(array('cache.enabled' => true, 'cache.FileName' => AuthorizationCacheTest::CACHE_FILE), 'clientId'); $this->assertNotNull($result); $this->assertTrue(is_array($result)); $this->assertEquals('clientId', $result['clientId']); $this->assertEquals('accessToken', $result['accessTokenEncrypted']); $this->assertEquals('tokenCreateTime', $result['tokenCreateTime']); $this->assertEquals('tokenExpiresIn', $result['tokenExpiresIn']); unlink(AuthorizationCacheTest::CACHE_FILE); } } rest-api-sdk-php/tests/PayPal/Test/Common/NestedClass.php 0000644 00000001032 15007532371 0017253 0 ustar 00 <?php namespace PayPal\Test\Common; use PayPal\Common\PayPalModel; class NestedClass extends PayPalModel { public function setId($id) { $this->id = $id; } public function getId() { return $this->id; } /** * * @param \PayPal\Test\Common\ArrayClass $info */ public function setInfo($info) { $this->info = $info; } /** * * @return \PayPal\Test\Common\ArrayClass */ public function getInfo() { return $this->info; } } rest-api-sdk-php/tests/PayPal/Test/Common/ArrayClass.php 0000644 00000001305 15007532371 0017112 0 ustar 00 <?php namespace PayPal\Test\Common; use PayPal\Common\PayPalModel; class ArrayClass extends PayPalModel { public function setName($name) { $this->name = $name; } public function getName() { return $this->name; } public function setDescription($description) { $this->description = $description; } public function getDescription() { return $this->description; } public function setTags($tags) { if (!is_array($tags)) { $tags = array($tags); } $this->tags = $tags; } /** * @return array */ public function getTags() { return $this->tags; } } rest-api-sdk-php/tests/PayPal/Test/Common/UserAgentTest.php 0000644 00000001616 15007532371 0017610 0 ustar 00 <?php use PayPal\Common\PayPalUserAgent; class UserAgentTest extends PHPUnit_Framework_TestCase { public function testGetValue() { $ua = PayPalUserAgent::getValue("name", "version"); list($id, $version, $features) = sscanf($ua, "PayPalSDK/%s %s (%[^[]])"); // Check that we pass the useragent in the expected format $this->assertNotNull($id); $this->assertNotNull($version); $this->assertNotNull($features); $this->assertEquals("name", $id); $this->assertEquals("version", $version); // Check that we pass in these mininal features $this->assertThat($features, $this->stringContains("os=")); $this->assertThat($features, $this->stringContains("bit=")); $this->assertThat($features, $this->stringContains("platform-ver=")); $this->assertGreaterThan(5, count(explode(';', $features))); } } rest-api-sdk-php/tests/PayPal/Test/Common/ChildClass.php 0000644 00000000117 15007532371 0017057 0 ustar 00 <?php namespace PayPal\Test\Common; class ChildClass extends SimpleClass { } rest-api-sdk-php/tests/PayPal/Test/Common/FormatConverterTest.php 0000644 00000010434 15007532371 0021031 0 ustar 00 <?php namespace PayPal\Test\Common; use PayPal\Api\Amount; use PayPal\Api\Currency; use PayPal\Api\Details; use PayPal\Api\InvoiceItem; use PayPal\Api\Item; use PayPal\Api\Tax; use PayPal\Common\PayPalModel; use PayPal\Converter\FormatConverter; use PayPal\Test\Validation\NumericValidatorTest; class FormatConverterTest extends \PHPUnit_Framework_TestCase { public static function classMethodListProvider() { return array( array(new Item(), 'Price'), array(new Item(), 'Tax'), array(new Amount(), 'Total'), array(new Currency(), 'Value'), array(new Details(), 'Shipping'), array(new Details(), 'SubTotal'), array(new Details(), 'Tax'), array(new Details(), 'Fee'), array(new Details(), 'ShippingDiscount'), array(new Details(), 'Insurance'), array(new Details(), 'HandlingFee'), array(new Details(), 'GiftWrap'), array(new InvoiceItem(), 'Quantity'), array(new Tax(), 'Percent') ); } public static function CurrencyListWithNoDecimalsProvider() { return array( array('JPY'), array('TWD') ); } public static function apiModelSettersProvider() { $provider = array(); foreach (NumericValidatorTest::positiveProvider() as $value) { foreach (self::classMethodListProvider() as $method) { $provider[] = array_merge($method, array($value)); } } return $provider; } public static function apiModelSettersInvalidProvider() { $provider = array(); foreach (NumericValidatorTest::invalidProvider() as $value) { foreach (self::classMethodListProvider() as $method) { $provider[] = array_merge($method, array($value)); } } return $provider; } /** * * @dataProvider \PayPal\Test\Validation\NumericValidatorTest::positiveProvider */ public function testFormatToTwoDecimalPlaces($input, $expected) { $result = FormatConverter::formatToNumber($input); $this->assertEquals($expected, $result); } /** * @dataProvider CurrencyListWithNoDecimalsProvider */ public function testPriceWithNoDecimalCurrencyInvalid($input) { try { FormatConverter::formatToPrice("1.234", $input); } catch (\InvalidArgumentException $ex) { $this->assertContains("value cannot have decimals for", $ex->getMessage()); } } /** * @dataProvider CurrencyListWithNoDecimalsProvider */ public function testPriceWithNoDecimalCurrencyValid($input) { $result = FormatConverter::formatToPrice("1.0000000", $input); $this->assertEquals("1", $result); } /** * * @dataProvider \PayPal\Test\Validation\NumericValidatorTest::positiveProvider */ public function testFormatToNumber($input, $expected) { $result = FormatConverter::formatToNumber($input); $this->assertEquals($expected, $result); } public function testFormatToNumberDecimals() { $result = FormatConverter::formatToNumber("0.0", 4); $this->assertEquals("0.0000", $result); } public function testFormat() { $result = FormatConverter::format("12.0123", "%0.2f"); $this->assertEquals("12.01", $result); } /** * @dataProvider apiModelSettersProvider * * @param PayPalModel $class Class Object * @param string $method Method Name where the format is being applied * @param array $values array of ['input', 'expectedResponse'] is provided */ public function testSettersOfKnownApiModel($class, $method, $values) { $obj = new $class(); $setter = "set" . $method; $getter = "get" . $method; $result = $obj->$setter($values[0]); $this->assertEquals($values[1], $result->$getter()); } /** * @dataProvider apiModelSettersInvalidProvider * @expectedException \InvalidArgumentException */ public function testSettersOfKnownApiModelInvalid($class, $methodName, $values) { $obj = new $class(); $setter = "set" . $methodName; $obj->$setter($values[0]); } } rest-api-sdk-php/tests/PayPal/Test/Common/SimpleClass.php 0000644 00000000701 15007532371 0017264 0 ustar 00 <?php namespace PayPal\Test\Common; use PayPal\Common\PayPalModel; class SimpleClass extends PayPalModel { public function setName($name) { $this->name = $name; } public function getName() { return $this->name; } public function setDescription($description) { $this->description = $description; } public function getDescription() { return $this->description; } } rest-api-sdk-php/tests/PayPal/Test/Common/ModelTest.php 0000644 00000017612 15007532371 0016756 0 ustar 00 <?php namespace PayPal\Test\Common; use PayPal\Api\Payment; use PayPal\Common\PayPalModel; use PayPal\Core\PayPalConfigManager; class ModelTest extends \PHPUnit_Framework_TestCase { public function testSimpleClassConversion() { $o = new SimpleClass(); $o->setName("test"); $o->setDescription("description"); $this->assertEquals("test", $o->getName()); $this->assertEquals("description", $o->getDescription()); $json = $o->toJSON(); $this->assertEquals('{"name":"test","description":"description"}', $json); $newO = new SimpleClass(); $newO->fromJson($json); $this->assertEquals($o, $newO); } public function testConstructorJSON() { $obj = new SimpleClass('{"name":"test","description":"description"}'); $this->assertEquals($obj->getName(), "test"); $this->assertEquals($obj->getDescription(), "description"); } public function testConstructorArray() { $arr = array('name' => 'test', 'description' => 'description'); $obj = new SimpleClass($arr); $this->assertEquals($obj->getName(), "test"); $this->assertEquals($obj->getDescription(), "description"); } public function testConstructorNull() { $obj = new SimpleClass(null); $this->assertNotEquals($obj->getName(), "test"); $this->assertNotEquals($obj->getDescription(), "description"); $this->assertNull($obj->getName()); $this->assertNull($obj->getDescription()); } /** * @expectedException \InvalidArgumentException * @expectedExceptionMessage Invalid JSON String */ public function testConstructorInvalidInput() { new SimpleClass("Something that is not even correct"); } public function testSimpleClassObjectConversion() { $json = '{"name":"test","description":"description"}'; $obj = new SimpleClass(); $obj->fromJson($json); $this->assertEquals("test", $obj->getName()); $this->assertEquals("description", $obj->getDescription()); } public function testSimpleClassObjectInvalidConversion() { try { $json = '{"name":"test","description":"description","invalid":"value"}'; $obj = new SimpleClass(); $obj->fromJson($json); $this->assertEquals("test", $obj->getName()); $this->assertEquals("description", $obj->getDescription()); } catch (\PHPUnit_Framework_Error_Notice $ex) { // No need to do anything } } /** * Test Case to determine if the unknown object is returned, it would not add that object to the model. */ public function testUnknownObjectConversion() { PayPalConfigManager::getInstance()->addConfigs(array('validation.level' => 'disabled')); $json = '{"name":"test","unknown":{ "id" : "123", "object": "456"},"description":"description"}'; $obj = new SimpleClass(); $obj->fromJson($json); $this->assertEquals("test", $obj->getName()); $this->assertEquals("description", $obj->getDescription()); $resultJson = $obj->toJSON(); $this->assertContains("unknown", $resultJson); $this->assertContains("id", $resultJson); $this->assertContains("object", $resultJson); $this->assertContains("123", $resultJson); $this->assertContains("456", $resultJson); PayPalConfigManager::getInstance()->addConfigs(array('validation.level' => 'strict')); } /** * Test Case to determine if the unknown object is returned, it would not add that object to the model. */ public function testUnknownArrayConversion() { PayPalConfigManager::getInstance()->addConfigs(array('validation.level' => 'disabled')); $json = '{"name":"test","unknown":[{"object": { "id" : "123", "object": "456"}}, {"more": { "id" : "123", "object": "456"}}],"description":"description"}'; $obj = new SimpleClass(); $obj->fromJson($json); $this->assertEquals("test", $obj->getName()); $this->assertEquals("description", $obj->getDescription()); $resultJson = $obj->toJSON(); $this->assertContains("unknown", $resultJson); $this->assertContains("id", $resultJson); $this->assertContains("object", $resultJson); $this->assertContains("123", $resultJson); $this->assertContains("456", $resultJson); PayPalConfigManager::getInstance()->addConfigs(array('validation.level' => 'strict')); } public function testEmptyArrayConversion() { $json = '{"id":"PAY-5DW86196ER176274EKT3AEYA","transactions":[{"related_resources":[]}]}'; $payment = new Payment($json); $result = $payment->toJSON(); $this->assertContains('"related_resources":[]', $result); $this->assertNotNull($result); } public function testMultipleEmptyArrayConversion() { $json = '{"id":"PAY-5DW86196ER176274EKT3AEYA","transactions":[{"related_resources":[{},{}]}]}'; $payment = new Payment($json); $result = $payment->toJSON(); $this->assertContains('"related_resources":[{},{}]', $result); $this->assertNotNull($result); } public function testSetterMagicMethod() { $obj = new PayPalModel(); $obj->something = "other"; $obj->else = array(); $obj->there = null; $obj->obj = '{}'; $obj->objs = array('{}'); $this->assertEquals("other", $obj->something); $this->assertTrue(is_array($obj->else)); $this->assertNull($obj->there); $this->assertEquals('{}', $obj->obj); $this->assertTrue(is_array($obj->objs)); $this->assertEquals('{}', $obj->objs[0]); } public function testInvalidMagicMethodWithDisabledValidation() { PayPalConfigManager::getInstance()->addConfigs(array('validation.level' => 'disabled')); $obj = new SimpleClass(); try { $obj->invalid = "value2"; $this->assertEquals($obj->invalid, "value2"); } catch (\PHPUnit_Framework_Error_Notice $ex) { $this->fail("It should not have thrown a Notice Error as it is disabled."); } PayPalConfigManager::getInstance()->addConfigs(array('validation.level' => 'strict')); } public function testInvalidMagicMethodWithValidationLevel() { PayPalConfigManager::getInstance()->addConfigs(array('validation.level' => 'log')); $obj = new SimpleClass(); $obj->invalid2 = "value2"; $this->assertEquals($obj->invalid2, "value2"); PayPalConfigManager::getInstance()->addConfigs(array('validation.level' => 'strict')); } public function testArrayClassConversion() { $o = new ArrayClass(); $o->setName("test"); $o->setDescription("description"); $o->setTags(array('payment', 'info', 'test')); $this->assertEquals("test", $o->getName()); $this->assertEquals("description", $o->getDescription()); $this->assertEquals(array('payment', 'info', 'test'), $o->getTags()); $json = $o->toJSON(); $this->assertEquals('{"name":"test","description":"description","tags":["payment","info","test"]}', $json); $newO = new ArrayClass(); $newO->fromJson($json); $this->assertEquals($o, $newO); } public function testNestedClassConversion() { $n = new ArrayClass(); $n->setName("test"); $n->setDescription("description"); $o = new NestedClass(); $o->setId('123'); $o->setInfo($n); $this->assertEquals("123", $o->getId()); $this->assertEquals("test", $o->getInfo()->getName()); $json = $o->toJSON(); $this->assertEquals('{"id":"123","info":{"name":"test","description":"description"}}', $json); $newO = new NestedClass(); $newO->fromJson($json); $this->assertEquals($o, $newO); } } rest-api-sdk-php/tests/PayPal/Test/Common/PayPalModelTest.php 0000644 00000017762 15007532371 0020073 0 ustar 00 <?php use PayPal\Common\PayPalModel; class SimpleModelTestClass extends PayPalModel { /** * * @access public * @param string $field1 * @return self */ public function setField1($field1) { $this->field1 = $field1; return $this; } /** * * @access public * @return string */ public function getField1() { return $this->field1; } /** * * @access public * @param string $field2 * @return self */ public function setField2($field2) { $this->field2 = $field2; return $this; } /** * * @access public * @return string */ public function getField2() { return $this->field2; } } class ContainerModelTestClass extends PayPalModel { /** * * @access public * @param string $field1 */ public function setField1($field1) { $this->field1 = $field1; return $this; } /** * * @access public * @return string */ public function getField1() { return $this->field1; } /** * * @access public * @param SimpleModelTestClass $field1 */ public function setNested1($nested1) { $this->nested1 = $nested1; return $this; } /** * * @access public * @return SimpleModelTestClass */ public function getNested1() { return $this->nested1; } } class ListModelTestClass extends PayPalModel { /** * * @access public * @param string $list1 */ public function setList1($list1) { $this->list1 = $list1; } /** * * @access public * @return string */ public function getList1() { return $this->list1; } /** * * @access public * @param SimpleModelTestClass $list2 array of SimpleModelTestClass */ public function setList2($list2) { $this->list2 = $list2; return $this; } /** * * @access public * @return SimpleModelTestClass array of SimpleModelTestClass */ public function getList2() { return $this->list2; } } /** * Test class for PayPalModel. * */ class PayPalModelTest extends PHPUnit_Framework_TestCase { /** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { } /** * Tears down the fixture, for example, closes a network connection. * This method is called after a test is executed. */ protected function tearDown() { } /** * @test */ public function testSimpleConversion() { $o = new SimpleModelTestClass(); $o->setField1('value 1'); $o->setField2("value 2"); $this->assertEquals('{"field1":"value 1","field2":"value 2"}', $o->toJSON()); $oCopy = new SimpleModelTestClass(); $oCopy->fromJson($o->toJSON()); $this->assertEquals($o, $oCopy); } /** * @test */ public function testEmptyObject() { $child = new SimpleModelTestClass(); $child->setField1(null); $parent = new ContainerModelTestClass(); $parent->setField1("parent"); $parent->setNested1($child); $this->assertEquals('{"field1":"parent","nested1":{}}', $parent->toJSON()); $parentCopy = new ContainerModelTestClass(); $parentCopy->fromJson($parent->toJSON()); $this->assertEquals($parent, $parentCopy); } /** * @test */ public function testSpecialChars() { $o = new SimpleModelTestClass(); $o->setField1('value "1'); $o->setField2("value 2"); $this->assertEquals('{"field1":"value \"1","field2":"value 2"}', $o->toJSON()); $oCopy = new SimpleModelTestClass(); $oCopy->fromJson($o->toJSON()); $this->assertEquals($o, $oCopy); } /** * @test */ public function testNestedConversion() { $child = new SimpleModelTestClass(); $child->setField1('value 1'); $child->setField2("value 2"); $parent = new ContainerModelTestClass(); $parent->setField1("parent"); $parent->setNested1($child); $this->assertEquals('{"field1":"parent","nested1":{"field1":"value 1","field2":"value 2"}}', $parent->toJSON()); $parentCopy = new ContainerModelTestClass(); $parentCopy->fromJson($parent->toJSON()); $this->assertEquals($parent, $parentCopy); } /** * @test */ public function testListConversion() { $c1 = new SimpleModelTestClass(); $c1->setField1("a")->setField2('value'); $c2 = new SimpleModelTestClass(); $c1->setField1("another")->setField2('object'); $parent = new ListModelTestClass(); $parent->setList1(array('simple', 'list', 'with', 'integer', 'keys')); $parent->setList2(array($c1, $c2)); $parentCopy = new ListModelTestClass(); $parentCopy->fromJson($parent->toJSON()); $this->assertEquals($parent, $parentCopy); } public function EmptyNullProvider() { return array( array(0, true), array(null, false), array("", true), array("null", true), array(-1, true), array('', true) ); } /** * @dataProvider EmptyNullProvider * @param string|null $field2 * @param bool $matches */ public function testEmptyNullConversion($field2, $matches) { $c1 = new SimpleModelTestClass(); $c1->setField1("a")->setField2($field2); $this->assertTrue(strpos($c1->toJSON(),"field2") !== !$matches); } public function getProvider() { return array( array('[[]]', 1, array(array())), array('[{}]', 1, array(new PayPalModel())), array('[{"id":"123"}]', 1, array(new PayPalModel(array('id' => '123')))), array('{"id":"123"}', 1, array(new PayPalModel(array('id' => '123')))), array('[]', 0, array()), array('{}', 1, array(new PayPalModel())), array(array(), 0, array()), array(array("id" => "123"), 1, array(new PayPalModel(array('id' =>'123')))), array(null, 0, null), array('',0, array()), array('[[], {"id":"123"}]', 2, array(array(), new PayPalModel(array("id"=> "123")))), array('[{"id":"123"}, {"id":"321"}]', 2, array( new PayPalModel(array("id" => "123")), new PayPalModel(array("id" => "321")) ) ), array(array(array("id" => "123"), array("id" => "321")), 2, array( new PayPalModel(array("id" => "123")), new PayPalModel(array("id" => "321")) )), array(new PayPalModel('{"id": "123"}'), 1, array(new PayPalModel(array("id" => "123")))) ); } public function getInvalidProvider() { return array( array('{]'), array('[{]') ); } /** * @dataProvider getProvider * @param string|null $input * @param int $count * @param mixed $expected */ public function testGetList($input, $count, $expected) { $result = PayPalModel::getList($input); $this->assertEquals($expected, $result); if ($input) { $this->assertNotNull($result); $this->assertTrue(is_array($result)); $this->assertEquals($count, sizeof($result)); } } /** * @dataProvider getInvalidProvider * @expectedException InvalidArgumentException * @expectedExceptionMessage Invalid JSON String * @param string|null $input */ public function testGetListInvalidInput($input) { $result = PayPalModel::getList($input); } } rest-api-sdk-php/tests/PayPal/Test/Common/ArrayUtilTest.php 0000644 00000001030 15007532371 0017615 0 ustar 00 <?php namespace PayPal\Test\Common; use PayPal\Common\ArrayUtil; class ArrayUtilTest extends \PHPUnit_Framework_TestCase { public function testIsAssocArray() { $arr = array(1, 2, 3); $this->assertEquals(false, ArrayUtil::isAssocArray($arr)); $arr = array( 'name' => 'John Doe', 'City' => 'San Jose' ); $this->assertEquals(true, ArrayUtil::isAssocArray($arr)); $arr[] = 'CA'; $this->assertEquals(false, ArrayUtil::isAssocArray($arr)); } } rest-api-sdk-php/tests/PayPal/Test/Rest/ApiContextTest.php 0000644 00000001432 15007532371 0017452 0 ustar 00 <?php use PayPal\Rest\ApiContext; /** * Test class for ApiContextTest. * */ class ApiContextTest extends PHPUnit_Framework_TestCase { /** * @var ApiContext */ public $apiContext; public function setUp() { $this->apiContext = new ApiContext(); } public function testGetRequestId() { $requestId = $this->apiContext->getRequestId(); $this->assertNotNull($requestId); $this->assertEquals($requestId, $this->apiContext->getRequestId()); } public function testResetRequestId() { $requestId = $this->apiContext->getRequestId(); $newRequestId = $this->apiContext->resetRequestId(); $this->assertNotNull($newRequestId); $this->assertNotEquals($newRequestId, $requestId); } } rest-api-sdk-php/tests/PayPal/Test/Validation/JsonValidatorTest.php 0000644 00000002720 15007532371 0021331 0 ustar 00 <?php namespace PayPal\Test\Validation; use PayPal\Validation\JsonValidator; class JsonValidatorTest extends \PHPUnit_Framework_TestCase { public static function positiveProvider() { return array( array(null), array(''), array("{}"), array('{"json":"value", "bool":false, "int":1, "float": 0.123, "array": [{"json":"value", "bool":false, "int":1, "float": 0.123},{"json":"value", "bool":false, "int":1, "float": 0.123} ]}') ); } public static function invalidProvider() { return array( array('{'), array('}'), array(' '), array(array('1' => '23')), array('{"json":"value, "bool":false, "int":1, "float": 0.123, "array": [{"json":"value, "bool":false, "int":1, "float": 0.123}"json":"value, "bool":false, "int":1, "float": 0.123} ]}') ); } /** * * @dataProvider positiveProvider */ public function testValidate($input) { $this->assertTrue(JsonValidator::validate($input)); } /** * * @dataProvider invalidProvider * @expectedException \InvalidArgumentException */ public function testInvalidJson($input) { JsonValidator::validate($input); } /** * * @dataProvider invalidProvider */ public function testInvalidJsonSilent($input) { $this->assertFalse(JsonValidator::validate($input, true)); } } rest-api-sdk-php/tests/PayPal/Test/Validation/UrlValidatorTest.php 0000644 00000002756 15007532371 0021173 0 ustar 00 <?php namespace PayPal\Test\Validation; use PayPal\Validation\UrlValidator; class UrlValidatorTest extends \PHPUnit_Framework_TestCase { public static function positiveProvider() { return array( array("https://www.paypal.com"), array("http://www.paypal.com"), array("https://paypal.com"), array("https://www.paypal.com/directory/file"), array("https://www.paypal.com/directory/file?something=1&other=true"), array("https://www.paypal.com?value="), array("https://www.paypal.com/123123"), array("https://www.subdomain.paypal.com"), array("https://www.sub-domain-with-dash.paypal-website.com"), array("https://www.paypal.com?value=space%20separated%20value"), array("https://www.special@character.com"), ); } public static function invalidProvider() { return array( array("www.paypal.com"), array(""), array(null), array("https://www.sub_domain_with_underscore.paypal.com"), ); } /** * * @dataProvider positiveProvider */ public function testValidate($input) { UrlValidator::validate($input, "Test Value"); } /** * * @dataProvider invalidProvider * @expectedException \InvalidArgumentException */ public function testValidateException($input) { UrlValidator::validate($input, "Test Value"); } } rest-api-sdk-php/tests/PayPal/Test/Validation/NumericValidatorTest.php 0000644 00000002714 15007532371 0022025 0 ustar 00 <?php namespace PayPal\Test\Validation; use PayPal\Validation\NumericValidator; class NumericValidatorTest extends \PHPUnit_Framework_TestCase { public static function positiveProvider() { return array( array(".5", "0.50"), array(".55", "0.55"), array("0", "0.00"), array(null, null), array("01", "1.00"), array("01.1", "1.10"), array("10.0", "10.00"), array("0.0", "0.00"), array("00.00", "0.00"), array("000.111", "0.11"), array("000.0001", "0.00"), array("-0.001", "0.00"), array("-0", "0.00"), array("-00.00", "0.00"), array("-10.00", "-10.00"), array("", null), array(" ", null), array(1.20, "1.20") ); } public static function invalidProvider() { return array( array("01.j"), array("j.10"), array("empty"), array("null") ); } /** * * @dataProvider positiveProvider */ public function testValidate($input) { $this->assertTrue(NumericValidator::validate($input, "Test Value")); } /** * * @dataProvider invalidProvider * @expectedException \InvalidArgumentException */ public function testValidateException($input) { NumericValidator::validate($input, "Test Value"); } } rest-api-sdk-php/tests/PayPal/Test/Validation/ArgumentValidatorTest.php 0000644 00000002053 15007532371 0022201 0 ustar 00 <?php namespace PayPal\Test\Validation; use PayPal\Validation\ArgumentValidator; class ArgumentValidatorTest extends \PHPUnit_Framework_TestCase { public static function positiveProvider() { return array( array("1"), array("something here"), array(1), array(array(1,2,3)), array(0.123), array(true), array(false), array(array()), ); } public static function invalidProvider() { return array( array(null), array(''), array(' ') ); } /** * * @dataProvider positiveProvider */ public function testValidate($input) { $this->assertTrue(ArgumentValidator::validate($input, "Name")); } /** * * @dataProvider invalidProvider * @expectedException \InvalidArgumentException */ public function testInvalidDataValidate($input) { $this->assertTrue(ArgumentValidator::validate($input, "Name")); } } rest-api-sdk-php/tests/PayPal/Test/Functional/Api/PayoutsFunctionalTest.php 0000644 00000010501 15007532371 0022756 0 ustar 00 <?php namespace PayPal\Test\Functional\Api; use PayPal\Api\Payout; use PayPal\Api\PayoutBatch; use PayPal\Api\PayoutItem; use PayPal\Test\Functional\Setup; /** * Class Payouts * * @package PayPal\Test\Api */ class PayoutsFunctionalTest extends \PHPUnit_Framework_TestCase { public $operation; public $response; public $mockPayPalRestCall; public $apiContext; public static $batchId; public function setUp() { $className = $this->getClassName(); $testName = $this->getName(); $operationString = file_get_contents(__DIR__ . "/../resources/$className/$testName.json"); $this->operation = json_decode($operationString, true); $this->response = true; if (array_key_exists('body', $this->operation['response'])) { $this->response = json_encode($this->operation['response']['body']); } Setup::SetUpForFunctionalTests($this); } /** * Returns just the classname of the test you are executing. It removes the namespaces. * @return string */ public function getClassName() { return join('', array_slice(explode('\\', get_class($this)), -1)); } public function testCreate() { $request = $this->operation['request']['body']; $obj = new Payout($request); if (Setup::$mode != 'mock') { $obj->getSenderBatchHeader()->setSenderBatchId(uniqid()); } PayoutsFunctionalTest::$batchId = $obj->getSenderBatchHeader()->getSenderBatchId(); $params = array('sync_mode' => 'true'); $result = $obj->create($params, $this->apiContext, $this->mockPayPalRestCall); $this->assertNotNull($result); $this->assertEquals(PayoutsFunctionalTest::$batchId, $result->getBatchHeader()->getSenderBatchHeader()->getSenderBatchId()); $this->assertEquals('SUCCESS', $result->getBatchHeader()->getBatchStatus()); $items = $result->getItems(); $this->assertTrue(sizeof($items) > 0); $item = $items[0]; $this->assertEquals('UNCLAIMED', $item->getTransactionStatus()); return $result; } /** * @depends testCreate * @param $payoutBatch PayoutBatch * @return PayoutBatch */ public function testGet($payoutBatch) { $result = Payout::get($payoutBatch->getBatchHeader()->getPayoutBatchId(), $this->apiContext, $this->mockPayPalRestCall); $this->assertNotNull($result); $this->assertNotNull($result->getBatchHeader()->getBatchStatus()); $this->assertEquals(PayoutsFunctionalTest::$batchId, $result->getBatchHeader()->getSenderBatchHeader()->getSenderBatchId()); return $result; } /** * @depends testCreate * @param $payoutBatch PayoutBatch * @return PayoutBatch */ public function testGetItem($payoutBatch) { $items = $payoutBatch->getItems(); $item = $items[0]; $result = PayoutItem::get($item->getPayoutItemId(), $this->apiContext, $this->mockPayPalRestCall); $this->assertNotNull($result); $this->assertEquals($item->getPayoutItemId(), $result->getPayoutItemId()); $this->assertEquals($item->getPayoutBatchId(), $result->getPayoutBatchId()); $this->assertEquals($item->getTransactionId(), $result->getTransactionId()); $this->assertEquals($item->getPayoutItemFee(), $result->getPayoutItemFee()); } /** * @depends testCreate * @param $payoutBatch PayoutBatch * @return PayoutBatch */ public function testCancel($payoutBatch) { $items = $payoutBatch->getItems(); $item = $items[0]; if ($item->getTransactionStatus() != 'UNCLAIMED') { $this->markTestSkipped('Transaction status needs to be Unclaimed for this test '); return; } $result = PayoutItem::cancel($item->getPayoutItemId(), $this->apiContext, $this->mockPayPalRestCall); $this->assertNotNull($result); $this->assertEquals($item->getPayoutItemId(), $result->getPayoutItemId()); $this->assertEquals($item->getPayoutBatchId(), $result->getPayoutBatchId()); $this->assertEquals($item->getTransactionId(), $result->getTransactionId()); $this->assertEquals($item->getPayoutItemFee(), $result->getPayoutItemFee()); $this->assertEquals('RETURNED', $result->getTransactionStatus()); } } rest-api-sdk-php/tests/PayPal/Test/Functional/Api/BillingPlansFunctionalTest.php 0000644 00000014063 15007532371 0023677 0 ustar 00 <?php namespace PayPal\Test\Functional\Api; use PayPal\Api\Patch; use PayPal\Api\PatchRequest; use PayPal\Api\Plan; use PayPal\Test\Functional\Setup; /** * Class Billing Plans * * @package PayPal\Test\Api */ class BillingPlansFunctionalTest extends \PHPUnit_Framework_TestCase { public static $obj; public $operation; public $response; public $mode = 'mock'; public $mockPayPalRestCall; public $apiContext; public function setUp() { $className = $this->getClassName(); $testName = $this->getName(); $this->setupTest($className, $testName); } public function setupTest($className, $testName) { $operationString = file_get_contents(__DIR__ . "/../resources/$className/$testName.json"); $this->operation = json_decode($operationString, true); $this->response = true; if (array_key_exists('body', $this->operation['response'])) { $this->response = json_encode($this->operation['response']['body']); } Setup::SetUpForFunctionalTests($this); } /** * Helper function to get a Plan object in Active State * * @return Plan */ public static function getPlan() { if (!self::$obj) { $test = new self(); // Creates a Plan $test->setupTest($test->getClassName(), 'testCreate'); self::$obj = $test->testCreate(); // Updates the Status to Active $test->setupTest($test->getClassName(), 'testUpdateChangingState'); self::$obj = $test->testUpdateChangingState(self::$obj); } return self::$obj; } /** * Returns just the classname of the test you are executing. It removes the namespaces. * @return string */ public function getClassName() { return join('', array_slice(explode('\\', get_class($this)), -1)); } public function testCreate() { $request = $this->operation['request']['body']; $obj = new Plan($request); $result = $obj->create($this->apiContext, $this->mockPayPalRestCall); $this->assertNotNull($result); self::$obj = $result; return $result; } public function testCreateWithNOChargeModel() { $request = $this->operation['request']['body']; $obj = new Plan($request); $result = $obj->create($this->apiContext, $this->mockPayPalRestCall); $this->assertNotNull($result); return $result; } /** * @depends testCreate * @param $plan Plan * @return Plan */ public function testGet($plan) { $result = Plan::get($plan->getId(), $this->apiContext, $this->mockPayPalRestCall); $this->assertNotNull($result); $this->assertEquals($plan->getId(), $result->getId()); $this->assertEquals($plan, $result, "", 0, 10, true); return $result; } /** * @depends testGet * @param $plan Plan */ public function testGetList($plan) { $result = Plan::all(array('page_size' => '20', 'total_required' => 'yes'), $this->apiContext, $this->mockPayPalRestCall); $this->assertNotNull($result); $totalPages = $result->getTotalPages(); $found = false; $foundObject = null; do { foreach ($result->getPlans() as $obj) { if ($obj->getId() == $plan->getId()) { $found = true; $foundObject = $obj; break; } } if (!$found) { $result = Plan::all(array('page' => --$totalPages, 'page_size' => '20', 'total_required' => 'yes'), $this->apiContext, $this->mockPayPalRestCall); } } while ($totalPages > 0 && $found == false); $this->assertTrue($found, "The Created Plan was not found in the get list"); $this->assertEquals($plan->getId(), $foundObject->getId()); } /** * @depends testGet * @param $plan Plan */ public function testUpdateChangingMerchantPreferences($plan) { /** @var Patch[] $request */ $request = $this->operation['request']['body'][0]; $patch = new Patch(); $patch->setOp($request['op']); $patch->setPath($request['path']); $patch->setValue($request['value']); $patches = array(); $patches[] = $patch; $patchRequest = new PatchRequest(); $patchRequest->setPatches($patches); $result = $plan->update($patchRequest, $this->apiContext, $this->mockPayPalRestCall); $this->assertTrue($result); } /** * @depends testGet * @param $plan Plan */ public function testUpdateChangingPD($plan) { /** @var Patch[] $request */ $request = $this->operation['request']['body'][0]; $patch = new Patch(); $patch->setOp($request['op']); $paymentDefinitions = $plan->getPaymentDefinitions(); $patch->setPath('/payment-definitions/' . $paymentDefinitions[0]->getId()); $patch->setValue($request['value']); $patches = array(); $patches[] = $patch; $patchRequest = new PatchRequest(); $patchRequest->setPatches($patches); $result = $plan->update($patchRequest, $this->apiContext, $this->mockPayPalRestCall); $this->assertTrue($result); } /** * @depends testGet * @param $plan Plan * @return Plan */ public function testUpdateChangingState($plan) { /** @var Patch[] $request */ $request = $this->operation['request']['body'][0]; $patch = new Patch(); $patch->setOp($request['op']); $patch->setPath($request['path']); $patch->setValue($request['value']); $patches = array(); $patches[] = $patch; $patchRequest = new PatchRequest(); $patchRequest->setPatches($patches); $result = $plan->update($patchRequest, $this->apiContext, $this->mockPayPalRestCall); $this->assertTrue($result); return Plan::get($plan->getId(), $this->apiContext, $this->mockPayPalRestCall); } } rest-api-sdk-php/tests/PayPal/Test/Functional/Api/WebhookFunctionalTest.php 0000644 00000013073 15007532371 0022717 0 ustar 00 <?php namespace PayPal\Test\Functional\Api; use PayPal\Api\Patch; use PayPal\Api\PatchRequest; use PayPal\Api\Webhook; use PayPal\Api\WebhookEvent; use PayPal\Api\WebhookEventType; use PayPal\Api\WebhookEventTypeList; use PayPal\Api\WebhookList; use PayPal\Exception\PayPalConnectionException; use PayPal\Test\Functional\Setup; /** * Class WebhookFunctionalTest * * @package PayPal\Test\Api */ class WebhookFunctionalTest extends \PHPUnit_Framework_TestCase { public $operation; public $response; public $mockPayPalRestCall; public $apiContext; public function setUp() { $className = $this->getClassName(); $testName = $this->getName(); $operationString = file_get_contents(__DIR__ . "/../resources/$className/$testName.json"); $this->operation = json_decode($operationString, true); $this->response = true; if (array_key_exists('body', $this->operation['response'])) { $this->response = json_encode($this->operation['response']['body']); } Setup::SetUpForFunctionalTests($this); } /** * Returns just the classname of the test you are executing. It removes the namespaces. * @return string */ public function getClassName() { return join('', array_slice(explode('\\', get_class($this)), -1)); } public function testCreate() { $request = $this->operation['request']['body']; $obj = new Webhook($request); // Adding a random url request to make it unique $obj->setUrl($obj->getUrl() . '?rand=' . uniqid()); $result = null; try { $result = $obj->create($this->apiContext, $this->mockPayPalRestCall); } catch (PayPalConnectionException $ex) { $data = $ex->getData(); if (strpos($data,'WEBHOOK_NUMBER_LIMIT_EXCEEDED') !== false) { $this->deleteAll(); $result = $obj->create($this->apiContext, $this->mockPayPalRestCall); } else { $this->fail($ex->getMessage()); } } $this->assertNotNull($result); return $result; } public function deleteAll() { $result = Webhook::getAll($this->apiContext, $this->mockPayPalRestCall); foreach ($result->getWebhooks() as $webhookObject) { $webhookObject->delete($this->apiContext, $this->mockPayPalRestCall); } } /** * @depends testCreate * @param $webhook Webhook * @return Webhook */ public function testGet($webhook) { $result = Webhook::get($webhook->getId(), $this->apiContext, $this->mockPayPalRestCall); $this->assertNotNull($result); $this->assertEquals($webhook->getId(), $result->getId()); $this->assertEquals($webhook, $result, "", 0, 10, true); return $result; } /** * @depends testGet * @param $webhook Webhook * @return WebhookEventTypeList */ public function testGetSubscribedEventTypes($webhook) { $result = WebhookEventType::subscribedEventTypes($webhook->getId(), $this->apiContext, $this->mockPayPalRestCall); $this->assertNotNull($result); $this->assertEquals(2, sizeof($result->getEventTypes())); return $result; } /** * @depends testGet * @param $webhook Webhook * @return WebhookList */ public function testGetAll($webhook) { $result = Webhook::getAll($this->apiContext, $this->mockPayPalRestCall); $this->assertNotNull($result); $found = false; $foundObject = null; foreach ($result->getWebhooks() as $webhookObject) { if ($webhookObject->getId() == $webhook->getId()) { $found = true; $foundObject = $webhookObject; break; } } $this->assertTrue($found, "The Created Webhook was not found in the get list"); $this->assertEquals($webhook->getId(), $foundObject->getId()); return $result; } /** * @depends testGet * @param $webhook Webhook */ public function testUpdate($webhook) { $patches = array(); foreach ($this->operation['request']['body'] as $request) { /** @var Patch[] $request */ $patch = new Patch(); $patch->setOp($request['op']); $patch->setPath($request['path']); $patch->setValue($request['value']); if ($request['path'] == "/url") { $new_url = $request['value'] . '?rand=' .uniqid(); $patch->setValue($new_url); } $patches[] = $patch; } $patchRequest = new PatchRequest(); $patchRequest->setPatches($patches); $result = $webhook->update($patchRequest, $this->apiContext, $this->mockPayPalRestCall); $this->assertNotNull($result); $found = false; $foundObject = null; foreach ($result->getEventTypes() as $eventType) { if ($eventType->getName() == "PAYMENT.SALE.REFUNDED") { $found = true; break; } } $this->assertTrue($found); } /** * @depends testGet * @param $webhook Webhook */ public function testDelete($webhook) { $result = $webhook->delete($this->apiContext, $this->mockPayPalRestCall); $this->assertTrue($result); } public function testEventSearch() { $result = WebhookEvent::all(array(),$this->apiContext, $this->mockPayPalRestCall); $this->assertNotNull($result); return $result; } } rest-api-sdk-php/tests/PayPal/Test/Functional/Api/PaymentsFunctionalTest.php 0000644 00000006740 15007532371 0023124 0 ustar 00 <?php namespace PayPal\Test\Functional\Api; use PayPal\Api\Payment; use PayPal\Api\Refund; use PayPal\Api\Sale; use PayPal\Test\Functional\Setup; /** * Class WebProfile * * @package PayPal\Test\Api */ class PaymentsFunctionalTest extends \PHPUnit_Framework_TestCase { public $operation; public $response; public $mockPayPalRestCall; public $apiContext; public function setUp() { $className = $this->getClassName(); $testName = $this->getName(); $operationString = file_get_contents(__DIR__ . "/../resources/$className/$testName.json"); $this->operation = json_decode($operationString, true); $this->response = true; if (array_key_exists('body', $this->operation['response'])) { $this->response = json_encode($this->operation['response']['body']); } Setup::SetUpForFunctionalTests($this); } /** * Returns just the classname of the test you are executing. It removes the namespaces. * @return string */ public function getClassName() { return join('', array_slice(explode('\\', get_class($this)), -1)); } public function testCreate() { $request = $this->operation['request']['body']; $obj = new Payment($request); $result = $obj->create($this->apiContext, $this->mockPayPalRestCall); $this->assertNotNull($result); return $result; } public function testCreateWallet() { $request = $this->operation['request']['body']; $obj = new Payment($request); $result = $obj->create($this->apiContext, $this->mockPayPalRestCall); $this->assertNotNull($result); return $result; } /** * @depends testCreate * @param $payment Payment * @return Payment */ public function testGet($payment) { $result = Payment::get($payment->getId(), $this->apiContext, $this->mockPayPalRestCall); $this->assertNotNull($result); $this->assertEquals($payment->getId(), $result->getId()); return $result; } /** * @depends testGet * @param $payment Payment * @return Sale */ public function testGetSale($payment) { $transactions = $payment->getTransactions(); $transaction = $transactions[0]; $relatedResources = $transaction->getRelatedResources(); $resource = $relatedResources[0]; $result = Sale::get($resource->getSale()->getId(), $this->apiContext, $this->mockPayPalRestCall); $this->assertNotNull($result); $this->assertEquals($resource->getSale()->getId(), $result->getId()); return $result; } /** * @depends testGetSale * @param $sale Sale * @return Sale */ public function testRefundSale($sale) { $refund = new Refund($this->operation['request']['body']); $result = $sale->refund($refund, $this->apiContext, $this->mockPayPalRestCall); $this->assertNotNull($result); $this->assertEquals('completed', $result->getState()); $this->assertEquals($sale->getId(), $result->getSaleId()); $this->assertEquals($sale->getParentPayment(), $result->getParentPayment()); } /** * @depends testGet * @param $payment Payment * @return Payment */ public function testExecute($payment) { if (Setup::$mode == 'sandbox') { $this->markTestSkipped('Not executable on sandbox environment. Needs human interaction'); } } } rest-api-sdk-php/tests/PayPal/Test/Functional/Api/WebProfileFunctionalTest.php 0000644 00000011737 15007532371 0023364 0 ustar 00 <?php namespace PayPal\Test\Functional\Api; use PayPal\Api\CreateProfileResponse; use PayPal\Api\Patch; use PayPal\Api\WebProfile; use PayPal\Test\Functional\Setup; /** * Class WebProfile * * @package PayPal\Test\Api */ class WebProfileFunctionalTest extends \PHPUnit_Framework_TestCase { public $operation; public $response; public $mockPayPalRestCall; public $apiContext; public function setUp() { $className = $this->getClassName(); $testName = $this->getName(); $operationString = file_get_contents(__DIR__ . "/../resources/$className/$testName.json"); $this->operation = json_decode($operationString, true); $this->response = true; if (array_key_exists('body', $this->operation['response'])) { $this->response = json_encode($this->operation['response']['body']); } Setup::SetUpForFunctionalTests($this); } /** * Returns just the classname of the test you are executing. It removes the namespaces. * @return string */ public function getClassName() { return join('', array_slice(explode('\\', get_class($this)), -1)); } public function testCreate() { $request = $this->operation['request']['body']; $obj = new WebProfile($request); $obj->setName(uniqid()); $result = $obj->create($this->apiContext, $this->mockPayPalRestCall); $this->assertNotNull($result); return $result; } /** * @depends testCreate * @param $createProfileResponse CreateProfileResponse * @return WebProfile */ public function testGet($createProfileResponse) { $result = WebProfile::get($createProfileResponse->getId(), $this->apiContext, $this->mockPayPalRestCall); $this->assertNotNull($result); $this->assertEquals($createProfileResponse->getId(), $result->getId()); $this->assertEquals($this->operation['response']['body']['presentation']['logo_image'], $result->getPresentation()->getLogoImage()); $this->assertEquals($this->operation['response']['body']['input_fields']['no_shipping'], $result->getInputFields()->getNoShipping()); $this->assertEquals($this->operation['response']['body']['input_fields']['address_override'], $result->getInputFields()->getAddressOverride()); return $result; } /** * @depends testGet * @param $webProfile WebProfile */ public function testGetList($webProfile) { $result = WebProfile::get_list($this->apiContext, $this->mockPayPalRestCall); $this->assertNotNull($result); $found = false; $foundObject = null; foreach ($result as $webProfileObject) { if ($webProfileObject->getId() == $webProfile->getId()) { $found = true; $foundObject = $webProfileObject; break; } } $this->assertTrue($found, "The Created Web Profile was not found in the get list"); $this->assertEquals($webProfile->getId(), $foundObject->getId()); $this->assertEquals($this->operation['response']['body'][0]['presentation']['logo_image'], $foundObject->getPresentation()->getLogoImage()); $this->assertEquals($this->operation['response']['body'][0]['input_fields']['no_shipping'], $foundObject->getInputFields()->getNoShipping()); $this->assertEquals($this->operation['response']['body'][0]['input_fields']['address_override'], $foundObject->getInputFields()->getAddressOverride()); } /** * @depends testGet * @param $webProfile WebProfile */ public function testUpdate($webProfile) { $boolValue = $webProfile->getInputFields()->getNoShipping(); $newValue = ($boolValue + 1) % 2; $webProfile->getInputFields()->setNoShipping($newValue); $result = $webProfile->update($this->apiContext, $this->mockPayPalRestCall); $this->assertNotNull($result); $this->assertEquals($webProfile->getInputFields()->getNoShipping(), $newValue); } /** * @depends testGet * @param $webProfile WebProfile */ public function testPartialUpdate($webProfile) { $patches = array(); $patches[] = new Patch('{ "op": "add", "path": "/presentation/brand_name", "value":"new_brand_name" }'); $patches[] = new Patch('{ "op": "remove", "path": "/flow_config/landing_page_type" }'); $result = $webProfile->partial_update($patches, $this->apiContext, $this->mockPayPalRestCall); $this->assertTrue($result); } /** * @depends testGet * @param $createProfileResponse CreateProfileResponse */ public function testDelete($createProfileResponse) { $webProfile = new WebProfile(); $webProfile->setId($createProfileResponse->getId()); $result = $webProfile->delete($this->apiContext, $this->mockPayPalRestCall); $this->assertTrue($result); } } rest-api-sdk-php/tests/PayPal/Test/Functional/Api/InvoiceFunctionalTest.php 0000644 00000016022 15007532371 0022712 0 ustar 00 <?php namespace PayPal\Test\Functional\Api; use PayPal\Api\CancelNotification; use PayPal\Api\Invoice; use PayPal\Api\Notification; use PayPal\Api\PaymentDetail; use PayPal\Api\RefundDetail; use PayPal\Api\Search; use PayPal\Test\Functional\Setup; /** * Class Invoice * * @package PayPal\Test\Api */ class InvoiceFunctionalTest extends \PHPUnit_Framework_TestCase { public static $obj; public $operation; public $response; public $mockPayPalRestCall; public $apiContext; public function setUp() { $className = $this->getClassName(); $testName = $this->getName(); $this->setupTest($className, $testName); } public function setupTest($className, $testName) { $operationString = file_get_contents(__DIR__ . "/../resources/$className/$testName.json"); $this->operation = json_decode($operationString, true); $this->response = true; if (array_key_exists('body', $this->operation['response'])) { $this->response = json_encode($this->operation['response']['body']); } Setup::SetUpForFunctionalTests($this); } /** * Returns just the classname of the test you are executing. It removes the namespaces. * @return string */ public function getClassName() { return join('', array_slice(explode('\\', get_class($this)), -1)); } public function testCreate() { $request = $this->operation['request']['body']; $obj = new Invoice($request); $result = $obj->create($this->apiContext, $this->mockPayPalRestCall); $this->assertNotNull($result); self::$obj = $result; return $result; } /** * @depends testCreate * @param $invoice Invoice * @return Invoice */ public function testGet($invoice) { $result = Invoice::get($invoice->getId(), $this->apiContext, $this->mockPayPalRestCall); $this->assertNotNull($result); $this->assertEquals($invoice->getId(), $result->getId()); return $result; } /** * @depends testCreate * @param $invoice Invoice * @return Invoice */ public function testSend($invoice) { $result = $invoice->send($this->apiContext, $this->mockPayPalRestCall); $this->assertNotNull($result); return $invoice; } /** * @depends testSend * @param $invoice Invoice * @return Invoice */ public function testGetAll($invoice) { $result = Invoice::getAll(array('page_size' => '20', 'total_count_required' => 'true'), $this->apiContext, $this->mockPayPalRestCall); $this->assertNotNull($result); $this->assertNotNull($result->getTotalCount()); $totalPages = ceil($result->getTotalCount()/20); $found = false; $foundObject = null; do { foreach ($result->getInvoices() as $obj) { if ($obj->getId() == $invoice->getId()) { $found = true; $foundObject = $obj; break; } } if (!$found) { $result = Invoice::getAll(array('page' => --$totalPages, 'page_size' => '20', 'total_required' => 'yes'), $this->apiContext, $this->mockPayPalRestCall); } } while ($totalPages > 0 && $found == false); $this->assertTrue($found, "The Created Invoice was not found in the get list"); $this->assertEquals($invoice->getId(), $foundObject->getId()); } /** * @depends testSend * @param $invoice Invoice * @return Invoice */ public function testUpdate($invoice) { $result = $invoice->update($this->apiContext, $this->mockPayPalRestCall); $this->assertNotNull($result); $this->assertEquals($invoice->getId(), $result->getId()); } /** * @depends testSend * @param $invoice Invoice * @return Invoice */ public function testSearch($invoice) { $request = $this->operation['request']['body']; $search = new Search($request); $result = Invoice::search($search, $this->apiContext, $this->mockPayPalRestCall); $this->assertNotNull($result); $this->assertNotNull($result->getTotalCount()); } /** * @depends testSend * @param $invoice Invoice * @return Invoice */ public function testRemind($invoice) { $request = $this->operation['request']['body']; $notification = new Notification($request); $result = $invoice->remind($notification, $this->apiContext, $this->mockPayPalRestCall); $this->assertNotNull($result); } /** * @depends testSend * @param $invoice Invoice * @return Invoice */ public function testCancel($invoice) { $request = $this->operation['request']['body']; $notification = new CancelNotification($request); $result = $invoice->cancel($notification, $this->apiContext, $this->mockPayPalRestCall); $this->assertNotNull($result); } /** * @depends testSend * @param $invoice Invoice * @return Invoice */ public function testQRCode($invoice) { $result = Invoice::qrCode($invoice->getId(), array(), $this->apiContext, $this->mockPayPalRestCall); $this->assertNotNull($result); $this->assertNotNull($result->getImage()); } /** * @depends testSend * @param $invoice Invoice * @return Invoice */ public function testRecordPayment($invoice) { $this->setupTest($this->getClassName(), 'testCreate'); $invoice = $this->testCreate($invoice); $this->setupTest($this->getClassName(), 'testSend'); $invoice = $this->testSend($invoice); $this->setupTest($this->getClassName(), 'testRecordPayment'); $request = $this->operation['request']['body']; $paymentDetail = new PaymentDetail($request); $result = $invoice->recordPayment($paymentDetail, $this->apiContext, $this->mockPayPalRestCall); $this->assertNotNull($result); return $invoice; } /** * @depends testRecordPayment * @param $invoice Invoice * @return Invoice */ public function testRecordRefund($invoice) { $request = $this->operation['request']['body']; $refundDetail = new RefundDetail($request); $result = $invoice->recordRefund($refundDetail, $this->apiContext, $this->mockPayPalRestCall); $this->assertNotNull($result); $this->setupTest($this->getClassName(), 'testDelete'); $invoice = $this->testDelete($invoice); return $invoice; } /** * @depends testGet * @param $invoice Invoice * @return Invoice */ public function testDelete($invoice) { $this->setupTest($this->getClassName(), 'testCreate'); $invoice = $this->testCreate($invoice); $this->setupTest($this->getClassName(), 'testDelete'); $result = $invoice->delete($this->apiContext, $this->mockPayPalRestCall); $this->assertNotNull($result); } } rest-api-sdk-php/tests/PayPal/Test/Functional/Api/BillingAgreementsFunctionalTest.php 0000644 00000017067 15007532371 0024723 0 ustar 00 <?php namespace PayPal\Test\Functional\Api; use PayPal\Api\Agreement; use PayPal\Api\AgreementStateDescriptor; use PayPal\Api\Currency; use PayPal\Api\Patch; use PayPal\Api\PatchRequest; use PayPal\Api\Plan; use PayPal\Test\Functional\Setup; /** * Class Billing Agreements * * @package PayPal\Test\Api */ class BillingAgreementsFunctionalTest extends \PHPUnit_Framework_TestCase { public $operation; public $response; public $apiContext; public $mockPayPalRestCall; public function setUp() { $className = $this->getClassName(); $testName = $this->getName(); $this->setupTest($className, $testName); } public function setupTest($className, $testName) { $operationString = file_get_contents(__DIR__ . "/../resources/$className/$testName.json"); $this->operation = json_decode($operationString, true); $this->response = true; if (array_key_exists('body', $this->operation['response'])) { $this->response = json_encode($this->operation['response']['body']); } Setup::SetUpForFunctionalTests($this); } /** * Returns just the classname of the test you are executing. It removes the namespaces. * @return string */ public function getClassName() { return join('', array_slice(explode('\\', get_class($this)), -1)); } /** * @return Agreement */ public function testCreatePayPalAgreement() { $plan = BillingPlansFunctionalTest::getPlan(); $request = $this->operation['request']['body']; $agreement = new Agreement($request); // Update the Schema to use a working Plan $agreement->getPlan()->setId($plan->getId()); $result = $agreement->create($this->apiContext, $this->mockPayPalRestCall); $this->assertNotNull($result); return $result; } /** * @depends testCreatePayPalAgreement * @param $agreement Agreement * @return Agreement */ public function testExecute($agreement) { if (Setup::$mode == 'sandbox') { $this->markTestSkipped('Not executable on sandbox environment. Needs human interaction'); } $links = $agreement->getLinks(); $url = parse_url($links[0]->getHref(), 6); parse_str($url, $result); $paymentToken = $result['token']; $this->assertNotNull($paymentToken); $this->assertNotEmpty($paymentToken); $result = $agreement->execute($paymentToken, $this->apiContext, $this->mockPayPalRestCall); return $result; } /** * @return Agreement */ public function testCreateCCAgreement() { $plan = BillingPlansFunctionalTest::getPlan(); $request = $this->operation['request']['body']; $agreement = new Agreement($request); // Update the Schema to use a working Plan $agreement->getPlan()->setId($plan->getId()); $result = $agreement->create($this->apiContext, $this->mockPayPalRestCall); $this->assertNotNull($result); return $result; } /** * @depends testCreateCCAgreement * @param $agreement Agreement * @return Plan */ public function testGet($agreement) { $result = Agreement::get($agreement->getId(), $this->apiContext, $this->mockPayPalRestCall); $this->assertNotNull($result); $this->assertEquals($agreement->getId(), $result->getId()); return $result; } /** * @depends testGet * @param $agreement Agreement */ public function testUpdate($agreement) { /** @var Patch[] $request */ $request = $this->operation['request']['body'][0]; $patch = new Patch(); $patch->setOp($request['op']); $patch->setPath($request['path']); $patch->setValue($request['value']); $patches = array(); $patches[] = $patch; $patchRequest = new PatchRequest(); $patchRequest->setPatches($patches); $result = $agreement->update($patchRequest, $this->apiContext, $this->mockPayPalRestCall); $this->assertTrue($result); } /** * @depends testGet * @param $agreement Agreement * @return Agreement */ public function testSetBalance($agreement) { $this->markTestSkipped('Skipped as the fix is on the way.'); $currency = new Currency($this->operation['request']['body']); $result = $agreement->setBalance($currency, $this->apiContext, $this->mockPayPalRestCall); $this->assertTrue($result); return $agreement; } /** * @depends testGet * @param $agreement Agreement * @return Agreement */ public function testBillBalance($agreement) { $this->markTestSkipped('Skipped as the fix is on the way.'); $agreementStateDescriptor = new AgreementStateDescriptor($this->operation['request']['body']); $result = $agreement->billBalance($agreementStateDescriptor, $this->apiContext, $this->mockPayPalRestCall); $this->assertTrue($result); return $agreement; } /** * @depends testGet * @param $agreement Agreement * @return Agreement */ public function testGetTransactions($agreement) { $params = array('start_date' => date('Y-m-d', strtotime('-15 years')), 'end_date' => date('Y-m-d', strtotime('+5 days'))); $result = Agreement::searchTransactions($agreement->getId(), $params, $this->apiContext, $this->mockPayPalRestCall); $this->assertNotNull($result); $this->assertTrue(is_array($result->getAgreementTransactionList())); $this->assertTrue(sizeof($result->getAgreementTransactionList()) > 0); $list = $result->getAgreementTransactionList(); $first = $list[0]; $this->assertEquals($first->getTransactionId(), $agreement->getId()); } /** * @depends testGet * @param $agreement Agreement * @return Agreement */ public function testSuspend($agreement) { $agreementStateDescriptor = new AgreementStateDescriptor($this->operation['request']['body']); $result = $agreement->suspend($agreementStateDescriptor, $this->apiContext, $this->mockPayPalRestCall); $this->setupTest($this->getClassName(), 'testGetSuspended'); $get = $this->testGet($agreement); $this->assertTrue($result); $this->assertEquals('Suspended', $get->getState()); return $get; } /** * @depends testSuspend * @param $agreement Agreement * @return Agreement */ public function testReactivate($agreement) { $agreementStateDescriptor = new AgreementStateDescriptor($this->operation['request']['body']); $result = $agreement->reActivate($agreementStateDescriptor, $this->apiContext, $this->mockPayPalRestCall); $this->assertTrue($result); $this->setupTest($this->getClassName(), 'testGet'); $get = $this->testGet($agreement); $this->assertEquals('Active', $get->getState()); return $get; } /** * @depends testReactivate * @param $agreement Agreement * @return Agreement */ public function testCancel($agreement) { $agreementStateDescriptor = new AgreementStateDescriptor($this->operation['request']['body']); $result = $agreement->cancel($agreementStateDescriptor, $this->apiContext, $this->mockPayPalRestCall); $this->assertTrue($result); $this->setupTest($this->getClassName(), 'testGetCancelled'); $get = $this->testGet($agreement); $this->assertEquals('Cancelled', $get->getState()); return $get; } } rest-api-sdk-php/tests/PayPal/Test/Functional/Setup.php 0000644 00000003256 15007532371 0017027 0 ustar 00 <?php namespace PayPal\Test\Functional; use PayPal\Auth\OAuthTokenCredential; use PayPal\Core\PayPalCredentialManager; use PayPal\Rest\ApiContext; class Setup { public static $mode = 'mock'; public static function SetUpForFunctionalTests(\PHPUnit_Framework_TestCase &$test) { $configs = array( 'mode' => 'sandbox', 'http.ConnectionTimeOut' => 30, 'log.LogEnabled' => true, 'log.FileName' => '../PayPal.log', 'log.LogLevel' => 'FINE', 'validation.level' => 'log' ); $test->apiContext = new ApiContext( new OAuthTokenCredential('AYSq3RDGsmBLJE-otTkBtM-jBRd1TCQwFf9RGfwddNXWz0uFU9ztymylOhRS', 'EGnHDxD_qRPdaLdZz8iCr8N7_MzF-YHPTkjs6NKYQvQSBngp4PTTVWkPZRbL') ); $test->apiContext->setConfig($configs); //PayPalConfigManager::getInstance()->addConfigFromIni(__DIR__. '/../../../sdk_config.ini'); //PayPalConfigManager::getInstance()->addConfigs($configs); PayPalCredentialManager::getInstance()->setCredentialObject(PayPalCredentialManager::getInstance()->getCredentialObject('acct1')); self::$mode = getenv('REST_MODE') ? getenv('REST_MODE') : 'mock'; if (self::$mode != 'sandbox') { // Mock PayPalRest Caller if mode set to mock $test->mockPayPalRestCall = $test->getMockBuilder('\PayPal\Transport\PayPalRestCall') ->disableOriginalConstructor() ->getMock(); $test->mockPayPalRestCall->expects($test->any()) ->method('execute') ->will($test->returnValue( $test->response )); } } } rest-api-sdk-php/tests/PayPal/Test/Functional/resources/WebProfileFunctionalTest/testCreate.json 0000644 00000002474 15007532371 0027150 0 ustar 00 { "description": "Create a web experience profile.", "title": "Create profile", "runnable": true, "operationId": "web-profile.create", "user": { "scopes": [ "https://api.paypal.com/v1/payments/.*" ] }, "credentials": { "oauth": { "clientId": "test-client-01", "clientSecret": "test_secret_a", "path": "/v1/oauth2/token" } }, "request": { "path": "v1/payment-experience/web-profiles/", "method": "POST", "headers": { "Content-Type": "application/json", "PayPal-Request-Id": "abcdefgh123", "Authorization": "Bearer ECvJ_yBNz_UfMmCvWEbT_2ZWXdzbFFQZ-1Y5K2NGgeHn" }, "body": { "name":"someName2", "presentation":{ "logo_image":"http://www.ebay.com" }, "input_fields":{ "no_shipping":1, "address_override":1 }, "flow_config":{ "landing_page_type":"billing", "bank_txn_pending_url":"http://www.ebay.com" } } }, "response": { "status": "201", "headers": { "Content-Type": "application/json" }, "body": { "id": "XP-RFV4-PVD8-AGHJ-8E5J" } } } rest-api-sdk-php/tests/PayPal/Test/Functional/resources/WebProfileFunctionalTest/testGet.json 0000644 00000002360 15007532371 0026456 0 ustar 00 { "description": "Fetch a web experience profile.", "title": "Get profile", "runnable": true, "operationId": "web-profile.get", "user": { "scopes": [ "https://api.paypal.com/v1/payments/.*" ] }, "credentials": { "oauth": { "clientId": "test-client-01", "clientSecret": "test_secret_a", "path": "/v1/oauth2/token" } }, "request": { "path": "/v1/payment-experience/web-profiles/XP-RFV4-PVD8-AGHJ-8E5J", "method": "GET", "headers": { "Authorization": "Bearer ECvJ_yBNz_UfMmCvWEbT_2ZWXdzbFFQZ-1Y5K2NGgeHn" } }, "response": { "status": "200", "headers": { "Content-Type": "application/json" }, "body": { "id": "XP-RFV4-PVD8-AGHJ-8E5J", "name":"someName2", "presentation":{ "logo_image":"http://www.ebay.com" }, "input_fields":{ "no_shipping":1, "address_override":1 }, "flow_config":{ "landing_page_type":"billing", "bank_txn_pending_url":"http://www.ebay.com" } } } } tests/PayPal/Test/Functional/resources/WebProfileFunctionalTest/testPartialUpdate.json 0000644 00000002276 15007532371 0030425 0 ustar 00 rest-api-sdk-php { "description": "Partially update a web experience profile.", "title": "Partially Update profile", "runnable": true, "operationId": "web-profile.partial-update", "user": { "scopes": [ "https://api.paypal.com/v1/payments/.*" ] }, "credentials": { "oauth": { "clientId": "test-client-01", "clientSecret": "test_secret_a", "path": "/v1/oauth2/token" } }, "request": { "path": "v1/payment-experience/web-profiles/XP-RFV4-PVD8-AGHJ-8E5J", "method": "PATCH", "headers": { "Content-Type": "application/json", "PayPal-Request-Id": "abcdefgh123", "Authorization": "Bearer ECvJ_yBNz_UfMmCvWEbT_2ZWXdzbFFQZ-1Y5K2NGgeHn" }, "body": [ { "op": "add", "path": "/presentation/brand_name", "value":"new_brand_name" }, { "op": "remove", "path": "/flow_config/landing_page_type" } ] }, "response": { "status": "204", "headers": { "Content-Type": "application/json" } } } rest-api-sdk-php/tests/PayPal/Test/Functional/resources/WebProfileFunctionalTest/testUpdate.json 0000644 00000002331 15007532371 0027157 0 ustar 00 { "description": "Update a web experience profile.", "title": "Update profile", "runnable": true, "operationId": "web-profile.update", "user": { "scopes": [ "https://api.paypal.com/v1/payments/.*" ] }, "credentials": { "oauth": { "clientId": "test-client-01", "clientSecret": "test_secret_a", "path": "/v1/oauth2/token" } }, "request": { "path": "v1/payment-experience/web-profiles/XP-RFV4-PVD8-AGHJ-8E5J", "method": "PUT", "headers": { "Content-Type": "application/json", "Authorization": "Bearer ECvJ_yBNz_UfMmCvWEbT_2ZWXdzbFFQZ-1Y5K2NGgeHn" }, "body": { "name":"someName2", "presentation":{ "logo_image":"http://www.ebay.com" }, "input_fields":{ "no_shipping":0, "address_override":1 }, "flow_config":{ "landing_page_type":"billing", "bank_txn_pending_url":"http://www.ebay.com" } } }, "response": { "status": "204", "headers": { "Content-Type": "application/json" } } } rest-api-sdk-php/tests/PayPal/Test/Functional/resources/WebProfileFunctionalTest/testDelete.json 0000644 00000001362 15007532371 0027142 0 ustar 00 { "description": "Delete a web experience profile list.", "title": "Delete profile", "runnable": true, "operationId": "web-profile.delete", "user": { "scopes": [ "https://api.paypal.com/v1/payments/.*" ] }, "credentials": { "oauth": { "clientId": "test-client-01", "clientSecret": "test_secret_a", "path": "/v1/oauth2/token" } }, "request": { "path": "v1/payment-experience/web-profiles/XP-RFV4-PVD8-AGHJ-8E5J", "method": "DELETE", "headers": { "Authorization": "Bearer ECvJ_yBNz_UfMmCvWEbT_2ZWXdzbFFQZ-1Y5K2NGgeHn" } }, "response": { "status": "204", "headers": { } } } rest-api-sdk-php/tests/PayPal/Test/Functional/resources/WebProfileFunctionalTest/testGetList.json 0000644 00000004461 15007532371 0027316 0 ustar 00 { "description": "Fetch web experience profile list for a given merchant.", "title": "Get profile list", "runnable": true, "operationId": "web-profile.get-list", "user": { "scopes": [ "https://api.paypal.com/v1/payments/.*" ] }, "credentials": { "oauth": { "clientId": "test-client-01", "clientSecret": "test_secret_a", "path": "/v1/oauth2/token" } }, "request": { "path": "/v1/payment-experience/web-profiles", "method": "GET", "headers": { "Authorization": "Bearer ECvJ_yBNz_UfMmCvWEbT_2ZWXdzbFFQZ-1Y5K2NGgeHn" } }, "response": { "status": "200", "headers": { "Content-Type": "application/json" }, "body": [ { "id": "XP-RFV4-PVD8-AGHJ-8E5J", "name":"someName2", "presentation":{ "logo_image":"http://www.ebay.com" }, "input_fields":{ "no_shipping":1, "address_override":1 }, "flow_config":{ "landing_page_type":"billing", "bank_txn_pending_url":"http://www.ebay.com" } }, { "id": "XP-A88A-LYLW-8Y3X-E5ER", "name": "someName2", "flow_config": { "landing_page_type": "billing", "bank_txn_pending_url": "http://www.ebay.com" }, "input_fields": { "no_shipping": 1, "address_override": 1 }, "presentation": { "logo_image": "http://www.ebay.com" } }, { "id": "XP-RFV4-PVD8-AGHJ-8E5J", "name": "someName2", "flow_config": { "bank_txn_pending_url": "http://www.ebay.com" }, "input_fields": { "no_shipping": 1, "address_override": 1 }, "presentation": { "logo_image": "http://www.ebay.com" } } ] } } tests/PayPal/Test/Functional/resources/BillingAgreementsFunctionalTest/testReactivate.json 0000644 00000001403 15007532371 0031301 0 ustar 00 rest-api-sdk-php { "description" : "This operation activates the suspended agreement", "title" : "Reactivate agreement", "runnable" : true, "operationId" : "agreement.re-activate", "user" : { "scopes" : [ "https://uri.paypal.com/services/subscriptions"] }, "credentials" : { "oauth": { "path" : "/v1/oauth/token", "clientId":"", "clientSecret":"" } }, "request" : { "path" : "v1/payments/billing-agreements/{Agreement-Id}/re-activate", "method" : "POST", "headers" : {}, "body" : { "note": "Reactivating the profile" } }, "response" : { "status" : "204 No Content", "headers" : {}, "body" : {} } } tests/PayPal/Test/Functional/resources/BillingAgreementsFunctionalTest/testSuspend.json 0000644 00000001353 15007532371 0030637 0 ustar 00 rest-api-sdk-php { "description" : "This operation suspends the agreement", "title" : "Suspend agreement", "runnable" : true, "operationId" : "agreement.suspend", "user" : { "scopes" : [ "https://uri.paypal.com/services/subscriptions"] }, "credentials" : { "oauth": { "path" : "/v1/oauth/token", "clientId":"", "clientSecret":"" } }, "request" : { "path" : "v1/payments/billing-agreements/{Agreement-Id}/suspend", "method" : "POST", "headers" : {}, "body" : { "note": "Suspending the profile" } }, "response" : { "status" : "204 No Content", "headers" : {}, "body" : {} } } tests/PayPal/Test/Functional/resources/BillingAgreementsFunctionalTest/testCancel.json 0000644 00000001347 15007532371 0030406 0 ustar 00 rest-api-sdk-php { "description" : "This operation cancels the agreement", "title" : "Cancel agreement", "runnable" : true, "operationId" : "agreement.cancel", "user" : { "scopes" : [ "https://uri.paypal.com/services/subscriptions"] }, "credentials" : { "oauth": { "path" : "/v1/oauth/token", "clientId":"", "clientSecret":"" } }, "request" : { "path" : "v1/payments/billing-agreements/{Agreement-Id}/cancel", "method" : "POST", "headers" : {}, "body" : { "note": "Cancelling the profile" } }, "response" : { "status" : "204 No Content", "headers" : {}, "body" : {} } } rest-api-sdk-php/tests/PayPal/Test/Functional/resources/BillingAgreementsFunctionalTest/testGet.json0000644 00000012013 15007532371 0030007 0 ustar 00 { "description": "This operation fetches details of the agreement", "title": "Fetch agreement details", "runnable": true, "operationId": "agreement.get", "user": { "scopes": ["https://uri.paypal.com/services/subscriptions"] }, "credentials": { "oauth": { "path": "/v1/oauth/token", "clientId": "", "clientSecret": "" } }, "request": { "path": "v1/payments/billing-agreements/I-5D3XDN2D5FH1", "method": "GET", "headers": {}, "body": {} }, "response": { "status": "200 OK", "headers": {}, "body": { "id": "I-V8SSE9WLJGY6", "state": "Active", "description": "Payment with credit Card ", "plan": { "payment_definitions": [ { "type": "TRIAL", "frequency": "Week", "amount": { "currency": "USD", "value": "9.19" }, "cycles": "2", "charge_models": [ { "type": "TAX", "amount": { "currency": "USD", "value": "2.00" } }, { "type": "SHIPPING", "amount": { "currency": "USD", "value": "1.00" } } ], "frequency_interval": "5" }, { "type": "REGULAR", "frequency": "Month", "amount": { "currency": "USD", "value": "100.00" }, "cycles": "12", "charge_models": [ { "type": "TAX", "amount": { "currency": "USD", "value": "12.00" } }, { "type": "SHIPPING", "amount": { "currency": "USD", "value": "10.00" } } ], "frequency_interval": "2" } ], "merchant_preferences": { "setup_fee": { "currency": "USD", "value": "1.00" }, "max_fail_attempts": "0", "auto_bill_amount": "YES" } }, "links": [ { "href": "https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-XTN3V7NY6KG7/suspend", "rel": "suspend", "method": "POST" }, { "href": "https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-XTN3V7NY6KG7/re-activate", "rel": "re_activate", "method": "POST" }, { "href": "https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-XTN3V7NY6KG7/cancel", "rel": "cancel", "method": "POST" }, { "href": "https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-XTN3V7NY6KG7/bill-balance", "rel": "self", "method": "POST" }, { "href": "https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-XTN3V7NY6KG7/set-balance", "rel": "self", "method": "POST" } ], "start_date": "2015-06-17T16:45:04Z", "agreement_details": { "outstanding_balance": { "currency": "USD", "value": "200.00" }, "cycles_remaining": "2", "cycles_completed": "0", "next_billing_date": "2015-06-17T10:00:00Z", "last_payment_date": "2014-10-28T22:48:56Z", "last_payment_amount": { "currency": "USD", "value": "1.00" }, "final_payment_date": "2017-06-26T10:00:00Z", "failed_payment_count": "0" } } } } tests/PayPal/Test/Functional/resources/BillingAgreementsFunctionalTest/testCreateCCAgreement.json 0000644 00000004037 15007532371 0032461 0 ustar 00 rest-api-sdk-php { "description": "This operation creates agreement having Credit card as payment option", "title": "Agreement created using credit card", "runnable": true, "operationId": "agreement.create", "user": { "scopes": ["https://uri.paypal.com/services/subscriptions"] }, "credentials": { "oauth": { "path": "/v1/oauth/token", "clientId": "", "clientSecret": "" } }, "request": { "path": "v1/payments/billing-agreements/", "method": "POST", "headers": {}, "body": { "name": "DPRP", "description": "Payment with credit Card ", "start_date": "2019-06-17T9:45:04Z", "plan": { "id": "P-1WJ68935LL406420PUTENA2I" }, "shipping_address": { "line1": "111 First Street", "city": "Saratoga", "state": "CA", "postal_code": "95070", "country_code": "US" }, "payer": { "payment_method": "credit_card", "payer_info": { "email": "jaypatel512-facilitator@hotmail.com" }, "funding_instruments": [ { "credit_card": { "type": "visa", "number": "4204466604263862", "expire_month": "12", "expire_year": "2017", "cvv2": "128" } } ] } } }, "response": { "status": "200 OK", "headers": {}, "body": { "id": "I-V8SSE9WLJGY6", "links": [ { "href": "https://stage2p2163.qa.paypal.com/v1/payments/billing-agreements/I-V8SSE9WLJGY6", "rel": "self", "method": "GET" } ] } } } tests/PayPal/Test/Functional/resources/BillingAgreementsFunctionalTest/testUpdate.json 0000644 00000002341 15007532371 0030436 0 ustar 00 rest-api-sdk-php { "description": "This operation updates agreement", "title": "Update agreement", "runnable": true, "operationId": "agreement.update", "user": { "scopes": ["https://uri.paypal.com/services/subscriptions"] }, "credentials": { "oauth": { "path": "/v1/oauth/token", "clientId": "", "clientSecret": "" } }, "request": { "path": "v1/payments/billing-agreements/{Agreement-Id}", "method": "PATCH", "headers": {}, "body": [ { "op": "replace", "path": "/", "value": { "description": "Updated description", "start_date": "2024-06-18T10:00:00Z", "shipping_address":{ "line1":"Hotel Blue Diamond", "line2":"Church Street", "city":"San Jose", "state":"CA", "postal_code":"95112", "country_code":"US" } } } ] }, "response": { "status": "200 OK", "headers": {}, "body": {} } } tests/PayPal/Test/Functional/resources/BillingAgreementsFunctionalTest/testGetSuspended.json 0000644 00000012014 15007532371 0031604 0 ustar 00 rest-api-sdk-php { "description": "This operation fetches details of the agreement", "title": "Fetch agreement details", "runnable": true, "operationId": "agreement.get", "user": { "scopes": ["https://uri.paypal.com/services/subscriptions"] }, "credentials": { "oauth": { "path": "/v1/oauth/token", "clientId": "", "clientSecret": "" } }, "request": { "path": "v1/payments/billing-agreements/I-5D3XDN2D5FH1", "method": "GET", "headers": {}, "body": {} }, "response": { "status": "200 OK", "headers": {}, "body": { "id": "I-V8SSE9WLJGY6", "state": "Suspended", "description": "Payment with credit Card ", "plan": { "payment_definitions": [ { "type": "TRIAL", "frequency": "Week", "amount": { "currency": "USD", "value": "9.19" }, "cycles": "2", "charge_models": [ { "type": "TAX", "amount": { "currency": "USD", "value": "2.00" } }, { "type": "SHIPPING", "amount": { "currency": "USD", "value": "1.00" } } ], "frequency_interval": "5" }, { "type": "REGULAR", "frequency": "Month", "amount": { "currency": "USD", "value": "100.00" }, "cycles": "12", "charge_models": [ { "type": "TAX", "amount": { "currency": "USD", "value": "12.00" } }, { "type": "SHIPPING", "amount": { "currency": "USD", "value": "10.00" } } ], "frequency_interval": "2" } ], "merchant_preferences": { "setup_fee": { "currency": "USD", "value": "1.00" }, "max_fail_attempts": "0", "auto_bill_amount": "YES" } }, "links": [ { "href": "https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-XTN3V7NY6KG7/suspend", "rel": "suspend", "method": "POST" }, { "href": "https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-XTN3V7NY6KG7/re-activate", "rel": "re_activate", "method": "POST" }, { "href": "https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-XTN3V7NY6KG7/cancel", "rel": "cancel", "method": "POST" }, { "href": "https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-XTN3V7NY6KG7/bill-balance", "rel": "self", "method": "POST" }, { "href": "https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-XTN3V7NY6KG7/set-balance", "rel": "self", "method": "POST" } ], "start_date": "2015-06-17T16:45:04Z", "agreement_details": { "outstanding_balance": { "currency": "USD", "value": "0.00" }, "cycles_remaining": "2", "cycles_completed": "0", "next_billing_date": "2015-06-17T10:00:00Z", "last_payment_date": "2014-10-28T22:48:56Z", "last_payment_amount": { "currency": "USD", "value": "1.00" }, "final_payment_date": "2017-06-26T10:00:00Z", "failed_payment_count": "0" } } } } tests/PayPal/Test/Functional/resources/BillingAgreementsFunctionalTest/testCreateWithOverride.json 0000644 00000012364 15007532371 0032761 0 ustar 00 rest-api-sdk-php { "description" : "This operation creates agreement having PayPal as payment option", "title" : "Agreement created having PayPal as payment option", "runnable" : true, "operationId" : "agreement.create", "user" : { "scopes" : [ "https://uri.paypal.com/services/subscriptions"] }, "credentials" : { "oauth": { "path" : "/v1/oauth/token", "clientId":"", "clientSecret":"" } }, "request" : { "path" : "v1/payments/billing-agreements/", "method" : "POST", "headers" : {}, "body" : { "name":"Override Agreement", "description": "Agreement where merchant preferences and charge model is overridden", "start_date" : "2014-06-17T03:05:05Z", "payer":{ "payment_method":"paypal", "payer_info": { "email":"kkarunanidhi-per1@paypal.com" } }, "plan":{ "id":"P-1WJ68935LL406420PUTENA2I" }, "shipping_address":{ "line1":"Hotel Staybridge", "line2":"Crooke Street", "city":"San Jose", "state":"CA", "postal_code":"95112", "country_code":"US" }, "override_merchant_preferences":{ "setup_fee": { "value" : "3", "currency" : "GBP" }, "return_url":"http://indiatimes.com", "cancel_url":"http://rediff.com", "auto_bill_amount": "YES", "initial_fail_amount_action": "CONTINUE", "max_fail_attempts": "11" }, "override_charge_models":[ { "charge_id": "CHM-8373958130821962WUTENA2Q", "amount": { "value" :"1", "currency" : "GBP" } } ] } }, "response" : { "status" : "201 Created", "headers" : {}, "body" : { "name": "Override Agreement", "description": "Agreement where merchant preferences and charge model is overridden", "plan": { "id": "P-1WJ68935LL406420PUTENA2I", "state": "ACTIVE", "name": "Fast Speed Plan", "description": "Vanilla plan", "type": "INFINITE", "payment_definitions": [ { "id": "PD-9WG6983719571780GUTENA2I", "name": "Payment Definition-1", "type": "REGULAR", "frequency": "Day", "amount": { "currency": "GBP", "value": "10" }, "charge_models": [ { "id": "CHM-8373958130821962WUTENA2Q", "type": "SHIPPING", "amount": { "currency": "GBP", "value": "1" } }, { "id": "CHM-2937144979861454NUTENA2Q", "type": "TAX", "amount": { "currency": "GBP", "value": "2" } } ], "cycles": "0", "frequency_interval": "1" }, { "id": "PD-89M493313S710490TUTENA2Q", "name": "Payment Definition-1", "type": "TRIAL", "frequency": "Month", "amount": { "currency": "GBP", "value": "100" }, "charge_models": [ { "id": "CHM-78K47820SS4923826UTENA2Q", "type": "SHIPPING", "amount": { "currency": "GBP", "value": "10" } }, { "id": "CHM-9M366179U7339472RUTENA2Q", "type": "TAX", "amount": { "currency": "GBP", "value": "12" } } ], "cycles": "5", "frequency_interval": "2" } ], "merchant_preferences": { "setup_fee": { "currency": "GBP", "value": "3" }, "max_fail_attempts": "11", "return_url": "http://indiatimes.com", "cancel_url": "http://rediff.com", "auto_bill_amount": "YES", "initial_fail_amount_action": "CONTINUE" } }, "links": [ { "href": "https://stage2p2163.qa.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-83C745436S346813F", "rel": "approval_url", "method": "REDIRECT" }, { "href": "https://stage2p2163.qa.paypal.com/v1/payments/billing-agreements/EC-83C745436S346813F/agreement-execute", "rel": "execute", "method": "POST" } ], "start_date": "2014-06-17T03:05:05Z" } } } tests/PayPal/Test/Functional/resources/BillingAgreementsFunctionalTest/testGetCancelled.json 0000644 00000012014 15007532371 0031524 0 ustar 00 rest-api-sdk-php { "description": "This operation fetches details of the agreement", "title": "Fetch agreement details", "runnable": true, "operationId": "agreement.get", "user": { "scopes": ["https://uri.paypal.com/services/subscriptions"] }, "credentials": { "oauth": { "path": "/v1/oauth/token", "clientId": "", "clientSecret": "" } }, "request": { "path": "v1/payments/billing-agreements/I-5D3XDN2D5FH1", "method": "GET", "headers": {}, "body": {} }, "response": { "status": "200 OK", "headers": {}, "body": { "id": "I-V8SSE9WLJGY6", "state": "Cancelled", "description": "Payment with credit Card ", "plan": { "payment_definitions": [ { "type": "TRIAL", "frequency": "Week", "amount": { "currency": "USD", "value": "9.19" }, "cycles": "2", "charge_models": [ { "type": "TAX", "amount": { "currency": "USD", "value": "2.00" } }, { "type": "SHIPPING", "amount": { "currency": "USD", "value": "1.00" } } ], "frequency_interval": "5" }, { "type": "REGULAR", "frequency": "Month", "amount": { "currency": "USD", "value": "100.00" }, "cycles": "12", "charge_models": [ { "type": "TAX", "amount": { "currency": "USD", "value": "12.00" } }, { "type": "SHIPPING", "amount": { "currency": "USD", "value": "10.00" } } ], "frequency_interval": "2" } ], "merchant_preferences": { "setup_fee": { "currency": "USD", "value": "1.00" }, "max_fail_attempts": "0", "auto_bill_amount": "YES" } }, "links": [ { "href": "https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-XTN3V7NY6KG7/suspend", "rel": "suspend", "method": "POST" }, { "href": "https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-XTN3V7NY6KG7/re-activate", "rel": "re_activate", "method": "POST" }, { "href": "https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-XTN3V7NY6KG7/cancel", "rel": "cancel", "method": "POST" }, { "href": "https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-XTN3V7NY6KG7/bill-balance", "rel": "self", "method": "POST" }, { "href": "https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-XTN3V7NY6KG7/set-balance", "rel": "self", "method": "POST" } ], "start_date": "2015-06-17T16:45:04Z", "agreement_details": { "outstanding_balance": { "currency": "USD", "value": "0.00" }, "cycles_remaining": "2", "cycles_completed": "0", "next_billing_date": "2015-06-17T10:00:00Z", "last_payment_date": "2014-10-28T22:48:56Z", "last_payment_amount": { "currency": "USD", "value": "1.00" }, "final_payment_date": "2017-06-26T10:00:00Z", "failed_payment_count": "0" } } } } PayPal/Test/Functional/resources/BillingAgreementsFunctionalTest/testCreatePayPalAgreement.json 0000644 00000012235 15007532371 0033361 0 ustar 00 rest-api-sdk-php/tests { "description": "This operation creates agreement having PayPal as payment option", "title": "Agreement created having PayPal as payment option", "runnable": true, "operationId": "agreement.create", "user": { "scopes": ["https://uri.paypal.com/services/subscriptions"] }, "credentials": { "oauth": { "path": "/v1/oauth/token", "clientId": "", "clientSecret": "" } }, "request": { "path": "v1/payments/billing-agreements/", "method": "POST", "headers": {}, "body": { "name": "Base Agreement", "description": "Basic agreement", "start_date": "2019-06-17T9:45:04Z", "plan": { "id": "P-1WJ68935LL406420PUTENA2I" }, "payer": { "payment_method": "paypal" }, "shipping_address": { "line1": "111 First Street", "city": "Saratoga", "state": "CA", "postal_code": "95070", "country_code": "US" } } }, "response": { "status": "201 Created", "headers": {}, "body": { "name": "Base Agreement", "description": "Basic agreement", "plan": { "id": "P-1WJ68935LL406420PUTENA2I", "state": "ACTIVE", "name": "Fast Speed Plan", "description": "Bathinda", "type": "INFINITE", "payment_definitions": [ { "id": "PD-9WG6983719571780GUTENA2I", "name": "Payment Definition-1", "type": "REGULAR", "frequency": "Day", "amount": { "currency": "GBP", "value": "10" }, "charge_models": [ { "id": "CHM-8373958130821962WUTENA2Q", "type": "SHIPPING", "amount": { "currency": "GBP", "value": "1" } }, { "id": "CHM-2937144979861454NUTENA2Q", "type": "TAX", "amount": { "currency": "GBP", "value": "2" } } ], "cycles": "0", "frequency_interval": "1" }, { "id": "PD-89M493313S710490TUTENA2Q", "name": "Payment Definition-1", "type": "TRIAL", "frequency": "Month", "amount": { "currency": "GBP", "value": "100" }, "charge_models": [ { "id": "CHM-78K47820SS4923826UTENA2Q", "type": "SHIPPING", "amount": { "currency": "GBP", "value": "10" } }, { "id": "CHM-9M366179U7339472RUTENA2Q", "type": "TAX", "amount": { "currency": "GBP", "value": "12" } } ], "cycles": "5", "frequency_interval": "2" } ], "merchant_preferences": { "setup_fee": { "currency": "GBP", "value": "1234" }, "max_fail_attempts": "21", "return_url": "http://www.paypal.com", "cancel_url": "http://www.yahoo.com", "auto_bill_amount": "YES", "initial_fail_amount_action": "CONTINUE" } }, "links": [ { "href": "https://stage2p2163.qa.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-32P34986EV202211E", "rel": "approval_url", "method": "REDIRECT" }, { "href": "https://stage2p2163.qa.paypal.com/v1/payments/billing-agreements/EC-32P34986EV202211E/agreement-execute", "rel": "execute", "method": "POST" } ], "start_date": "2114-06-17T9:45:04Z" } } } tests/PayPal/Test/Functional/resources/BillingAgreementsFunctionalTest/testGetTransactions.json 0000644 00000004020 15007532371 0032320 0 ustar 00 rest-api-sdk-php { "description" : "This operation lists the transactions for the agreement", "title" : "Transaction listing of agreement", "runnable" : true, "operationId" : "agreement.transactions", "user" : { "scopes" : [ "https://uri.paypal.com/services/subscriptions"] }, "credentials" : { "oauth": { "path" : "/v1/oauth/token", "clientId":"", "clientSecret":"" } }, "request" : { "path" : "v1/payments/billing-agreements/{Agreement-Id}/transaction?start-date=yyyy-mm-dd&end-date=yyyy-mm-dd", "method" : "GET", "headers" : {}, "body" : {} }, "response" : { "status" : "200 OK", "headers" : {}, "body" : { "agreement_transaction_list": [ { "transaction_id": "I-V8SSE9WLJGY6", "status": "Created", "transaction_type": "Recurring Payment", "payer_email": "", "payer_name": " ", "time_stamp": "2014-06-16T13:46:53Z", "time_zone": "GMT" }, { "transaction_id": "I-V8SSE9WLJGY6", "status": "Suspended", "transaction_type": "Recurring Payment", "payer_email": "", "payer_name": " ", "time_stamp": "2014-06-16T13:52:26Z", "time_zone": "GMT" }, { "transaction_id": "I-V8SSE9WLJGY6", "status": "Reactivated", "transaction_type": "Recurring Payment", "payer_email": "", "payer_name": " ", "time_stamp": "2014-06-16T14:00:23Z", "time_zone": "GMT" }, { "transaction_id": "I-V8SSE9WLJGY6", "status": "Canceled", "transaction_type": "Recurring Payment", "payer_email": "", "payer_name": " ", "time_stamp": "2014-06-16T14:02:54Z", "time_zone": "GMT" } ] } } } tests/PayPal/Test/Functional/resources/BillingAgreementsFunctionalTest/testBillBalance.json 0000644 00000002070 15007532371 0031343 0 ustar 00 rest-api-sdk-php { "description" : "Bill an outstanding amount for an agreement by passing the ID of the agreement to the request URI. In addition, pass an agreement_state_descriptor object in the request JSON that includes a note about the reason for changing the state of the agreement and the amount and currency for the agreement.", "title" : "bill-balance", "runnable" : true, "operationId" : "agreement.bill-balance", "user" : { "scopes" : [ "https://uri.paypal.com/services/subscriptions"] }, "credentials" : { "oauth": { "path" : "/v1/oauth/token", "clientId":"", "clientSecret":"" } }, "request" : { "path" : "v1/payments/billing-agreements/{Agreement-Id}/bill-balance", "method" : "POST", "headers" : {}, "body" : { "note":"Billing Balance Amount", "amount": { "value" : "100", "currency" : "USD" } } }, "response" : { "status" : "204 No Content", "headers" : {}, "body" : {} } } tests/PayPal/Test/Functional/resources/BillingAgreementsFunctionalTest/testSetBalance.json 0000644 00000001645 15007532371 0031223 0 ustar 00 rest-api-sdk-php { "description" : "Set the balance for an agreement by passing the ID of the agreement to the request URI. In addition, pass a common_currency object in the request JSON that specifies the currency type and value of the balance.", "title" : "set-balance", "runnable" : true, "operationId" : "agreement.set-balance", "user" : { "scopes" : [ "https://uri.paypal.com/services/subscriptions"] }, "credentials" : { "oauth": { "path" : "/v1/oauth/token", "clientId":"", "clientSecret":"" } }, "request" : { "path" : "v1/payments/billing-agreements/{Agreement-Id}/set-balance", "method" : "POST", "headers" : {}, "body" : { "value" : "200", "currency" : "USD" } }, "response" : { "status" : "204 No Content", "headers" : {}, "body" : {} } } tests/PayPal/Test/Functional/resources/BillingAgreementsFunctionalTest/testExecute.json 0000644 00000001704 15007532371 0030620 0 ustar 00 rest-api-sdk-php { "description" : "Create PayPal agreement after buyer approval", "title" : "Agreement creation", "runnable" : true, "operationId" : "agreement.execute", "user" : { "scopes" : ["https://uri.paypal.com/services/subscriptions" ] }, "credentials" : { "oauth": { "path" : "/v1/oauth/token", "clientId":"", "clientSecret":"" } }, "request" : { "path" : "v1/payments/billing-agreements/EC-6CT996018D989343F/agreement-execute", "method" : "POST", "headers" : {}, "body" : {} }, "response" : { "status" : "200 OK", "headers" : {}, "body" : { "id": "I-5D3XDN2D5FH1", "links": [ { "href": "https://stage2p2163.qa.paypal.com/v1/payments/billing-agreements/I-5D3XDN2D5FH1", "rel": "self", "method": "GET" } ] } } } rest-api-sdk-php/tests/PayPal/Test/Functional/resources/WebhookFunctionalTest/testEventResend.json 0000644 00000005444 15007532371 0027527 0 ustar 00 { "description":"Resend a webhook event", "title":"Resend a webhook event", "runnable":true, "operationId":"event.resend", "user":{ "scopes":[ "https://uri.paypal.com/services/applications/webhooks" ] }, "credentials":{ "oauth":{ "path":"/v1/oauth/token", "clientId":"", "clientSecret":"" } }, "request":{ "path":"v1/notifications/webhooks-events/8PT597110X687430LKGECATA/resend", "method":"GET", "headers":{ "Content-Type":"application/json", "Authorization":"Bearer ECvJ_yBNz_UfMmCvWEbT_2ZWXdzbFFQZ-1Y5K2NGgeHn" } }, "response":{ "status":"202", "headers":{ "Content-Type":"application/json", "Paypal-Debug-id":"0c444abc1d12d" }, "body":{ "id":"8PT597110X687430LKGECATA", "create_time":"2013-06-25T21:41:28Z", "resource_type":"authorization", "trigger_event":"PAYMENT.AUTHORIZATION.CREATED", "summary":"A payment authorization was created", "resource":{ "id":"2DC87612EK520411B", "create_time":"2013-06-25T21:39:15Z", "update_time":"2013-06-25T21:39:17Z", "state":"authorized", "amount":{ "total":"7.47", "currency":"USD", "details":{ "subtotal":"7.47" } }, "parent_payment":"PAY-36246664YD343335CKHFA4AY", "valid_until":"2013-07-24T21:39:15Z", "links":[ { "href":"https://api.paypal.com/v1/payments/authorization/2DC87612EK520411B", "rel":"self", "method":"GET" }, { "href":"https://api.paypal.com/v1/payments/authorization/2DC87612EK520411B/capture", "rel":"capture", "method":"POST" }, { "href":"https://api.paypal.com/v1/payments/authorization/2DC87612EK520411B/void", "rel":"void", "method":"POST" }, { "href":"https://api.paypal.com/v1/payments/payment/PAY-36246664YD343335CKHFA4AY", "rel":"parent_payment", "method":"GET" } ] }, "links":[ { "href":"https://api.paypal.com/v1/notfications/webhooks-events/8PT597110X687430LKGECATA", "rel":"self", "method":"GET" }, { "href":"https://api.paypal.com/v1/notfications/webhooks-events/8PT597110X687430LKGECATA/resend", "rel":"resend", "method":"POST" } ] } } } rest-api-sdk-php/tests/PayPal/Test/Functional/resources/WebhookFunctionalTest/testCreate.json 0000644 00000004005 15007532371 0026500 0 ustar 00 { "description":"Create a webhook", "title":"Create a webhook", "runnable":true, "operationId":"webhooks.create", "user":{ "scopes":[ "https://uri.paypal.com/services/applications/webhooks" ] }, "credentials":{ "oauth":{ "path":"/v1/oauth/token", "clientId":"", "clientSecret":"" } }, "request":{ "path":"v1/notifications/webhooks", "method":"POST", "headers":{ "Content-Type":"application/json", "Authorization":"Bearer ECvJ_yBNz_UfMmCvWEbT_2ZWXdzbFFQZ-1Y5K2NGgeHn" }, "body":{ "url":"https://requestb.in/10ujt3c1", "event_types":[ { "name":"PAYMENT.AUTHORIZATION.CREATED" }, { "name":"PAYMENT.AUTHORIZATION.VOIDED" } ] } }, "response":{ "status":"201", "headers":{ "Content-Type":"application/json", "Paypal-Debug-id":"0c444abc1d12d" }, "body":{ "id":"0EH40505U7160970P", "url":"https://requestb.in/10ujt3c1", "event_types":[ { "name":"PAYMENT.AUTHORIZATION.CREATED", "description":"A payment authorization was created" }, { "name":"PAYMENT.AUTHORIZATION.VOIDED", "description":"A payment authorization was voided" } ], "links":[ { "href":"https://api.paypal.com/v1/notifications/webhooks/0EH40505U7160970P", "rel":"self", "method":"GET" }, { "href":"https://api.paypal.com/v1/notifications/webhooks/0EH40505U7160970P", "rel":"update", "method":"PATCH" }, { "href":"https://api.paypal.com/v1/notifications/webhooks/0EH40505U7160970P", "rel":"delete", "method":"DELETE" } ] } } } rest-api-sdk-php/tests/PayPal/Test/Functional/resources/WebhookFunctionalTest/testGet.json 0000644 00000003376 15007532371 0026026 0 ustar 00 { "description":"Get a webhook", "title":"Get a webhook", "runnable":true, "operationId":"webhooks.get", "user":{ "scopes":[ "https://uri.paypal.com/services/applications/webhooks" ] }, "credentials":{ "oauth":{ "path":"/v1/oauth/token", "clientId":"", "clientSecret":"" } }, "request":{ "path":"v1/notifications/webhooks/0EH40505U7160970P", "method":"GET", "headers":{ "Content-Type":"application/json", "Authorization":"Bearer ECvJ_yBNz_UfMmCvWEbT_2ZWXdzbFFQZ-1Y5K2NGgeHn" } }, "response":{ "status":"200", "headers":{ "Content-Type":"application/json", "Paypal-Debug-id":"0c444abc1d12d" }, "body":{ "id":"0EH40505U7160970P", "url":"https://requestb.in/10ujt3c1", "event_types":[ { "name":"PAYMENT.AUTHORIZATION.CREATED", "description":"A payment authorization was created" }, { "name":"PAYMENT.AUTHORIZATION.VOIDED", "description":"A payment authorization was voided" } ], "links":[ { "href":"https://api.paypal.com/v1/notifications/webhooks/0EH40505U7160970P", "rel":"self", "method":"GET" }, { "href":"https://api.paypal.com/v1/notifications/webhooks/0EH40505U7160970P", "rel":"update", "method":"PATCH" }, { "href":"https://api.paypal.com/v1/notifications/webhooks/0EH40505U7160970P", "rel":"delete", "method":"DELETE" } ] } } } rest-api-sdk-php/tests/PayPal/Test/Functional/resources/WebhookFunctionalTest/testGetAll.json 0000644 00000006243 15007532371 0026453 0 ustar 00 { "description":"Get all webhooks", "title":"Get all webhook", "runnable":true, "operationId":"webhooks.get-all", "user":{ "scopes":[ "https://uri.paypal.com/services/applications/webhooks" ] }, "credentials":{ "oauth":{ "path":"/v1/oauth/token", "clientId":"", "clientSecret":"" } }, "request":{ "path":"v1/notifications/webhooks", "method":"GET", "headers":{ "Content-Type":"application/json", "Authorization":"Bearer ECvJ_yBNz_UfMmCvWEbT_2ZWXdzbFFQZ-1Y5K2NGgeHn" } }, "response":{ "status":"200", "headers":{ "Content-Type":"application/json", "Paypal-Debug-id":"0c444abc1d12d" }, "body":{ "webhooks":[ { "id":"40Y916089Y8324740", "url":"http://www.ebay.com/paypal_webhook", "event_types":[ { "name":"PAYMENT.AUTHORIZATION.CREATED", "description":"A payment authorization was created" }, { "name":"PAYMENT.AUTHORIZATION.VOIDED", "description":"A payment authorization was voided" } ], "links":[ { "href":"https://api.paypal.com/v1/notifications/webhooks/40Y916089Y8324740", "rel":"self", "method":"GET" }, { "href":"https://api.paypal.com/v1/notifications/webhooks/40Y916089Y8324740", "rel":"update", "method":"PATCH" }, { "href":"https://api.paypal.com/v1/notifications/webhooks/40Y916089Y8324740", "rel":"delete", "method":"DELETE" } ] }, { "id":"0EH40505U7160970P", "url":"http://www.ebay.com/another_paypal_webhook", "event_types":[ { "name":"PAYMENT.AUTHORIZATION.CREATED", "description":"A payment authorization was created" }, { "name":"PAYMENT.AUTHORIZATION.VOIDED", "description":"A payment authorization was voided" } ], "links":[ { "href":"https://api.paypal.com/v1/notifications/webhooks/0EH40505U7160970P", "rel":"self", "method":"GET" }, { "href":"https://api.paypal.com/v1/notifications/webhooks/0EH40505U7160970P", "rel":"update", "method":"PATCH" }, { "href":"https://api.paypal.com/v1/notifications/webhooks/0EH40505U7160970P", "rel":"delete", "method":"DELETE" } ] } ] } } } rest-api-sdk-php/tests/PayPal/Test/Functional/resources/WebhookFunctionalTest/testUpdate.json 0000644 00000003712 15007532371 0026523 0 ustar 00 { "description":"Update a webhook", "title":"Updated a webhook", "runnable":true, "operationId":"webhooks.update", "user":{ "scopes":[ "https://uri.paypal.com/services/applications/webhooks" ] }, "credentials":{ "oauth":{ "path":"/v1/oauth/token", "clientId":"", "clientSecret":"" } }, "request":{ "path":"v1/notifications/webhooks/0EH40505U7160970P", "method":"PATCH", "headers":{ "Content-Type":"application/json", "Authorization":"Bearer ECvJ_yBNz_UfMmCvWEbT_2ZWXdzbFFQZ-1Y5K2NGgeHn" }, "body":[ { "op":"replace", "path":"/url", "value":"https://requestb.in/10ujt3c1" }, { "op":"replace", "path":"/event_types", "value":[ { "name":"PAYMENT.SALE.REFUNDED" } ] } ] }, "response":{ "status":"200", "headers":{ "Content-Type":"application/json", "Paypal-Debug-id":"0c444abc1d12d" }, "body":{ "id":"0EH40505U7160970P", "url":"https://requestb.in/10ujt3c1", "event_types":[ { "name":"PAYMENT.SALE.REFUNDED", "description":"A sale payment was refunded" } ], "links":[ { "href":"https://api.paypal.com/v1/notifications/webhooks/0EH40505U7160970P", "rel":"self", "method":"GET" }, { "href":"https://api.paypal.com/v1/notifications/webhooks/0EH40505U7160970P", "rel":"update", "method":"PATCH" }, { "href":"https://api.paypal.com/v1/notifications/webhooks/0EH40505U7160970P", "rel":"delete", "method":"DELETE" } ] } } } rest-api-sdk-php/tests/PayPal/Test/Functional/resources/WebhookFunctionalTest/testEventSearch.json 0000644 00000015626 15007532371 0027517 0 ustar 00 { "description":"Get list of webhook events", "title":"Get list of webhook events", "runnable":true, "operationId":"event.list", "user":{ "scopes":[ "https://uri.paypal.com/services/applications/webhooks" ] }, "credentials":{ "oauth":{ "path":"/v1/oauth/token", "clientId":"", "clientSecret":"" } }, "request":{ "path":"v1/notifications/webhooks-events", "method":"GET", "headers":{ "Content-Type":"application/json", "Authorization":"Bearer ECvJ_yBNz_UfMmCvWEbT_2ZWXdzbFFQZ-1Y5K2NGgeHn" } }, "response":{ "status":"200", "headers":{ "Content-Type":"application/json", "Paypal-Debug-id":"0c444abc1d12d" }, "body":{ "events": [ { "id": "8PT597110X687430LKGECATA", "create_time": "2013-06-25T21:41:28Z", "resource_type": "authorization", "event_type": "PAYMENT.AUTHORIZATION.CREATED", "summary": "A payment authorization was created", "resource": { "id": "2DC87612EK520411B", "create_time": "2013-06-25T21:39:15Z", "update_time": "2013-06-25T21:39:17Z", "state": "authorized", "amount": { "total": "7.47", "currency": "USD", "details": { "subtotal": "7.47" } }, "parent_payment": "PAY-36246664YD343335CKHFA4AY", "valid_until": "2013-07-24T21:39:15Z", "links": [ { "href": "https://api.sandbox.paypal.com/v1/payments/authorization/2DC87612EK520411B", "rel": "self", "method": "GET" }, { "href": "https://api.sandbox.paypal.com/v1/payments/authorization/2DC87612EK520411B/capture", "rel": "capture", "method": "POST" }, { "href": "https://api.sandbox.paypal.com/v1/payments/authorization/2DC87612EK520411B/void", "rel": "void", "method": "POST" }, { "href": "https://api.sandbox.paypal.com/v1/payments/payment/PAY-36246664YD343335CKHFA4AY", "rel": "parent_payment", "method": "GET" } ] }, "links": [ { "href": "https://api.sandbox.paypal.com/v1/notfications/webhooks-events/8PT597110X687430LKGECATA", "rel": "self", "method": "GET" }, { "href": "https://api.sandbox.paypal.com/v1/notfications/webhooks-events/8PT597110X687430LKGECATA/resend", "rel": "resend", "method": "POST" } ] }, { "id": "HTSPGS710X687430LKGECATA", "create_time": "2013-06-25T21:41:28Z", "resource_type": "authorization", "event_type": "PAYMENT.AUTHORIZATION.CREATED", "summary": "A payment authorization was created", "resource": { "id": "HATH7S72EK520411B", "create_time": "2013-06-25T21:39:15Z", "update_time": "2013-06-25T21:39:17Z", "state": "authorized", "amount": { "total": "7.47", "currency": "USD", "details": { "subtotal": "7.47" } }, "parent_payment": "PAY-ALDSFJ64YD343335CKHFA4AY", "valid_until": "2013-07-24T21:39:15Z", "links": [ { "href": "https://api.sandbox.paypal.com/v1/payments/authorization/HATH7S72EK520411B", "rel": "self", "method": "GET" }, { "href": "https://api.sandbox.paypal.com/v1/payments/authorization/HATH7S72EK520411B/capture", "rel": "capture", "method": "POST" }, { "href": "https://api.sandbox.paypal.com/v1/payments/authorization/HATH7S72EK520411B/void", "rel": "void", "method": "POST" }, { "href": "https://api.sandbox.paypal.com/v1/payments/payment/PAY-HATH7S72EK520411B", "rel": "parent_payment", "method": "GET" } ] }, "links": [ { "href": "https://api.sandbox.paypal.com/v1/notfications/webhooks-events/HTSPGS710X687430LKGECATA", "rel": "self", "method": "GET" }, { "href": "https://api.sandbox.paypal.com/v1/notfications/webhooks-events/HTSPGS710X687430LKGECATA/resend", "rel": "resend", "method": "POST" } ] } ], "count": 2, "links": [ { "href": "https://api.sandbox.paypal.com/v1/notifications/webhooks-events/?start_time=2014-08-04T12:46:47-07:00&amp;end_time=2014-09-18T12:46:47-07:00&amp;page_size=2&amp;move_to=next&amp;index_time=2014-09-17T23:07:35Z&amp;index_id=3", "rel": "next", "method": "GET" }, { "href": "https://api.sandbox.paypal.com/v1/notifications/webhooks-events/?start_time=2014-08-04T12:46:47-07:00&amp;end_time=2014-09-18T12:46:47-07:00&amp;page_size=2&amp;move_to=previous&amp;index_time=2014-09-17T23:07:35Z&amp;index_id=0", "rel": "previous", "method": "GET" } ] } } } tests/PayPal/Test/Functional/resources/WebhookFunctionalTest/testGetSubscribedEventTypes.json 0000644 00000002257 15007532371 0032001 0 ustar 00 rest-api-sdk-php { "description":"Events subscribed for a webhook", "title":"Events subscribed for a webhook", "runnable":true, "operationId":"webhook.subscribed-event-types.list", "user":{ "scopes":[ "https://uri.paypal.com/services/applications/webhooks" ] }, "credentials":{ "oauth":{ "path":"/v1/oauth/token", "clientId":"", "clientSecret":"" } }, "request":{ "path":"v1/notifications/webhooks/0EH40505U7160970P/event-types", "method":"GET", "headers":{ "Content-Type":"application/json", "Authorization":"Bearer ECvJ_yBNz_UfMmCvWEbT_2ZWXdzbFFQZ-1Y5K2NGgeHn" } }, "response":{ "status":"200", "headers":{ "Content-Type":"application/json", "Paypal-Debug-id":"0c444abc1d12d" }, "body":{ "event_types":[ { "name":"PAYMENT.AUTHORIZATION.CREATED", "description":"A payment authorization was created" }, { "name":"PAYMENT.AUTHORIZATION.VOIDED", "description":"A payment authorization was voided" } ] } } } rest-api-sdk-php/tests/PayPal/Test/Functional/resources/WebhookFunctionalTest/testDelete.json 0000644 00000001415 15007532371 0026501 0 ustar 00 { "description":"Delete a webhook", "title":"Delete a webhook", "runnable":true, "operationId":"webhooks.delete", "user":{ "scopes":[ "https://uri.paypal.com/services/applications/webhooks" ] }, "credentials":{ "oauth":{ "path":"/v1/oauth/token", "clientId":"", "clientSecret":"" } }, "request":{ "path":"v1/notifications/webhooks/5GP028458E2496506", "method":"DELETE", "headers":{ "Content-Type":"application/json", "Authorization":"Bearer ECvJ_yBNz_UfMmCvWEbT_2ZWXdzbFFQZ-1Y5K2NGgeHn" } }, "response":{ "status":"204", "headers":{ "Content-Type":"application/json", "Paypal-Debug-id":"0c444abc1d12d" } } } rest-api-sdk-php/tests/PayPal/Test/Functional/resources/WebhookFunctionalTest/testGetEvent.json 0000644 00000005420 15007532371 0027020 0 ustar 00 { "description":"Get a webhook event", "title":"Get a webhook event", "runnable":true, "operationId":"event.get", "user":{ "scopes":[ "https://uri.paypal.com/services/applications/webhooks" ] }, "credentials":{ "oauth":{ "path":"v1/oauth/token", "clientId":"", "clientSecret":"" } }, "request":{ "path":"v1/notifications/webhooks-events/8PT597110X687430LKGECATA", "method":"GET", "headers":{ "Content-Type":"application/json", "Authorization":"Bearer ECvJ_yBNz_UfMmCvWEbT_2ZWXdzbFFQZ-1Y5K2NGgeHn" } }, "response":{ "status":"200", "headers":{ "Content-Type":"application/json", "Paypal-Debug-id":"0c444abc1d12d" }, "body":{ "id":"8PT597110X687430LKGECATA", "create_time":"2013-06-25T21:41:28Z", "resource_type":"authorization", "event_type":"PAYMENT.AUTHORIZATION.CREATED", "summary":"A payment authorization was created", "resource":{ "id":"2DC87612EK520411B", "create_time":"2013-06-25T21:39:15Z", "update_time":"2013-06-25T21:39:17Z", "state":"authorized", "amount":{ "total":"7.47", "currency":"USD", "details":{ "subtotal":"7.47" } }, "parent_payment":"PAY-36246664YD343335CKHFA4AY", "valid_until":"2013-07-24T21:39:15Z", "links":[ { "href":"https://api.paypal.com/v1/payments/authorization/2DC87612EK520411B", "rel":"self", "method":"GET" }, { "href":"https://api.paypal.com/v1/payments/authorization/2DC87612EK520411B/capture", "rel":"capture", "method":"POST" }, { "href":"https://api.paypal.com/v1/payments/authorization/2DC87612EK520411B/void", "rel":"void", "method":"POST" }, { "href":"https://api.paypal.com/v1/payments/payment/PAY-36246664YD343335CKHFA4AY", "rel":"parent_payment", "method":"GET" } ] }, "links":[ { "href":"https://api.paypal.com/v1/notfications/webhooks-events/8PT597110X687430LKGECATA", "rel":"self", "method":"GET" }, { "href":"https://api.paypal.com/v1/notfications/webhooks-events/8PT597110X687430LKGECATA/resend", "rel":"resend", "method":"POST" } ] } } } tests/PayPal/Test/Functional/resources/WebhookFunctionalTest/webhook_get_available_event_types.json 0000644 00000003125 15007532371 0033242 0 ustar 00 rest-api-sdk-php { "description":"List of supported webhook events", "title":"List of supported webhook events", "runnable":true, "operationId":"available-event-type.list", "credentials":{ "oauth":{ "path":"/v1/oauth/token", "clientId":"", "clientSecret":"" } }, "request":{ "path":"v1/notifications/webhooks-event-types", "method":"GET", "headers":{ "Content-Type":"application/json", "Authorization":"Bearer ECvJ_yBNz_UfMmCvWEbT_2ZWXdzbFFQZ-1Y5K2NGgeHn" } }, "response":{ "status":"200", "headers":{ "Content-Type":"application/json", "Paypal-Debug-id":"0c444abc1d12d" }, "body":{ "event_types":[ { "name":"PAYMENT.AUTHORIZATION.CREATED", "description":"A payment authorization was created" }, { "name":"PAYMENT.AUTHORIZATION.VOIDED", "description":"A payment authorization was voided" }, { "name":"PAYMENT.CAPTURE.COMPLETED", "description":"A capture payment was completed" }, { "name":"PAYMENT.CAPTURE.REFUNDED", "description":"A capture payment was refunded" }, { "name":"PAYMENT.SALE.COMPLETED", "description":"A sale payment was completed" }, { "name":"PAYMENT.SALE.REFUNDED", "description":"A sale payment was refunded" } ] } } } rest-api-sdk-php/tests/PayPal/Test/Functional/resources/InvoiceFunctionalTest/testCreate.json 0000644 00000012413 15007532371 0026500 0 ustar 00 { "operationId": "invoice.create", "title": "Create an invoice", "description": "Create an invoice", "runnable": true, "user": { "scopes": [ "https://uri.paypal.com/services/invoicing" ] }, "credentials": { "oauth": { "clientId": "stage2managed", "clientSecret": "secret", "path": "/v1/oauth2/token" }, "login": {}, "openIdConnect": {} }, "request": { "path": "v1/invoicing/invoices/", "method": "POST", "headers": { "X-PAYPAL-SECURITY-CONTEXT": "{\"actor\":{\"auth_claims\":[\"CLIENT_ID_SECRET\"],\"auth_state\":\"LOGGEDIN\",\"account_number\":\"1942617323817135416\",\"encrypted_account_number\":\"6QNCBKP95EWWN\",\"party_id\":\"1942617323817135416\"},\"auth_token\":\"A015vRRfXmgj2UscSiBbwz1Elw8RW.ypMlPJsMH77snr6fc\",\"auth_token_type\":\"ACCESS_TOKEN\",\"last_validated\":1405632568,\"scopes\":[\"openid\",\"https://uri.paypal.com/services/invoicing\",\"https://uri.paypal.com/services/subscriptions\",\"https://api.paypal.com/v1/payments/.*\",\"https://api.paypal.com/v1/vault/credit-card/.*\",\"https://api.paypal.com/v1/vault/credit-card\"],\"client_id\":\"AewC1RCK3i4Z7WTbE0cz5buvd_NW17sYbYI4kc29c5qGxeh-0P7sMuXh2chc\",\"claims\":{\"actor_payer_id\":\"6QNCBKP95EWWN\"},\"subjects\":[]}" }, "body": {"merchant_info": { "email": "jaypatel512-facilitator@hotmail.com", "first_name": "Dennis", "last_name": "Doctor", "business_name": "Medical Professionals, LLC", "phone": { "country_code": "001", "national_number": "5032141716" }, "address": { "line1": "1234 Main St.", "city": "Portland", "state": "OR", "postal_code": "97217", "country_code": "US" } }, "billing_info": [ { "email": "example@example.com" } ], "items": [ { "name": "Sutures", "quantity": 100, "unit_price": { "currency": "USD", "value": "5.00" } } ], "note": "Medical Invoice 16 Jul, 2013 PST", "payment_term": { "term_type": "NET_45" }, "shipping_info": { "first_name": "Sally", "last_name": "Patient", "business_name": "Not applicable", "phone": { "country_code": "001", "national_number": "5039871234" }, "address": { "line1": "1234 Main St.", "city": "Portland", "state": "OR", "postal_code": "97217", "country_code": "US" } } } }, "response": { "status": "201 Created", "headers": {}, "body": { "id": "INV2-RF6D-L66T-D7H2-CRU7", "number": "ABCD4971", "status": "DRAFT", "merchant_info": { "email": "ppaas_default@paypal.com", "first_name": "Dennis", "last_name": "Doctor", "business_name": "Medical Professionals, LLC", "phone": { "country_code": "1", "national_number": "5032141234" }, "address": { "line1": "1234 Main St.", "city": "Portland", "state": "OR", "postal_code": "97217", "country_code": "US" } }, "billing_info": [ { "email": "email@example.com" } ], "shipping_info": { "first_name": "Sally", "last_name": "Patient", "business_name": "Not applicable", "phone": { "country_code": "1", "national_number": "5039871234" }, "address": { "line1": "1234 Broad St.", "city": "Portland", "state": "OR", "postal_code": "97216", "country_code": "US" } }, "items": [ { "name": "Sutures", "quantity": 100, "unit_price": { "currency": "USD", "value": "5.00" } } ], "invoice_date": "2014-02-27 PST", "payment_term": { "term_type": "NET_45", "due_date": "2015-04-13 PDT" }, "tax_calculated_after_discount": false, "tax_inclusive": false, "note": "Medical Invoice 16 Jul, 2013 PST", "total_amount": { "currency": "USD", "value": "500.00" } } } } rest-api-sdk-php/tests/PayPal/Test/Functional/resources/InvoiceFunctionalTest/testCancel.json 0000644 00000003027 15007532371 0026463 0 ustar 00 { "operationId": "invoice.cancel", "title": "Cancel an invoice", "description": "Cancel an invoice", "runnable": true, "user": { "scopes": [] }, "credentials": { "oauth": { "clientId": "", "clientSecret": "", "path": "" }, "login": {}, "openIdConnect": {} }, "request": { "path": "v1/invoicing/invoices/INV2-WW57-VFCD-X5H4-XTUP/cancel", "method": "POST", "headers": { "X-PAYPAL-SECURITY-CONTEXT": "{\"actor\":{\"auth_claims\":[\"CLIENT_ID_SECRET\"],\"auth_state\":\"LOGGEDIN\",\"account_number\":\"1942617323817135416\",\"encrypted_account_number\":\"6QNCBKP95EWWN\",\"party_id\":\"1942617323817135416\"},\"auth_token\":\"A015vRRfXmgj2UscSiBbwz1Elw8RW.ypMlPJsMH77snr6fc\",\"auth_token_type\":\"ACCESS_TOKEN\",\"last_validated\":1405632568,\"scopes\":[\"openid\",\"https://uri.paypal.com/services/invoicing\",\"https://uri.paypal.com/services/subscriptions\",\"https://api.paypal.com/v1/payments/.*\",\"https://api.paypal.com/v1/vault/credit-card/.*\",\"https://api.paypal.com/v1/vault/credit-card\"],\"client_id\":\"AewC1RCK3i4Z7WTbE0cz5buvd_NW17sYbYI4kc29c5qGxeh-0P7sMuXh2chc\",\"claims\":{\"actor_payer_id\":\"6QNCBKP95EWWN\"},\"subjects\":[]}" }, "body": { "subject": "Past due", "note": "Canceling invoice", "send_to_merchant": true, "send_to_payer": true } }, "response": { "headers": {}, "status": "" } } rest-api-sdk-php/tests/PayPal/Test/Functional/resources/InvoiceFunctionalTest/testGet.json 0000644 00000007206 15007532371 0026020 0 ustar 00 { "description": "Get the invoice resource for the given identifier.", "title": "Get invoice details", "runnable": true, "operationId": "invoice.get", "user": { "scopes": [] }, "credentials": { "oauth": { "clientId": "", "clientSecret": "", "path": "" }, "login": {}, "openIdConnect": {} }, "request": { "path": "v1/invoicing/invoices/INV2-RF6D-L66T-D7H2-CRU7", "method": "GET", "headers": { "X-PAYPAL-SECURITY-CONTEXT": "{\"actor\":{\"auth_claims\":[\"CLIENT_ID_SECRET\"],\"auth_state\":\"LOGGEDIN\",\"account_number\":\"1942617323817135416\",\"encrypted_account_number\":\"6QNCBKP95EWWN\",\"party_id\":\"1942617323817135416\"},\"auth_token\":\"A015vRRfXmgj2UscSiBbwz1Elw8RW.ypMlPJsMH77snr6fc\",\"auth_token_type\":\"ACCESS_TOKEN\",\"last_validated\":1405632568,\"scopes\":[\"openid\",\"https://uri.paypal.com/services/invoicing\",\"https://uri.paypal.com/services/subscriptions\",\"https://api.paypal.com/v1/payments/.*\",\"https://api.paypal.com/v1/vault/credit-card/.*\",\"https://api.paypal.com/v1/vault/credit-card\"],\"client_id\":\"AewC1RCK3i4Z7WTbE0cz5buvd_NW17sYbYI4kc29c5qGxeh-0P7sMuXh2chc\",\"claims\":{\"actor_payer_id\":\"6QNCBKP95EWWN\"},\"subjects\":[]}" }, "body": {} }, "response": { "status": "", "headers": {}, "body": { "id": "INV2-RF6D-L66T-D7H2-CRU7", "number": "0002", "status": "DRAFT", "merchant_info": { "email": "ppaas_default@paypal.com", "first_name": "Dennis", "last_name": "Doctor", "business_name": "Medical Professionals, LLC", "phone": { "country_code": "1", "national_number": "5032141716" }, "address": { "line1": "1234 Main St.", "city": "Portland", "state": "OR", "postal_code": "97217", "country_code": "US" } }, "billing_info": [ { "email": "example@example.com" } ], "shipping_info": { "first_name": "Sally", "last_name": "Patient", "business_name": "Not applicable", "phone": { "country_code": "1", "national_number": "5039871234" }, "address": { "line1": "1234 Broad St.", "city": "Portland", "state": "OR", "postal_code": "97216", "country_code": "US" } }, "items": [ { "name": "Sutures", "quantity": 100, "unit_price": { "currency": "USD", "value": "5.00" } } ], "invoice_date": "2014-03-24 PDT", "payment_term": { "term_type": "NET_45", "due_date": "2014-05-08 PDT" }, "tax_calculated_after_discount": false, "tax_inclusive": false, "note": "Medical Invoice 16 Jul, 2013 PST", "total_amount": { "currency": "USD", "value": "500.00" }, "metadata": { "created_date": "2014-03-24 12:11:52 PDT" } } } } rest-api-sdk-php/tests/PayPal/Test/Functional/resources/InvoiceFunctionalTest/testRecordRefund.json 0000644 00000001022 15007532371 0027651 0 ustar 00 { "description": "Record a refund for an invoice.", "title": "Record a refund for an invoice.", "runnable": true, "operationId": "invoice.record-refund", "request": { "path": "v1/invoicing/invoices/INV2-T4UQ-VW4W-K7N7-XM2R/record-refund", "method": "POST", "headers": {}, "body": { "date" : "2013-11-10 14:00:00 PST", "note" : "Refunded by cash!" } }, "response": { "status": "", "headers": {}, "body": {} } } rest-api-sdk-php/tests/PayPal/Test/Functional/resources/InvoiceFunctionalTest/testGetAll.json 0000644 00000013571 15007532371 0026453 0 ustar 00 { "description": "get all invoices", "title": "get all invoices", "runnable": true, "operationId": "invoice.get_all", "user": { "scopes": [] }, "credentials": { "oauth": { "clientId": "", "clientSecret": "", "path": "" }, "login": {}, "openIdConnect": {} }, "request": { "path": "v1/invoicing/invoices?page=0&page_size=10&total_count_required=true", "method": "GET", "headers": { "X-PAYPAL-SECURITY-CONTEXT": "{\"actor\":{\"auth_claims\":[\"CLIENT_ID_SECRET\"],\"auth_state\":\"LOGGEDIN\",\"account_number\":\"1942617323817135416\",\"encrypted_account_number\":\"6QNCBKP95EWWN\",\"party_id\":\"1942617323817135416\"},\"auth_token\":\"A015vRRfXmgj2UscSiBbwz1Elw8RW.ypMlPJsMH77snr6fc\",\"auth_token_type\":\"ACCESS_TOKEN\",\"last_validated\":1405632568,\"scopes\":[\"openid\",\"https://uri.paypal.com/services/invoicing\",\"https://uri.paypal.com/services/subscriptions\",\"https://api.paypal.com/v1/payments/.*\",\"https://api.paypal.com/v1/vault/credit-card/.*\",\"https://api.paypal.com/v1/vault/credit-card\"],\"client_id\":\"AewC1RCK3i4Z7WTbE0cz5buvd_NW17sYbYI4kc29c5qGxeh-0P7sMuXh2chc\",\"claims\":{\"actor_payer_id\":\"6QNCBKP95EWWN\"},\"subjects\":[]}" }, "body": {} }, "response": { "status": "", "headers": {}, "body": { "total_count": 5, "invoices": [ { "id": "INV2-2NB5-UJ7A-YSUJ-ABCD", "number": "9879878979003791", "status": "DRAFT", "merchant_info": { "email": "sample@sample.com" }, "billing_info": [ { "email": "example@example.com" } ], "shipping_info": { "email": "example@example.com", "first_name": "Sally", "last_name": "Patient", "business_name": "Not applicable" }, "invoice_date": "2014-02-27 PST", "note": "Medical Invoice 16 Jul, 2013 PST", "total_amount": { "currency": "USD", "value": "0.00" }, "metadata": { "created_date": "2014-02-27 23:55:58 PST" } }, { "id": "INV2-5AYC-UE5K-XXEG-ABCD", "number": "9879878979003790", "status": "DRAFT", "merchant_info": { "email": "sample@sample.com" }, "billing_info": [ { "email": "example@example.com" } ], "shipping_info": { "email": "example@example.com", "first_name": "Sally", "last_name": "Patient", "business_name": "Not applicable" }, "invoice_date": "2014-02-27 PST", "note": "Medical Invoice 16 Jul, 2013 PST", "total_amount": { "currency": "USD", "value": "0.00" }, "metadata": { "created_date": "2014-02-27 19:41:56 PST" } }, { "id": "INV2-C4QH-KEKM-C5QE-ABCD", "number": "9879878979003789", "status": "DRAFT", "merchant_info": { "email": "sample@sample.com" }, "billing_info": [ { "email": "example@example.com" } ], "shipping_info": { "email": "example@example.com", "first_name": "Sally", "last_name": "Patient", "business_name": "Not applicable" }, "invoice_date": "2014-02-27 PST", "note": "Medical Invoice 16 Jul, 2013 PST", "total_amount": { "currency": "USD", "value": "0.00" }, "metadata": { "created_date": "2014-02-27 15:34:11 PST" } }, { "id": "INV2-RF6D-L66T-D7H2-CRU7", "number": "9879878979003788", "status": "DRAFT", "merchant_info": { "email": "sample@sample.com" }, "billing_info": [ { "email": "example@example.com" } ], "shipping_info": { "email": "example@example.com", "first_name": "Sally", "last_name": "Patient", "business_name": "Not applicable" }, "invoice_date": "2014-02-27 PST", "note": "Medical Invoice 16 Jul, 2013 PST", "total_amount": { "currency": "USD", "value": "12.00" }, "metadata": { "created_date": "2014-02-27 15:34:01 PST" } } ] } } } rest-api-sdk-php/tests/PayPal/Test/Functional/resources/InvoiceFunctionalTest/testUpdate.json 0000644 00000012510 15007532371 0026515 0 ustar 00 { "description": "Full update of the invoice resource for the given identifier.", "title": "Full update of the invoice resource for the given identifier.", "runnable": true, "operationId": "invoice.update", "user": { "scopes": [] }, "credentials": { "oauth": { "clientId": "", "clientSecret": "", "path": "" }, "login": {}, "openIdConnect": {} }, "request": { "path": "v1/invoicing/invoices/INV2-RF6D-L66T-D7H2-CRU7", "method": "PUT", "headers": { "X-PAYPAL-SECURITY-CONTEXT": "{\"actor\":{\"auth_claims\":[\"CLIENT_ID_SECRET\"],\"auth_state\":\"LOGGEDIN\",\"account_number\":\"1942617323817135416\",\"encrypted_account_number\":\"6QNCBKP95EWWN\",\"party_id\":\"1942617323817135416\"},\"auth_token\":\"A015vRRfXmgj2UscSiBbwz1Elw8RW.ypMlPJsMH77snr6fc\",\"auth_token_type\":\"ACCESS_TOKEN\",\"last_validated\":1405632568,\"scopes\":[\"openid\",\"https://uri.paypal.com/services/invoicing\",\"https://uri.paypal.com/services/subscriptions\",\"https://api.paypal.com/v1/payments/.*\",\"https://api.paypal.com/v1/vault/credit-card/.*\",\"https://api.paypal.com/v1/vault/credit-card\"],\"client_id\":\"AewC1RCK3i4Z7WTbE0cz5buvd_NW17sYbYI4kc29c5qGxeh-0P7sMuXh2chc\",\"claims\":{\"actor_payer_id\":\"6QNCBKP95EWWN\"},\"subjects\":[]}" }, "body": { "merchant_info": { "email": "ppaas_default@paypal.com", "first_name": "Dennis", "last_name": "Doctor", "business_name": "Medical Professionals, LLC", "phone": { "country_code": "001", "national_number": "5032141716" }, "address": { "line1": "1234 Main St.", "city": "Portland", "state": "OR", "postal_code": "97217", "country_code": "US" } }, "billing_info": [ { "email": "example@example.com" } ], "items": [ { "name": "Sutures", "quantity": 100, "unit_price": { "currency": "USD", "value": "5" } } ], "note": "Medical Invoice 16 Jul, 2013 PST", "payment_term": { "term_type": "NET_45" }, "shipping_info": { "first_name": "Sally", "last_name": "Patient", "business_name": "Not applicable", "phone": { "country_code": "001", "national_number": "5039871234" }, "address": { "line1": "1234 Broad St.", "city": "Portland", "state": "OR", "postal_code": "97216", "country_code": "US" } } } }, "response": { "status": "", "headers": {}, "body": { "id": "INV2-RF6D-L66T-D7H2-CRU7", "number": "0014", "status": "DRAFT", "merchant_info": { "email": "ppaas_default@paypal.com", "first_name": "Dennis", "last_name": "Doctor", "business_name": "Medical Professionals, LLC", "phone": { "country_code": "1", "national_number": "5032141716" }, "address": { "line1": "1234 Main St.", "city": "Portland", "state": "OR", "postal_code": "97217", "country_code": "US" } }, "billing_info": [ { "email": "example@example.com" } ], "shipping_info": { "first_name": "Sally", "last_name": "Patient", "business_name": "Not applicable", "phone": { "country_code": "1", "national_number": "5039871234" }, "address": { "line1": "1234 Broad St.", "city": "Portland", "state": "OR", "postal_code": "97216", "country_code": "US" } }, "items": [ { "name": "Sutures", "quantity": 100, "unit_price": { "currency": "USD", "value": "5.00" } } ], "invoice_date": "2014-03-24 PDT", "payment_term": { "term_type": "NET_45", "due_date": "2014-05-08 PDT" }, "tax_calculated_after_discount": false, "tax_inclusive": false, "note": "Medical Invoice 16 Jul, 2013 PST", "total_amount": { "currency": "USD", "value": "500.00" } } } } rest-api-sdk-php/tests/PayPal/Test/Functional/resources/InvoiceFunctionalTest/testRecordPayment.json0000644 00000001057 15007532371 0030053 0 ustar 00 { "description": "Record a payment for an invoice.", "title": "Record a payment for an invoice.", "runnable": true, "operationId": "invoice.record-payment", "request": { "path": "v1/invoicing/invoices/INV2-T4UQ-VW4W-K7N7-XM2R/record-payment", "method": "POST", "headers": {}, "body": { "method": "CASH", "date": "2014-07-06 03:30:00 PST", "note": "Cash received." } }, "response": { "status": "", "headers": {}, "body": {} } } rest-api-sdk-php/tests/PayPal/Test/Functional/resources/InvoiceFunctionalTest/testSearch.json 0000644 00000005071 15007532371 0026504 0 ustar 00 { "description": "Search for invoice resources.", "title": "Search for invoice resources.", "runnable": true, "operationId": "invoice.search", "user": { "scopes": [] }, "credentials": { "oauth": { "clientId": "", "clientSecret": "", "path": "" }, "login": {}, "openIdConnect": {} }, "request": { "path": "v1/invoicing/search/", "method": "POST", "headers": { "X-PAYPAL-SECURITY-CONTEXT": "{\"actor\":{\"auth_claims\":[\"CLIENT_ID_SECRET\"],\"auth_state\":\"LOGGEDIN\",\"account_number\":\"1942617323817135416\",\"encrypted_account_number\":\"6QNCBKP95EWWN\",\"party_id\":\"1942617323817135416\"},\"auth_token\":\"A015vRRfXmgj2UscSiBbwz1Elw8RW.ypMlPJsMH77snr6fc\",\"auth_token_type\":\"ACCESS_TOKEN\",\"last_validated\":1405632568,\"scopes\":[\"openid\",\"https://uri.paypal.com/services/invoicing\",\"https://uri.paypal.com/services/subscriptions\",\"https://api.paypal.com/v1/payments/.*\",\"https://api.paypal.com/v1/vault/credit-card/.*\",\"https://api.paypal.com/v1/vault/credit-card\"],\"client_id\":\"AewC1RCK3i4Z7WTbE0cz5buvd_NW17sYbYI4kc29c5qGxeh-0P7sMuXh2chc\",\"claims\":{\"actor_payer_id\":\"6QNCBKP95EWWN\"},\"subjects\":[]}" }, "body": { "page": 0, "page_size": 3, "total_count_required": true } }, "response": { "status": "", "headers": {}, "body": { "total_count": 1, "invoices": [ { "id": "INV2-RF6D-L66T-D7H2-CRU7", "number": "0001", "status": "SENT", "merchant_info": { "email": "dennis@sample.com" }, "billing_info": [ { "email": "sally-patient@example.com" } ], "shipping_info": { "email": "sally-patient@example.com" }, "invoice_date": "2012-05-09 PST", "payment_term": { "due_date": "2012-05-24 PST" }, "total_amount": { "currency": "USD", "value": "250" }, "metadata": { "created_date": "2012-05-09 04:48:57 PST" } } ] } } } rest-api-sdk-php/tests/PayPal/Test/Functional/resources/InvoiceFunctionalTest/testSend.json 0000644 00000002670 15007532371 0026172 0 ustar 00 { "description": "Sends a legitimate invoice to the payer.", "title": "Sends a legitimate invoice to the payer.", "runnable": true, "operationId": "invoice.send", "user": { "scopes": [] }, "credentials": { "oauth": { "clientId": "", "clientSecret": "", "path": "" }, "login": {}, "openIdConnect": {} }, "request": { "path": "v1/invoicing/invoices/INV2-RF6D-L66T-D7H2-CRU7/send", "method": "POST", "headers": { "X-PAYPAL-SECURITY-CONTEXT": "{\"actor\":{\"auth_claims\":[\"CLIENT_ID_SECRET\"],\"auth_state\":\"LOGGEDIN\",\"account_number\":\"1942617323817135416\",\"encrypted_account_number\":\"6QNCBKP95EWWN\",\"party_id\":\"1942617323817135416\"},\"auth_token\":\"A015vRRfXmgj2UscSiBbwz1Elw8RW.ypMlPJsMH77snr6fc\",\"auth_token_type\":\"ACCESS_TOKEN\",\"last_validated\":1405632568,\"scopes\":[\"openid\",\"https://uri.paypal.com/services/invoicing\",\"https://uri.paypal.com/services/subscriptions\",\"https://api.paypal.com/v1/payments/.*\",\"https://api.paypal.com/v1/vault/credit-card/.*\",\"https://api.paypal.com/v1/vault/credit-card\"],\"client_id\":\"AewC1RCK3i4Z7WTbE0cz5buvd_NW17sYbYI4kc29c5qGxeh-0P7sMuXh2chc\",\"claims\":{\"actor_payer_id\":\"6QNCBKP95EWWN\"},\"subjects\":[]}" }, "body": {} }, "response": { "status": "", "headers": {}, "body": {} } } rest-api-sdk-php/tests/PayPal/Test/Functional/resources/InvoiceFunctionalTest/testDelete.json 0000644 00000002611 15007532371 0026476 0 ustar 00 { "description": "Delete an invoice", "title": "Delete an invoice", "runnable": true, "operationId": "invoice.delete", "user": { "scopes": [] }, "credentials": { "oauth": { "clientId": "", "clientSecret": "", "path": "" }, "login": {}, "openIdConnect": {} }, "request": { "path": "v1/invoicing/invoices/INV2-92MG-CNXV-ND7G-P3D2", "method": "DELETE", "headers": { "X-PAYPAL-SECURITY-CONTEXT": "{\"actor\":{\"auth_claims\":[\"CLIENT_ID_SECRET\"],\"auth_state\":\"LOGGEDIN\",\"account_number\":\"1942617323817135416\",\"encrypted_account_number\":\"6QNCBKP95EWWN\",\"party_id\":\"1942617323817135416\"},\"auth_token\":\"A015vRRfXmgj2UscSiBbwz1Elw8RW.ypMlPJsMH77snr6fc\",\"auth_token_type\":\"ACCESS_TOKEN\",\"last_validated\":1405632568,\"scopes\":[\"openid\",\"https://uri.paypal.com/services/invoicing\",\"https://uri.paypal.com/services/subscriptions\",\"https://api.paypal.com/v1/payments/.*\",\"https://api.paypal.com/v1/vault/credit-card/.*\",\"https://api.paypal.com/v1/vault/credit-card\"],\"client_id\":\"AewC1RCK3i4Z7WTbE0cz5buvd_NW17sYbYI4kc29c5qGxeh-0P7sMuXh2chc\",\"claims\":{\"actor_payer_id\":\"6QNCBKP95EWWN\"},\"subjects\":[]}" }, "body": {} }, "response": { "status": "", "headers": {}, "body": {} } } rest-api-sdk-php/tests/PayPal/Test/Functional/resources/InvoiceFunctionalTest/testRemind.json 0000644 00000003056 15007532371 0026516 0 ustar 00 { "description": "Reminds the payer to pay the invoice.", "title": "Reminds the payer to pay the invoice.", "runnable": true, "operationId": "invoice.remind", "user": { "scopes": [] }, "credentials": { "oauth": { "clientId": "", "clientSecret": "", "path": "" }, "login": {}, "openIdConnect": {} }, "request": { "path": "v1/invoicing/invoices/INV2-T4UQ-VW4W-K7N7-XM2R/remind", "method": "POST", "headers": { "X-PAYPAL-SECURITY-CONTEXT": "{\"actor\":{\"auth_claims\":[\"CLIENT_ID_SECRET\"],\"auth_state\":\"LOGGEDIN\",\"account_number\":\"1942617323817135416\",\"encrypted_account_number\":\"6QNCBKP95EWWN\",\"party_id\":\"1942617323817135416\"},\"auth_token\":\"A015vRRfXmgj2UscSiBbwz1Elw8RW.ypMlPJsMH77snr6fc\",\"auth_token_type\":\"ACCESS_TOKEN\",\"last_validated\":1405632568,\"scopes\":[\"openid\",\"https://uri.paypal.com/services/invoicing\",\"https://uri.paypal.com/services/subscriptions\",\"https://api.paypal.com/v1/payments/.*\",\"https://api.paypal.com/v1/vault/credit-card/.*\",\"https://api.paypal.com/v1/vault/credit-card\"],\"client_id\":\"AewC1RCK3i4Z7WTbE0cz5buvd_NW17sYbYI4kc29c5qGxeh-0P7sMuXh2chc\",\"claims\":{\"actor_payer_id\":\"6QNCBKP95EWWN\"},\"subjects\":[]}" }, "body": { "subject": "Past due", "note": "Please pay soon", "send_to_merchant": true } }, "response": { "status": "", "headers": {}, "body": {} } } rest-api-sdk-php/tests/PayPal/Test/Functional/resources/InvoiceFunctionalTest/testQRCode.json 0000644 00000002757 15007532371 0026424 0 ustar 00 { "description": "Generates QR code for the Invoice URL identified by invoice_id.", "title": "Get QR code", "runnable": true, "operationId": "invoice.qr_code", "user": { "scopes": [] }, "credentials": { "oauth": { "clientId": "", "clientSecret": "", "path": "" }, "login": {}, "openIdConnect": {} }, "request": { "path": "v1/invoicing/invoices/INV2-S6FG-ZZCK-VXMM-8KKP/qr-code", "method": "GET", "headers": { "X-PAYPAL-SECURITY-CONTEXT": "{\"actor\":{\"auth_claims\":[\"CLIENT_ID_SECRET\"],\"auth_state\":\"LOGGEDIN\",\"account_number\":\"1942617323817135416\",\"encrypted_account_number\":\"6QNCBKP95EWWN\",\"party_id\":\"1942617323817135416\"},\"auth_token\":\"A015vRRfXmgj2UscSiBbwz1Elw8RW.ypMlPJsMH77snr6fc\",\"auth_token_type\":\"ACCESS_TOKEN\",\"last_validated\":1405632568,\"scopes\":[\"openid\",\"https://uri.paypal.com/services/invoicing\",\"https://uri.paypal.com/services/subscriptions\",\"https://api.paypal.com/v1/payments/.*\",\"https://api.paypal.com/v1/vault/credit-card/.*\",\"https://api.paypal.com/v1/vault/credit-card\"],\"client_id\":\"AewC1RCK3i4Z7WTbE0cz5buvd_NW17sYbYI4kc29c5qGxeh-0P7sMuXh2chc\",\"claims\":{\"actor_payer_id\":\"6QNCBKP95EWWN\"},\"subjects\":[]}" }, "body": {} }, "response": { "status": "", "headers": {}, "body": { "image": "iVBORw0KGgoAA......XUDM" } } } rest-api-sdk-php/tests/PayPal/Test/Functional/resources/PayoutsFunctionalTest/testGetItem.json 0000644 00000003063 15007532371 0026704 0 ustar 00 { "description": "Sender needs status of one item.", "title": "GET item sample", "runnable": true, "operationId": "payouts.item", "user": { "scopes": [] }, "credentials": { "oauth": { "path": "/v1/oauth/token", "clientId": "", "clientSecret": "" } }, "request": { "path": "v1/payments/payouts-item/452345", "method": "GET", "headers": { "Content-Type": "application/json", "Content-Encoding": "gzip" }, "body": {} }, "response": { "status": "200 OK", "headers": { "Content-Type": "application/json", "Content-Encoding": "gzip" }, "body": { "payout_item_id": "VHBFGN95AWV82", "transaction_status": "PENDING", "payout_item_fee": { "currency": "USD", "value": "0.02" }, "payout_batch_id": "CDZEC5MJ8R5HY", "transaction_id": "0728664497487461D", "sender_batch_id": "2014021887", "payout_item": { "amount": { "currency": "USD", "value": "0.99" }, "note": "Thanks you.", "receiver": "shirt-supplier-one@gmail.com", "recipient_type": "EMAIL", "sender_item_id": "item_154a716f035001" }, "links": [ { "href": "https://api.sandbox.paypal.com/v1/payments/payouts-item/HUUQ5YASYLQFN", "rel": "self", "method": "GET" }, { "href": "https://api.sandbox.paypal.com/v1/payments/payouts/LNLSEVGU4P85S", "rel": "batch", "method": "GET" } ] } } } rest-api-sdk-php/tests/PayPal/Test/Functional/resources/PayoutsFunctionalTest/testCreate.json 0000644 00000006743 15007532371 0026561 0 ustar 00 { "description" : "Sender POSTs a batch with 1 payout request. This example is for sync_mode=true. This means an immediate response. For sync_mode=false, the output will be run in back ground and the repsonse will be different.", "title" : "POST batch sample", "runnable" : true, "operationId" : "payouts", "user" : { "scopes" : [ ] }, "credentials" : { "oauth": { "path" : "/v1/oauth/token", "clientId":"", "clientSecret":"" } }, "request":{ "path":"v1/payments/payouts?sync_mode=true", "method":"POST", "headers": { "Content-Type": "application/json", "Content-Encoding": "gzip" }, "body":{ "sender_batch_header":{ "sender_batch_id":"2014021801", "email_subject":"You have a Payout!" }, "items":[ { "recipient_type":"EMAIL", "amount":{ "value":"1.0", "currency":"USD" }, "note":"Thanks for your patronage!", "sender_item_id":"2014031400023", "receiver":"shirt-supplier-one@mail.com" } ] } }, "response" : { "status" : "201 OK", "headers" : { "Content-Type": "application/json", "Content-Encoding": "gzip" }, "body" : { "batch_header": { "payout_batch_id": "CDZEC5MJ8R5HY", "batch_status": "SUCCESS", "time_created": "2014-46-14T06:46:22Z", "time_completed": "2014-46-14T06:46:23Z", "sender_batch_header": { "sender_batch_id":"2014021801", "email_subject": "You have a Payout!" }, "amount": { "currency": "USD", "value": "1.0" }, "fees": { "currency": "USD", "value": "0.02" } }, "items": [ { "payout_item_id": "VHBFGN95AWV82", "transaction_id": "0728664497487461D", "transaction_status": "UNCLAIMED", "payout_item_fee": { "currency": "USD", "value": "0.02" }, "payout_batch_id": "CDZEC5MJ8R5HY", "payout_item": { "amount": { "currency": "USD", "value": "1.0" }, "note": "Thanks for your patronage!", "receiver": "anybody01@gmail.com", "recipient_type": "EMAIL", "sender_item_id": "201403140001" }, "time_processed": "2014-46-14T06:46:23Z", "links": [ { "href": "https://api.sandbox.paypal.com/v1/payments/payouts-item/VHBFGN95AWV82", "rel": "item", "method": "GET" } ] } ], "links": [ { "href": "https://api.sandbox.paypal.com/v1/payments/payouts/CDZEC5MJ8R5HY", "rel": "self", "method": "GET" } ] } } } rest-api-sdk-php/tests/PayPal/Test/Functional/resources/PayoutsFunctionalTest/testCancel.json 0000644 00000003525 15007532371 0026536 0 ustar 00 { "description":"User initiates cancel on unlcaimed payouts item.", "title":"Cancel item sample", "runnable":true, "operationId":"payouts.item.cancel", "user":{ "scopes":[ ] }, "credentials":{ "oauth":{ "path":"/v1/oauth/token", "clientId":"", "clientSecret":"" } }, "request":{ "path":"v1/payments/payouts-item/452345/cancel", "method":"POST", "headers":{ "Content-Type":"application/json", "Content-Encoding":"gzip" }, "body":{ } }, "response":{ "status":"200 OK", "headers":{ "Content-Type":"application/json", "Content-Encoding":"gzip" }, "body":{ "payout_item_id":"VHBFGN95AWV82", "transaction_id":"0728664497487461D", "transaction_status":"RETURNED", "payout_item_fee":{ "currency":"USD", "value":"0.02" }, "payout_batch_id":"CDZEC5MJ8R5HY", "sender_batch_id":"2014021801", "payout_item":{ "recipient_type":"EMAIL", "amount":{ "value":"1.00", "currency":"USD" }, "note":"Thanks for your patronage!", "receiver":"anybody01@gmail.com", "payouts_item_id":"1421342", "sender_item_id":"14Feb_234" }, "time_processed":"2014-01-27T10:17:41Z", "errors":{ "name":"RECEIVER_UNREGISTERED", "message":"Receiver is unregistered", "information_link": "https://developer.paypal.com/webapps/developer/docs/api/#RECEIVER_UNREGISTERED" }, "links":[ { "rel":"self", "href":"https://api.sandbox.paypal.com/v1/payments/payouts-item/1421342", "method":"GET" }, { "rel":"batch", "href":"https://api.sandbox.paypal.com/v1/payments/payouts/20140724", "method":"GET" } ] } } } rest-api-sdk-php/tests/PayPal/Test/Functional/resources/PayoutsFunctionalTest/testGet.json 0000644 00000021001 15007532371 0026055 0 ustar 00 { "description" : "GET of a batch with multiple items.", "title" : "GET batch with multiple items", "runnable" : true, "operationId" : "payouts.get", "user" : { "scopes" : [ ] }, "credentials" : { "oauth": { "path" : "/v1/oauth/token", "clientId":"", "clientSecret":"" }, "login" : { }, "openIdConnect" : { } }, "request" : { "path" : "v1/payments/payouts/12345678", "method" : "GET", "headers" : { "Content-Type": "application/json", "Content-Encoding": "gzip" }, "body":{ } }, "response" : { "status" : "200 OK", "headers" : { "Content-Type": "application/json", "Content-Encoding": "gzip" }, "body":{ "batch_header":{ "payout_batch_id":"12345678", "batch_status":"PROCESSING", "sender_batch_id":"2014021801123", "time_created":"2014-01-27T10:17:00Z", "time_completed":"2014-01-27T11:17:39.00Z", "sender_batch_header":{ "sender_batch_id":"2014021801", "email_subject":"You have a Payout!" }, "amount":{ "value":"435.85", "currency":"USD" }, "fees":{ "value":"5.84", "currency":"USD" } }, "items":[ { "payout_item_id":"452176", "transaction_id":"434176", "transaction_status":"SUCCESS", "payout_batch_id":"12345678", "sender_batch_id":"2014021887", "payout_item_fee":{ "currency":"USD", "value":"1.00" }, "payout_item":{ "recipient_type":"EMAIL", "amount":{ "value":"65.24", "currency":"EUR" }, "note":"Thanks for your patronage!", "receiver":"anybody77@gmail.com", "payouts_item_id":"1421388", "sender_item_id":"14Feb_978" }, "time_created":"2014-01-27T10:17:00:00Z", "time_processed":"2014-01-27T10:18:32Z" }, { "payout_item_id":"452123", "transaction_id":"434123", "transaction_status":"SUCCESS", "payout_batch_id":"12345678", "sender_batch_id":"2014021802", "payout_item_fee":{ "currency":"USD", "value":"1.00" }, "payout_item":{ "recipient_type":"EMAIL", "amount":{ "value":"59.87", "currency":"EUR" }, "note":"Thanks for your patronage!", "receiver":"anybody34@gmail.com", "payouts_item_id":"1421345", "sender_item_id":"14Feb_321" }, "time_created":"2014-01-27T10:17:00Z", "time_processed":"2014-01-27T10:18:15Z" }, { "payout_item_id":"452323", "transaction_id":"434543", "transaction_status":"SUCCESS", "payout_batch_id":"12345678", "sender_batch_id":"2014021802", "payout_item_fee":{ "currency":"USD", "value":"1.00" }, "payout_item":{ "recipient_type":"EMAIL", "amount":{ "value":"59.87", "currency":"EUR" }, "note":"Thanks for your patronage!", "receiver":"anybody03@gmail.com", "payouts_item_id":"1421355", "sender_item_id":"14Feb_239" }, "time_created":"2014-01-27T10:17:00Z", "time_processed":"2014-01-27T10:17:15Z" }, { "payout_item_id":"452350", "transaction_id":"434543", "transaction_status":"SUCCESS", "payout_batch_id":"12345678", "sender_batch_id":"2014021801", "payout_item_fee":{ "currency":"USD", "value":"0.75" }, "payout_item":{ "recipient_type":"EMAIL", "amount":{ "value":"19.87", "currency":"USD" }, "note":"Thanks for your patronage!", "receiver":"anybody02@gmail.com", "payouts_item_id":"1421332", "sender_item_id":"14Feb_235" }, "time_created":"2014-01-27T10:17:00Z", "time_processed":"2014-01-27T10:17:25Z" }, { "payout_item_id":"452345", "transaction_id":"4345", "transaction_status":"SUCCESS", "payout_batch_id":"12345678", "sender_batch_id":"2014021801", "payout_item_fee":{ "currency":"USD", "value":"0.75" }, "payout_item":{ "recipient_type":"EMAIL", "amount":{ "value":"9.87", "currency":"USD" }, "note":"Thanks for your patronage!", "receiver":"anybody01@gmail.com", "payouts_item_id":"1421342", "sender_item_id":"14Feb_234" }, "time_created":"2014-01-27T10:17:00Z", "time_processed":"2014-01-27T10:17:37Z" }, { "payout_item_id":"4782902", "transaction_id":"6456456", "transaction_status":"SUCCESS", "payout_item_fee":{ "currency":"USD", "value":"2.35" }, "payout_batch_id":"12345678", "sender_batch_id":"2014021801", "payout_item":{ "recipient_type":"PHONE", "amount":{ "value":"112.34", "currency":"EUR" }, "note":"Thanks for your support!", "receiver":"91-734-234-1234", "payouts_item_id":"1421343", "sender_item_id":"14Feb_235" }, "time_created":"2014-01-27T10:17:00Z", "time_processed":"2014-01-27T10:17:52Z" }, { "payout_item_id":"4782902", "transaction_id":"", "transaction_status":"PROCESSING", "payout_batch_id":"12345678", "sender_batch_id":"2014021801", "payout_item":{ "recipient_type":"PHONE", "amount":{ "value":"5.32", "currency":"USD" }, "note":"Thanks for your patronage!", "receiver":"408X234-1234", "payouts_item_id":"1421344", "sender_item_id":"14Feb_235" }, "time_created":"2014-01-27T10:17:00Z", "time_processed":"2014-01-27T10:17:41Z" } ] } } } tests/PayPal/Test/Functional/resources/BillingPlansFunctionalTest/testUpdateChangingPD.json 0000644 00000002116 15007532371 0031304 0 ustar 00 rest-api-sdk-php { "description": "Patch operation for changing payment definition values", "title": "Patch operation for payment definition", "runnable": true, "operationId": "plan.update", "user": { "scopes": ["https://uri.paypal.com/services/subscriptions"] }, "credentials": { "oauth": { "path": "/v1/oauth/token", "clientId": "", "clientSecret": "" } }, "request": { "path": "v1/payments/billing-plans/{PLAN-ID}/", "method": "PATCH", "headers": {}, "body": [ { "op": "replace", "path": "/payment-definitions/PD-4816080302132415WUQBT7WA", "value": { "name": "Updated Payment Definition", "frequency": "Day", "amount": { "currency": "USD", "value": "1" } } } ] }, "response": { "status": "200 OK", "headers": {}, "body": {} } } rest-api-sdk-php/tests/PayPal/Test/Functional/resources/BillingPlansFunctionalTest/testCreate.json 0000644 00000015027 15007532371 0027466 0 ustar 00 { "description": "This operation creates a billing plan having a regular and trial billing period", "title": "Billing Plan with regular and trial billing period", "runnable": true, "operationId": "plan.create", "user": { "scopes": ["https://uri.paypal.com/services/subscriptions"] }, "credentials": { "oauth": { "path": "/v1/oauth/token", "clientId": "", "clientSecret": "" } }, "request": { "path": "v1/payments/billing-plans/", "method": "POST", "headers": {}, "body": { "name": "Sample Plan", "description": "Plan with regular and trial", "type": "fixed", "payment_definitions": [ { "name": "Regular Payment Definition", "type": "REGULAR", "frequency": "MONTH", "frequency_interval": "2", "amount": { "value": "100", "currency": "USD" }, "cycles": "12", "charge_models": [ { "type": "SHIPPING", "amount": { "value": "10", "currency": "USD" } }, { "type": "TAX", "amount": { "value": "12", "currency": "USD" } } ] }, { "name": "Trial Payment Definition", "type": "trial", "frequency": "week", "frequency_interval": "5", "amount": { "value": "9.19", "currency": "USD" }, "cycles": "2", "charge_models": [ { "type": "SHIPPING", "amount": { "value": "1", "currency": "USD" } }, { "type": "TAX", "amount": { "value": "2", "currency": "USD" } } ] } ], "merchant_preferences": { "setup_fee": { "value": "1", "currency": "USD" }, "return_url": "http://www.paypal.com", "cancel_url": "http://www.yahoo.com", "auto_bill_amount": "YES", "initial_fail_amount_action": "CONTINUE", "max_fail_attempts": "0" } } }, "response": { "status": "201 Created", "headers": {}, "body": { "id": "P-7DC96732KA7763723UOPKETA", "state": "CREATED", "name": "Sample Plan", "description": "Plan with regular and trial", "type": "FIXED", "payment_definitions": [ { "id": "PD-0MF87809KK310750TUOPKETA", "name": "Regular Payment Definition", "type": "REGULAR", "frequency": "Month", "amount": { "currency": "USD", "value": "100" }, "charge_models": [ { "id": "CHM-89H01708244053321UOPKETA", "type": "SHIPPING", "amount": { "currency": "USD", "value": "10" } }, { "id": "CHM-1V202179WT9709019UOPKETA", "type": "TAX", "amount": { "currency": "USD", "value": "12" } } ], "cycles": "12", "frequency_interval": "2" }, { "id": "PD-03223056L66578712UOPKETA", "name": "Trial Payment Definition", "type": "TRIAL", "frequency": "Week", "amount": { "currency": "USD", "value": "9.19" }, "charge_models": [ { "id": "CHM-7XN63093LF858372XUOPKETA", "type": "SHIPPING", "amount": { "currency": "USD", "value": "1" } }, { "id": "CHM-6JY06508UT8026625UOPKETA", "type": "TAX", "amount": { "currency": "USD", "value": "2" } } ], "cycles": "2", "frequency_interval": "5" } ], "merchant_preferences": { "setup_fee": { "currency": "USD", "value": "1" }, "max_fail_attempts": "0", "return_url": "http://www.paypal.com", "cancel_url": "http://www.yahoo.com", "auto_bill_amount": "YES", "initial_fail_amount_action": "CONTINUE" }, "create_time": "2014-06-16T07:40:20.940Z", "update_time": "2014-06-16T07:40:20.940Z", "links": [ { "href": "https://localhost:12379/v1/payments/billing-plans/P-7DC96732KA7763723UOPKETA", "rel": "self", "method": "GET" } ] } } } rest-api-sdk-php/tests/PayPal/Test/Functional/resources/BillingPlansFunctionalTest/testGet.json 0000644 00000007767 15007532371 0027016 0 ustar 00 { "description": "This operation fetches billing plan details cooresponding to the id.", "title": "Fetch billing plan details", "runnable": true, "operationId": "plan.get", "user": { "scopes": ["https://uri.paypal.com/services/subscriptions"] }, "credentials": { "oauth": { "path": "/v1/oauth/token", "clientId": "", "clientSecret": "" } }, "request": { "path": "v1/payments/billing-plans/P-7DC96732KA7763723UOPKETA", "method": "GET", "headers": {}, "body": {} }, "response": { "status": "200 OK", "headers": {}, "body": { "id": "P-7DC96732KA7763723UOPKETA", "state": "CREATED", "name": "Sample Plan", "description": "Plan with regular and trial", "type": "FIXED", "payment_definitions": [ { "id": "PD-03223056L66578712UOPKETA", "name": "Trial Payment Definition", "type": "TRIAL", "frequency": "Week", "amount": { "currency": "USD", "value": "9.19" }, "charge_models": [ { "id": "CHM-6JY06508UT8026625UOPKETA", "type": "TAX", "amount": { "currency": "USD", "value": "2" } }, { "id": "CHM-7XN63093LF858372XUOPKETA", "type": "SHIPPING", "amount": { "currency": "USD", "value": "1" } } ], "cycles": "2", "frequency_interval": "5" }, { "id": "PD-0MF87809KK310750TUOPKETA", "name": "Regular Payment Definition", "type": "REGULAR", "frequency": "Month", "amount": { "currency": "USD", "value": "100" }, "charge_models": [ { "id": "CHM-1V202179WT9709019UOPKETA", "type": "TAX", "amount": { "currency": "USD", "value": "12" } }, { "id": "CHM-89H01708244053321UOPKETA", "type": "SHIPPING", "amount": { "currency": "USD", "value": "10" } } ], "cycles": "12", "frequency_interval": "2" } ], "merchant_preferences": { "setup_fee": { "currency": "USD", "value": "1" }, "max_fail_attempts": "0", "return_url": "http://www.paypal.com", "cancel_url": "http://www.yahoo.com", "auto_bill_amount": "YES", "initial_fail_amount_action": "CONTINUE" }, "create_time": "2014-06-16T07:40:20.940Z", "update_time": "2014-06-16T07:40:20.940Z", "links": [ { "href": "https://localhost:12379/v1/payments/billing-plans/P-7DC96732KA7763723UOPKETA", "rel": "self", "method": "GET" } ] } } } tests/PayPal/Test/Functional/resources/BillingPlansFunctionalTest/testCreateWithNOChargeModel.json 0000644 00000006126 15007532371 0032573 0 ustar 00 rest-api-sdk-php { "description": "This operation creates a billing plan with no charge models and minimal merchant preferences", "title": "Billing Plan with no charge model and minimal merchant preferences", "runnable": true, "operationId": "plan.create", "user": { "scopes": ["https://uri.paypal.com/services/subscriptions"] }, "credentials": { "oauth": { "path": "/v1/oauth/token", "clientId": "", "clientSecret": "" } }, "request": { "path": "v1/payments/billing-plans/", "method": "POST", "headers": {}, "body": { "name": "Plan with minimal merchant pref", "description": "Plan with one payment definition,minimal merchant preferences and no charge models", "type": "fixed", "payment_definitions": [ { "name": "Payment Definition-1", "type": "REGULAR", "frequency": "MONTH", "frequency_interval": "2", "amount": { "value": "100", "currency": "USD" }, "cycles": "12" } ], "merchant_preferences": { "return_url": "http://www.paypal.com", "cancel_url": "http://www.yahoo.com" } } }, "response": { "status": "201 Created", "headers": {}, "body": { "id": "P-1TV69435N82273154UPWDU4I", "state": "CREATED", "name": "Plan with minimal merchant pref", "description": "Plan with one payment definition,minimal merchant preferences and no charge models", "type": "FIXED", "payment_definitions": [ { "id": "PD-62U12008P21526502UPWDU4I", "name": "Payment Definition-1", "type": "REGULAR", "frequency": "Month", "amount": { "currency": "USD", "value": "100" }, "charge_models": [], "cycles": "12", "frequency_interval": "2" } ], "merchant_preferences": { "setup_fee": { "currency": "USD", "value": "0" }, "max_fail_attempts": "0", "return_url": "http://www.paypal.com", "cancel_url": "http://www.yahoo.com", "auto_bill_amount": "NO", "initial_fail_amount_action": "CONTINUE" }, "create_time": "2014-06-16T09:05:06.161Z", "update_time": "2014-06-16T09:05:06.161Z", "links": [ { "href": "https://localhost:12379/v1/payments/billing-plans/P-1TV69435N82273154UPWDU4I", "rel": "self", "method": "GET" } ] } } } tests/PayPal/Test/Functional/resources/BillingPlansFunctionalTest/testUpdateChangingState.json 0000644 00000001567 15007532371 0032072 0 ustar 00 rest-api-sdk-php { "description": "This operation changes the state of billing plan to active if its in created state.", "title": "Patch Request for changing state", "runnable": true, "operationId": "plan.update", "user": { "scopes": ["https://uri.paypal.com/services/subscriptions"] }, "credentials": { "oauth": { "path": "/v1/oauth/token", "clientId": "", "clientSecret": "" } }, "request": { "path": "v1/payments/billing-plans/{PLAN-ID}/", "method": "PATCH", "headers": {}, "body": [ { "op": "replace", "path": "/", "value": { "state": "ACTIVE" } } ] }, "response": { "status": "200 OK", "headers": {}, "body": {} } } rest-api-sdk-php/tests/PayPal/Test/Functional/resources/BillingPlansFunctionalTest/testGetList.json 0000644 00000006251 15007532371 0027635 0 ustar 00 { "description": "This operation fetches billing plan list", "title": "Billing Plan list", "runnable": true, "operationId": "plans", "user": { "scopes": ["https://uri.paypal.com/services/subscriptions"] }, "credentials": { "oauth": { "path": "/v1/oauth/token", "clientId": "", "clientSecret": "" } }, "request": { "path": "v1/payments/billing-plans?page_size=3&status=ACTIVE&page_size=2&page=1&total_required=yes", "method": "GET", "headers": {}, "body": {} }, "response": { "status": "200 OK", "headers": {}, "body": { "total_items": "166", "total_pages": "83", "plans": [ { "id": "P-7DC96732KA7763723UOPKETA", "state": "ACTIVE", "name": "Testing1-Regular3", "description": "Create Plan for Regular", "type": "FIXED", "create_time": "2014-08-22T04:41:52.836Z", "update_time": "2014-08-22T04:41:53.169Z", "links": [ { "href": "https://stage2p1353.qa.paypal.com/v1/payments/billing-plans/P-6EM196669U062173D7QCVDRA", "rel": "self", "method": "GET" } ] }, { "id": "P-83567698LH138572V7QCVZJY", "state": "ACTIVE", "name": "Testing1-Regular4", "description": "Create Plan for Regular", "type": "INFINITE", "create_time": "2014-08-22T04:41:55.623Z", "update_time": "2014-08-22T04:41:56.055Z", "links": [ { "href": "https://stage2p1353.qa.paypal.com/v1/payments/billing-plans/P-83567698LH138572V7QCVZJY", "rel": "self", "method": "GET" } ] } ], "links": [ { "href": "https://stage2p1353.qa.paypal.com/v1/payments/billing-plans?page_size=2&page=1&start=3&status=active", "rel": "start", "method": "GET" }, { "href": "https://stage2p1353.qa.paypal.com/v1/payments/billing-plans?page_size=2&page=0&status=active", "rel": "previous_page", "method": "GET" }, { "href": "https://stage2p1353.qa.paypal.com/v1/payments/billing-plans?page_size=2&page=2&status=active", "rel": "next_page", "method": "GET" }, { "href": "https://stage2p1353.qa.paypal.com/v1/payments/billing-plans?page_size=2&page=82&status=active", "rel": "last", "method": "GET" } ] } } } Test/Functional/resources/BillingPlansFunctionalTest/testUpdateChangingMerchantPreferences.json 0000644 00000002034 15007532371 0034723 0 ustar 00 rest-api-sdk-php/tests/PayPal { "description": "Patch operation for changing merchant preferences values", "title": "Patch Operation for changing merchant preferences", "runnable": true, "operationId": "plan.update", "user": { "scopes": ["https://uri.paypal.com/services/subscriptions"] }, "credentials": { "oauth": { "path": "/v1/oauth/token", "clientId": "", "clientSecret": "" } }, "request": { "path": "v1/payments/billing-plans/{PLAN-ID}/", "method": "PATCH", "headers": {}, "body": [ { "op": "replace", "path": "/merchant-preferences", "value": { "cancel_url": "http://www.cancel.com", "setup_fee": { "value": "5", "currency": "USD" } } } ] }, "response": { "status": "200 OK", "headers": {}, "body": {} } } rest-api-sdk-php/tests/PayPal/Test/Functional/resources/PaymentsFunctionalTest/testCreate.json 0000644 00000010047 15007532371 0026705 0 ustar 00 { "description": "Creates a payment resource.", "title": "payment", "runnable": true, "operationId": "payment.create", "user": { "scopes": [ ] }, "credentials": { "oauth": { "clientId": "", "clientSecret": "", "path": "" }, "login": { }, "openIdConnect": { } }, "request": { "headers": { }, "body": { "intent": "sale", "payer": { "payment_method": "credit_card", "funding_instruments": [ { "credit_card": { "number": "4160285494148633", "type": "visa", "expire_month": 11, "expire_year": 2018, "cvv2": "874", "first_name": "Betsy", "last_name": "Buyer", "billing_address": { "line1": "111 First Street", "city": "Saratoga", "state": "CA", "postal_code": "95070", "country_code": "US" } } } ] }, "transactions": [ { "amount": { "total": "7.47", "currency": "USD", "details": { "subtotal": "7.41", "tax": "0.03", "shipping": "0.03" } }, "description": "This is the payment transaction description." } ] }, "path": "/v1/payments/payment", "method": "POST" }, "response": { "headers": { }, "body": { "id": "PAY-17S8410768582940NKEE66EQ", "create_time": "2013-01-31T04:12:02Z", "update_time": "2013-01-31T04:12:04Z", "state": "approved", "intent": "sale", "payer": { "payment_method": "credit_card", "funding_instruments": [ { "credit_card": { "type": "visa", "number": "xxxxxxxxxxxx0331", "expire_month": "11", "expire_year": "2018", "first_name": "Betsy", "last_name": "Buyer", "billing_address": { "line1": "111 First Street", "city": "Saratoga", "state": "CA", "postal_code": "95070", "country_code": "US" } } } ] }, "transactions": [ { "amount": { "total": "7.47", "currency": "USD", "details": { "tax": "0.03", "shipping": "0.03" } }, "description": "This is the payment transaction description.", "related_resources": [ { "sale": { "id": "4RR959492F879224U", "create_time": "2013-01-31T04:12:02Z", "update_time": "2013-01-31T04:12:04Z", "state": "completed", "amount": { "total": "7.47", "currency": "USD" }, "parent_payment": "PAY-17S8410768582940NKEE66EQ", "links": [ { "href": "https://api.paypal.com/v1/payments/sale/4RR959492F879224U", "rel": "self", "method": "GET" }, { "href": "https://api.paypal.com/v1/payments/sale/4RR959492F879224U/refund", "rel": "refund", "method": "POST" }, { "href": "https://api.paypal.com/v1/payments/payment/PAY-17S8410768582940NKEE66EQ", "rel": "parent_payment", "method": "GET" } ] } } ] } ], "links": [ { "href": "https://api.paypal.com/v1/payments/payment/PAY-17S8410768582940NKEE66EQ", "rel": "self", "method": "GET" } ] }, "status": "201 Created" } } rest-api-sdk-php/tests/PayPal/Test/Functional/resources/PaymentsFunctionalTest/testGet.json 0000644 00000010156 15007532371 0026222 0 ustar 00 { "description": "Obtain the payment resource for the given identifier.", "title": "Get a payment resource", "runnable": true, "operationId": "payment.get", "user": { "scopes": [] }, "credentials": { "oauth": { "clientId": "", "clientSecret": "", "path": "" }, "login": {}, "openIdConnect": {} }, "request": { "headers": {}, "body": {}, "path": "/v1/payments/payment/PAY-5YK922393D847794YKER7MUI", "method": "GET" }, "response": { "headers": {}, "body": { "id": "PAY-17S8410768582940NKEE66EQ", "create_time": "2013-01-31T04:12:02Z", "update_time": "2013-01-31T04:12:04Z", "state": "approved", "intent": "sale", "payer": { "payment_method": "credit_card", "funding_instruments": [ { "credit_card": { "type": "visa", "number": "xxxxxxxxxxxx0331", "expire_month": "11", "expire_year": "2018", "first_name": "Betsy", "last_name": "Buyer", "billing_address": { "line1": "111 First Street", "city": "Saratoga", "state": "CA", "postal_code": "95070", "country_code": "US" } } } ] }, "transactions": [ { "amount": { "total": "7.47", "currency": "USD", "details": { "tax": "0.03", "shipping": "0.03" } }, "description": "This is the payment transaction description.", "related_resources": [ { "sale": { "id": "4RR959492F879224U", "create_time": "2013-01-31T04:12:02Z", "update_time": "2013-01-31T04:12:04Z", "state": "completed", "amount": { "total": "7.47", "currency": "USD" }, "parent_payment": "PAY-17S8410768582940NKEE66EQ", "links": [ { "href": "https://api.paypal.com/v1/payments/sale/4RR959492F879224U", "rel": "self", "method": "GET" }, { "href": "https://api.paypal.com/v1/payments/sale/4RR959492F879224U/refund", "rel": "refund", "method": "POST" }, { "href": "https://api.paypal.com/v1/payments/payment/PAY-17S8410768582940NKEE66EQ", "rel": "parent_payment", "method": "GET" } ] } } ] } ], "links": [ { "href": "https://api.paypal.com/v1/payments/payment/PAY-17S8410768582940NKEE66EQ", "rel": "self", "method": "GET" } ] }, "status": "200 OK" } } rest-api-sdk-php/tests/PayPal/Test/Functional/resources/PaymentsFunctionalTest/testRefundSale.json 0000644 00000003372 15007532371 0027535 0 ustar 00 { "description": "Creates a refunded sale resource.", "title": "Refund a Sale", "runnable": true, "operationId": "sale.refund", "user": { "scopes": [] }, "credentials": { "oauth": { "clientId": "", "clientSecret": "", "path": "" }, "login": {}, "openIdConnect": {} }, "request": { "headers": {}, "body": { "amount": { "total": "2.34", "currency": "USD" } }, "path": "/v1/sales/4RR959492F879224U/refund", "method": "POST" }, "response": { "headers": {}, "body": { "id": "4CF18861HF410323U", "create_time": "2013-01-31T04:13:34Z", "update_time": "2013-01-31T04:13:36Z", "state": "completed", "amount": { "total": "2.34", "currency": "USD" }, "sale_id": "4RR959492F879224U", "parent_payment": "PAY-17S8410768582940NKEE66EQ", "links": [ { "href": "https://api.paypal.com/v1/payments/refund/4CF18861HF410323U", "rel": "self", "method": "GET" }, { "href": "https://api.paypal.com/v1/payments/payment/PAY-46E69296BH2194803KEE662Y", "rel": "parent_payment", "method": "GET" }, { "href": "https://api.paypal.com/v1/payments/sale/2MU78835H4515710F", "rel": "sale", "method": "GET" } ] }, "status": "201 Created" } } rest-api-sdk-php/tests/PayPal/Test/Functional/resources/PaymentsFunctionalTest/testGetSale.json 0000644 00000003463 15007532371 0027032 0 ustar 00 { "description": "Lookup a Sale resource.", "title": "Sale Resource", "runnable": true, "operationId": "sale.get", "user": { "scopes": [] }, "credentials": { "oauth": { "clientId": "", "clientSecret": "", "path": "" }, "login": {}, "openIdConnect": {} }, "request": { "headers": {}, "body": {}, "path": "/v1/sales/4RR959492F879224U", "method": "GET" }, "response": { "headers": {}, "body": { "id": "4RR959492F879224U", "create_time": "2014-10-28T19:27:39Z", "update_time": "2014-10-28T19:28:02Z", "amount": { "total": "7.47", "currency": "USD" }, "payment_mode": "INSTANT_TRANSFER", "state": "completed", "protection_eligibility": "ELIGIBLE", "protection_eligibility_type": "ITEM_NOT_RECEIVED_ELIGIBLE,UNAUTHORIZED_PAYMENT_ELIGIBLE", "parent_payment": "PAY-17S8410768582940NKEE66EQ", "links": [ { "href": "https://api.sandbox.paypal.com/v1/payments/sale/5SA006225W236580K", "rel": "self", "method": "GET" }, { "href": "https://api.sandbox.paypal.com/v1/payments/sale/5SA006225W236580K/refund", "rel": "refund", "method": "POST" }, { "href": "https://api.sandbox.paypal.com/v1/payments/payment/PAY-48W25034R6080713AKRH64KY", "rel": "parent_payment", "method": "GET" } ] }, "status": "201 OK" } } rest-api-sdk-php/tests/PayPal/Test/Functional/resources/PaymentsFunctionalTest/testCreateWallet.json0000644 00000015732 15007532371 0030064 0 ustar 00 { "description": "Creates a payment resource.", "title": "payment", "runnable": true, "operationId": "payment.create", "user": { "scopes": [] }, "credentials": { "oauth": { "clientId": "", "clientSecret": "", "path": "" }, "login": {}, "openIdConnect": {} }, "request": { "headers": {}, "body": { "intent": "sale", "payer": { "payment_method": "paypal", "payer_info": { "tax_id_type": "BR_CPF", "tax_id": "Fh618775611" } }, "redirect_urls": { "return_url": "http://localhost/Server-SDK/rest-api-sdk-php/sample/payments/ExecutePayment.php?success=true", "cancel_url": "http://localhost/Server-SDK/rest-api-sdk-php/sample/payments/ExecutePayment.php?success=false" }, "transactions": [ { "amount": { "total": "20.00", "currency": "USD", "details": { "subtotal": "17.50", "tax": "1.30", "shipping": "1.20", "handling_fee": "1.00", "shipping_discount": "-1.00", "insurance": "0.00" } }, "description": "This is the payment transaction description.", "custom": "EBAY_EMS_90048630024435", "invoice_number": "48787589677", "payment_options": { "allowed_payment_method": "INSTANT_FUNDING_SOURCE" }, "soft_descriptor": "ECHI5786786", "item_list": { "items": [ { "name": "hat", "description": "Browncolorsatinhat", "quantity": "1", "price": "7.50", "tax": "0.30", "sku": "1", "currency": "USD" }, { "name": "handbag", "description": "Blackcolorhandbag", "quantity": "5", "price": "2.00", "tax": "0.20", "sku": "product34", "currency": "USD" } ], "shipping_address": { "recipient_name": "HelloWorld", "line1": "2211 North First Street", "city": "San Jose", "country_code": "US", "postal_code": "95131", "phone": "011862212345678", "state": "CA" } } } ] }, "path": "/v1/payments/payment", "method": "POST" }, "response": { "headers": {}, "body": { "id": "PAY-17S8410768582940NKEE66EQ", "create_time": "2013-01-31T04: 12: 02Z", "update_time": "2013-01-31T04: 12: 04Z", "state": "approved", "intent": "sale", "payer": { "payment_method": "credit_card", "funding_instruments": [ { "credit_card": { "type": "visa", "number": "xxxxxxxxxxxx0331", "expire_month": "11", "expire_year": "2018", "first_name": "Betsy", "last_name": "Buyer", "billing_address": { "line1": "111FirstStreet", "city": "Saratoga", "state": "CA", "postal_code": "95070", "country_code": "US" } } } ] }, "transactions": [ { "amount": { "total": "20.00", "currency": "USD", "details": { "subtotal": "17.50", "tax": "1.30", "shipping": "1.20" } }, "description": "Thisisthepaymenttransactiondescription.", "related_resources": [ { "sale": { "id": "4RR959492F879224U", "create_time": "2013-01-31T04: 12: 02Z", "update_time": "2013-01-31T04: 12: 04Z", "state": "completed", "amount": { "total": "7.47", "currency": "USD" }, "parent_payment": "PAY-17S8410768582940NKEE66EQ", "links": [ { "href": "https: //api.paypal.com/v1/payments/sale/4RR959492F879224U", "rel": "self", "method": "GET" }, { "href": "https: //api.paypal.com/v1/payments/sale/4RR959492F879224U/refund", "rel": "refund", "method": "POST" }, { "href": "https: //api.paypal.com/v1/payments/payment/PAY-17S8410768582940NKEE66EQ", "rel": "parent_payment", "method": "GET" } ] } } ] } ], "links": [ { "href": "https: //api.paypal.com/v1/payments/payment/PAY-17S8410768582940NKEE66EQ", "rel": "self", "method": "GET" } ] }, "status": "201 Created" } } rest-api-sdk-php/tests/PayPal/Test/Functional/resources/PaymentsFunctionalTest/testGetPending.json 0000644 00000007751 15007532371 0027536 0 ustar 00 { "description": "Obtain the payment resource for the given identifier.", "title": "Get a payment resource", "runnable": true, "operationId": "payment.get", "user": { "scopes": [] }, "credentials": { "oauth": { "clientId": "", "clientSecret": "", "path": "" }, "login": {}, "openIdConnect": {} }, "request": { "headers": {}, "body": {}, "path": "/v1/payments/payment/PAY-5YK922393D847794YKER7MUI", "method": "GET" }, "response": { "headers": {}, "body": { "id": "PAY-5YK922393D847794YKER7MUI", "create_time": "2013-02-19T22:01:53Z", "update_time": "2013-02-19T22:01:55Z", "state": "approved", "intent": "sale", "payer": { "payment_method": "paypal", "status": "VERIFIED" }, "transactions": [ { "amount": { "total": "7.47", "currency": "USD", "details": { "subtotal": "7.47" } }, "description": "This is the payment transaction description.", "related_resources": [ { "sale": { "id": "36C38912MN9658832", "create_time": "2013-02-19T22:01:53Z", "update_time": "2013-02-19T22:01:55Z", "amount": { "total": "7.47", "currency": "USD" }, "payment_mode": "INSTANT_TRANSFER", "state": "pending", "reason_code": "ECHECK", "protection_eligibility": "ELIGIBLE", "protection_eligibility_type": "ELIGIBLE", "clearing_time": "2014-06-12T07:00:00Z", "parent_payment": "PAY-5YK922393D847794YKER7MUI", "links": [ { "href": "https://api.paypal.com/v1/payments/sale/36C38912MN9658832", "rel": "self", "method": "GET" }, { "href": "https://api.paypal.com/v1/payments/sale/36C38912MN9658832/refund", "rel": "refund", "method": "POST" }, { "href": "https://www.paypal.com/cgi-bin/webscr?cmd=_complete-express-checkout&token=EC-92V50600P8987630S", "rel": "payment_instruction_redirect", "method": "GET" }, { "href": "https://api.paypal.com/v1/payments/payment/PAY-5YK922393D847794YKER7MUI", "rel": "parent_payment", "method": "GET" } ] } } ] } ], "links": [ { "href": "https://api.paypal.com/v1/payments/payment/PAY-5YK922393D847794YKER7MUI", "rel": "self", "method": "GET" } ] }, "status": "200 OK" } } rest-api-sdk-php/tests/PayPal/Test/Functional/resources/PaymentsFunctionalTest/testExecute.json 0000644 00000007063 15007532371 0027110 0 ustar 00 { "description": "Completes a payment.", "title": "Execute Payment", "runnable": true, "operationId": "payment.execute", "user": { "scopes": [] }, "credentials": { "oauth": { "clientId": "", "clientSecret": "", "path": "" }, "login": {}, "openIdConnect": {} }, "request": { "headers": {}, "body": { "payer_id": "CR87QHB7JTRSC" }, "path": "/v1/payments/payment/PAY-34629814WL663112AKEE3AWQ/execute", "method": "POST" }, "response": { "headers": {}, "body": { "id": "PAY-34629814WL663112AKEE3AWQ", "create_time": "2013-01-30T23:44:26Z", "update_time": "2013-01-30T23:44:28Z", "state": "approved", "intent": "sale", "payer": { "payment_method": "paypal", "payer_info": { "email": "bbuyer@example.com", "first_name": "Betsy", "last_name": "Buyer", "payer_id": "CR87QHB7JTRSC" } }, "transactions": [ { "amount": { "total": "7.47", "currency": "USD", "details": { "tax": "0.04", "shipping": "0.06" } }, "description": "This is the payment transaction description.", "related_resources": [ { "sale": { "id": "1KE4800207592173L", "create_time": "2013-01-30T23:44:26Z", "update_time": "2013-01-30T23:44:28Z", "state": "completed", "amount": { "total": "7.47", "currency": "USD" }, "parent_payment": "PAY-34629814WL663112AKEE3AWQ", "links": [ { "href": "https://api.paypal.com/v1/payments/sale/1KE4800207592173L", "rel": "self", "method": "GET" }, { "href": "https://api.paypal.com/v1/payments/sale/1KE4800207592173L/refund", "rel": "refund", "method": "POST" }, { "href": "https://api.paypal.com/v1/payments/payment/PAY-34629814WL663112AKEE3AWQ", "rel": "parent_payment", "method": "GET" } ] } } ] } ], "links": [ { "href": "https://api.paypal.com/v1/payments/payment/PAY-34629814WL663112AKEE3AWQ", "rel": "self", "method": "GET" } ] }, "status": "200 OK" } } rest-api-sdk-php/tests/PayPal/Test/Core/PayPalCredentialManagerTest.php 0000644 00000011060 15007532371 0022021 0 ustar 00 <?php use PayPal\Core\PayPalCredentialManager; /** * Test class for PayPalCredentialManager. * * @runTestsInSeparateProcesses */ class PayPalCredentialManagerTest extends \PHPUnit_Framework_TestCase { /** * @var PayPalCredentialManager */ protected $object; private $config = array( 'acct1.ClientId' => 'client-id', 'acct1.ClientSecret' => 'client-secret', 'http.ConnectionTimeOut' => '30', 'http.Retry' => '5', 'service.RedirectURL' => 'https://www.sandbox.paypal.com/webscr&cmd=', 'service.DevCentralURL' => 'https://developer.paypal.com', 'service.EndPoint.IPN' => 'https://www.sandbox.paypal.com/cgi-bin/webscr', 'service.EndPoint.AdaptivePayments' => 'https://svcs.sandbox.paypal.com/', 'service.SandboxEmailAddress' => 'platform_sdk_seller@gmail.com', 'log.FileName' => 'PayPal.log', 'log.LogLevel' => 'INFO', 'log.LogEnabled' => '1', ); /** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { $this->object = PayPalCredentialManager::getInstance($this->config); } /** * Tears down the fixture, for example, closes a network connection. * This method is called after a test is executed. */ protected function tearDown() { } /** * @test */ public function testGetInstance() { $instance = $this->object->getInstance($this->config); $this->assertTrue($instance instanceof PayPalCredentialManager); } /** * @test */ public function testGetSpecificCredentialObject() { $cred = $this->object->getCredentialObject('acct1'); $this->assertNotNull($cred); $this->assertAttributeEquals('client-id', 'clientId', $cred); $this->assertAttributeEquals('client-secret', 'clientSecret', $cred); } /** * @after testGetDefaultCredentialObject * * @throws \PayPal\Exception\PayPalInvalidCredentialException */ public function testSetCredentialObject() { $authObject = $this->getMockBuilder('\Paypal\Auth\OAuthTokenCredential') ->disableOriginalConstructor() ->getMock(); $cred = $this->object->setCredentialObject($authObject)->getCredentialObject(); $this->assertNotNull($cred); $this->assertSame($this->object->getCredentialObject(), $authObject); } /** * @after testGetDefaultCredentialObject * * @throws \PayPal\Exception\PayPalInvalidCredentialException */ public function testSetCredentialObjectWithUserId() { $authObject = $this->getMockBuilder('\Paypal\Auth\OAuthTokenCredential') ->disableOriginalConstructor() ->getMock(); $cred = $this->object->setCredentialObject($authObject, 'sample')->getCredentialObject('sample'); $this->assertNotNull($cred); $this->assertSame($this->object->getCredentialObject(), $authObject); } /** * @after testGetDefaultCredentialObject * * @throws \PayPal\Exception\PayPalInvalidCredentialException */ public function testSetCredentialObjectWithoutDefault() { $authObject = $this->getMockBuilder('\Paypal\Auth\OAuthTokenCredential') ->disableOriginalConstructor() ->getMock(); $cred = $this->object->setCredentialObject($authObject, null, false)->getCredentialObject(); $this->assertNotNull($cred); $this->assertNotSame($this->object->getCredentialObject(), $authObject); } /** * @test */ public function testGetInvalidCredentialObject() { $this->setExpectedException('PayPal\Exception\PayPalInvalidCredentialException'); $cred = $this->object->getCredentialObject('invalid_biz_api1.gmail.com'); } /** * */ public function testGetDefaultCredentialObject() { $cred = $this->object->getCredentialObject(); $this->assertNotNull($cred); $this->assertAttributeEquals('client-id', 'clientId', $cred); $this->assertAttributeEquals('client-secret', 'clientSecret', $cred); } /** * @test */ public function testGetRestCredentialObject() { $cred = $this->object->getCredentialObject('acct1'); $this->assertNotNull($cred); $this->assertAttributeEquals($this->config['acct1.ClientId'], 'clientId', $cred); $this->assertAttributeEquals($this->config['acct1.ClientSecret'], 'clientSecret', $cred); } } rest-api-sdk-php/tests/PayPal/Test/Core/PayPalHttpConfigTest.php 0000644 00000006632 15007532371 0020532 0 ustar 00 <?php namespace PayPal\Test\Core; use PayPal\Core\PayPalHttpConfig; /** * Test class for PayPalHttpConfigTest. * */ class PayPalHttpConfigTest extends \PHPUnit_Framework_TestCase { protected $object; private $config = array( 'http.ConnectionTimeOut' => '30', 'http.Retry' => '5', ); /** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { } /** * Tears down the fixture, for example, closes a network connection. * This method is called after a test is executed. */ protected function tearDown() { } /** * @test */ public function testHeaderFunctions() { $o = new PayPalHttpConfig(); $o->addHeader('key1', 'value1'); $o->addHeader('key2', 'value'); $o->addHeader('key2', 'overwritten'); $this->assertEquals(2, count($o->getHeaders())); $this->assertEquals('overwritten', $o->getHeader('key2')); $this->assertNull($o->getHeader('key3')); $o = new PayPalHttpConfig(); $o->addHeader('key1', 'value1'); $o->addHeader('key2', 'value'); $o->addHeader('key2', 'and more', false); $this->assertEquals(2, count($o->getHeaders())); $this->assertEquals('value;and more', $o->getHeader('key2')); $o->removeHeader('key2'); $this->assertEquals(1, count($o->getHeaders())); $this->assertNull($o->getHeader('key2')); } /** * @test */ public function testCurlOpts() { $o = new PayPalHttpConfig(); $o->setCurlOptions(array('k' => 'v')); $curlOpts = $o->getCurlOptions(); $this->assertEquals(1, count($curlOpts)); $this->assertEquals('v', $curlOpts['k']); } public function testRemoveCurlOpts() { $o = new PayPalHttpConfig(); $o->setCurlOptions(array('k' => 'v')); $curlOpts = $o->getCurlOptions(); $this->assertEquals(1, count($curlOpts)); $this->assertEquals('v', $curlOpts['k']); $o->removeCurlOption('k'); $curlOpts = $o->getCurlOptions(); $this->assertEquals(0, count($curlOpts)); } /** * @test */ public function testUserAgent() { $ua = 'UAString'; $o = new PayPalHttpConfig(); $o->setUserAgent($ua); $curlOpts = $o->getCurlOptions(); $this->assertEquals($ua, $curlOpts[CURLOPT_USERAGENT]); } /** * @test */ public function testSSLOpts() { $sslCert = '../cacert.pem'; $sslPass = 'passPhrase'; $o = new PayPalHttpConfig(); $o->setSSLCert($sslCert, $sslPass); $curlOpts = $o->getCurlOptions(); $this->assertArrayHasKey(CURLOPT_SSLCERT, $curlOpts); $this->assertEquals($sslPass, $curlOpts[CURLOPT_SSLCERTPASSWD]); } /** * @test */ public function testProxyOpts() { $proxy = 'http://me:secret@hostname:8081'; $o = new PayPalHttpConfig(); $o->setHttpProxy($proxy); $curlOpts = $o->getCurlOptions(); $this->assertEquals('hostname:8081', $curlOpts[CURLOPT_PROXY]); $this->assertEquals('me:secret', $curlOpts[CURLOPT_PROXYUSERPWD]); $this->setExpectedException('PayPal\Exception\PayPalConfigurationException'); $o->setHttpProxy('invalid string'); } } ?> rest-api-sdk-php/tests/PayPal/Test/Core/PPConfigManagerTest.php.skipped 0000644 00000007761 15007532371 0021760 0 ustar 00 <?php use PayPal\Core\PayPalConfigManager; class PPConfigManagerTest extends \PHPUnit_Framework_TestCase { /** * @var PayPalConfigManager */ protected $object; /** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { $this->object = new \ReflectionClass('PayPal\Core\PayPalConfigManager'); runkit_constant_remove('PP_CONFIG_PATH'); } /** * Tears down the fixture, for example, closes a network connection. * This method is called after a test is executed. */ protected function tearDown() { $property = $this->object->getProperty('instance'); $property->setValue(null); } public function testGetInstance() { define("PP_CONFIG_PATH", dirname(dirname(dirname(__DIR__)))); $this->object = PayPalConfigManager::getInstance(); $instance = $this->object->getInstance(); $instance2 = $this->object->getInstance(); $this->assertTrue($instance instanceof PayPalConfigManager); $this->assertSame($instance, $instance2); } public function testGet() { define("PP_CONFIG_PATH", dirname(dirname(dirname(__DIR__)))); $this->object = PayPalConfigManager::getInstance(); $ret = $this->object->get('acct2'); $this->assertConfiguration( array('acct2.ClientId' => 'TestClientId', 'acct2.ClientSecret' => 'TestClientSecret'), $ret ); $this->assertTrue(sizeof($ret) == 2); } public function testGetIniPrefix() { define("PP_CONFIG_PATH", dirname(dirname(dirname(__DIR__)))); $this->object = PayPalConfigManager::getInstance(); $ret = $this->object->getIniPrefix(); $this->assertContains('acct1', $ret); $this->assertEquals(sizeof($ret), 2); $ret = $this->object->getIniPrefix('TestClientId'); $this->assertEquals('acct2', $ret); } public function testConfigByDefault() { define("PP_CONFIG_PATH", dirname(dirname(dirname(__DIR__)))); $this->object = PayPalConfigManager::getInstance(); // Test file based config params and defaults $config = PayPalConfigManager::getInstance()->getConfigHashmap(); $this->assertConfiguration(array('mode' => 'sandbox', 'http.ConnectionTimeOut' => '60'), $config); } public function testConfigByCustom() { define("PP_CONFIG_PATH", dirname(dirname(dirname(__DIR__)))); $this->object = PayPalConfigManager::getInstance(); // Test custom config params and defaults $config = PayPalConfigManager::getInstance()->addConfigs(array('mode' => 'custom', 'http.ConnectionTimeOut' => 900))->getConfigHashmap(); $this->assertConfiguration(array('mode' => 'custom', 'http.ConnectionTimeOut' => '900'), $config); } public function testConfigByFileAndCustom() { define("PP_CONFIG_PATH", __DIR__. '/non_existent/'); $this->object = PayPalConfigManager::getInstance(); $config = PayPalConfigManager::getInstance()->getConfigHashmap(); $this->assertArrayHasKey('http.ConnectionTimeOut', $config); $this->assertEquals('30', $config['http.ConnectionTimeOut']); $this->assertEquals('5', $config['http.Retry']); //Add more configs $config = PayPalConfigManager::getInstance()->addConfigs(array('http.Retry' => "10", 'mode' => 'sandbox'))->getConfigHashmap(); $this->assertConfiguration(array('http.ConnectionTimeOut' => "30", 'http.Retry' => "10", 'mode' => 'sandbox'), $config); } /** * Asserts if each configuration is available and has expected value. * * @param $conditions * @param $config */ public function assertConfiguration($conditions, $config) { foreach($conditions as $key => $value) { $this->assertArrayHasKey($key, $config); $this->assertEquals($value, $config[$key]); } } } ?> rest-api-sdk-php/tests/PayPal/Test/Core/PayPalLoggingManagerTest.php 0000644 00000002256 15007532371 0021344 0 ustar 00 <?php use PayPal\Core\PayPalLoggingManager; /** * Test class for PayPalLoggingManager. * */ class PayPalLoggingManagerTest extends \PHPUnit_Framework_TestCase { /** * @var PayPalLoggingManager */ protected $object; /** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { $this->object = PayPalLoggingManager::getInstance('InvoiceTest'); } /** * Tears down the fixture, for example, closes a network connection. * This method is called after a test is executed. */ protected function tearDown() { } /** * @test */ public function testError() { $this->object->error('Test Error Message'); } /** * @test */ public function testWarning() { $this->object->warning('Test Warning Message'); } /** * @test */ public function testInfo() { $this->object->info('Test info Message'); } /** * @test */ public function testFine() { $this->object->fine('Test fine Message'); } } ?> rest-api-sdk-php/tests/PayPal/Test/Handler/OauthHandlerTest.php 0000644 00000003077 15007532371 0020421 0 ustar 00 <?php namespace PayPal\Test\Handler; use PayPal\Auth\OAuthTokenCredential; use PayPal\Core\PayPalHttpConfig; use PayPal\Handler\OauthHandler; use PayPal\Rest\ApiContext; class OauthHandlerTest extends \PHPUnit_Framework_TestCase { /** * @var \PayPal\Handler\OauthHandler */ public $handler; /** * @var PayPalHttpConfig */ public $httpConfig; /** * @var ApiContext */ public $apiContext; /** * @var array */ public $config; public function setUp() { $this->apiContext = new ApiContext( new OAuthTokenCredential( 'clientId', 'clientSecret' ) ); } public function modeProvider() { return array( array( array('mode' => 'sandbox') ), array( array('mode' => 'live')), array( array( 'mode' => 'sandbox','oauth.EndPoint' => 'http://localhost/')), array( array('mode' => 'sandbox','service.EndPoint' => 'http://service.localhost/')) ); } /** * @dataProvider modeProvider * @param $configs */ public function testGetEndpoint($configs) { $config = $configs + array( 'cache.enabled' => true, 'http.headers.header1' => 'header1value' ); $this->apiContext->setConfig($config); $this->httpConfig = new PayPalHttpConfig(null, 'POST', $config); $this->handler = new OauthHandler($this->apiContext); $this->handler->handle($this->httpConfig, null, $this->config); } } rest-api-sdk-php/tests/PayPal/Test/Auth/OAuthTokenCredentialTest.php 0000644 00000011431 15007532371 0021374 0 ustar 00 <?php namespace PayPal\Test\Auth; use PayPal\Auth\OAuthTokenCredential; use PayPal\Cache\AuthorizationCache; use PayPal\Core\PayPalConfigManager; use PayPal\Rest\ApiContext; use PayPal\Test\Cache\AuthorizationCacheTest; use PayPal\Test\Constants; class OAuthTokenCredentialTest extends \PHPUnit_Framework_TestCase { /** * @group integration */ public function testGetAccessToken() { $cred = new OAuthTokenCredential(Constants::CLIENT_ID, Constants::CLIENT_SECRET); $this->assertEquals(Constants::CLIENT_ID, $cred->getClientId()); $this->assertEquals(Constants::CLIENT_SECRET, $cred->getClientSecret()); $config = PayPalConfigManager::getInstance()->getConfigHashmap(); $token = $cred->getAccessToken($config); $this->assertNotNull($token); // Check that we get the same token when issuing a new call before token expiry $newToken = $cred->getAccessToken($config); $this->assertNotNull($newToken); $this->assertEquals($token, $newToken); } /** * @group integration */ public function testInvalidCredentials() { $this->setExpectedException('PayPal\Exception\PayPalConnectionException'); $cred = new OAuthTokenCredential('dummy', 'secret'); $this->assertNull($cred->getAccessToken(PayPalConfigManager::getInstance()->getConfigHashmap())); } public function testGetAccessTokenUnit() { $config = array( 'mode' => 'sandbox', 'cache.enabled' => true, 'cache.FileName' => AuthorizationCacheTest::CACHE_FILE ); $cred = new OAuthTokenCredential('clientId', 'clientSecret'); //{"clientId":{"clientId":"clientId","accessToken":"accessToken","tokenCreateTime":1421204091,"tokenExpiresIn":288000000}} AuthorizationCache::push($config, 'clientId', $cred->encrypt('accessToken'), 1421204091, 288000000); $apiContext = new ApiContext($cred); $apiContext->setConfig($config); $this->assertEquals('clientId', $cred->getClientId()); $this->assertEquals('clientSecret', $cred->getClientSecret()); $result = $cred->getAccessToken($config); $this->assertNotNull($result); } public function testGetAccessTokenUnitMock() { $config = array( 'mode' => 'sandbox' ); /** @var OAuthTokenCredential $auth */ $auth = $this->getMockBuilder('\PayPal\Auth\OAuthTokenCredential') ->setConstructorArgs(array('clientId', 'clientSecret')) ->setMethods(array('getToken')) ->getMock(); $auth->expects($this->any()) ->method('getToken') ->will($this->returnValue( array('refresh_token' => 'refresh_token_value') )); $response = $auth->getRefreshToken($config, 'auth_value'); $this->assertNotNull($response); $this->assertEquals('refresh_token_value', $response); } public function testUpdateAccessTokenUnitMock() { $config = array( 'mode' => 'sandbox' ); /** @var OAuthTokenCredential $auth */ $auth = $this->getMockBuilder('\PayPal\Auth\OAuthTokenCredential') ->setConstructorArgs(array('clientId', 'clientSecret')) ->setMethods(array('getToken')) ->getMock(); $auth->expects($this->any()) ->method('getToken') ->will($this->returnValue( array( 'access_token' => 'accessToken', 'expires_in' => 280 ) )); $response = $auth->updateAccessToken($config); $this->assertNotNull($response); $this->assertEquals('accessToken', $response); $response = $auth->updateAccessToken($config, 'refresh_token'); $this->assertNotNull($response); $this->assertEquals('accessToken', $response); } /** * @expectedException \PayPal\Exception\PayPalConnectionException * @expectedExceptionMessage Could not generate new Access token. Invalid response from server: */ public function testUpdateAccessTokenNullReturnUnitMock() { $config = array( 'mode' => 'sandbox' ); /** @var OAuthTokenCredential $auth */ $auth = $this->getMockBuilder('\PayPal\Auth\OAuthTokenCredential') ->setConstructorArgs(array('clientId', 'clientSecret')) ->setMethods(array('getToken')) ->getMock(); $auth->expects($this->any()) ->method('getToken') ->will($this->returnValue( array( ) )); $response = $auth->updateAccessToken($config); $this->assertNotNull($response); $this->assertEquals('accessToken', $response); } } rest-api-sdk-php/tests/sdk_config.ini 0000644 00000002576 15007532371 0013622 0 ustar 00 ;Account credentials from developer portal [Account] acct1.ClientId = AYSq3RDGsmBLJE-otTkBtM-jBRd1TCQwFf9RGfwddNXWz0uFU9ztymylOhRS acct1.ClientSecret = EGnHDxD_qRPdaLdZz8iCr8N7_MzF-YHPTkjs6NKYQvQSBngp4PTTVWkPZRbL acct2.ClientId = TestClientId acct2.ClientSecret = TestClientSecret ;Connection Information [Http] http.ConnectionTimeOut = 60 http.Retry = 1 ;http.Proxy=http://[username:password]@hostname[:port][/path] mode=sandbox ;Service Configuration [Service] service.EndPoint="https://api.sandbox.paypal.com" ; Uncomment this line for integrating with the live endpoint ; service.EndPoint="https://api.paypal.com" ;Logging Information [Log] log.LogEnabled=true ; When using a relative path, the log file is created ; relative to the .php file that is the entry point ; for this request. You can also provide an absolute ; path here log.FileName=PayPal.log ; Logging level can be one of FINE, INFO, WARN or ERROR ; Logging is most verbose in the 'FINE' level and ; decreases as you proceed towards ERROR log.LogLevel=DEBUG ;Validation Configuration [validation] ; If validation is set to strict, the PayPalModel would make sure that ; there are proper accessors (Getters and Setters) for each model ; objects. Accepted value is ; 'log' : logs the error message to logger only (default) ; 'strict' : throws a php notice message ; 'disable' : disable the validation validation.level=strict rest-api-sdk-php/.coveralls.yml 0000644 00000000233 15007532371 0012430 0 ustar 00 # .coveralls.yml configuration # for php-coveralls src_dir: lib coverage_clover: build/coverage/clover.xml json_path: build/coverage/coveralls-upload.json rest-api-sdk-php/generate-api.sh 0000644 00000001371 15007532371 0012536 0 ustar 00 #!/bin/sh # Get ApiGen.phar wget http://www.apigen.org/apigen.phar # Generate SDK Docs php apigen.phar generate --template-theme="bootstrap" -s lib -d ../gh-pages/docs # Copy Home Page from Master Branch to Gh-Pages folder cp -r docs/* ../gh-pages/ # Copy samples cp -r sample ../gh-pages/sample # As PHP is not allowed in Github cp sample/index.php ../gh-pages/sample/index.html cd ../gh-pages # Set identity git config --global user.email "travis@travis-ci.org" git config --global user.name "Travis" # Add branch git init git remote add origin https://${GH_TOKEN}@github.com/paypal/PayPal-PHP-SDK.git > /dev/null git checkout -B gh-pages # Push generated files git add . git commit -m "Docs updated by Travis" git push origin gh-pages -fq > /dev/null rest-api-sdk-php/README.md 0000644 00000006707 15007532371 0011130 0 ustar 00 # REST API SDK for PHP  [](https://travis-ci.org/paypal/PayPal-PHP-SDK) [](https://coveralls.io/r/paypal/PayPal-PHP-SDK?branch=master) __Welcome to PayPal PHP SDK__. This repository contains PayPal's PHP SDK and samples for REST API. > **Before starting to use the sdk, please be aware of the [existing issues and currently unavailable or upcoming features](https://github.com/paypal/rest-api-sdk-python/wiki/Existing-Issues-and-Unavailable%5CUpcoming-features) for the REST APIs. (which the sdks are based on)** ## Please Note > **The Payment Card Industry (PCI) Council has [mandated](http://blog.pcisecuritystandards.org/migrating-from-ssl-and-early-tls) that early versions of TLS be retired from service. All organizations that handle credit card information are required to comply with this standard. As part of this obligation, PayPal is updating its services to require TLS 1.2 for all HTTPS connections. At this time, PayPal will also require HTTP/1.1 for all connections. [Click here](https://github.com/paypal/tls-update) for more information** > **If you have the SDK v1.6.2 or higher installed, you can easily test this by running the [TLSCheck sample](sample/tls/TlsCheck.php).** ## SDK Documentation [ Our PayPal-PHP-SDK Page ](http://paypal.github.io/PayPal-PHP-SDK/) includes all the documentation related to PHP SDK. Everything from SDK Wiki, to Sample Codes, to Releases. Here are few quick links to get you there faster. * [ PayPal-PHP-SDK Home Page ](http://paypal.github.io/PayPal-PHP-SDK/) * [ Wiki ](https://github.com/paypal/PayPal-PHP-SDK/wiki) * [ Samples ](http://paypal.github.io/PayPal-PHP-SDK/sample/) * [ Installation ](https://github.com/paypal/PayPal-PHP-SDK/wiki/Installation) * [ Make your First SDK Call](https://github.com/paypal/PayPal-PHP-SDK/wiki/Making-First-Call) * [ PayPal Developer Docs] (https://developer.paypal.com/docs/) ## Latest Updates - If you are running into SSL Connect Error talking to sandbox or live, please update your SDK to latest version or, follow instructions as shown [here](https://github.com/paypal/PayPal-PHP-SDK/issues/474) - Checkout the latest 1.0.0 release. Here are all the [ breaking Changes in v1.0.0 ](https://github.com/paypal/PayPal-PHP-SDK/wiki/Breaking-Changes---1.0.0) if you are migrating from older versions. - Now we have a [Github Page](http://paypal.github.io/PayPal-PHP-SDK/), that helps you find all helpful resources building applications using PayPal-PHP-SDK. ## Prerequisites - PHP 5.3 or above - [curl](http://php.net/manual/en/book.curl.php), [json](http://php.net/manual/en/book.json.php) & [openssl](http://php.net/manual/en/book.openssl.php) extensions must be enabled ## More help * [Going Live](https://github.com/paypal/PayPal-PHP-SDK/wiki/Going-Live) * [PayPal-PHP-SDK Home Page](http://paypal.github.io/PayPal-PHP-SDK/) * [SDK Documentation](https://github.com/paypal/PayPal-PHP-SDK/wiki) * [Sample Source Code](http://paypal.github.io/PayPal-PHP-SDK/sample/) * [API Reference](https://developer.paypal.com/webapps/developer/docs/api/) * [Reporting Issues / Feature Requests] (https://github.com/paypal/PayPal-PHP-SDK/issues) * [Pizza App Using Paypal REST API] (https://github.com/paypal/rest-api-sample-app-php) rest-api-sdk-php/phpunit.integration.xml 0000644 00000002127 15007532371 0014374 0 ustar 00 <?xml version="1.0" encoding="UTF-8"?> <phpunit bootstrap="./tests/bootstrap.php" colors="true" processIsolation="false" stopOnFailure="false" syntaxCheck="false" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" testSuiteLoaderClass="PHPUnit_Runner_StandardTestSuiteLoader"> <php> <env name="REST_MODE" value="sandbox"/> </php> <testsuites> <testsuite name="All"> <directory>tests</directory> </testsuite> </testsuites> <logging> <log type="junit" target="build/junit.xml" logIncompleteSkipped="false" /> <log type="coverage-html" target="build/coverage/" charset="UTF-8" highlight="true" lowUpperBound="35" highLowerBound="70"/> <log type="coverage-clover" target="build/coverage/clover.xml"/> </logging> <filter> <whitelist> <directory suffix=".php">./lib</directory> <exclude> </exclude> </whitelist> </filter> </phpunit> rest-api-sdk-php/.gitignore 0000644 00000000251 15007532371 0011625 0 ustar 00 build .DS_Store phpunit.local.xml *.log # IDE .idea .project .settings .buildpath atlassian-ide-plugin.xml *.bak # Composer vendor composer.lock # Project var tools rest-api-sdk-php/LICENSE.txt 0000644 00000013507 15007532371 0011470 0 ustar 00 PAYPAL, INC. SDK LICENSE NOTICE TO USER: PayPal, Inc. is providing the Software and Documentation for use under the terms of this Agreement. Any use, reproduction, modification or distribution of the Software or Documentation, or any derivatives or portions hereof, constitutes your acceptance of this Agreement. As used in this Agreement, "PayPal" means PayPal, Inc. "Software" means the software code accompanying this agreement. "Documentation" means the documents, specifications and all other items accompanying this Agreement other than the Software. 1. LICENSE GRANT Subject to the terms of this Agreement, PayPal hereby grants you a non-exclusive, worldwide, royalty free license to use, reproduce, prepare derivative works from, publicly display, publicly perform, distribute and sublicense the Software for any purpose, provided the copyright notice below appears in a conspicuous location within the source code of the distributed Software and this license is distributed in the supporting documentation of the Software you distribute. Furthermore, you must comply with all third party licenses in order to use the third party software contained in the Software. Subject to the terms of this Agreement, PayPal hereby grants you a non-exclusive, worldwide, royalty free license to use, reproduce, publicly display, publicly perform, distribute and sublicense the Documentation for any purpose. You may not modify the Documentation. No title to the intellectual property in the Software or Documentation is transferred to you under the terms of this Agreement. You do not acquire any rights to the Software or the Documentation except as expressly set forth in this Agreement. If you choose to distribute the Software in a commercial product, you do so with the understanding that you agree to defend, indemnify and hold harmless PayPal and its suppliers against any losses, damages and costs arising from the claims, lawsuits or other legal actions arising out of such distribution. You may distribute the Software in object code form under your own license, provided that your license agreement: (a) complies with the terms and conditions of this license agreement; (b) effectively disclaims all warranties and conditions, express or implied, on behalf of PayPal; (c) effectively excludes all liability for damages on behalf of PayPal; (d) states that any provisions that differ from this Agreement are offered by you alone and not PayPal; and (e) states that the Software is available from you or PayPal and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange. 2. DISCLAIMER OF WARRANTY PAYPAL LICENSES THE SOFTWARE AND DOCUMENTATION TO YOU ONLY ON AN "AS IS" BASIS WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. PAYPAL MAKES NO WARRANTY THAT THE SOFTWARE OR DOCUMENTATION WILL BE ERROR-FREE. Each user of the Software or Documentation is solely responsible for determining the appropriateness of using and distributing the Software and Documentation and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs, or equipment, and unavailability or interruption of operations. Use of the Software and Documentation is made with the understanding that PayPal will not provide you with any technical or customer support or maintenance. Some states or jurisdictions do not allow the exclusion of implied warranties or limitations on how long an implied warranty may last, so the above limitations may not apply to you. To the extent permissible, any implied warranties are limited to ninety (90) days. 3. LIMITATION OF LIABILITY PAYPAL AND ITS SUPPLIERS SHALL NOT BE LIABLE FOR LOSS OR DAMAGE ARISING OUT OF THIS AGREEMENT OR FROM THE USE OF THE SOFTWARE OR DOCUMENTATION. IN NO EVENT WILL PAYPAL OR ITS SUPPLIERS BE LIABLE TO YOU OR ANY THIRD PARTY FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, INCIDENTAL, OR SPECIAL DAMAGES INCLUDING LOST PROFITS, LOST SAVINGS, COSTS, FEES, OR EXPENSES OF ANY KIND ARISING OUT OF ANY PROVISION OF THIS AGREEMENT OR THE USE OR THE INABILITY TO USE THE SOFTWARE OR DOCUMENTATION, HOWEVER CAUSED AND UNDER ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR TORT INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. PAYPAL'S AGGREGATE LIABILITY AND THAT OF ITS SUPPLIERS UNDER OR IN CONNECTION WITH THIS AGREEMENT SHALL BE LIMITED TO THE AMOUNT PAID BY YOU FOR THE SOFTWARE AND DOCUMENTATION. 4. TRADEMARK USAGE PayPal is a trademark PayPal, Inc. in the United States and other countries. Such trademarks may not be used to endorse or promote any product unless expressly permitted under separate agreement with PayPal. 5. TERM Your rights under this Agreement shall terminate if you fail to comply with any of the material terms or conditions of this Agreement and do not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all your rights under this Agreement terminate, you agree to cease use and distribution of the Software and Documentation as soon as reasonably practicable. 6. GOVERNING LAW AND JURISDICTION. This Agreement is governed by the statutes and laws of the State of California, without regard to the conflicts of law principles thereof. If any part of this Agreement is found void and unenforceable, it will not affect the validity of the balance of the Agreement, which shall remain valid and enforceable according to its terms. Any dispute arising out of or related to this Agreement shall be brought in the courts of Santa Clara County, California, USA. rest-api-sdk-php/sample/common.php 0000644 00000017545 15007532371 0013135 0 ustar 00 <?php /* Common functions used across samples */ /** * Helper Class for Printing Results * * Class ResultPrinter */ class ResultPrinter { private static $printResultCounter = 0; /** * Prints HTML Output to web page. * * @param string $title * @param string $objectName * @param string $objectId * @param mixed $request * @param mixed $response * @param string $errorMessage */ public static function printOutput($title, $objectName, $objectId = null, $request = null, $response = null, $errorMessage = null) { if (PHP_SAPI == 'cli') { self::$printResultCounter++; printf("\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); printf("(%d) %s", self::$printResultCounter, strtoupper($title)); printf("\n-------------------------------------------------------------\n\n"); if ($objectId) { printf("Object with ID: %s \n", $objectId); } printf("-------------------------------------------------------------\n"); printf("\tREQUEST:\n"); self::printConsoleObject($request); printf("\n\n\tRESPONSE:\n"); self::printConsoleObject($response, $errorMessage); printf("\n-------------------------------------------------------------\n\n"); } else { if (self::$printResultCounter == 0) { include "header.html"; echo ' <div class="row header"><div class="col-md-5 pull-left"><br /><a href="../index.php"><h1 class="home">❮❮ Back to Samples</h1></a><br /></div> <br /> <div class="col-md-4 pull-right"><img src="https://www.paypalobjects.com/webstatic/developer/logo2_paypal_developer_2x.png" class="logo" width="300"/></div> </div>'; echo '<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">'; } self::$printResultCounter++; echo ' <div class="panel panel-default"> <div class="panel-heading '. ($errorMessage ? 'error' : '') .'" role="tab" id="heading-'.self::$printResultCounter.'"> <h4 class="panel-title"> <a data-toggle="collapse" data-parent="#accordion" href="#step-'. self::$printResultCounter .'" aria-expanded="false" aria-controls="step-'.self::$printResultCounter.'"> '. self::$printResultCounter .'. '. $title . ($errorMessage ? ' (Failed)' : '') . '</a> </h4> </div> <div id="step-'.self::$printResultCounter.'" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading-'. self::$printResultCounter . '"> <div class="panel-body"> '; if ($objectId) { echo "<div>" . ($objectName ? $objectName : "Object") . " with ID: $objectId </div>"; } echo '<div class="row hidden-xs hidden-sm hidden-md"><div class="col-md-6"><h4>Request Object</h4>'; self::printObject($request); echo '</div><div class="col-md-6"><h4 class="'. ($errorMessage ? 'error' : '') .'">Response Object</h4>'; self::printObject($response, $errorMessage); echo '</div></div>'; echo '<div class="hidden-lg"><ul class="nav nav-tabs" role="tablist"> <li role="presentation" ><a href="#step-'.self::$printResultCounter .'-request" role="tab" data-toggle="tab">Request</a></li> <li role="presentation" class="active"><a href="#step-'.self::$printResultCounter .'-response" role="tab" data-toggle="tab">Response</a></li> </ul> <div class="tab-content"> <div role="tabpanel" class="tab-pane" id="step-'.self::$printResultCounter .'-request"><h4>Request Object</h4>'; self::printObject($request) ; echo '</div><div role="tabpanel" class="tab-pane active" id="step-'.self::$printResultCounter .'-response"><h4>Response Object</h4>'; self::printObject($response, $errorMessage); echo '</div></div></div></div> </div> </div>'; } flush(); } /** * Prints success response HTML Output to web page. * * @param string $title * @param string $objectName * @param string $objectId * @param mixed $request * @param mixed $response */ public static function printResult($title, $objectName, $objectId = null, $request = null, $response = null) { self::printOutput($title, $objectName, $objectId, $request, $response, false); } /** * Prints Error * * @param $title * @param $objectName * @param null $objectId * @param null $request * @param \Exception $exception */ public static function printError($title, $objectName, $objectId = null, $request = null, $exception = null) { $data = null; if ($exception instanceof \PayPal\Exception\PayPalConnectionException) { $data = $exception->getData(); } self::printOutput($title, $objectName, $objectId, $request, $data, $exception->getMessage()); } protected static function printConsoleObject($object, $error = null) { if ($error) { echo 'ERROR:'. $error; } if ($object) { if (is_a($object, 'PayPal\Common\PayPalModel')) { /** @var $object \PayPal\Common\PayPalModel */ echo $object->toJSON(128); } elseif (is_string($object) && \PayPal\Validation\JsonValidator::validate($object, true)) { echo str_replace('\\/', '/', json_encode(json_decode($object), 128)); } elseif (is_string($object)) { echo $object; } else { print_r($object); } } else { echo "No Data"; } } protected static function printObject($object, $error = null) { if ($error) { echo '<p class="error"><i class="fa fa-exclamation-triangle"></i> '. $error. '</p>'; } if ($object) { if (is_a($object, 'PayPal\Common\PayPalModel')) { /** @var $object \PayPal\Common\PayPalModel */ echo '<pre class="prettyprint '. ($error ? 'error' : '') .'">' . $object->toJSON(128) . "</pre>"; } elseif (is_string($object) && \PayPal\Validation\JsonValidator::validate($object, true)) { echo '<pre class="prettyprint '. ($error ? 'error' : '') .'">'. str_replace('\\/', '/', json_encode(json_decode($object), 128)) . "</pre>"; } elseif (is_string($object)) { echo '<pre class="prettyprint '. ($error ? 'error' : '') .'">' . $object . '</pre>'; } else { echo "<pre>"; print_r($object); echo "</pre>"; } } else { echo "<span>No Data</span>"; } } } /** * ### getBaseUrl function * // utility function that returns base url for * // determining return/cancel urls * * @return string */ function getBaseUrl() { if (PHP_SAPI == 'cli') { $trace=debug_backtrace(); $relativePath = substr(dirname($trace[0]['file']), strlen(dirname(dirname(__FILE__)))); echo "Warning: This sample may require a server to handle return URL. Cannot execute in command line. Defaulting URL to http://localhost$relativePath \n"; return "http://localhost" . $relativePath; } $protocol = 'http'; if ($_SERVER['SERVER_PORT'] == 443 || (!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on')) { $protocol .= 's'; } $host = $_SERVER['HTTP_HOST']; $request = $_SERVER['PHP_SELF']; return dirname($protocol . '://' . $host . $request); } rest-api-sdk-php/sample/payouts/GetPayoutBatchStatus.php 0000644 00000002161 15007532371 0017424 0 ustar 00 <?php // # Get Payout Batch Status Sample // // This sample code demonstrate how you can get the batch payout status of a created batch payout, as documented here at: // https://developer.paypal.com/docs/api/#get-the-status-of-a-batch-payout // API used: GET /v1/payments/payouts/<Payout-Batch-Id> /** @var \PayPal\Api\PayoutBatch $payoutBatch */ $payoutBatch = require 'CreateBatchPayout.php'; // ## Payout Batch ID // You can replace this with your Payout Batch Id on already created Payout. $payoutBatchId = $payoutBatch->getBatchHeader()->getPayoutBatchId(); // ### Get Payout Batch Status try { $output = \PayPal\Api\Payout::get($payoutBatchId, $apiContext); } catch (Exception $ex) { // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printError("Get Payout Batch Status", "PayoutBatch", null, $payoutBatchId, $ex); exit(1); } // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printResult("Get Payout Batch Status", "PayoutBatch", $output->getBatchHeader()->getPayoutBatchId(), null, $output); return $output; rest-api-sdk-php/sample/payouts/GetPayoutItemStatus.php 0000644 00000002435 15007532371 0017305 0 ustar 00 <?php // # Get Payout Item Status Sample // // Use this call to get data about a payout item, including the status, without retrieving an entire batch. You can get the status of an individual payout item in a batch in order to review the current status of a previously-unclaimed, or pending, payout item. // https://developer.paypal.com/docs/api/#get-the-status-of-a-payout-item // API used: GET /v1/payments/payouts-item/<Payout-Item-Id> /** @var \PayPal\Api\PayoutBatch $payoutBatch */ $payoutBatch = require 'GetPayoutBatchStatus.php'; // ## Payout Item ID // You can replace this with your Payout Batch Id on already created Payout. $payoutItems = $payoutBatch->getItems(); $payoutItem = $payoutItems[0]; $payoutItemId = $payoutItem->getPayoutItemId(); // ### Get Payout Item Status try { $output = \PayPal\Api\PayoutItem::get($payoutItemId, $apiContext); } catch (Exception $ex) { // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printError("Get Payout Item Status", "PayoutItem", null, $payoutItemId, $ex); exit(1); } // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printResult("Get Payout Item Status", "PayoutItem", $output->getPayoutItemId(), null, $output); return $output; rest-api-sdk-php/sample/payouts/CreateSinglePayout.php 0000644 00000005346 15007532371 0017114 0 ustar 00 <?php // # Create Single Synchronous Payout Sample // // This sample code demonstrate how you can create a synchronous payout sample, as documented here at: // https://developer.paypal.com/docs/integration/direct/create-single-payout/ // API used: /v1/payments/payouts?sync_mode=true require __DIR__ . '/../bootstrap.php'; // Create a new instance of Payout object $payouts = new \PayPal\Api\Payout(); // This is how our body should look like: /* * { "sender_batch_header":{ "sender_batch_id":"2014021801", "email_subject":"You have a Payout!" }, "items":[ { "recipient_type":"EMAIL", "amount":{ "value":"1.0", "currency":"USD" }, "note":"Thanks for your patronage!", "sender_item_id":"2014031400023", "receiver":"shirt-supplier-one@mail.com" } ] } */ $senderBatchHeader = new \PayPal\Api\PayoutSenderBatchHeader(); // ### NOTE: // You can prevent duplicate batches from being processed. If you specify a `sender_batch_id` that was used in the last 30 days, the batch will not be processed. For items, you can specify a `sender_item_id`. If the value for the `sender_item_id` is a duplicate of a payout item that was processed in the last 30 days, the item will not be processed. // #### Batch Header Instance $senderBatchHeader->setSenderBatchId(uniqid()) ->setEmailSubject("You have a Payout!"); // #### Sender Item // Please note that if you are using single payout with sync mode, you can only pass one Item in the request $senderItem = new \PayPal\Api\PayoutItem(); $senderItem->setRecipientType('Email') ->setNote('Thanks for your patronage!') ->setReceiver('shirt-supplier-one@gmail.com') ->setSenderItemId("2014031400023") ->setAmount(new \PayPal\Api\Currency('{ "value":"1.0", "currency":"USD" }')); $payouts->setSenderBatchHeader($senderBatchHeader) ->addItem($senderItem); // For Sample Purposes Only. $request = clone $payouts; // ### Create Payout try { $output = $payouts->createSynchronous($apiContext); } catch (Exception $ex) { // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printError("Created Single Synchronous Payout", "Payout", null, $request, $ex); exit(1); } // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printResult("Created Single Synchronous Payout", "Payout", $output->getBatchHeader()->getPayoutBatchId(), $request, $output); return $output; rest-api-sdk-php/sample/payouts/CreateBatchPayout.php 0000644 00000010102 15007532371 0016676 0 ustar 00 <?php // # Create Bulk Payout Sample // // This sample code demonstrate how you can create a synchronous payout sample, as documented here at: // https://developer.paypal.com/docs/integration/direct/create-batch-payout/ // API used: /v1/payments/payouts require __DIR__ . '/../bootstrap.php'; // Create a new instance of Payout object $payouts = new \PayPal\Api\Payout(); // This is how our body should look like: /* *{ "sender_batch_header": { "sender_batch_id": "random_uniq_id", "email_subject": "You have a payment" }, "items": [ { "recipient_type": "EMAIL", "amount": { "value": 0.99, "currency": "USD" }, "receiver": "shirt-supplier-one@mail.com", "note": "Thank you.", "sender_item_id": "item_1" }, { "recipient_type": "EMAIL", "amount": { "value": 0.90, "currency": "USD" }, "receiver": "shirt-supplier-two@mail.com", "note": "Thank you.", "sender_item_id": "item_2" }, { "recipient_type": "EMAIL", "amount": { "value": 2.00, "currency": "USD" }, "receiver": "shirt-supplier-three@mail.com", "note": "Thank you.", "sender_item_id": "item_3" } ] } */ $senderBatchHeader = new \PayPal\Api\PayoutSenderBatchHeader(); // ### NOTE: // You can prevent duplicate batches from being processed. If you specify a `sender_batch_id` that was used in the last 30 days, the batch will not be processed. For items, you can specify a `sender_item_id`. If the value for the `sender_item_id` is a duplicate of a payout item that was processed in the last 30 days, the item will not be processed. // #### Batch Header Instance $senderBatchHeader->setSenderBatchId(uniqid()) ->setEmailSubject("You have a payment"); // #### Sender Item // Please note that if you are using single payout with sync mode, you can only pass one Item in the request $senderItem1 = new \PayPal\Api\PayoutItem(); $senderItem1->setRecipientType('Email') ->setNote('Thanks you.') ->setReceiver('shirt-supplier-one@gmail.com') ->setSenderItemId("item_1" . uniqid()) ->setAmount(new \PayPal\Api\Currency('{ "value":"0.99", "currency":"USD" }')); // #### Sender Item 2 // There are many different ways of assigning values in PayPal SDK. Here is another way where you could directly inject json string. $senderItem2 = new \PayPal\Api\PayoutItem( '{ "recipient_type": "EMAIL", "amount": { "value": 0.90, "currency": "USD" }, "receiver": "shirt-supplier-two@mail.com", "note": "Thank you.", "sender_item_id": "item_2" }' ); // #### Sender Item 3 // One more way of assigning values in constructor when creating instance of PayPalModel object. Injecting array. $senderItem3 = new \PayPal\Api\PayoutItem( array( "recipient_type" => "EMAIL", "receiver" => "shirt-supplier-three@mail.com", "note" => "Thank you.", "sender_item_id" => uniqid(), "amount" => array( "value" => "0.90", "currency" => "USD" ) ) ); $payouts->setSenderBatchHeader($senderBatchHeader) ->addItem($senderItem1)->addItem($senderItem2)->addItem($senderItem3); // For Sample Purposes Only. $request = clone $payouts; // ### Create Payout try { $output = $payouts->create(null, $apiContext); } catch (Exception $ex) { // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printError("Created Batch Payout", "Payout", null, $request, $ex); exit(1); } // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printResult("Created Batch Payout", "Payout", $output->getBatchHeader()->getPayoutBatchId(), $request, $output); return $output; rest-api-sdk-php/sample/payouts/CancelPayoutItem.php 0000644 00000003540 15007532371 0016545 0 ustar 00 <?php // # Cancel Payout Item Status Sample // // Use this call to cancel an existing, unclaimed transaction. If an unclaimed item is not claimed within 30 days, the funds will be automatically returned to the sender. This call can be used to cancel the unclaimed item prior to the automatic 30-day return. // https://developer.paypal.com/docs/api/#cancel-an-unclaimed-payout-item // API used: POST /v1/payments/payouts-item/<Payout-Item-Id>/cancel /** @var \PayPal\Api\PayoutBatch $payoutBatch */ $payoutBatch = require 'CreateSinglePayout.php'; // ## Payout Item ID // You can replace this with your Payout Batch Id on already created Payout. $payoutItems = $payoutBatch->getItems(); $payoutItem = $payoutItems[0]; $payoutItemId = $payoutItem->getPayoutItemId(); $output = null; // ### Cancel Payout Item // Check if Payout Item is UNCLAIMED, and if so, cancel it. try { if ($payoutItem->getTransactionStatus() == 'UNCLAIMED') { // Cancel the Payout Item $output = \PayPal\Api\PayoutItem::cancel($payoutItemId, $apiContext); // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printResult("Cancel Unclaimed Payout Item", "PayoutItem", $output->getPayoutItemId(), null, $output); } else { // The item transaction status is not unclaimed. You can only cancel an unclaimed transaction. // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printError("Cancel Unclaimed Payout Item", "PayoutItem", null, $payoutItemId, new Exception("Payout Item Status is not UNCLAIMED")); } } catch (Exception $ex) { // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printError("Cancel Unclaimed Payout Item", "PayoutItem", null, $payoutItemId, $ex); exit(1); } return $output; rest-api-sdk-php/sample/payment-experience/GetWebProfile.php 0000644 00000002525 15007532371 0020135 0 ustar 00 <?php // ### Get Web Profile // If your request is successful, the API returns a web_profile object response that contains the profile details. // Documentation available at https://developer.paypal.com/webapps/developer/docs/api/#retrieve-a-web-experience-profile // We are going to re-use the sample code from CreateWebProfile.php. // If you have not visited the sample yet, please visit it before trying GetWebProfile.php // The CreateWebProfile.php will create a web profile for us, and return a CreateProfileResponse, // that contains the web profile ID. /** @var \PayPal\Api\CreateProfileResponse $result */ $createProfileResponse = require 'CreateWebProfile.php'; try { // If your request is successful, the API returns a web_profile object response that contains the profile details. $webProfile = \PayPal\Api\WebProfile::get($createProfileResponse->getId(), $apiContext); } catch (\PayPal\Exception\PayPalConnectionException $ex) { // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printError("Get Web Profile", "Web Profile", $webProfile->getId(), null, $ex); exit(1); } // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printResult("Get Web Profile", "Web Profile", $webProfile->getId(), null, $webProfile); return $webProfile; rest-api-sdk-php/sample/payment-experience/CreateWebProfile.php 0000644 00000007157 15007532371 0020627 0 ustar 00 <?php require __DIR__ . '/../bootstrap.php'; // ### Create Web Profile // Use the /web-profiles resource to create seamless payment experience profiles. See the payment experience overview for further information about using the /payment resource to create the PayPal payment and pass the experience_profile_id. // Documentation available at https://developer.paypal.com/webapps/developer/docs/api/#create-a-web-experience-profile // Lets create an instance of FlowConfig and add // landing page type information $flowConfig = new \PayPal\Api\FlowConfig(); // Type of PayPal page to be displayed when a user lands on the PayPal site for checkout. Allowed values: Billing or Login. When set to Billing, the Non-PayPal account landing page is used. When set to Login, the PayPal account login landing page is used. $flowConfig->setLandingPageType("Billing"); // The URL on the merchant site for transferring to after a bank transfer payment. $flowConfig->setBankTxnPendingUrl("http://www.yeowza.com/"); // Parameters for style and presentation. $presentation = new \PayPal\Api\Presentation(); // A URL to logo image. Allowed vaues: .gif, .jpg, or .png. $presentation->setLogoImage("http://www.yeowza.com/favico.ico") // A label that overrides the business name in the PayPal account on the PayPal pages. ->setBrandName("YeowZa! Paypal") // Locale of pages displayed by PayPal payment experience. ->setLocaleCode("US"); // Parameters for input fields customization. $inputFields = new \PayPal\Api\InputFields(); // Enables the buyer to enter a note to the merchant on the PayPal page during checkout. $inputFields->setAllowNote(true) // Determines whether or not PayPal displays shipping address fields on the experience pages. Allowed values: 0, 1, or 2. When set to 0, PayPal displays the shipping address on the PayPal pages. When set to 1, PayPal does not display shipping address fields whatsoever. When set to 2, if you do not pass the shipping address, PayPal obtains it from the buyer’s account profile. For digital goods, this field is required, and you must set it to 1. ->setNoShipping(1) // Determines whether or not the PayPal pages should display the shipping address and not the shipping address on file with PayPal for this buyer. Displaying the PayPal street address on file does not allow the buyer to edit that address. Allowed values: 0 or 1. When set to 0, the PayPal pages should not display the shipping address. When set to 1, the PayPal pages should display the shipping address. ->setAddressOverride(0); // #### Payment Web experience profile resource $webProfile = new \PayPal\Api\WebProfile(); // Name of the web experience profile. Required. Must be unique $webProfile->setName("YeowZa! T-Shirt Shop" . uniqid()) // Parameters for flow configuration. ->setFlowConfig($flowConfig) // Parameters for style and presentation. ->setPresentation($presentation) // Parameters for input field customization. ->setInputFields($inputFields); // For Sample Purposes Only. $request = clone $webProfile; try { // Use this call to create a profile. $createProfileResponse = $webProfile->create($apiContext); } catch (\PayPal\Exception\PayPalConnectionException $ex) { // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printError("Created Web Profile", "Web Profile", null, $request, $ex); exit(1); } // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printResult("Created Web Profile", "Web Profile", $createProfileResponse->getId(), $request, $createProfileResponse); return $createProfileResponse; rest-api-sdk-php/sample/payment-experience/UpdateWebProfile.php 0000644 00000002552 15007532371 0020640 0 ustar 00 <?php // #### Update Web Profile // Use this call to update an experience profile. // Documentation available at https://developer.paypal.com/webapps/developer/docs/api/#update-a-web-experience-profile // We will be re-using the sample code to get a web profile. GetWebProfile.php will // create a new web profileId for sample, and return the web profile object. /** @var \PayPal\Api\WebProfile $webProfile */ $webProfile = require 'GetWebProfile.php'; // Updated the logo image of presentation object in a given web profile. $webProfile->getPresentation()->setLogoImage("http://www.google.com/favico.ico"); try { // Update the web profile to change the logo image. if ($webProfile->update($apiContext)) { // If the update is successfull, we can now get the object, and verify the web profile // object $updatedWebProfile = \PayPal\Api\WebProfile::get($webProfile->getId(), $apiContext); } } catch (\Exception $ex) { // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printError("Updated Web Profile", "Web Profile", $webProfile->getId(), $webProfile, $ex); exit(1); } // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printResult("Updated Web Profile", "Web Profile", $updatedWebProfile->getId(), $webProfile, $updatedWebProfile); rest-api-sdk-php/sample/payment-experience/PartiallyUpdateWebProfile.php 0000644 00000004123 15007532371 0022516 0 ustar 00 <?php // #### Partially Update Web Profile // Use this call to partially update a web experience profile. // Documentation available at https://developer.paypal.com/webapps/developer/docs/api/#partially-update-a-web-experience-profile // We will be re-using the sample code to get a web profile. GetWebProfile.php will // create a new web profileId for sample, and return the web profile object. /** @var \PayPal\Api\WebProfile $webProfile */ $webProfile = require 'GetWebProfile.php'; // ### Create Patch Operation // APIs allows us to pass an array of patches // to make patch operations. // Each Patch operation can be created by using Patch Class // as shown below $patchOperation1 = new \PayPal\Api\Patch(); // The operation to perform. Required. Allowed values: add, remove, replace, move, copy, test $patchOperation1->setOp("add") // string containing a JSON-Pointer value that references a location within the target document (the target location) where the operation is performed. Required. ->setPath("/presentation/brand_name") // New value to apply based on the operation. ->setValue("New Brand Name"); // Similar patch operation to remove the landing page type $patchOperation2 = new \PayPal\Api\Patch(); $patchOperation2->setOp("remove") ->setPath("/flow_config/landing_page_type"); //Generate an array of patch operations $patches = array($patchOperation1, $patchOperation2); try { // Execute the partial update, to carry out these two operations on a given web profile object if ($webProfile->partial_update($patches, $apiContext)) { $webProfile = \PayPal\Api\WebProfile::get($webProfile->getId(), $apiContext); } } catch (\Exception $ex) { // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printError("Partially Updated Web Profile", "Web Profile", $webProfile->getId(), $patches, $ex); exit(1); } // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printResult("Partially Updated Web Profile", "Web Profile", $webProfile->getId(), $patches, $webProfile); rest-api-sdk-php/sample/payment-experience/DeleteWebProfile.php 0000644 00000002461 15007532371 0020617 0 ustar 00 <?php // #### Delete Web Profile // Use this call to delete a web experience profile. // Documentation available at https://developer.paypal.com/webapps/developer/docs/api/#delete-a-web-experience-profile // We are going to re-use the sample code from CreateWebProfile.php. // If you have not visited the sample yet, please visit it before trying GetWebProfile.php // The CreateWebProfile.php will create a web profile for us, and return a CreateProfileResponse, // that contains the web profile ID. /** @var \PayPal\Api\CreateProfileResponse $result */ $createProfileResponse = require_once 'CreateWebProfile.php'; // Create a new instance of web Profile ID, and set the ID. $webProfile = new \PayPal\Api\WebProfile(); $webProfile->setId($createProfileResponse->getId()); try { // Execute the delete method $webProfile->delete($apiContext); } catch (\PayPal\Exception\PayPalConnectionException $ex) { // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printError("Deleted Web Profile", "Web Profile", $createProfileResponse->getId(), null, $ex); exit(1); } // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printResult("Deleted Web Profile", "Web Profile", $createProfileResponse->getId(), null, null); rest-api-sdk-php/sample/payment-experience/ListWebProfiles.php 0000644 00000001740 15007532371 0020512 0 ustar 00 <?php $apiContext = require __DIR__ . '/../bootstrap.php'; // ### Retrieve List of All Web Profiles // Documentation available at https://developer.paypal.com/webapps/developer/docs/api/#list-web-experience-profiles // Retrieve the list of all web profiles by calling the // static `get_list` method on the WebProfile class. // (See bootstrap.php for more on `ApiContext`) try { $list = \PayPal\Api\WebProfile::get_list($apiContext); } catch (\PayPal\Exception\PayPalConnectionException $ex) { // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printError("Get List of All Web Profiles", "Web Profiles", null, null, $ex); exit(1); } $result = ''; foreach ($list as $object) { $result .= $object->toJSON(128) . PHP_EOL; } // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printResult("Get List of All Web Profiles", "Web Profiles", null, null, $result); return $list; rest-api-sdk-php/sample/invoice/RecordRefund.php 0000644 00000003767 15007532371 0015664 0 ustar 00 <?php // # Record Refund Sample // This sample code demonstrate how you can record // an invoice as refunded. /** @var Invoice $invoice */ $invoice = require 'RecordPayment.php'; use PayPal\Api\Invoice; use PayPal\Api\RefundDetail; try { // ### Record Object // Create a RefundDetail object, and fill in the required fields // You can use the new way of injecting json directly to the object. $refund = new RefundDetail( '{ "date" : "2014-07-06 03:30:00 PST", "note" : "Refund provided by cash." }' ); // ### Record Refund for Invoice // Record a refund on invoice object by calling the // `recordRefund` method // on the Invoice class by passing a valid // notification object // (See bootstrap.php for more on `ApiContext`) $refundStatus = $invoice->recordRefund($refund, $apiContext); } catch (Exception $ex) { // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printError("Refund for Invoice", "Invoice", null, null, $ex); exit(1); } // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printResult("Refund for Invoice", "Invoice", $invoice->getId(), $refund, null); // ### 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($invoice->getId(), $apiContext); } catch (Exception $ex) { // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printError("Get Invoice (Not Required - For Sample Only)", "Invoice", $invoice->getId(), $invoice->getId(), $ex); exit(1); } // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printResult("Get Invoice (Not Required - For Sample Only)", "Invoice", $invoice->getId(), $invoice->getId(), $invoice); return $invoice; rest-api-sdk-php/sample/invoice/SendInvoice.php 0000644 00000003035 15007532371 0015474 0 ustar 00 <?php // # Create Invoice Sample // This sample code demonstrate how you can send // a legitimate invoice to the payer /** @var Invoice $invoice */ $invoice = require 'CreateInvoice.php'; use PayPal\Api\Invoice; try { // ### 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 (Exception $ex) { // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printError("Send Invoice", "Invoice", null, null, $ex); exit(1); } // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printResult("Send Invoice", "Invoice", $invoice->getId(), null, null); // ### 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($invoice->getId(), $apiContext); } catch (Exception $ex) { // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printError("Get Invoice (Not Required - For Sample Only)", "Invoice", $invoice->getId(), $invoice->getId(), $ex); exit(1); } // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printResult("Get Invoice (Not Required - For Sample Only)", "Invoice", $invoice->getId(), $invoice->getId(), $invoice); return $invoice; rest-api-sdk-php/sample/invoice/RemindInvoice.php 0000644 00000003733 15007532371 0016026 0 ustar 00 <?php // # Remind Invoice Sample // This sample code demonstrate how you can remind // an invoice to the payer /** @var Invoice $invoice */ $invoice = require 'SendInvoice.php'; use PayPal\Api\Invoice; use PayPal\Api\Notification; try { // ### 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 (Exception $ex) { // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printError("Remind Invoice", "Invoice", null, $notify, $ex); exit(1); } // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printResult("Remind Invoice", "Invoice", null, $notify, null); // ### 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($invoice->getId(), $apiContext); } catch (Exception $ex) { // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printError("Get Invoice (Not Required - For Sample Only)", "Invoice", $invoice->getId(), $invoice->getId(), $ex); exit(1); } // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printResult("Get Invoice (Not Required - For Sample Only)", "Invoice", $invoice->getId(), $invoice->getId(), $invoice); return $invoice; rest-api-sdk-php/sample/invoice/CancelInvoice.php 0000644 00000002457 15007532371 0015777 0 ustar 00 <?php // # Cancel Invoice Sample // This sample code demonstrate how you can cancel // an invoice. /** @var Invoice $invoice */ $invoice = require 'SendInvoice.php'; use PayPal\Api\CancelNotification; use PayPal\Api\Invoice; try { // ### 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 (Exception $ex) { // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printError("Cancel Invoice", "Invoice", null, $notify, $ex); exit(1); } // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printResult("Cancel Invoice", "Invoice", $invoice->getId(), $notify, null); rest-api-sdk-php/sample/invoice/DeleteInvoice.php 0000644 00000001540 15007532371 0016004 0 ustar 00 <?php // # Delete Invoice Sample // This sample code demonstrate how you can delete // an invoice. /** @var Invoice $invoice */ $invoice = require 'CreateInvoice.php'; use PayPal\Api\Invoice; try { // ### Delete Invoice // Delete invoice object by calling the // `delete` method // on the Invoice class by passing a valid // notification object // (See bootstrap.php for more on `ApiContext`) $deleteStatus = $invoice->delete($apiContext); } catch (Exception $ex) { // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printError("Delete Invoice", "Invoice", null, $deleteStatus, $ex); exit(1); } // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printResult("Delete Invoice", "Invoice", $invoice->getId(), null, null); rest-api-sdk-php/sample/invoice/SearchInvoices.php 0000644 00000002427 15007532371 0016177 0 ustar 00 <?php // # Search Invoices Sample // This sample code demonstrate how you can // search invoices from history. /** @var Invoice $invoice */ $invoice = require 'CreateInvoice.php'; use PayPal\Api\Invoice; use PayPal\Api\Search; try { // ### Search Object // Fill up your search criteria for Invoice search. // Using the new way to inject raw json string to constructor $search = new Search( '{ "start_invoice_date" : "2010-05-10 PST", "end_invoice_date" : "2019-05-11 PST", "page" : 1, "page_size" : 20, "total_count_required" : true }' ); // ### Search Invoices // Retrieve the Invoice History object by calling the // static `search` method on the Invoice class. // Refer the method doc for valid values for keys // (See bootstrap.php for more on `ApiContext`) $invoices = Invoice::search($search, $apiContext); } catch (Exception $ex) { // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printError("Search Invoice", "Invoice", null, null, $ex); exit(1); } // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printResult("Search Invoice", "Invoice", null, $search, $invoices); rest-api-sdk-php/sample/invoice/RecordPayment.php 0000644 00000004016 15007532371 0016042 0 ustar 00 <?php // # Record Payment Sample // This sample code demonstrate how you can record // an invoice as paid. /** @var Invoice $invoice */ $invoice = require 'SendInvoice.php'; use PayPal\Api\Invoice; use PayPal\Api\PaymentDetail; try { // ### Record Object // Create a PaymentDetail object, and fill in the required fields // You can use the new way of injecting json directly to the object. $record = new PaymentDetail( '{ "method" : "CASH", "date" : "2014-07-06 03:30:00 PST", "note" : "Cash received." }' ); // ### Record Payment for Invoice // Record a payment on invoice object by calling the // `recordPayment` method // on the Invoice class by passing a valid // notification object // (See bootstrap.php for more on `ApiContext`) $recordStatus = $invoice->recordPayment($record, $apiContext); } catch (Exception $ex) { // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printError("Payment for Invoice", "Invoice", null, null, $ex); exit(1); } // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printResult("Payment for Invoice", "Invoice", $invoice->getId(), $record, null); // ### 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($invoice->getId(), $apiContext); } catch (Exception $ex) { // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printError("Get Invoice (Not Required - For Sample Only)", "Invoice", $invoice->getId(), $invoice->getId(), $ex); exit(1); } // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printResult("Get Invoice (Not Required - For Sample Only)", "Invoice", $invoice->getId(), $invoice->getId(), $invoice); return $invoice; rest-api-sdk-php/sample/invoice/CreateInvoice.php 0000644 00000011075 15007532371 0016011 0 ustar 00 <?php // # Create Invoice Sample // This sample code demonstrate how you can create // an invoice. require __DIR__ . '/../bootstrap.php'; use PayPal\Api\Address; use PayPal\Api\BillingInfo; use PayPal\Api\Cost; use PayPal\Api\Currency; use PayPal\Api\Invoice; use PayPal\Api\InvoiceAddress; use PayPal\Api\InvoiceItem; use PayPal\Api\MerchantInfo; use PayPal\Api\PaymentTerm; use PayPal\Api\Phone; 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())) ->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("jaypatel512-facilitator@hotmail.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"); $billing[0]->setBusinessName("Jay Inc") ->setAdditionalInfo("This is the billing Info") ->setAddress(new InvoiceAddress()); $billing[0]->getAddress() ->setLine1("1234 Main St.") ->setCity("Portland") ->setState("OR") ->setPostalCode("97217") ->setCountryCode("US"); // ### Items List // You could provide the list of all items for // detailed breakdown of invoice $items = array(); $items[0] = new InvoiceItem(); $items[0] ->setName("Sutures") ->setQuantity(100) ->setUnitPrice(new Currency()); $items[0]->getUnitPrice() ->setCurrency("USD") ->setValue(5); // #### Tax Item // You could provide Tax information to each item. $tax = new \PayPal\Api\Tax(); $tax->setPercent(1)->setName("Local Tax on Sutures"); $items[0]->setTax($tax); // Second Item $items[1] = new InvoiceItem(); // Lets add some discount to this item. $item1discount = new Cost(); $item1discount->setPercent("3"); $items[1] ->setName("Injection") ->setQuantity(5) ->setDiscount($item1discount) ->setUnitPrice(new Currency()); $items[1]->getUnitPrice() ->setCurrency("USD") ->setValue(5); // #### Tax Item // You could provide Tax information to each item. $tax2 = new \PayPal\Api\Tax(); $tax2->setPercent(3)->setName("Local Tax on Injection"); $items[1]->setTax($tax2); $invoice->setItems($items); // #### Final Discount // You can add final discount to the invoice as shown below. You could either use "percent" or "value" when providing the discount $cost = new Cost(); $cost->setPercent("2"); $invoice->setDiscount($cost); $invoice->getPaymentTerm() ->setTermType("NET_45"); // ### Shipping Information $invoice->getShippingInfo() ->setFirstName("Sally") ->setLastName("Patient") ->setBusinessName("Not applicable") ->setPhone(new Phone()) ->setAddress(new InvoiceAddress()); $invoice->getShippingInfo()->getPhone() ->setCountryCode("001") ->setNationalNumber("5039871234"); $invoice->getShippingInfo()->getAddress() ->setLine1("1234 Main St.") ->setCity("Portland") ->setState("OR") ->setPostalCode("97217") ->setCountryCode("US"); // ### Logo // You can set the logo in the invoice by providing the external URL pointing to a logo $invoice->setLogoUrl('https://www.paypalobjects.com/webstatic/i/logo/rebrand/ppcom.svg'); // For Sample Purposes Only. $request = clone $invoice; 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 (Exception $ex) { // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printError("Create Invoice", "Invoice", null, $request, $ex); exit(1); } // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printResult("Create Invoice", "Invoice", $invoice->getId(), $request, $invoice); return $invoice; rest-api-sdk-php/sample/invoice/RetrieveQRCode.php 0000644 00000003506 15007532371 0016114 0 ustar 00 <?php // # Retrieve QR Code for Invoice Sample // Specify an invoice ID to get a QR code (image) that corresponds to the invoice ID. A QR code for an invoice can be added to a paper or PDF invoice. When a customer uses their mobile device to scan the QR code, the customer is redirected to the PayPal mobile payment flow, where they can pay online with PayPal or a credit card. /** @var Invoice $invoice */ $invoice = require 'SendInvoice.php'; use PayPal\Api\Invoice; try { // ### Retrieve QR Code of Sent Invoice // Retrieve QR Code of Sent Invoice by calling the // `qrCode` method // on the Invoice class by passing a valid // notification object // (See bootstrap.php for more on `ApiContext`) $image = Invoice::qrCode($invoice->getId(), array('height' => '300', 'width' => '300'), $apiContext); // ### Optionally Save to File // This is not a required step. However, if you want to store this image as a file, you can use // 'saveToFile' method with proper file name. // This will save the image as /samples/invoice/images/sample.png $path = $image->saveToFile("images/sample.png"); } catch (Exception $ex) { // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printError("Retrieved QR Code for Invoice", "Invoice", $invoice->getId(), null, $ex); exit(1); } // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printResult("Retrieved QR Code for Invoice", "Invoice", $invoice->getId(), null, $image); // ### Show the Image // In PHP, there are many ways to present an images. // One of the ways, you could directly inject the base64-encoded string // with proper image information in front of it. echo '<img src="data:image/png;base64,'. $image->getImage() . '" alt="Invoice QR Code" />'; rest-api-sdk-php/sample/invoice/ListInvoice.php 0000644 00000001704 15007532371 0015517 0 ustar 00 <?php // # List Invoices Sample // This sample code demonstrate how you can get // all invoice from history. /** @var Invoice $invoice */ $invoice = require 'CreateInvoice.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::getAll(array('page' => 0, 'page_size' => 4, 'total_count_required' => "true"), $apiContext); } catch (Exception $ex) { // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printError("Lookup Invoice History", "Invoice", null, null, $ex); exit(1); } // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printResult("Lookup Invoice History", "Invoice", null, null, $invoices); rest-api-sdk-php/sample/invoice/images/sample.png 0000644 00000003217 15007532371 0016013 0 ustar 00 �PNG IHDR , , �"