diff --git a/lib/PayPal/Api/PatchRequest.php b/lib/PayPal/Api/PatchRequest.php index fe5a82f..74b4210 100644 --- a/lib/PayPal/Api/PatchRequest.php +++ b/lib/PayPal/Api/PatchRequest.php @@ -81,6 +81,6 @@ class PatchRequest extends PPModel foreach ($this->getPatches() as $patch) { $json[] = $patch->toArray(); } - return json_encode($json, $options); + return str_replace('\\/', '/', json_encode($json, $options)); } } diff --git a/lib/PayPal/Auth/OAuthTokenCredential.php b/lib/PayPal/Auth/OAuthTokenCredential.php index b27b097..44fc55a 100644 --- a/lib/PayPal/Auth/OAuthTokenCredential.php +++ b/lib/PayPal/Auth/OAuthTokenCredential.php @@ -184,7 +184,7 @@ class OAuthTokenCredential extends ResourceModel { $base64ClientID = base64_encode($clientId . ":" . $clientSecret); $headers = array( - "User-Agent" => PPUserAgent::getValue(RestHandler::$sdkName, RestHandler::$sdkVersion), + "User-Agent" => PPUserAgent::getValue(PPConstants::SDK_NAME, PPConstants::SDK_VERSION), "Authorization" => "Basic " . $base64ClientID, "Accept" => "*/*" ); diff --git a/lib/PayPal/Core/PPConstants.php b/lib/PayPal/Core/PPConstants.php index d9f44ae..b1cf97d 100644 --- a/lib/PayPal/Core/PPConstants.php +++ b/lib/PayPal/Core/PPConstants.php @@ -12,7 +12,7 @@ class PPConstants { const SDK_NAME = 'PayPal-PHP-SDK'; - const SDK_VERSION = '0.14.0'; + const SDK_VERSION = '0.14.1'; const REST_SANDBOX_ENDPOINT = "https://api.sandbox.paypal.com/"; const OPENID_REDIRECT_SANDBOX_URL = "https://www.sandbox.paypal.com/webapps/auth/protocol/openidconnect"; diff --git a/lib/PayPal/Rest/RestHandler.php b/lib/PayPal/Rest/RestHandler.php index 364aaf7..3e060f4 100644 --- a/lib/PayPal/Rest/RestHandler.php +++ b/lib/PayPal/Rest/RestHandler.php @@ -9,6 +9,7 @@ use PayPal\Auth\OAuthTokenCredential; use PayPal\Common\PPUserAgent; use PayPal\Core\PPConstants; use PayPal\Core\PPCredentialManager; +use PayPal\Core\PPHttpConfig; use PayPal\Exception\PPConfigurationException; use PayPal\Exception\PPInvalidCredentialException; use PayPal\Exception\PPMissingCredentialException; @@ -26,20 +27,6 @@ class RestHandler implements IPPHandler */ private $apiContext; - /** - * Public Variable - * - * @var string $sdkName - */ - public static $sdkName = "rest-sdk-php"; - - /** - * Public Variable - * - * @var string $sdkVersion - */ - public static $sdkVersion = "0.13.2"; - /** * Construct * @@ -51,7 +38,7 @@ class RestHandler implements IPPHandler } /** - * @param \Paypal\Core\PPHttpConfig $httpConfig + * @param PPHttpConfig $httpConfig * @param string $request * @param mixed $options * @return mixed|void @@ -87,7 +74,7 @@ class RestHandler implements IPPHandler ); if (!array_key_exists("User-Agent", $httpConfig->getHeaders())) { - $httpConfig->addHeader("User-Agent", PPUserAgent::getValue(self::$sdkName, self::$sdkVersion)); + $httpConfig->addHeader("User-Agent", PPUserAgent::getValue(PPConstants::SDK_NAME, PPConstants::SDK_VERSION)); } if (!is_null($credential) && $credential instanceof OAuthTokenCredential && is_null($httpConfig->getHeader('Authorization'))) { diff --git a/sample/.htaccess b/sample/.htaccess new file mode 100644 index 0000000..eaf2fb9 --- /dev/null +++ b/sample/.htaccess @@ -0,0 +1,7 @@ + +php_value display_errors On +php_flag magic_quotes 1 +php_flag magic_quotes_gpc 1 +php_value mbstring.http_input auto +php_value date.timezone America/Los_Angeles + diff --git a/sample/billing/CreateBillingAgreementWithCreditCard.php b/sample/billing/CreateBillingAgreementWithCreditCard.php index f60dde9..7cd9e7e 100644 --- a/sample/billing/CreateBillingAgreementWithCreditCard.php +++ b/sample/billing/CreateBillingAgreementWithCreditCard.php @@ -67,7 +67,7 @@ $agreement->setPlan($plan); // Add Payer $payer = new Payer(); $payer->setPaymentMethod('credit_card') - ->setPayerInfo(new PayerInfo(['email' => 'jaypatel512-facilitator@hotmail.com'])); + ->setPayerInfo(new PayerInfo(array('email' => 'jaypatel512-facilitator@hotmail.com'))); // Add Credit Card to Funding Instruments $creditCard = new CreditCard(); diff --git a/sample/billing/CreatePlan.php b/sample/billing/CreatePlan.php index 0ba16f7..f5ba47b 100644 --- a/sample/billing/CreatePlan.php +++ b/sample/billing/CreatePlan.php @@ -33,12 +33,12 @@ $paymentDefinition->setName('Regular Payments') ->setFrequency('Month') ->setFrequencyInterval("2") ->setCycles("12") - ->setAmount(new Currency(['value' => 100, 'currency' => 'USD'])); + ->setAmount(new Currency(array('value' => 100, 'currency' => 'USD'))); // Charge Models $chargeModel = new ChargeModel(); $chargeModel->setType('SHIPPING') - ->setAmount(new Currency(['value' => 10, 'currency' => 'USD'])); + ->setAmount(new Currency(array('value' => 10, 'currency' => 'USD'))); $paymentDefinition->setChargeModels(array($chargeModel)); @@ -49,7 +49,7 @@ $merchantPreferences->setReturnUrl("$baseUrl/ExecuteAgreement.php?success=true") ->setAutoBillAmount("yes") ->setInitialFailAmountAction("CONTINUE") ->setMaxFailAttempts("0") - ->setSetupFee(new Currency(['value' => 1, 'currency' => 'USD'])); + ->setSetupFee(new Currency(array('value' => 1, 'currency' => 'USD'))); $plan->setPaymentDefinitions(array($paymentDefinition)); diff --git a/sample/billing/UpdatePlanPaymentDefinitions.php b/sample/billing/UpdatePlanPaymentDefinitions.php new file mode 100644 index 0000000..912b95e --- /dev/null +++ b/sample/billing/UpdatePlanPaymentDefinitions.php @@ -0,0 +1,51 @@ + + +// ### Changing Plan Amount +// This example demonstrate how you could change the plan amount + +// Retrieving the Plan object from Create Plan Sample to demonstrate the List +/** @var Plan $createdPlan */ +$createdPlan = require 'CreatePlan.php'; + +use PayPal\Api\Plan; +use PayPal\Api\PatchRequest; +use PayPal\Api\Patch; + +try { + $patch = new Patch(); + + $paymentDefinitions = $createdPlan->getPaymentDefinitions(); + $paymentDefinitionId = $paymentDefinitions[0]->getId(); + $patch->setOp('replace') + ->setPath('/payment-definitions/' . $paymentDefinitionId) + ->setValue(json_decode( + '{ + "name": "Updated Payment Definition", + "frequency": "Day", + "amount": { + "currency": "USD", + "value": "50" + } + }' + )); + $patchRequest = new PatchRequest(); + $patchRequest->addPatch($patch); + + $createdPlan->update($patchRequest, $apiContext); + + $plan = Plan::get($createdPlan->getId(), $apiContext); + +} catch (Exception $ex) { + ResultPrinter::printError("Updated the Plan Payment Definition", "Plan", null, $patchRequest, $ex); + exit(1); +} + +ResultPrinter::printResult("Updated the Plan Payment Definition", "Plan", $plan->getId(), $patchRequest, $plan); + +return $plan; diff --git a/sample/common.php b/sample/common.php index 0b26849..51ca6fa 100644 --- a/sample/common.php +++ b/sample/common.php @@ -30,19 +30,35 @@ class ResultPrinter * @param string $objectId * @param mixed $request * @param mixed $response - * @param string $error + * @param string $errorMessage */ public static function printOutput($title, $objectName, $objectId = null, $request = null, $response = null, $errorMessage = null) { - if (self::$printResultCounter == 0) { - include "header.html"; - echo '
+ 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 '

❮❮ Back to Samples



'; - echo '
'; - } - self::$printResultCounter++; - echo ' + echo '
'; + } + self::$printResultCounter++; + echo '
'; - + } flush(); } @@ -112,6 +128,27 @@ class ResultPrinter 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\PPModel')) { + /** @var $object \PayPal\Common\PPModel */ + 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) { @@ -145,7 +182,12 @@ class ResultPrinter */ 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'; diff --git a/sample/doc/assets/behavior.js b/sample/doc/assets/behavior.js index 542f56f..5fa0a1b 100644 --- a/sample/doc/assets/behavior.js +++ b/sample/doc/assets/behavior.js @@ -390,6 +390,46 @@ f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3 ] } ] + }, { + "type": "file", + "data": { + "language": { + "nameMatchers": [{}, ".fbp"], + "pygmentsLexer": "php", + "singleLineComment": ["//"], + "ignorePrefix": "}", + "foldPrefix": "^", + "name": "PHP" + }, + "sourcePath": "/Users/japatel/Documents/workspace/Server-SDK/rest-api-sdk-php/sample/billing/UpdatePlanPaymentDefinitions.php", + "projectPath": "billing/UpdatePlanPaymentDefinitions.php", + "targetPath": "billing/UpdatePlanPaymentDefinitions", + "pageTitle": "billing/UpdatePlanPaymentDefinitions", + "title": "UpdatePlanPaymentDefinitions" + }, + "depth": 2, + "outline": [ + { + "type": "heading", + "data": { + "level": 1, + "title": "Update a plan", + "slug": "update-a-plan" + }, + "depth": 1, + "children": [ + { + "type": "heading", + "data": { + "level": 3, + "title": "Changing Plan Amount", + "slug": "changing-plan-amount" + }, + "depth": 3 + } + ] + } + ] } ] }, { diff --git a/sample/doc/billing/CreateBillingAgreementWithCreditCard.html b/sample/doc/billing/CreateBillingAgreementWithCreditCard.html index d6786a3..091bc75 100644 --- a/sample/doc/billing/CreateBillingAgreementWithCreditCard.html +++ b/sample/doc/billing/CreateBillingAgreementWithCreditCard.html @@ -55,7 +55,7 @@ Please note that the plan Id should be only set in this case.

$plan->setId($createdPlan->getId()); $agreement->setPlan($plan);

Add Payer

$payer = new Payer(); $payer->setPaymentMethod('credit_card') - ->setPayerInfo(new PayerInfo(['email' => 'jaypatel512-facilitator@hotmail.com']));

Add Credit Card to Funding Instruments

$creditCard = new CreditCard(); + ->setPayerInfo(new PayerInfo(array('email' => 'jaypatel512-facilitator@hotmail.com')));

Add Credit Card to Funding Instruments

$creditCard = new CreditCard(); $creditCard->setType('visa') ->setNumber('4417119669820331') ->setExpireMonth('12') diff --git a/sample/doc/billing/CreatePlan.html b/sample/doc/billing/CreatePlan.html index 802c519..0eaad08 100644 --- a/sample/doc/billing/CreatePlan.html +++ b/sample/doc/billing/CreatePlan.html @@ -16,9 +16,9 @@ You should be able to see the acceptable values in the comments.

->setFrequency('Month') ->setFrequencyInterval("2") ->setCycles("12") - ->setAmount(new Currency(['value' => '100', 'currency' => 'USD']));

Charge Models

$chargeModel = new ChargeModel(); + ->setAmount(new Currency(array('value' => 100, 'currency' => 'USD')));

Charge Models

$chargeModel = new ChargeModel(); $chargeModel->setType('SHIPPING') - ->setAmount(new Currency(['value' => '10', 'currency' => 'USD'])); + ->setAmount(new Currency(array('value' => 10, 'currency' => 'USD'))); $paymentDefinition->setChargeModels(array($chargeModel)); @@ -29,7 +29,7 @@ You should be able to see the acceptable values in the comments.

->setAutoBillAmount("yes") ->setInitialFailAmountAction("CONTINUE") ->setMaxFailAttempts("0") - ->setSetupFee(new Currency(['value' => '1', 'currency' => 'USD'])); + ->setSetupFee(new Currency(array('value' => 1, 'currency' => 'USD'))); $plan->setPaymentDefinitions(array($paymentDefinition)); diff --git a/sample/doc/billing/UpdatePlanPaymentDefinitions.html b/sample/doc/billing/UpdatePlanPaymentDefinitions.html new file mode 100644 index 0000000..6bbf26a --- /dev/null +++ b/sample/doc/billing/UpdatePlanPaymentDefinitions.html @@ -0,0 +1,43 @@ +billing/UpdatePlanPaymentDefinitions
billing/UpdatePlanPaymentDefinitions.php
<?php

Update a plan

+

This sample code demonstrate how you can update a billing plan, as documented here at: +https://developer.paypal.com/webapps/developer/docs/api/#update-a-plan +API used: /v1/payments/billing-plans/

Changing Plan Amount

+

This example demonstrate how you could change the plan amount

Retrieving the Plan object from Create Plan Sample to demonstrate the List

/** @var Plan $createdPlan */ +$createdPlan = require 'CreatePlan.php'; + +use PayPal\Api\Plan; +use PayPal\Api\PatchRequest; +use PayPal\Api\Patch; + +try { + $patch = new Patch(); + + $paymentDefinitions = $createdPlan->getPaymentDefinitions(); + $paymentDefinitionId = $paymentDefinitions[0]->getId(); + $patch->setOp('replace') + ->setPath('/payment-definitions/' . $paymentDefinitionId) + ->setValue(json_decode( + '{ + "name": "Updated Payment Definition", + "frequency": "Day", + "amount": { + "currency": "USD", + "value": "50" + } + }' + )); + $patchRequest = new PatchRequest(); + $patchRequest->addPatch($patch); + + $createdPlan->update($patchRequest, $apiContext); + + $plan = Plan::get($createdPlan->getId(), $apiContext); + +} catch (Exception $ex) { + ResultPrinter::printError("Updated the Plan Payment Definition", "Plan", null, $patchRequest, $ex); + exit(1); +} + +ResultPrinter::printResult("Updated the Plan Payment Definition", "Plan", $plan->getId(), $patchRequest, $plan); + +return $plan;
\ No newline at end of file diff --git a/sample/doc/payments/AuthorizationCapture.html b/sample/doc/payments/AuthorizationCapture.html index 9df4bcb..b37203c 100644 --- a/sample/doc/payments/AuthorizationCapture.html +++ b/sample/doc/payments/AuthorizationCapture.html @@ -14,7 +14,7 @@ with a valid ApiContext (See bootstrap.php for more on ApiContext)< $amt = new Amount(); $amt->setCurrency("USD") - ->setTotal("1.00"); + ->setTotal(1); ### Capture $capture = new Capture(); diff --git a/sample/doc/payments/AuthorizePayment.html b/sample/doc/payments/AuthorizePayment.html index 53d04f8..072252f 100644 --- a/sample/doc/payments/AuthorizePayment.html +++ b/sample/doc/payments/AuthorizePayment.html @@ -38,7 +38,7 @@ to correct setting. In this case, it would be 'authorize'

$amount = new Amount(); $amount->setCurrency("USD") - ->setTotal("1.00"); + ->setTotal(1); $transaction = new Transaction(); $transaction->setAmount($amount) diff --git a/sample/doc/payments/CreatePayment.html b/sample/doc/payments/CreatePayment.html index 1db6b89..d70c98e 100644 --- a/sample/doc/payments/CreatePayment.html +++ b/sample/doc/payments/CreatePayment.html @@ -37,29 +37,29 @@ information

'Ground Coffee 40 oz') ->setCurrency('USD') ->setQuantity(1) - ->setTax('0.30') - ->setPrice('7.50'); + ->setTax(0.3) + ->setPrice(7.50); $item2 = new Item(); $item2->setName('Granola bars') ->setDescription('Granola Bars with Peanuts') ->setCurrency('USD') ->setQuantity(5) - ->setTax('0.20') - ->setPrice('2.00'); + ->setTax(0.2) + ->setPrice(2); $itemList = new ItemList(); $itemList->setItems(array($item1, $item2));

Additional payment details

Use this optional field to set additional payment information such as tax, shipping charges etc.

$details = new Details(); -$details->setShipping('1.20') - ->setTax('1.30') - ->setSubtotal('17.50');

Amount

+$details->setShipping(1.2) + ->setTax(1.3) + ->setSubtotal(17.5);

Amount

Lets you specify a payment amount. You can also specify additional details such as shipping, tax.

$amount = new Amount(); $amount->setCurrency("USD") - ->setTotal("20.00") + ->setTotal(20) ->setDetails($details);

Transaction

A transaction defines the contract of a payment - what is the payment for and who diff --git a/sample/doc/payments/CreatePaymentUsingPayPal.html b/sample/doc/payments/CreatePaymentUsingPayPal.html index ffcefae..1f604b8 100644 --- a/sample/doc/payments/CreatePaymentUsingPayPal.html +++ b/sample/doc/payments/CreatePaymentUsingPayPal.html @@ -19,26 +19,26 @@ information

$item1->setName('Ground Coffee 40 oz') ->setCurrency('USD') ->setQuantity(1) - ->setPrice('7.50'); + ->setPrice(7.5); $item2 = new Item(); $item2->setName('Granola bars') ->setCurrency('USD') ->setQuantity(5) - ->setPrice('2.00'); + ->setPrice(2); $itemList = new ItemList(); $itemList->setItems(array($item1, $item2));

Additional payment details

Use this optional field to set additional payment information such as tax, shipping charges etc.

$details = new Details(); -$details->setShipping('1.20') - ->setTax('1.30') - ->setSubtotal('17.50');

Amount

+$details->setShipping(1.2) + ->setTax(1.3) + ->setSubtotal(17.50);

Amount

Lets you specify a payment amount. You can also specify additional details such as shipping, tax.

$amount = new Amount(); $amount->setCurrency("USD") - ->setTotal("20.00") + ->setTotal(20) ->setDetails($details);

Transaction

A transaction defines the contract of a payment - what is the payment for and who diff --git a/sample/doc/payments/CreatePaymentUsingSavedCard.html b/sample/doc/payments/CreatePaymentUsingSavedCard.html index 624f98c..bdbfafa 100644 --- a/sample/doc/payments/CreatePaymentUsingSavedCard.html +++ b/sample/doc/payments/CreatePaymentUsingSavedCard.html @@ -30,26 +30,26 @@ information

$item1->setName('Ground Coffee 40 oz') ->setCurrency('USD') ->setQuantity(1) - ->setPrice('7.50'); + ->setPrice(7.5); $item2 = new Item(); $item2->setName('Granola bars') ->setCurrency('USD') ->setQuantity(5) - ->setPrice('2.00'); + ->setPrice(2); $itemList = new ItemList(); $itemList->setItems(array($item1, $item2));

Additional payment details

Use this optional field to set additional payment information such as tax, shipping charges etc.

$details = new Details(); -$details->setShipping('1.20') - ->setTax('1.30') - ->setSubtotal('17.50');

Amount

+$details->setShipping(1.2) + ->setTax(1.3) + ->setSubtotal(17.5);

Amount

Lets you specify a payment amount. You can also specify additional details such as shipping, tax.

$amount = new Amount(); $amount->setCurrency("USD") - ->setTotal("20.00") + ->setTotal(20) ->setDetails($details);

Transaction

A transaction defines the contract of a payment - what is the payment for and who diff --git a/sample/doc/payments/Reauthorization.html b/sample/doc/payments/Reauthorization.html index 9bbc6dd..cf8472d 100644 --- a/sample/doc/payments/Reauthorization.html +++ b/sample/doc/payments/Reauthorization.html @@ -12,7 +12,7 @@ has expired.

$amount = new Amount(); $amount->setCurrency("USD"); - $amount->setTotal("1.00");

Reauthorize with amount being reauthorized

$authorization->setAmount($amount); + $amount->setTotal(1);

Reauthorize with amount being reauthorized

$authorization->setAmount($amount); $reAuthorization = $authorization->reauthorize($apiContext); } catch (Exception $ex) { diff --git a/sample/doc/sale/RefundSale.html b/sample/doc/sale/RefundSale.html index 14fd6d7..064329b 100644 --- a/sample/doc/sale/RefundSale.html +++ b/sample/doc/sale/RefundSale.html @@ -13,7 +13,7 @@ API used: /v1/payments/sale/{sale-id}/refund

$amt = new Amount(); $amt->setCurrency('USD') - ->setTotal('0.01');

Refund object

$refund = new Refund(); + ->setTotal(0.01);

Refund object

$refund = new Refund(); $refund->setAmount($amt);

Sale

A sale transaction. Create a Sale object with the diff --git a/sample/index.html b/sample/index.html index bcf17be..23b6b7a 100644 --- a/sample/index.html +++ b/sample/index.html @@ -167,6 +167,15 @@

+
  • +
    +
    Update Plan Payment Definitions/Amount
    + +
    +
  • List Billing Plans
    diff --git a/tests/PayPal/Test/Functional/resources/BillingPlansFunctionalTest/testCreateWithNOChargeModel.json b/tests/PayPal/Test/Functional/resources/BillingPlansFunctionalTest/testCreateWithNOChargeModel.json index 2817d35..d918587 100755 --- a/tests/PayPal/Test/Functional/resources/BillingPlansFunctionalTest/testCreateWithNOChargeModel.json +++ b/tests/PayPal/Test/Functional/resources/BillingPlansFunctionalTest/testCreateWithNOChargeModel.json @@ -1,93 +1,91 @@ { - "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" ] + "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" : { + "credentials": { "oauth": { - "path" : "/v1/oauth/token", - "clientId":"", - "clientSecret":"" + "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" - } - - } + "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" - } - ] - } + "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" + } + ] + } } } diff --git a/tests/PayPal/Test/Functional/resources/BillingPlansFunctionalTest/testGet.json b/tests/PayPal/Test/Functional/resources/BillingPlansFunctionalTest/testGet.json index 03bc5c9..cacd37d 100755 --- a/tests/PayPal/Test/Functional/resources/BillingPlansFunctionalTest/testGet.json +++ b/tests/PayPal/Test/Functional/resources/BillingPlansFunctionalTest/testGet.json @@ -1,116 +1,115 @@ { - "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"] + "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" : { + "credentials": { "oauth": { - "path" : "/v1/oauth/token", - "clientId":"", - "clientSecret":"" + "path": "/v1/oauth/token", + "clientId": "", + "clientSecret": "" } }, - "request" : { - "path" : "v1/payments/billing-plans/P-7DC96732KA7763723UOPKETA", - "method" : "GET", - "headers" : {}, - "body" : {} + "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" - } - ] - } + "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" + } + ] + } } } diff --git a/tests/PayPal/Test/Functional/resources/BillingPlansFunctionalTest/testGetList.json b/tests/PayPal/Test/Functional/resources/BillingPlansFunctionalTest/testGetList.json index a3be9ec..9460c54 100755 --- a/tests/PayPal/Test/Functional/resources/BillingPlansFunctionalTest/testGetList.json +++ b/tests/PayPal/Test/Functional/resources/BillingPlansFunctionalTest/testGetList.json @@ -1,87 +1,86 @@ { - "description" : "This operation fetches billing plan list", - "title" : "Billing Plan list", - "runnable" : true, - "operationId" : "plans", - "user" : { - "scopes" : ["https://uri.paypal.com/services/subscriptions" ] + "description": "This operation fetches billing plan list", + "title": "Billing Plan list", + "runnable": true, + "operationId": "plans", + "user": { + "scopes": ["https://uri.paypal.com/services/subscriptions"] }, - "credentials" : { + "credentials": { "oauth": { - "path" : "/v1/oauth/token", - "clientId":"", - "clientSecret":"" + "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" : {} + "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" - } - ] + "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" + } + ] } } } diff --git a/tests/PayPal/Test/Functional/resources/BillingPlansFunctionalTest/testUpdateChangingMerchantPreferences.json b/tests/PayPal/Test/Functional/resources/BillingPlansFunctionalTest/testUpdateChangingMerchantPreferences.json index 7fd9759..1abbcfd 100755 --- a/tests/PayPal/Test/Functional/resources/BillingPlansFunctionalTest/testUpdateChangingMerchantPreferences.json +++ b/tests/PayPal/Test/Functional/resources/BillingPlansFunctionalTest/testUpdateChangingMerchantPreferences.json @@ -1,40 +1,39 @@ { - "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"] + "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" : { + "credentials": { "oauth": { - "path" : "/v1/oauth/token", - "clientId":"", - "clientSecret":"" + "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" : { } + "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": {} } } diff --git a/tests/PayPal/Test/Functional/resources/BillingPlansFunctionalTest/testUpdateChangingPD.json b/tests/PayPal/Test/Functional/resources/BillingPlansFunctionalTest/testUpdateChangingPD.json index 69205ec..e7c9f23 100755 --- a/tests/PayPal/Test/Functional/resources/BillingPlansFunctionalTest/testUpdateChangingPD.json +++ b/tests/PayPal/Test/Functional/resources/BillingPlansFunctionalTest/testUpdateChangingPD.json @@ -1,41 +1,40 @@ { - "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"] + "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" : { + "credentials": { "oauth": { - "path" : "/v1/oauth/token", - "clientId":"", - "clientSecret":"" + "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" - } - } - } - ] + "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" : { } + "response": { + "status": "200 OK", + "headers": {}, + "body": {} } } diff --git a/tests/PayPal/Test/Functional/resources/BillingPlansFunctionalTest/testUpdateChangingState.json b/tests/PayPal/Test/Functional/resources/BillingPlansFunctionalTest/testUpdateChangingState.json index d0f95f0..340639e 100755 --- a/tests/PayPal/Test/Functional/resources/BillingPlansFunctionalTest/testUpdateChangingState.json +++ b/tests/PayPal/Test/Functional/resources/BillingPlansFunctionalTest/testUpdateChangingState.json @@ -1,37 +1,36 @@ { - "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" ] + "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" : { + "credentials": { "oauth": { - "path" : "/v1/oauth/token", - "clientId":"", - "clientSecret":"" + "path": "/v1/oauth/token", + "clientId": "", + "clientSecret": "" } }, - "request" : { - "path" : "v1/payments/billing-plans/{PLAN-ID}/", - "method" : "PATCH", - "headers" : {}, - "body" : - [ - { - "op":"replace", - "path":"/", - "value":{ - "state":"ACTIVE" - } - } - ] + "request": { + "path": "v1/payments/billing-plans/{PLAN-ID}/", + "method": "PATCH", + "headers": {}, + "body": [ + { + "op": "replace", + "path": "/", + "value": { + "state": "ACTIVE" + } + } + ] }, - "response" : { - "status" : "200 OK", - "headers" : {}, - "body" : { } + "response": { + "status": "200 OK", + "headers": {}, + "body": {} } }