Parameters for input fields customization.
상속: extends PayPal\Common\PayPalModel
 function update_profile($config)
 {
     // auth
     $apiContext = $this->apiContext();
     // set FlowConfig
     $flowConfig = new FlowConfig();
     $flowConfig->setLandingPageType($config['flow_config']['landing_page_type']);
     // set Presentation
     $presentation = new Presentation();
     if ($config['presentation']['logo_image'] != '') {
         $presentation->setLogoImage(substr($config['presentation']['logo_image'], 0, 127));
     }
     if ($config['presentation']['brand_name'] != '') {
         $presentation->setBrandName(substr($config['presentation']['brand_name'], 0, 127));
     }
     if ($config['presentation']['locale_code'] != '') {
         $presentation->setLocaleCode(strtoupper($config['presentation']['locale_code']));
     }
     $addess_override = $config['input_fields']['address_override'] == '0' ? 1 : 0;
     // set InputFields
     $inputFields = new InputFields();
     $inputFields->setAllowNote(0)->setNoShipping(0)->setAddressOverride((int) $addess_override);
     // set WebProfile
     $webProfile = new WebProfile();
     $webProfile->setId($config['id'])->setName($config['name'])->setFlowConfig($flowConfig)->setPresentation($presentation)->setInputFields($inputFields);
     try {
         $webProfile->update($apiContext);
         $valid = true;
     } catch (Exception $ex) {
         $this->LoggingManager->log(print_r($ex, true), 'DEBUG');
         $valid = false;
         if ($ex instanceof \PayPal\Exception\PayPalConnectionException) {
             global $messageStack;
             $error_json = $ex->getData();
             $error = json_decode($error_json, true);
             $messageStack->add_session((isset($error['name']) ? '<b>' . $error['name'] . ':</b> ' : '') . $error['message'], 'warning');
             if (isset($error['details'])) {
                 for ($i = 0, $n = count($error['details']); $i < $n; $i++) {
                     $messageStack->add_session($error['details'][$i]['field'] . ': ' . $error['details'][$i]['issue'], 'warning');
                 }
             }
         }
     }
     if ($config['status'] == '1') {
         $sql_data_array = array(array('config_key' => 'PAYPAL_STANDARD_PROFILE', 'config_value' => $config['id']));
         $this->save_config($sql_data_array);
     } elseif ($config['id'] == $this->get_config('PAYPAL_STANDARD_PROFILE')) {
         $this->delete_config('PAYPAL_STANDARD_PROFILE');
     }
     $sql_data_array = array(array('config_key' => strtoupper($config['id']) . '_TIME', 'config_value' => time()), array('config_key' => strtoupper($config['id']) . '_ADDRESS', 'config_value' => $addess_override));
     $this->save_config($sql_data_array);
 }
 /**
  * @depends testSerializationDeserialization
  * @param InputFields $obj
  */
 public function testGetters($obj)
 {
     $this->assertEquals($obj->getAllowNote(), true);
     $this->assertEquals($obj->getNoShipping(), 123);
     $this->assertEquals($obj->getAddressOverride(), 123);
 }
예제 #3
0
 /**
  * Build WebProfile
  *
  * @return boolean|WebProfile
  */
 protected function buildWebProfile()
 {
     $webProfile = new WebProfile();
     if (Mage::getStoreConfig('iways_paypalplus/dev/web_profile_id')) {
         $webProfile->setId(Mage::getStoreConfig('iways_paypalplus/dev/web_profile_id'));
         return $webProfile;
     }
     try {
         $webProfile->setName('magento_' . microtime());
         $webProfile->setPresentation($this->buildWebProfilePresentation());
         $inputFields = new InputFields();
         $inputFields->setAddressOverride(1);
         $webProfile->setInputFields($inputFields);
         $response = $webProfile->create($this->_apiContext);
         $this->saveWebProfileId($response->getId());
         return $response;
     } catch (\PayPal\Exception\PayPalConnectionException $ex) {
         Mage::helper('iways_paypalplus')->handleException($ex);
     }
     return false;
 }