Enabled Billing Plans and Agreements APIs

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

View File

@@ -0,0 +1,246 @@
<?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\Common\PPModel;
use PayPal\Rest\ApiContext;
use PayPal\Rest\IResource;
use PayPal\Api\CreateProfileResponse;
use PayPal\Transport\PPRestCall;
use PayPal\Api\WebProfile;
/**
* Class Billing Agreements
*
* @package PayPal\Test\Api
*/
class BillingAgreementsFunctionalTest extends \PHPUnit_Framework_TestCase
{
public $operation;
public $response;
public $mode = 'mock';
public $mockPPRestCall;
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']);
}
$this->mode = getenv('REST_MODE') ? getenv('REST_MODE') : 'mock';
if ($this->mode != 'sandbox') {
// Mock PPRest Caller if mode set to mock
$this->mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PPRestCall')
->disableOriginalConstructor()
->getMock();
$this->mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
$this->response
));
}
}
/**
* 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(null, $this->mockPPRestCall);
$this->assertNotNull($result);
return $result;
}
/**
* @depends testCreatePayPalAgreement
* @param $agreement Agreement
* @return Agreement
*/
public function testExecute($agreement)
{
if ($this->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, null, $this->mockPPRestCall);
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(null, $this->mockPPRestCall);
$this->assertNotNull($result);
return $result;
}
/**
* @depends testCreateCCAgreement
* @param $agreement Agreement
* @return Plan
*/
public function testGet($agreement)
{
$result = Agreement::get($agreement->getId(), null, $this->mockPPRestCall);
$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, null, $this->mockPPRestCall);
$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, null, $this->mockPPRestCall);
$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, null, $this->mockPPRestCall);
$this->assertTrue($result);
return $agreement;
}
/**
* @depends testGet
* @param $agreement Agreement
* @return Agreement
*/
public function testGetTransactions($agreement)
{
$this->markTestSkipped('Skipped as the fix is on the way.');
$result = Agreement::transactions($agreement->getId(), null, $this->mockPPRestCall);
$this->assertNotNull($result);
}
/**
* @depends testGet
* @param $agreement Agreement
* @return Agreement
*/
public function testSuspend($agreement)
{
$agreementStateDescriptor = new AgreementStateDescriptor($this->operation['request']['body']);
$result = $agreement->suspend($agreementStateDescriptor, null, $this->mockPPRestCall);
$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, null, $this->mockPPRestCall);
$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, null, $this->mockPPRestCall);
$this->assertTrue($result);
$this->setupTest($this->getClassName(), 'testGetCancelled');
$get = $this->testGet($agreement);
$this->assertEquals('Cancelled', $get->getState());
return $get;
}
}

View File

@@ -0,0 +1,217 @@
<?php
namespace PayPal\Test\Functional\Api;
use PayPal\Api\Patch;
use PayPal\Api\PatchRequest;
use PayPal\Api\Plan;
use PayPal\Common\PPModel;
use PayPal\Rest\ApiContext;
use PayPal\Rest\IResource;
use PayPal\Api\CreateProfileResponse;
use PayPal\Transport\PPRestCall;
use PayPal\Api\WebProfile;
/**
* Class Billing Plans
*
* @package PayPal\Test\Api
*/
class BillingPlansFunctionalTest extends \PHPUnit_Framework_TestCase
{
public static $obj;
public $operation;
public $response;
public $mode = 'mock';
public $mockPPRestCall;
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']);
}
$this->mode = getenv('REST_MODE') ? getenv('REST_MODE') : 'mock';
if ($this->mode != 'sandbox') {
// Mock PPRest Caller if mode set to mock
$this->mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PPRestCall')
->disableOriginalConstructor()
->getMock();
$this->mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
$this->response
));
}
}
/**
* 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(null, $this->mockPPRestCall);
$this->assertNotNull($result);
self::$obj = $result;
return $result;
}
public function testCreateWithNOChargeModel()
{
$request = $this->operation['request']['body'];
$obj = new Plan($request);
$result = $obj->create(null, $this->mockPPRestCall);
$this->assertNotNull($result);
return $result;
}
/**
* @depends testCreate
* @param $plan Plan
* @return Plan
*/
public function testGet($plan)
{
$result = Plan::get($plan->getId(), null, $this->mockPPRestCall);
$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'), null, $this->mockPPRestCall);
$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'), null, $this->mockPPRestCall);
}
} 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, null, $this->mockPPRestCall);
$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, null, $this->mockPPRestCall);
$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, null, $this->mockPPRestCall);
$this->assertTrue($result);
return Plan::get($plan->getId(), null, $this->mockPPRestCall);
}
}

View File

@@ -0,0 +1,146 @@
<?php
namespace PayPal\Test\Functional\Api;
use PayPal\Api\Amount;
use PayPal\Api\Patch;
use PayPal\Api\PatchRequest;
use PayPal\Api\Payment;
use PayPal\Api\PaymentExecution;
use PayPal\Api\Refund;
use PayPal\Api\Sale;
use PayPal\Common\PPModel;
use PayPal\Rest\ApiContext;
use PayPal\Rest\IResource;
use PayPal\Api\CreateProfileResponse;
use PayPal\Transport\PPRestCall;
use PayPal\Api\WebProfile;
/**
* Class WebProfile
*
* @package PayPal\Test\Api
*/
class PaymentsFunctionalTest extends \PHPUnit_Framework_TestCase
{
public $operation;
public $response;
public $mode = 'mock';
public $mockPPRestCall;
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']);
}
$this->mode = getenv('REST_MODE') ? getenv('REST_MODE') : 'mock';
if ($this->mode != 'sandbox') {
// Mock PPRest Caller if mode set to mock
$this->mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PPRestCall')
->disableOriginalConstructor()
->getMock();
$this->mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
$this->response
));
}
}
/**
* 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(null, $this->mockPPRestCall);
$this->assertNotNull($result);
return $result;
}
public function testCreateWallet()
{
$request = $this->operation['request']['body'];
$obj = new Payment($request);
$result = $obj->create(null, $this->mockPPRestCall);
$this->assertNotNull($result);
return $result;
}
/**
* @depends testCreate
* @param $payment Payment
* @return Payment
*/
public function testGet($payment)
{
$result = Payment::get($payment->getId(), null, $this->mockPPRestCall);
$this->assertNotNull($result);
$this->assertEquals($payment->getId(), $result->getId());
$this->assertEquals($payment, $result, "", 0, 10, true);
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(), null, $this->mockPPRestCall);
$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, null, $this->mockPPRestCall);
$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 ($this->mode == 'sandbox') {
$this->markTestSkipped('Not executable on sandbox environment. Needs human interaction');
}
}
}

View File

@@ -1,6 +1,6 @@
<?php
namespace PayPal\Test\Api;
namespace PayPal\Test\Functional\Api;
use PayPal\Api\Patch;
use PayPal\Common\PPModel;

View File

@@ -0,0 +1,34 @@
{
"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" : {}
}
}

View File

@@ -0,0 +1,30 @@
{
"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" : {}
}
}

View File

@@ -0,0 +1,69 @@
{
"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": "2015-06-17T9:45:04Z",
"plan": {
"id": "P-1WJ68935LL406420PUTENA2I"
},
"shipping_address": {
"line1": "111 First Street",
"city": "Saratoga",
"state": "CA",
"postal_code": "95070",
"country_code": "US"
},
"payer": {
"payment_method": "credit_card",
"payer_info": {
"email": "jaypatel512-facilitator@hotmail.com"
},
"funding_instruments": [
{
"credit_card": {
"type": "visa",
"number": "4417119669820331",
"expire_month": "12",
"expire_year": "2017",
"cvv2": "128"
}
}
]
}
}
},
"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"
}
]
}
}
}

View File

@@ -0,0 +1,141 @@
{
"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": "2015-06-17T9:45:04Z",
"plan": {
"id": "P-1WJ68935LL406420PUTENA2I"
},
"payer": {
"payment_method": "paypal"
},
"shipping_address": {
"line1": "111 First Street",
"city": "Saratoga",
"state": "CA",
"postal_code": "95070",
"country_code": "US"
}
}
},
"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"
}
}
}

View File

@@ -0,0 +1,170 @@
{
"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"
}
}
}

View File

@@ -0,0 +1,37 @@
{
"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"
}
]
}
}
}

View File

@@ -0,0 +1,140 @@
{
"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"
}
}
}
}

View File

@@ -0,0 +1,140 @@
{
"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"
}
}
}
}

View File

@@ -0,0 +1,140 @@
{
"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"
}
}
}
}

View File

@@ -0,0 +1,67 @@
{
"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"
}
]
}
}
}

View File

@@ -0,0 +1,30 @@
{
"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" : {}
}
}

View File

@@ -0,0 +1,31 @@
{
"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" : {}
}
}

View File

@@ -0,0 +1,30 @@
{
"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" : {}
}
}

View File

@@ -0,0 +1,46 @@
{
"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": {}
}
}

View File

@@ -0,0 +1,186 @@
{
"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"
}
]
}
}
}

View File

@@ -0,0 +1,93 @@
{
"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"
}
]
}
}
}

View File

@@ -0,0 +1,116 @@
{
"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"
}
]
}
}
}

View File

@@ -0,0 +1,87 @@
{
"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"
}
]
}
}
}

View File

@@ -0,0 +1,40 @@
{
"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" : { }
}
}

View File

@@ -0,0 +1,41 @@
{
"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" : { }
}
}

View File

@@ -0,0 +1,39 @@
{
"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" : { }
}
}

View File

@@ -0,0 +1,148 @@
{
"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": "4417119669820331",
"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"
}
}

View File

@@ -0,0 +1,177 @@
{
"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"
}
}

View File

@@ -0,0 +1,98 @@
{
"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"
}
}

View File

@@ -0,0 +1,109 @@
{
"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"
}
}

View File

@@ -0,0 +1,100 @@
{
"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"
}
}

View File

@@ -0,0 +1,60 @@
{
"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"
}
}

View File

@@ -0,0 +1,62 @@
{
"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"
}
}