function list_profile() { // auth $apiContext = $this->apiContext(); // set WebProfile $webProfile = new WebProfile(); try { $webProfileList = $webProfile->get_list($apiContext); $valid = true; } catch (Exception $ex) { $this->LoggingManager->log(print_r($ex, true), 'DEBUG'); $valid = false; } // set array $list_array = array(); if ($valid === true) { for ($i = 0, $n = count($webProfileList); $i < $n; $i++) { $profile = $webProfileList[$i]; $flowConfig = $profile->getFlowConfig(); $inputFields = $profile->getInputFields(); $presentation = $profile->getPresentation(); $list_array[] = array('id' => $profile->getId(), 'name' => $profile->getName(), 'status' => $this->get_config('PAYPAL_STANDARD_PROFILE') == $profile->getId() ? true : false, 'flow_config' => array('landing_page_type' => is_object($flowConfig) ? $flowConfig->getLandingPageType() : ''), 'input_fields' => array('allow_note' => is_object($inputFields) ? $inputFields->getAllowNote() : '', 'no_shipping' => is_object($inputFields) ? $inputFields->getNoShipping() : '', 'address_override' => is_object($inputFields) ? $inputFields->getAddressOverride() : ''), 'presentation' => array('brand_name' => is_object($presentation) ? $presentation->getBrandName() : '', 'logo_image' => is_object($presentation) ? $presentation->getLogoImage() : '', 'locale_code' => is_object($presentation) ? $presentation->getLocaleCode() : '')); } } return $list_array; }
public function customIndex($parameters) { $this->viewParameters['deleteSelectButton'] = false; try { $parameters['webProfiles'] = \PayPal\Api\WebProfile::get_list($this->apiContext); } catch (\PayPal\Exception\PayPalConnectionException $e) { dd($e); } return $parameters; }
/** * @param Config $config * @return bool|\PayPal\Api\WebProfile[] False if something goes wrong. Otherwise, the profiles (NOTE: could be * empty if there are not profiles). */ public static function ListExperienceProfiles(Config $config) { try { $apiContext = self::getApiContext($config); $profiles = \PayPal\Api\WebProfile::get_list($apiContext); } catch (\Exception $ex) { return false; } return $profiles; }
/** * @depends testGet * @param $webProfile WebProfile */ public function testGetList($webProfile) { $result = WebProfile::get_list(null, $this->mockPayPalRestCall); $this->assertNotNull($result); $found = false; $foundObject = null; foreach ($result as $webProfileObject) { if ($webProfileObject->getId() == $webProfile->getId()) { $found = true; $foundObject = $webProfileObject; break; } } $this->assertTrue($found, "The Created Web Profile was not found in the get list"); $this->assertEquals($webProfile->getId(), $foundObject->getId()); $this->assertEquals($this->operation['response']['body'][0]['presentation']['logo_image'], $foundObject->getPresentation()->getLogoImage()); $this->assertEquals($this->operation['response']['body'][0]['input_fields']['no_shipping'], $foundObject->getInputFields()->getNoShipping()); $this->assertEquals($this->operation['response']['body'][0]['input_fields']['address_override'], $foundObject->getInputFields()->getAddressOverride()); }
<?php $apiContext = (require __DIR__ . '/../bootstrap.php'); // ### Retrieve List of All Web Profiles // Documentation available at https://developer.paypal.com/webapps/developer/docs/api/#list-web-experience-profiles // Retrieve the list of all web profiles by calling the // static `get_list` method on the WebProfile class. // (See bootstrap.php for more on `ApiContext`) try { $list = \PayPal\Api\WebProfile::get_list($apiContext); } catch (\PayPal\Exception\PayPalConnectionException $ex) { ResultPrinter::printError("Get List of All Web Profiles", "Web Profiles", null, null, $ex); exit(1); } $result = ''; foreach ($list as $object) { $result .= $object->toJSON(128) . PHP_EOL; } ResultPrinter::printResult("Get List of All Web Profiles", "Web Profiles", null, null, $result); return $list;
/** * @dataProvider mockProvider * @param WebProfile $obj */ public function testGetList($obj, $mockApiContext) { $mockPPRestCall = $this->getMockBuilder('\\PayPal\\Transport\\PayPalRestCall')->disableOriginalConstructor()->getMock(); $mockPPRestCall->expects($this->any())->method('execute')->will($this->returnValue(json_encode(array(json_decode(WebProfileTest::getJson()))))); $result = $obj->get_list($mockApiContext, $mockPPRestCall); $this->assertNotNull($result); }
public static function getPaymentExperienceProfileId() { $apiContext = self::getApiContext(); $list = \PayPal\Api\WebProfile::get_list($apiContext); if (count($list) > 0) { return $list[0]->getId(); } // ### Create Web Profile // Use the /web-profiles resource to create seamless payment experience profiles. See the payment experience overview for further information about using the /payment resource to create the PayPal payment and pass the experience_profile_id. // Documentation available at https://developer.paypal.com/webapps/developer/docs/api/#create-a-web-experience-profile // Lets create an instance of FlowConfig and add // landing page type information $flowConfig = new \PayPal\Api\FlowConfig(); // Type of PayPal page to be displayed when a user lands on the PayPal site for checkout. Allowed values: Billing or Login. When set to Billing, the Non-PayPal account landing page is used. When set to Login, the PayPal account login landing page is used. $flowConfig->setLandingPageType("Login"); // The URL on the merchant site for transferring to after a bank transfer payment. // $flowConfig->setBankTxnPendingUrl("http://www.yeowza.com/"); // When set to "commit", the buyer is shown an amount, and the button text will read "Pay Now" on the checkout page. $flowConfig->setUserAction(null); // Defines the HTTP method to use to redirect the user to a return URL. A valid value is `GET` or `POST`. // $flowConfig->setReturnUriHttpMethod("GET"); // // Parameters for style and presentation. $presentation = new \PayPal\Api\Presentation(); // A URL to logo image. Allowed vaues: .gif, .jpg, or .png. $presentation->setLogoImage("http://betterliving.social/assets/images/paypal_checkout_brand.jpg")->setBrandName(\Tbmt\Config::get('brand.name'))->setLocaleCode("US"); // A label to use as hypertext for the return to merchant link. // ->setReturnUrlLabel("Return") // A label to use as the title for the note to seller field. Used only when `allow_note` is `1`. // ->setNoteToSellerLabel("Thanks!"); // Parameters for input fields customization. $inputFields = new \PayPal\Api\InputFields(); // Enables the buyer to enter a note to the merchant on the PayPal page during checkout. $inputFields->setAllowNote(false)->setNoShipping(1)->setAddressOverride(0); // #### Payment Web experience profile resource $webProfile = new \PayPal\Api\WebProfile(); // Name of the web experience profile. Required. Must be unique $webProfile->setName("happiness-guide")->setFlowConfig($flowConfig)->setPresentation($presentation)->setInputFields($inputFields)->setTemporary(false); $createProfileResponse = $webProfile->create($apiContext); return $createProfileResponse->getId(); }
/** * Check if PayPal credentails are valid for given configuration. * * Uses WebProfile::get_list() * * @return bool */ public function testCredentials($website) { try { $this->setApiContext($website); $response = WebProfile::get_list($this->_apiContext); return true; } catch (PayPal\Exception\PayPalConnectionException $ex) { Mage::getSingleton('adminhtml/session')->addError(Mage::helper('iways_paypalplus')->__('Provided credentials not valid.')); return false; } catch (Exception $e) { Mage::logException($e); return false; } }