/** * @depends testCreate * @param $createProfileResponse CreateProfileResponse * @return WebProfile */ public function testGet($createProfileResponse) { $result = WebProfile::get($createProfileResponse->getId(), null, $this->mockPayPalRestCall); $this->assertNotNull($result); $this->assertEquals($createProfileResponse->getId(), $result->getId()); $this->assertEquals($this->operation['response']['body']['presentation']['logo_image'], $result->getPresentation()->getLogoImage()); $this->assertEquals($this->operation['response']['body']['input_fields']['no_shipping'], $result->getInputFields()->getNoShipping()); $this->assertEquals($this->operation['response']['body']['input_fields']['address_override'], $result->getInputFields()->getAddressOverride()); return $result; }
<?php // ### Get Web Profile // If your request is successful, the API returns a web_profile object response that contains the profile details. // Documentation available at https://developer.paypal.com/webapps/developer/docs/api/#retrieve-a-web-experience-profile // We are going to re-use the sample code from CreateWebProfile.php. // If you have not visited the sample yet, please visit it before trying GetWebProfile.php // The CreateWebProfile.php will create a web profile for us, and return a CreateProfileResponse, // that contains the web profile ID. /** @var \PayPal\Api\CreateProfileResponse $result */ $createProfileResponse = (require 'CreateWebProfile.php'); try { // If your request is successful, the API returns a web_profile object response that contains the profile details. $webProfile = \PayPal\Api\WebProfile::get($createProfileResponse->getId(), $apiContext); } catch (\PayPal\Exception\PayPalConnectionException $ex) { // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printError("Get Web Profile", "Web Profile", $webProfile->getId(), null, $ex); exit(1); } // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printResult("Get Web Profile", "Web Profile", $webProfile->getId(), null, $webProfile); return $webProfile;
/** * @dataProvider mockProvider * @param WebProfile $obj */ public function testGet($obj, $mockApiContext) { $mockPPRestCall = $this->getMockBuilder('\\PayPal\\Transport\\PayPalRestCall')->disableOriginalConstructor()->getMock(); $mockPPRestCall->expects($this->any())->method('execute')->will($this->returnValue(WebProfileTest::getJson())); $result = $obj->get("profileId", $mockApiContext, $mockPPRestCall); $this->assertNotNull($result); }
// #### Partially Update Web Profile // Use this call to partially update a web experience profile. // Documentation available at https://developer.paypal.com/webapps/developer/docs/api/#partially-update-a-web-experience-profile // We will be re-using the sample code to get a web profile. GetWebProfile.php will // create a new web profileId for sample, and return the web profile object. /** @var \PayPal\Api\WebProfile $webProfile */ $webProfile = (require 'GetWebProfile.php'); // ### Create Patch Operation // APIs allows us to pass an array of patches // to make patch operations. // Each Patch operation can be created by using Patch Class // as shown below $patchOperation1 = new \PayPal\Api\Patch(); // The operation to perform. Required. Allowed values: add, remove, replace, move, copy, test $patchOperation1->setOp("add")->setPath("/presentation/brand_name")->setValue("New Brand Name"); // Similar patch operation to remove the landing page type $patchOperation2 = new \PayPal\Api\Patch(); $patchOperation2->setOp("remove")->setPath("/flow_config/landing_page_type"); //Generate an array of patch operations $patches = array($patchOperation1, $patchOperation2); try { // Execute the partial update, to carry out these two operations on a given web profile object if ($webProfile->partial_update($patches, $apiContext)) { $webProfile = \PayPal\Api\WebProfile::get($webProfile->getId(), $apiContext); } } catch (\Exception $ex) { ResultPrinter::printError("Partially Updated Web Profile", "Web Profile", $webProfile->getId(), $patches, $ex); exit(1); } ResultPrinter::printResult("Partially Updated Web Profile", "Web Profile", $webProfile->getId(), $patches, $webProfile);
public function updateCustomRecord($parameters) { try { $webProfile = WebProfile::get($parameters['id'], $this->apiContext); $webProfile->getFlowConfig()->setLandingPageType($this->request->input('landingPageType')); $webProfile->getFlowConfig()->setBankTxnPendingUrl($this->request->input('bankTxnPendingUrl')); $webProfile->getPresentation()->setLogoImage($this->request->input('logoImage')); $webProfile->getPresentation()->setBrandName($this->request->input('brandName')); $webProfile->getPresentation()->setLocaleCode($this->request->input('localCode')); $webProfile->getInputFields()->setAllowNote($this->request->has('allowNote')); $webProfile->getInputFields()->setNoShipping((int) $this->request->input('shippingDataType')); $webProfile->getInputFields()->setAddressOverride((int) $this->request->input('displayShippingDataType')); $webProfile->setName($this->request->input('name')); if ($webProfile->update($this->apiContext)) { WebProfile::get($parameters['id'], $this->apiContext); } } catch (PayPalConnectionException $e) { dd($e); } }