当前位置: 首页>>代码示例>>PHP>>正文


PHP MP::getPaymentMethods方法代码示例

本文整理汇总了PHP中MP::getPaymentMethods方法的典型用法代码示例。如果您正苦于以下问题:PHP MP::getPaymentMethods方法的具体用法?PHP MP::getPaymentMethods怎么用?PHP MP::getPaymentMethods使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MP的用法示例。


在下文中一共展示了MP::getPaymentMethods方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getContent

 public function getContent()
 {
     $errors = array();
     $success = false;
     $payment_methods = null;
     $payment_methods_settings = null;
     $offline_payment_settings = null;
     $offline_methods_payments = null;
     if (Tools::getValue('login')) {
         $client_id = Tools::getValue('MERCADOPAGO_CLIENT_ID');
         $client_secret = Tools::getValue('MERCADOPAGO_CLIENT_SECRET');
         if (!$this->validateCredential($client_id, $client_secret)) {
             $errors[] = $this->l('Client Id or Client Secret invalid.');
             $success = false;
         } else {
             $this->setDefaultValues($client_id, $client_secret);
             // populate all payments accoring to country
             $mp = new MP($client_id, $client_secret);
             $payment_methods = $mp->getPaymentMethods();
             // load all offline payment method settings
             $offline_methods_payments = $mp->getOfflinePaymentMethods();
             $offline_payment_settings = array();
             foreach ($offline_methods_payments as $offline_payment) {
                 $op_banner_variable = 'MERCADOPAGO_' . strtoupper($offline_payment['id'] . '_BANNER');
                 $op_active_variable = 'MERCADOPAGO_' . strtoupper($offline_payment['id'] . '_ACTIVE');
                 $offline_payment_settings[$offline_payment['id']] = array('name' => $offline_payment['name'], 'banner' => Configuration::get($op_banner_variable), 'active' => Configuration::get($op_active_variable));
             }
         }
     } else {
         if (Tools::getValue('submitmercadopago')) {
             $client_id = Tools::getValue('MERCADOPAGO_CLIENT_ID');
             $client_secret = Tools::getValue('MERCADOPAGO_CLIENT_SECRET');
             $public_key = Tools::getValue('MERCADOPAGO_PUBLIC_KEY');
             $creditcard_active = Tools::getValue('MERCADOPAGO_CREDITCARD_ACTIVE');
             $boleto_active = Tools::getValue('MERCADOPAGO_BOLETO_ACTIVE');
             $standard_active = Tools::getValue('MERCADOPAGO_STANDARD_ACTIVE');
             $new_country = false;
             if (!$this->validateCredential($client_id, $client_secret)) {
                 $errors[] = $this->l('Client Id or Client Secret invalid.');
                 $success = false;
             } else {
                 $previous_country = $this->getCountry(Configuration::get('MERCADOPAGO_CLIENT_ID'), Configuration::get('MERCADOPAGO_CLIENT_SECRET'));
                 $current_country = $this->getCountry($client_id, $client_secret);
                 $new_country = $previous_country == $current_country ? false : true;
                 Configuration::updateValue('MERCADOPAGO_CLIENT_ID', $client_id);
                 Configuration::updateValue('MERCADOPAGO_CLIENT_SECRET', $client_secret);
                 Configuration::updateValue('MERCADOPAGO_COUNTRY', $this->getCountry($client_id, $client_secret));
                 $success = true;
                 if ($creditcard_active == 'true' && !empty($public_key)) {
                     Configuration::updateValue('MERCADOPAGO_PUBLIC_KEY', $public_key);
                 }
                 // populate all payments accoring to country
                 $this->mercadopago = new MP(Configuration::get('MERCADOPAGO_CLIENT_ID'), Configuration::get('MERCADOPAGO_CLIENT_SECRET'));
                 $payment_methods = $this->mercadopago->getPaymentMethods();
             }
             $category = Tools::getValue('MERCADOPAGO_CATEGORY');
             Configuration::updateValue('MERCADOPAGO_CATEGORY', $category);
             $creditcard_banner = Tools::getValue('MERCADOPAGO_CREDITCARD_BANNER');
             Configuration::updateValue('MERCADOPAGO_CREDITCARD_BANNER', $creditcard_banner);
             Configuration::updateValue('MERCADOPAGO_STANDARD_ACTIVE', $standard_active);
             Configuration::updateValue('MERCADOPAGO_BOLETO_ACTIVE', $boleto_active);
             Configuration::updateValue('MERCADOPAGO_CREDITCARD_ACTIVE', $creditcard_active);
             $standard_banner = Tools::getValue('MERCADOPAGO_STANDARD_BANNER');
             Configuration::updateValue('MERCADOPAGO_STANDARD_BANNER', $standard_banner);
             $window_type = Tools::getValue('MERCADOPAGO_WINDOW_TYPE');
             Configuration::updateValue('MERCADOPAGO_WINDOW_TYPE', $window_type);
             $iframe_width = Tools::getValue('MERCADOPAGO_IFRAME_WIDTH');
             Configuration::updateValue('MERCADOPAGO_IFRAME_WIDTH', $iframe_width);
             $iframe_height = Tools::getValue('MERCADOPAGO_IFRAME_HEIGHT');
             Configuration::updateValue('MERCADOPAGO_IFRAME_HEIGHT', $iframe_height);
             $installments = Tools::getValue('MERCADOPAGO_INSTALLMENTS');
             Configuration::updateValue('MERCADOPAGO_INSTALLMENTS', $installments);
             $auto_return = Tools::getValue('MERCADOPAGO_AUTO_RETURN');
             Configuration::updateValue('MERCADOPAGO_AUTO_RETURN', $auto_return);
             $exclude_all = true;
             foreach ($payment_methods as $payment_method) {
                 $pm_variable_name = 'MERCADOPAGO_' . strtoupper($payment_method['id']);
                 $value = Tools::getValue($pm_variable_name);
                 if ($value != 'on') {
                     $exclude_all = false;
                 }
                 // current settings
                 $payment_methods_settings[$payment_method['id']] = Configuration::get($pm_variable_name);
             }
             if (!$exclude_all) {
                 $payment_methods_settings = array();
                 foreach ($payment_methods as $payment_method) {
                     $pm_variable_name = 'MERCADOPAGO_' . strtoupper($payment_method['id']);
                     $value = Tools::getValue($pm_variable_name);
                     //save setting per payment_method
                     Configuration::updateValue($pm_variable_name, $value);
                     $payment_methods_settings[$payment_method['id']] = Configuration::get($pm_variable_name);
                 }
             } else {
                 $errors[] = $this->l('Cannnot exclude all payment methods.');
                 $success = false;
             }
             // if it is new country, reset values
             if ($new_country) {
                 $this->setCustomSettings($client_id, $client_secret, $this->getCountry($client_id, $client_secret));
//.........这里部分代码省略.........
开发者ID:GrupoGirat,项目名称:cart-prestashop,代码行数:101,代码来源:mercadopago.php


注:本文中的MP::getPaymentMethods方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。