diff --git a/README.md b/README.md index 344baa1..b6ae880 100644 --- a/README.md +++ b/README.md @@ -61,11 +61,10 @@ If you do not want to use composer, you can grab the SDK zip that contains Paypa ## Running the sample * Clone the repo and navigate to the samples folder. - * Samples have dependency on the sdk and you can use [`composer`](http://getcomposer.org) to get the dependencies. Ensure that you have composer installed on your machine, navigate to the samples folder and run `composer update --no-dev` to fetch the SDK. + * Samples have dependency on the sdk and you can use [`composer`](http://getcomposer.org) to get the dependencies. Ensure that you have composer installed on your machine, navigate to the root folder and run `composer update --no-dev` to fetch the SDK. * Optionally, update the bootstrap.php file with your own client Id and client secret, that you could find from the [developer portal](https://developer.paypal.com) * Run any of the samples in the 'samples' folder to see what the APIs can do. - ## Usage To write an app that uses the SDK diff --git a/lib/PayPal/Api/ItemList.php b/lib/PayPal/Api/ItemList.php index aa2e2eb..3504041 100644 --- a/lib/PayPal/Api/ItemList.php +++ b/lib/PayPal/Api/ItemList.php @@ -12,17 +12,25 @@ use PayPal\Rest\ApiContext; * * @package PayPal\Api * - * @property \PayPal\Api\Item items + * @property \PayPal\Api\Item[] items * @property \PayPal\Api\ShippingAddress shipping_address */ class ItemList extends PPModel { + /** + * Is this list empty? + */ + public function isEmpty() + { + return empty($this->items); + } + /** * List of items. - * * - * @param \PayPal\Api\Item $items - * + * + * @param \PayPal\Api\Item[] $items + * * @return $this */ public function setItems($items) @@ -43,10 +51,10 @@ class ItemList extends PPModel /** * Shipping address. - * + * * * @param \PayPal\Api\ShippingAddress $shipping_address - * + * * @return $this */ public function setShippingAddress($shipping_address) @@ -56,7 +64,34 @@ class ItemList extends PPModel } /** - * Shipping address. + * Append an item to the list. + * + * @return \PayPal\Api\Item + */ + public function addItem($item) + { + if (!$this->items) { + return $this->setItems(array($item)); + } else { + return $this->setItems( + array_merge($this->items, array($item)) + ); + } + } + + /** + * Remove an item from the list. + * Items are compared using === comparision (PHP.net) + * + * @return \PayPal\Api\Item + */ + public function removeItem($item) + { + return $this->setItems(array_diff($this->getItems(), array($item))); + } + + /** + * Get Shipping Address * * @return \PayPal\Api\ShippingAddress */ @@ -81,6 +116,7 @@ class ItemList extends PPModel /** * Shipping address. + * * @deprecated Instead use getShippingAddress * * @return \PayPal\Api\ShippingAddress diff --git a/lib/PayPal/Auth/Openid/PPOpenIdTokeninfo.php b/lib/PayPal/Auth/Openid/PPOpenIdTokeninfo.php index d180584..8940259 100644 --- a/lib/PayPal/Auth/Openid/PPOpenIdTokeninfo.php +++ b/lib/PayPal/Auth/Openid/PPOpenIdTokeninfo.php @@ -165,12 +165,12 @@ class PPOpenIdTokeninfo extends ResourceModel $params['grant_type'] = 'authorization_code'; } - if ($apiContext->get('client_id')) { - $clientId = $apiContext->get('client_id'); + if (sizeof($apiContext->get($clientId)) > 0) { + $clientId = $apiContext->get($clientId); } - if ($apiContext->get('client_secret')) { - $clientSecret = $apiContext->get('client_secret'); + if (sizeof($apiContext->get($clientSecret)) > 0) { + $clientSecret = $apiContext->get($clientSecret); } $json = self::executeCall( "/v1/identity/openidconnect/tokenservice", diff --git a/lib/PayPal/Common/PPModel.php b/lib/PayPal/Common/PPModel.php index bb33d68..37f6afe 100644 --- a/lib/PayPal/Common/PPModel.php +++ b/lib/PayPal/Common/PPModel.php @@ -220,4 +220,14 @@ class PPModel { return json_encode($this->toArray(), $options); } + + /** + * Magic Method for toString + * + * @return string + */ + public function __toString() + { + return json_encode($this->toArray()); + } } diff --git a/sample/bootstrap.php b/sample/bootstrap.php index c49e6c3..87728bb 100644 --- a/sample/bootstrap.php +++ b/sample/bootstrap.php @@ -24,8 +24,12 @@ use PayPal\Auth\OAuthTokenCredential; error_reporting(E_ALL); +// Replace these values by entering your own ClientId and Secret by visiting https://developer.paypal.com/webapps/developer/applications/myapps +$clientId = 'AYSq3RDGsmBLJE-otTkBtM-jBRd1TCQwFf9RGfwddNXWz0uFU9ztymylOhRS'; +$clientSecret = 'EGnHDxD_qRPdaLdZz8iCr8N7_MzF-YHPTkjs6NKYQvQSBngp4PTTVWkPZRbL'; + /** @var \Paypal\Rest\ApiContext $apiContext */ -$apiContext = getApiContext(); +$apiContext = getApiContext($clientId, $clientSecret); return $apiContext; /** @@ -33,7 +37,7 @@ return $apiContext; * * @return PayPal\Rest\ApiContext */ -function getApiContext() +function getApiContext($clientId, $clientSecret) { // ### Api context @@ -44,8 +48,8 @@ function getApiContext() $apiContext = new ApiContext( new OAuthTokenCredential( - 'EBWKjlELKMYqRNQ6sYvFo64FtaRLRR5BdHEESmha49TM', - 'EO422dn3gQLgDbuwqTjzrFgFtaRLRR5BdHEESmha49TM' + $clientId, + $clientSecret ) ); diff --git a/sample/payments/CreateOpenID.php b/sample/oauth/ObtainUserConsent.php similarity index 57% rename from sample/payments/CreateOpenID.php rename to sample/oauth/ObtainUserConsent.php index 30e9258..84dc918 100644 --- a/sample/payments/CreateOpenID.php +++ b/sample/oauth/ObtainUserConsent.php @@ -2,13 +2,10 @@ require __DIR__ . '/../bootstrap.php'; - -$clientId = 'AYSq3RDGsmBLJE-otTkBtM-jBRd1TCQwFf9RGfwddNXWz0uFU9ztymylOhRS'; -$clientSecret = 'EGnHDxD_qRPdaLdZz8iCr8N7_MzF-YHPTkjs6NKYQvQSBngp4PTTVWkPZRbL'; - -$baseUrl = getBaseUrl() . '/ExecuteAuth.php?success=true'; +$baseUrl = getBaseUrl() . '/UserConsentRedirect.php?success=true'; //Get User Consent +// The clientId is stored in the bootstrap file $redirectUrl = \PayPal\Auth\Openid\PPOpenIdSession::getAuthorizationUrl( $baseUrl, array('profile', 'email', 'phone'), diff --git a/sample/oauth/ObtainUserConsentFromRefreshToken.php b/sample/oauth/ObtainUserConsentFromRefreshToken.php new file mode 100644 index 0000000..84d133e --- /dev/null +++ b/sample/oauth/ObtainUserConsentFromRefreshToken.php @@ -0,0 +1,23 @@ + $refreshToken, + 'redirect_uri' => getBaseUrl() . '/UserConsentRedirect.php?success=true', + 'client_id' => $clientId, + 'client_secret' => $clientSecret +); +try { + $tokenInfo = new \PayPal\Auth\Openid\PPOpenIdTokeninfo(); + $tokenInfo = $tokenInfo->createFromRefreshToken($params, $apiContext); +} catch (PayPal\Exception\PPConnectionException $ex) { + echo "Exception: " . $ex->getMessage() . PHP_EOL; + var_dump($ex->getData()); + exit(1); +} + +print_result("Obtained Access Token From Refresh Token", "Access Token", $tokenInfo->getAccessToken(), $tokenInfo); diff --git a/sample/payments/ExecuteAuth.php b/sample/oauth/UserConsentRedirect.php similarity index 78% rename from sample/payments/ExecuteAuth.php rename to sample/oauth/UserConsentRedirect.php index eb38cb9..2559891 100644 --- a/sample/payments/ExecuteAuth.php +++ b/sample/oauth/UserConsentRedirect.php @@ -9,21 +9,17 @@ require __DIR__ . '/../bootstrap.php'; -$clientId = 'AYSq3RDGsmBLJE-otTkBtM-jBRd1TCQwFf9RGfwddNXWz0uFU9ztymylOhRS'; -$clientSecret = 'EGnHDxD_qRPdaLdZz8iCr8N7_MzF-YHPTkjs6NKYQvQSBngp4PTTVWkPZRbL'; - use PayPal\Api\ExecutePayment; use PayPal\Api\Payment; use PayPal\Api\PaymentExecution; session_start(); if(isset($_GET['success']) && $_GET['success'] == 'true') { - $code = $_GET['code']; $params = array( 'code' => $code, - 'redirect_uri' => getBaseUrl() . '/ExecuteAuth.php?success=true', + 'redirect_uri' => getBaseUrl() . '/UserConsentRedirect.php?success=true', 'client_id' => $clientId, 'client_secret' => $clientSecret ); @@ -34,6 +30,7 @@ if(isset($_GET['success']) && $_GET['success'] == 'true') { var_dump($ex->getData()); exit(1); } - echo $accessToken->toJSON(JSON_PRETTY_PRINT); + + print_result("Obtained Access Token", "Access Token", $accessToken->getAccessToken(), $accessToken); } diff --git a/sample/sdk_config.ini b/sample/sdk_config.ini index 63176d6..fb9874b 100644 --- a/sample/sdk_config.ini +++ b/sample/sdk_config.ini @@ -1,43 +1,43 @@ - - -## This is an example configuration file for the SDK. -## The sample scripts configure the SDK dynamically -## but you can choose to go for file based configuration -## in simpler apps (See bootstrap.php for more). - - -;Connection Information -[Http] -http.ConnectionTimeOut = 30 -http.Retry = 1 -;http.Proxy=http://[username:password]@hostname[:port] - -;Service Configuration -[Service] -mode=sandbox ; can be set to sandbox / live - -;Logging Information -[Log] - -log.LogEnabled=true - -; When using a relative path, the log file is created -; relative to the .php file that is the entry point -; for this request. You can also provide an absolute -; path here -log.FileName=../PayPal.log - -; Logging level can be one of FINE, INFO, WARN or ERROR -; Logging is most verbose in the 'FINE' level and -; decreases as you proceed towards ERROR -log.LogLevel=FINE - -;Validation Configuration -[validation] -; If validation is set to strict, the PPModel would make sure that -; there are proper accessors (Getters and Setters) for each model -; objects. Accepted value is -; 'log' : logs the error message to logger only (default) -; 'strict' : throws a php notice message -; 'disable' : disable the validation -validation.level=strict \ No newline at end of file + + +## This is an example configuration file for the SDK. +## The sample scripts configure the SDK dynamically +## but you can choose to go for file based configuration +## in simpler apps (See bootstrap.php for more). + + +;Connection Information +[Http] +http.ConnectionTimeOut = 30 +http.Retry = 1 +;http.Proxy=http://[username:password]@hostname[:port] + +;Service Configuration +[Service] +mode=sandbox ; can be set to sandbox / live + +;Logging Information +[Log] + +log.LogEnabled=true + +; When using a relative path, the log file is created +; relative to the .php file that is the entry point +; for this request. You can also provide an absolute +; path here +log.FileName=../PayPal.log + +; Logging level can be one of FINE, INFO, WARN or ERROR +; Logging is most verbose in the 'FINE' level and +; decreases as you proceed towards ERROR +log.LogLevel=FINE + +;Validation Configuration +[validation] +; If validation is set to strict, the PPModel would make sure that +; there are proper accessors (Getters and Setters) for each model +; objects. Accepted value is +; 'log' : logs the error message to logger only (default) +; 'strict' : throws a php notice message +; 'disable' : disable the validation +validation.level=strict diff --git a/tests/PayPal/Test/Api/ItemListTest.php b/tests/PayPal/Test/Api/ItemListTest.php index 8e05e25..6367f4b 100644 --- a/tests/PayPal/Test/Api/ItemListTest.php +++ b/tests/PayPal/Test/Api/ItemListTest.php @@ -7,8 +7,8 @@ use PayPal\Test\Constants; class ItemListTest extends \PHPUnit_Framework_TestCase { - - private $items = array(); + /** @var ItemList */ + private $items; private static $name = "item name"; private static $price = "1.12"; @@ -19,6 +19,7 @@ class ItemListTest extends \PHPUnit_Framework_TestCase public static function createItemList() { + /** @var Item $item */ $item = ItemTest::createItem(); $itemList = new ItemList(); @@ -48,4 +49,35 @@ class ItemListTest extends \PHPUnit_Framework_TestCase $this->assertEquals($itemList, $this->items); } -} \ No newline at end of file + public function testAddItemMethod() + { + $item2 = ItemTest::createItem(); + $item2->setName("Item2"); + $this->items->addItem($item2); + + $found = false; + foreach ($this->items->getItems() as $item) { + if ($item->getName() == $item2->getName()) { + $found = true; + } + } + $this->assertTrue($found); + } + + public function testRemoveItemMethod() + { + $itemList = new ItemList(); + $item1 = ItemTest::createItem(); + $item1->setName("Name1"); + $item2 = ItemTest::createItem(); + + $itemList->addItem($item1); + $itemList->addItem($item2); + + $itemList->removeItem($item2); + + $this->assertEquals(sizeof($itemList->getItems()), 1); + $remainingElements = $itemList->getItems(); + $this->assertEquals($remainingElements[0]->getName(), "Name1"); + } +} diff --git a/tests/PayPal/Test/Api/ItemTest.php b/tests/PayPal/Test/Api/ItemTest.php index b8bafbb..92170fc 100644 --- a/tests/PayPal/Test/Api/ItemTest.php +++ b/tests/PayPal/Test/Api/ItemTest.php @@ -49,4 +49,4 @@ class ItemTest extends \PHPUnit_Framework_TestCase $this->assertEquals($item, $this->item); } -} \ No newline at end of file +} diff --git a/tests/PayPal/Test/Functional/Api/WebProfileTest.php b/tests/PayPal/Test/Functional/Api/WebProfileTest.php new file mode 100644 index 0000000..3663edc --- /dev/null +++ b/tests/PayPal/Test/Functional/Api/WebProfileTest.php @@ -0,0 +1,165 @@ +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 WebProfile($request); + $obj->setName(uniqid()); + $result = $obj->create(null, $this->mockPPRestCall); + $this->assertNotNull($result); + return $result; + } + + /** + * @depends testCreate + * @param $createProfileResponse CreateProfileResponse + * @return WebProfile + */ + public function testGet($createProfileResponse) + { + $result = WebProfile::get($createProfileResponse->getId(), null, $this->mockPPRestCall); + $this->assertNotNull($result); + $this->assertEquals($createProfileResponse->getId(), $result->getId()); + $this->assertEquals($this->operation['response']['body']['presentation']['logo_image'], $result->getPresentation()->getLogoImage()); + $this->assertEquals($this->operation['response']['body']['input_fields']['no_shipping'], $result->getInputFields()->getNoShipping()); + $this->assertEquals($this->operation['response']['body']['input_fields']['address_override'], $result->getInputFields()->getAddressOverride()); + + return $result; + } + + + /** + * @depends testGet + * @param $webProfile WebProfile + */ + public function testGetList($webProfile) + { + $result = WebProfile::get_list(null, $this->mockPPRestCall); + $this->assertNotNull($result); + $found = false; + $foundObject = null; + foreach ($result as $webProfileObject) { + if ($webProfileObject->getId() == $webProfile->getId()) { + $found = true; + $foundObject = $webProfileObject; + break; + } + } + $this->assertTrue($found, "The Created Web Profile was not found in the get list"); + $this->assertEquals($webProfile->getId(), $foundObject->getId()); + $this->assertEquals($this->operation['response']['body'][0]['presentation']['logo_image'], $foundObject->getPresentation()->getLogoImage()); + $this->assertEquals($this->operation['response']['body'][0]['input_fields']['no_shipping'], $foundObject->getInputFields()->getNoShipping()); + $this->assertEquals($this->operation['response']['body'][0]['input_fields']['address_override'], $foundObject->getInputFields()->getAddressOverride()); + + } + + /** + * @depends testGet + * @param $webProfile WebProfile + */ + public function testUpdate($webProfile) + { + $boolValue = $webProfile->getInputFields()->getNoShipping(); + $newValue = ($boolValue + 1) % 2; + $webProfile->getInputFields()->setNoShipping($newValue); + $result = $webProfile->update(null, $this->mockPPRestCall); + $this->assertNotNull($result); + $this->assertEquals($webProfile->getInputFields()->getNoShipping(), $newValue); + } + + /** + * @depends testGet + * @param $webProfile WebProfile + */ + public function testPartialUpdate($webProfile) + { + $patches = array(); + $patches[] = new Patch('{ + "op": "add", + "path": "/presentation/brand_name", + "value":"new_brand_name" + }'); + $patches[] = new Patch('{ + "op": "remove", + "path": "/flow_config/landing_page_type" + + }'); + $result = $webProfile->partial_update($patches, null, $this->mockPPRestCall); + $this->assertTrue($result); + } + + /** + * @depends testGet + * @param $createProfileResponse CreateProfileResponse + */ + public function testDelete($createProfileResponse) + { + $webProfile = new WebProfile(); + $webProfile->setId($createProfileResponse->getId()); + $result = $webProfile->delete(null, $this->mockPPRestCall); + $this->assertTrue($result); + } + +} diff --git a/tests/PayPal/Test/Functional/resources/WebProfileFunctionalTest/testCreate.json b/tests/PayPal/Test/Functional/resources/WebProfileFunctionalTest/testCreate.json new file mode 100644 index 0000000..53c8798 --- /dev/null +++ b/tests/PayPal/Test/Functional/resources/WebProfileFunctionalTest/testCreate.json @@ -0,0 +1,50 @@ +{ + "description": "Create a web experience profile.", + "title": "Create profile", + "runnable": true, + "operationId": "web-profile.create", + "user": { + "scopes": [ + "https://api.paypal.com/v1/payments/.*" + ] + }, + "credentials": { + "oauth": { + "clientId": "test-client-01", + "clientSecret": "test_secret_a", + "path": "/v1/oauth2/token" + } + }, + "request": { + "path": "v1/payment-experience/web-profiles/", + "method": "POST", + "headers": { + "Content-Type": "application/json", + "PayPal-Request-Id": "abcdefgh123", + "Authorization": "Bearer ECvJ_yBNz_UfMmCvWEbT_2ZWXdzbFFQZ-1Y5K2NGgeHn" + }, + "body": { + "name":"someName2", + "presentation":{ + "logo_image":"http://www.ebay.com" + }, + "input_fields":{ + "no_shipping":1, + "address_override":1 + }, + "flow_config":{ + "landing_page_type":"billing", + "bank_txn_pending_url":"http://www.ebay.com" + } + } + }, + "response": { + "status": "201", + "headers": { + "Content-Type": "application/json" + }, + "body": { + "id": "XP-RFV4-PVD8-AGHJ-8E5J" + } + } +} diff --git a/tests/PayPal/Test/Functional/resources/WebProfileFunctionalTest/testDelete.json b/tests/PayPal/Test/Functional/resources/WebProfileFunctionalTest/testDelete.json new file mode 100644 index 0000000..6f873e4 --- /dev/null +++ b/tests/PayPal/Test/Functional/resources/WebProfileFunctionalTest/testDelete.json @@ -0,0 +1,30 @@ +{ + "description": "Delete a web experience profile list.", + "title": "Delete profile", + "runnable": true, + "operationId": "web-profile.delete", + "user": { + "scopes": [ + "https://api.paypal.com/v1/payments/.*" + ] + }, + "credentials": { + "oauth": { + "clientId": "test-client-01", + "clientSecret": "test_secret_a", + "path": "/v1/oauth2/token" + } + }, + "request": { + "path": "v1/payment-experience/web-profiles/XP-RFV4-PVD8-AGHJ-8E5J", + "method": "DELETE", + "headers": { + "Authorization": "Bearer ECvJ_yBNz_UfMmCvWEbT_2ZWXdzbFFQZ-1Y5K2NGgeHn" + } + }, + "response": { + "status": "204", + "headers": { + } + } +} diff --git a/tests/PayPal/Test/Functional/resources/WebProfileFunctionalTest/testGet.json b/tests/PayPal/Test/Functional/resources/WebProfileFunctionalTest/testGet.json new file mode 100644 index 0000000..d3bc266 --- /dev/null +++ b/tests/PayPal/Test/Functional/resources/WebProfileFunctionalTest/testGet.json @@ -0,0 +1,46 @@ +{ + "description": "Fetch a web experience profile.", + "title": "Get profile", + "runnable": true, + "operationId": "web-profile.get", + "user": { + "scopes": [ + "https://api.paypal.com/v1/payments/.*" + ] + }, + "credentials": { + "oauth": { + "clientId": "test-client-01", + "clientSecret": "test_secret_a", + "path": "/v1/oauth2/token" + } + }, + "request": { + "path": "/v1/payment-experience/web-profiles/XP-RFV4-PVD8-AGHJ-8E5J", + "method": "GET", + "headers": { + "Authorization": "Bearer ECvJ_yBNz_UfMmCvWEbT_2ZWXdzbFFQZ-1Y5K2NGgeHn" + } + }, + "response": { + "status": "200", + "headers": { + "Content-Type": "application/json" + }, + "body": { + "id": "XP-RFV4-PVD8-AGHJ-8E5J", + "name":"someName2", + "presentation":{ + "logo_image":"http://www.ebay.com" + }, + "input_fields":{ + "no_shipping":1, + "address_override":1 + }, + "flow_config":{ + "landing_page_type":"billing", + "bank_txn_pending_url":"http://www.ebay.com" + } + } + } +} diff --git a/tests/PayPal/Test/Functional/resources/WebProfileFunctionalTest/testGetList.json b/tests/PayPal/Test/Functional/resources/WebProfileFunctionalTest/testGetList.json new file mode 100644 index 0000000..14174c0 --- /dev/null +++ b/tests/PayPal/Test/Functional/resources/WebProfileFunctionalTest/testGetList.json @@ -0,0 +1,77 @@ +{ + "description": "Fetch web experience profile list for a given merchant.", + "title": "Get profile list", + "runnable": true, + "operationId": "web-profile.get-list", + "user": { + "scopes": [ + "https://api.paypal.com/v1/payments/.*" + ] + }, + "credentials": { + "oauth": { + "clientId": "test-client-01", + "clientSecret": "test_secret_a", + "path": "/v1/oauth2/token" + } + }, + "request": { + "path": "/v1/payment-experience/web-profiles", + "method": "GET", + "headers": { + "Authorization": "Bearer ECvJ_yBNz_UfMmCvWEbT_2ZWXdzbFFQZ-1Y5K2NGgeHn" + } + }, + "response": { + "status": "200", + "headers": { + "Content-Type": "application/json" + }, + "body": [ + { + "id": "XP-RFV4-PVD8-AGHJ-8E5J", + "name":"someName2", + "presentation":{ + "logo_image":"http://www.ebay.com" + }, + "input_fields":{ + "no_shipping":1, + "address_override":1 + }, + "flow_config":{ + "landing_page_type":"billing", + "bank_txn_pending_url":"http://www.ebay.com" + } + }, + { + "id": "XP-A88A-LYLW-8Y3X-E5ER", + "name": "someName2", + "flow_config": { + "landing_page_type": "billing", + "bank_txn_pending_url": "http://www.ebay.com" + }, + "input_fields": { + "no_shipping": 1, + "address_override": 1 + }, + "presentation": { + "logo_image": "http://www.ebay.com" + } + }, + { + "id": "XP-RFV4-PVD8-AGHJ-8E5J", + "name": "someName2", + "flow_config": { + "bank_txn_pending_url": "http://www.ebay.com" + }, + "input_fields": { + "no_shipping": 1, + "address_override": 1 + }, + "presentation": { + "logo_image": "http://www.ebay.com" + } + } + ] + } +} diff --git a/tests/PayPal/Test/Functional/resources/WebProfileFunctionalTest/testPartialUpdate.json b/tests/PayPal/Test/Functional/resources/WebProfileFunctionalTest/testPartialUpdate.json new file mode 100644 index 0000000..5850c5e --- /dev/null +++ b/tests/PayPal/Test/Functional/resources/WebProfileFunctionalTest/testPartialUpdate.json @@ -0,0 +1,45 @@ +{ + "description": "Partially update a web experience profile.", + "title": "Partially Update profile", + "runnable": true, + "operationId": "web-profile.partial-update", + "user": { + "scopes": [ + "https://api.paypal.com/v1/payments/.*" + ] + }, + "credentials": { + "oauth": { + "clientId": "test-client-01", + "clientSecret": "test_secret_a", + "path": "/v1/oauth2/token" + } + }, + "request": { + "path": "v1/payment-experience/web-profiles/XP-RFV4-PVD8-AGHJ-8E5J", + "method": "PATCH", + "headers": { + "Content-Type": "application/json", + "PayPal-Request-Id": "abcdefgh123", + "Authorization": "Bearer ECvJ_yBNz_UfMmCvWEbT_2ZWXdzbFFQZ-1Y5K2NGgeHn" + }, + "body": [ + { + "op": "add", + "path": "/presentation/brand_name", + "value":"new_brand_name" + }, + { + "op": "remove", + "path": "/flow_config/landing_page_type" + + } + ] + }, + "response": { + "status": "204", + "headers": { + "Content-Type": "application/json" + } + } +} diff --git a/tests/PayPal/Test/Functional/resources/WebProfileFunctionalTest/testUpdate.json b/tests/PayPal/Test/Functional/resources/WebProfileFunctionalTest/testUpdate.json new file mode 100644 index 0000000..022742d --- /dev/null +++ b/tests/PayPal/Test/Functional/resources/WebProfileFunctionalTest/testUpdate.json @@ -0,0 +1,46 @@ +{ + "description": "Update a web experience profile.", + "title": "Update profile", + "runnable": true, + "operationId": "web-profile.update", + "user": { + "scopes": [ + "https://api.paypal.com/v1/payments/.*" + ] + }, + "credentials": { + "oauth": { + "clientId": "test-client-01", + "clientSecret": "test_secret_a", + "path": "/v1/oauth2/token" + } + }, + "request": { + "path": "v1/payment-experience/web-profiles/XP-RFV4-PVD8-AGHJ-8E5J", + "method": "PUT", + "headers": { + "Content-Type": "application/json", + "Authorization": "Bearer ECvJ_yBNz_UfMmCvWEbT_2ZWXdzbFFQZ-1Y5K2NGgeHn" + }, + "body": { + "name":"someName2", + "presentation":{ + "logo_image":"http://www.ebay.com" + }, + "input_fields":{ + "no_shipping":0, + "address_override":1 + }, + "flow_config":{ + "landing_page_type":"billing", + "bank_txn_pending_url":"http://www.ebay.com" + } + } + }, + "response": { + "status": "204", + "headers": { + "Content-Type": "application/json" + } + } +}