/**
  * Returns the prepared customer parameter data.
  *
  * @return array
  */
 protected function getCustomerParameter()
 {
     $user = $this->getUser();
     if (empty($user)) {
         return array('LOCALECODE' => $this->plugin->getLocaleCode(true));
     }
     $shipping = $user['shippingaddress'];
     $name = $shipping['firstname'] . ' ' . $shipping['lastname'];
     if (!empty($shipping['company'])) {
         $name = $shipping['company'] . ' - ' . $name;
     }
     if (!empty($shipping['streetnumber'])) {
         $shipping['street'] .= ' ' . $shipping['streetnumber'];
     }
     if (!empty($shipping['additional_address_line1'])) {
         $shipping['street2'] = $shipping['additional_address_line1'];
         if (!empty($shipping['additional_address_line2'])) {
             $shipping['street2'] .= ' ' . $shipping['additional_address_line2'];
         }
     } else {
         $shipping['street2'] = '';
     }
     $customer = array('CUSTOMERSERVICENUMBER' => $user['billingaddress']['customernumber'], 'SHIPTONAME' => $name, 'SHIPTOSTREET' => $shipping['street'], 'SHIPTOSTREET2' => $shipping['street2'], 'SHIPTOZIP' => $shipping['zipcode'], 'SHIPTOCITY' => $shipping['city'], 'SHIPTOCOUNTRY' => $user['additional']['countryShipping']['countryiso'], 'EMAIL' => $user['additional']['user']['email'], 'SHIPTOPHONENUM' => $user['billingaddress']['phone'], 'LOCALECODE' => $this->plugin->getLocaleCode(true));
     if (!empty($user['additional']['stateShipping']['shortcode'])) {
         $customer['SHIPTOSTATE'] = $user['additional']['stateShipping']['shortcode'];
     }
     return $customer;
 }
Exemplo n.º 2
0
 /**
  * @param ControllerAction $action
  */
 public function onPaypalPlus(ControllerAction $action)
 {
     $config = $this->config;
     $router = $action->Front()->Router();
     $view = $action->View();
     $user = $view->getAssign('sUserData');
     $basket = $view->getAssign('sBasket');
     $cancelUrl = $router->assemble(array('controller' => 'payment_paypal', 'action' => 'cancel', 'forceSecure' => true));
     $returnUrl = $router->assemble(array('controller' => 'payment_paypal', 'action' => 'return', 'forceSecure' => true));
     $profile = $this->getProfile();
     $this->restClient->setAuthToken();
     $uri = 'payments/payment';
     $params = array('intent' => 'sale', 'experience_profile_id' => $profile['id'], 'payer' => array('payment_method' => 'paypal'), 'transactions' => $this->getTransactionData($basket, $user), 'redirect_urls' => array('return_url' => $returnUrl, 'cancel_url' => $cancelUrl));
     $payment = $this->restClient->create($uri, $params);
     if (!empty($payment['links'][1]['href'])) {
         $view->assign('PaypalPlusApprovalUrl', $payment['links'][1]['href']);
         $view->assign('PaypalPlusModeSandbox', $config->get('paypalSandbox'));
         $view->assign('PaypalLocale', $this->paypalBootstrap->getLocaleCode());
         $db = $this->bootstrap->get('db');
         $sql = 'SELECT paymentmeanID AS id, paypal_plus_media AS media
                 FROM s_core_paymentmeans_attributes WHERE paypal_plus_active = 1';
         $paymentMethods = $db->fetchAssoc($sql);
         $view->assign('PaypalPlusThirdPartyPaymentMethods', $paymentMethods);
         $this->session->PaypalPlusPayment = $payment['id'];
     }
 }
 /**
  * @return array
  */
 private function getProfileData()
 {
     $template = $this->bootstrap->get('template');
     $router = $this->bootstrap->get('router');
     $shop = $this->bootstrap->get('shop');
     $localeCode = $this->paypalBootstrap->getLocaleCode(true);
     $profileName = "{$shop->getHost()}{$shop->getBasePath()}[{$shop->getId()}]";
     $shopName = $this->config->get('paypalBrandName') ?: $this->bootstrap->get('config')->get('shopName');
     // (max length 127)
     if (strlen($shopName) > 127) {
         $shopName = substr($shopName, 0, 124) . '...';
     }
     $logoImage = $this->config->get('paypalLogoImage');
     $logoImage = 'string:{link file=' . var_export($logoImage, true) . ' fullPath}';
     $logoImage = $template->fetch($logoImage);
     $notifyUrl = $router->assemble(array('controller' => 'payment_paypal', 'action' => 'notify', 'forceSecure' => true));
     return array('name' => $profileName, 'presentation' => array('brand_name' => $shopName, 'logo_image' => $logoImage, 'locale_code' => $localeCode), 'input_fields' => array('allow_note' => true, 'no_shipping' => 0, 'address_override' => 1), 'flow_config' => array('bank_txn_pending_url' => $notifyUrl));
 }