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


PHP MP::get_access_token方法代码示例

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


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

示例1: toOptionArray

 public function toOptionArray()
 {
     $methods = array();
     //adiciona um valor vazio caso nao queria excluir nada
     $methods[] = array("value" => "", "label" => "");
     $client_id = Mage::getStoreConfig('payment/mercadopago/client_id');
     $client_secret = Mage::getStoreConfig('payment/mercadopago/client_secret');
     //verifico se as credenciais não são vazias, caso sejam não é possível obte-los
     if ($client_id != "" && $client_secret != "") {
         $mp = new MP($client_id, $client_secret);
         $access_token = $mp->get_access_token();
         Mage::helper('mercadopago')->log("Get payment methods by country... ", 'mercadopago.log');
         Mage::helper('mercadopago')->log("API payment methods: " . "/v1/payment_methods?access_token=" . $access_token, 'mercadopago.log');
         $response = MPRestClient::get("/v1/payment_methods?access_token=" . $access_token);
         Mage::helper('mercadopago')->log("API payment methods", 'mercadopago.log', $response);
         $response = $response['response'];
         foreach ($response as $m) {
             if ($m['id'] != 'account_money') {
                 $methods[] = array('value' => $m['id'], 'label' => Mage::helper('adminhtml')->__($m['name']));
             }
         }
     }
     return $methods;
 }
开发者ID:colombinis,项目名称:cart-magento,代码行数:24,代码来源:PaymentMethods.php

示例2: testLongLiveAccessToken

 public function testLongLiveAccessToken()
 {
     $mp = new MP($this->credentials["access_token"]);
     $this->assertTrue($mp->get_access_token() == $this->credentials["access_token"]);
 }
开发者ID:NAITUSEIRL,项目名称:wc-ctala-mercadopago,代码行数:5,代码来源:UnitTest.php

示例3: MP

<?php

$mp = new MP("ACCESS_TOKEN");
$request = array("uri" => "/oauth/token", "data" => array("client_secret" => $mp->get_access_token(), "grant_type" => "authorization_code", "code" => "AUTHORIZATION_CODE", "redirect_uri" => "REDIRECT_URI"), "headers" => array("content-type" => "application/x-www-form-urlencoded"), "authenticate" => false);
$mp->post($request);
开发者ID:jrivera294,项目名称:code-examples,代码行数:5,代码来源:get_credentials.php

示例4: MP

<?php

$mp = new MP("ACCESS_TOKEN");
$request = array("uri" => "/oauth/token", "data" => array("client_secret" => $mp->get_access_token(), "grant_type" => "refresh_token", "refresh_token" => "USER_RT"), "headers" => array("content-type" => "application/x-www-form-urlencoded"), "authenticate" => false);
$mp->post($request);
开发者ID:jrivera294,项目名称:code-examples,代码行数:5,代码来源:refresh_credentials.php

示例5: MP

/**
 * MercadoPago SDK
 * Receive IPN
 * @date 2015/03/17
 * @author fvaccaro
 */
// Include Mercadopago library
require_once "../../lib/mercadopago.php";
// Create an instance with your MercadoPago credentials (CLIENT_ID and CLIENT_SECRET):
// Argentina: https://www.mercadopago.com/mla/herramientas/aplicaciones
// Brasil: https://www.mercadopago.com/mlb/ferramentas/aplicacoes
// Mexico: https://www.mercadopago.com/mlm/herramientas/aplicaciones
// Venezuela: https://www.mercadopago.com/mlv/herramientas/aplicaciones
$mp = new MP("CLIENT_ID", "CLIENT_SECRET");
$params = ["access_token" => $mp->get_access_token()];
// Get the payment reported by the IPN. Glossary of attributes response in https://developers.mercadopago.com
if ($_GET["topic"] == 'payment') {
    $payment_info = $mp->get("/collections/notifications/" . $_GET["id"], $params, false);
    $merchant_order_info = $mp->get("/merchant_orders/" . $payment_info["response"]["collection"]["merchant_order_id"], $params, false);
    // Get the merchant_order reported by the IPN. Glossary of attributes response in https://developers.mercadopago.com
} else {
    if ($_GET["topic"] == 'merchant_order') {
        $merchant_order_info = $mp->get("/merchant_orders/" . $_GET["id"], $params, false);
    }
}
//If the payment's transaction amount is equal (or bigger) than the merchant order's amount you can release your items
if ($merchant_order_info["status"] == 200) {
    $transaction_amount_payments = 0;
    $transaction_amount_order = $merchant_order_info["response"]["total_amount"];
    $payments = $merchant_order_info["response"]["payments"];
开发者ID:basekit,项目名称:mercadopago-sdk-php,代码行数:30,代码来源:receive-ipn.php

示例6: action_ipn

 public function action_ipn()
 {
     $this->auto_render = FALSE;
     $id_order = $this->request->param('id');
     //retrieve info for the item in DB
     $order = new Model_Order();
     $order = $order->where('id_order', '=', $id_order)->where('status', '=', Model_Order::STATUS_CREATED)->limit(1)->find();
     if ($order->loaded()) {
         //its a fraud...lets let him know
         if ($order->is_fraud() === TRUE) {
             Kohana::$log->add(Log::ERROR, __('We had, issues with your transaction. Please try paying with another paymethod.'));
             $this->response->body('KO');
         }
         // Include Mercadopago library
         require Kohana::find_file('vendor/mercadopago', 'mercadopago');
         // Create an instance with your MercadoPago credentials (CLIENT_ID and CLIENT_SECRET):
         $mp = new MP(core::config('payment.mercadopago_client_id'), core::config('payment.mercadopago_client_secret'));
         $params = ["access_token" => $mp->get_access_token()];
         // Check mandatory parameters
         if (Core::get('id') == NULL or Core::get('topic') == NULL or !ctype_digit(Core::get('id'))) {
             $this->response->body('KO');
         }
         // Get the payment reported by the IPN. Glossary of attributes response in https://developers.mercadopago.com
         if (Core::get('topic') == 'payment') {
             try {
                 $payment_info = $mp->get("/collections/notifications/" . Core::get('id'), $params, false);
                 // Get the merchant_order reported by the IPN. Glossary of attributes response in https://developers.mercadopago.com
             } catch (Exception $e) {
                 Kohana::$log->add(Log::ERROR, $e);
                 $this->response->body('KO');
             }
             try {
                 $merchant_order_info = $mp->get("/merchant_orders/" . $payment_info["response"]["collection"]["merchant_order_id"], $params, false);
             } catch (Exception $e) {
                 Kohana::$log->add(Log::ERROR, $e);
                 $this->response->body('KO');
             }
         } else {
             if (Core::get('topic') == 'merchant_order') {
                 try {
                     $merchant_order_info = $mp->get("/merchant_orders/" . Core::get('id'), $params, false);
                 } catch (Exception $e) {
                     Kohana::$log->add(Log::ERROR, 'Order not loaded');
                     $this->response->body('KO');
                 }
             }
         }
         //If the payment's transaction amount is equal (or bigger) than the merchant order's amount you can release your items
         if (isset($merchant_order_info["status"]) and $merchant_order_info["status"] == 200) {
             $transaction_amount_payments = 0;
             $transaction_amount_order = $merchant_order_info["response"]["total_amount"];
             $payments = $merchant_order_info["response"]["payments"];
             foreach ($payments as $payment) {
                 if ($payment['status'] == 'approved') {
                     $transaction_amount_payments += $payment['transaction_amount'];
                 }
             }
             //correct payment
             if ($transaction_amount_payments >= $transaction_amount_order) {
                 $order->confirm_payment('mercadopago', Core::get('id'));
                 $this->response->body('OK');
             } else {
                 Kohana::$log->add(Log::ERROR, 'A payment has been made but is flagged as INVALID');
                 $this->response->body('KO');
             }
         }
     } else {
         Kohana::$log->add(Log::ERROR, 'Order not loaded');
         $this->response->body('KO');
     }
 }
开发者ID:kotsios5,项目名称:openclassifieds2,代码行数:71,代码来源:mercadopago.php

示例7: array

 function add_balance_to_user_array($args)
 {
     $fullArgs = array();
     if ($args['titulo']) {
         $fullArgs['titulo'] = $args['titulo'];
         unset($args['titulo']);
     }
     foreach ($args as $argumento) {
         $mp = new MP($argumento['identificador'], $argumento["Client_pass"]);
         $token = $mp->get_access_token();
         $user = explode("-", $token);
         $user_ID = end($user);
         $balance = $mp->get("/users/{$user_ID}/mercadopago_account/balance");
         $argumento['Saldo'] = $balance['response']['available_balance'];
         $argumento['Retenido'] = $balance['response']['unavailable_balance'];
         $fullArgs[] = $argumento;
     }
     return $fullArgs;
 }
开发者ID:xarkamx,项目名称:mercadopago,代码行数:19,代码来源:settings.php

示例8: testLongLiveAccessToken

 public function testLongLiveAccessToken()
 {
     $mp = new MP("LONG_LIVE_ACCESS_TOKEN");
     $this->assertTrue($mp->get_access_token() == "LONG_LIVE_ACCESS_TOKEN");
 }
开发者ID:hittten,项目名称:sdk-php,代码行数:5,代码来源:UnitTest.php

示例9: MP

<?php

require_once 'mercadopago.php';
$mp = new MP("CLIENT_ID", "CLIENT_SECRET");
$access_token = $mp->get_access_token();
print_r($access_token);
开发者ID:jrivera294,项目名称:code-examples,代码行数:6,代码来源:access_token.php


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