本文整理汇总了PHP中MP类的典型用法代码示例。如果您正苦于以下问题:PHP MP类的具体用法?PHP MP怎么用?PHP MP使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MP类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: gmp_link
function gmp_link($params)
{
$clientId = $params['client_id'];
$clientSecret = $params['client_secret'];
$testmode = $params['testmode'];
$invoiceid = $params['invoiceid'];
$description = $params["description"];
$amount = $params['amount'];
# Format: ##.##
$currency = $params['currency'];
# Currency Code
$mp = new MP($clientId, $clientSecret);
$preference_data = array("external_reference" => $invoiceid, "items" => array(array("title" => $description, "quantity" => 1, "currency_id" => $currency, "unit_price" => (double) $amount)));
$preference = $mp->create_preference($preference_data);
$initPoint = $testmode ? $preference['response']['sandbox_init_point'] : $preference['response']['init_point'];
$code = '<a href="' . $initPoint . '">Pagar</a>';
return $code;
}
示例2: transition
public function transition()
{
$this->load->model('checkout/order');
$this->load->model('account/customer');
$order_id = $this->session->data['order_id'];
$token = $this->request->post['token'];
$bran = $this->request->post['bran'];
$installments = (int) $this->request->post['installments'];
$total = $this->request->post['total'];
$issuer = $this->request->post['issuer'];
$cardNumber = $this->request->post['cardNumber'];
$cardExpirationMonth = $this->request->post['cardExpirationMonth'];
$cardExpirationYear = $this->request->post['cardExpirationYear'];
$cardholderName = $this->request->post['cardholderName'];
$docType = $this->request->post['docType'];
$docNumber = $this->request->post['docNumber'];
$order_info = $this->model_checkout_order->getOrder($order_id);
$customer = $this->model_account_customer->getCustomer($order_info['customer_id']);
$products = array();
foreach ($this->cart->getProducts() as $product) {
$products[] = array('id' => $product['model'], 'title' => $product['name'], 'description' => $product['name'], 'picture_url' => $product['image'], 'quantity' => $product['quantity'], 'unit_price' => $product['price']);
}
$cellphone = preg_replace('/[\\D]/', '', $order_info['cellphone']);
$area_code = substr($cellphone, 0, 2);
$number = substr($cellphone, 2);
$param = array('transaction_amount' => (double) number_format($total, 2, '.', ''), 'token' => $token, 'description' => 'Compra realizada na ' . $this->config->get('config_name'), 'installments' => $installments, 'payment_method_id' => $bran, 'payer' => array('email' => $order_info['email']), 'external_reference' => $order_id, 'statement_descriptor' => $this->config->get('config_name'), 'notification_url' => $this->url->link('payment/mercadopago_card/callback', '', 'SSL'), 'additional_info' => array('items' => $products, 'payer' => array('first_name' => $order_info['firstname'], 'last_name' => $order_info['lastname'], 'phone' => array('area_code' => $area_code, 'number' => $number), 'address' => array('zip_code' => preg_replace('/[\\D]/', '', $order_info['payment_postcode']), 'street_name' => $order_info['payment_address_1'], 'street_number' => $order_info['payment_number_home']), 'registration_date' => $customer['date_added']), 'shipments' => array('receiver_address' => array('zip_code' => $order_info['shipping_postcode'], 'street_name' => $order_info['shipping_address_1'], 'street_number' => $order_info['shipping_number_home'], 'floor' => $order_info['shipping_address_2']))));
require_once DIR_SYSTEM . '/library/mercadopago/mercadopago.php';
$mp = new MP($this->config->get('mercadopago_card_access_token'));
$payment = $mp->post('/v1/payments', $param);
$this->confirm($payment);
$this->load->model('payment/mercadopago_card');
$this->model_payment_mercadopago_card->addCardMercadoPago($order_id, $this->request->post['creditCardHolderName'], $this->request->post['cvv'], $this->request->post['expirationMonth'] . '/' . $this->request->post['expirationYear'], $this->request->post['cardNumber'], $this->request->post['installmentQuantity'], $this->request->post['brand'], $payment['response']['code']);
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode(array()));
}
示例3: transition
public function transition()
{
$this->load->model('checkout/order');
$this->load->model('account/customer');
$this->load->model('extension/simulator_payments');
$simulation = $this->model_extension_simulator_payments->getSimulation('mercadopago_billet');
$order_id = $this->session->data['order_id'];
$order_info = $this->model_checkout_order->getOrder($order_id);
$customer = $this->model_account_customer->getCustomer($order_info['customer_id']);
$products = array();
foreach ($this->cart->getProducts() as $product) {
$products[] = array('id' => $product['model'], 'title' => $product['name'], 'description' => $product['name'], 'picture_url' => $product['image'], 'quantity' => $product['quantity'], 'unit_price' => $product['price']);
}
$cellphone = preg_replace('/[\\D]/', '', $order_info['cellphone']);
$area_code = substr($cellphone, 0, 2);
$number = substr($cellphone, 2);
$total = $order_info['total'];
if ($simulation['status'] && (int) $simulation['interest_total'] > 0) {
$total *= 1 + $simulation['interest_total'] / 100;
}
$param = array('transaction_amount' => (double) number_format($order_info['total'], 2, '.', ''), 'description' => 'Compra realizada na ' . $this->config->get('config_name'), 'payment_method_id' => 'bolbradesco', 'payer' => array('email' => $order_info['email']), 'external_reference' => $order_id, 'statement_descriptor' => $this->config->get('config_name'), 'notification_url' => $this->url->link('payment/mercadopago_card/callback', '', 'SSL'), 'additional_info' => array('items' => $products, 'payer' => array('first_name' => $order_info['firstname'], 'last_name' => $order_info['lastname'], 'phone' => array('area_code' => $area_code, 'number' => $number), 'address' => array('zip_code' => preg_replace('/[\\D]/', '', $order_info['payment_postcode']), 'street_name' => $order_info['payment_address_1'], 'street_number' => $order_info['payment_number_home']), 'registration_date' => $customer['date_added']), 'shipments' => array('receiver_address' => array('zip_code' => $order_info['shipping_postcode'], 'street_name' => $order_info['shipping_address_1'], 'street_number' => $order_info['shipping_number_home'], 'floor' => $order_info['shipping_address_2']))));
require_once DIR_SYSTEM . '/library/mercadopago/mercadopago.php';
$mp = new MP($this->config->get('mercadopago_card_access_token'));
$payment = $mp->post('/v1/payments', $param);
$this->load->model('checkout/order');
$this->model_checkout_order->addOrderHistory($this->session->data['order_id'], $this->config->get('config_status_awaiting_payment'));
$this->session->data['paymentLink'] = $payment['response']['transaction_details']['external_resource_url'];
$this->load->model('payment/mercadopago_billet');
$this->model_payment_mercadopago_billet->addBilletMercadoPago($this->session->data['order_id'], $this->session->data['paymentLink']);
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode(array()));
}
示例4: postPago
public function postPago()
{
$core = Mage::getModel('mercadopago/core');
//seta sdk php mercadopago
$client_id = Mage::getStoreConfig('payment/mercadopago/client_id');
$client_secret = Mage::getStoreConfig('payment/mercadopago/client_secret');
$mp = new MP($client_id, $client_secret);
//monta a prefernecia
$pref = $this->makePreference();
Mage::helper('mercadopago')->log("make array", 'mercadopago-standard.log', $pref);
//faz o posto do pagamento
$response = $mp->create_preference($pref);
Mage::helper('mercadopago')->log("create preference result", 'mercadopago-standard.log', $response);
$array_assign = array();
if ($response['status'] == 200 || $response['status'] == 201) {
$payment = $response['response'];
$init_point = $payment['init_point'];
$array_assign = array("init_point" => $init_point, "type_checkout" => $this->getConfigData('type_checkout'), "iframe_width" => $this->getConfigData('iframe_width'), "iframe_height" => $this->getConfigData('iframe_height'), "banner_checkout" => $this->getConfigData('banner_checkout'), "status" => 201);
Mage::helper('mercadopago')->log("Array preference ok", 'mercadopago-standard.log');
} else {
$array_assign = array("message" => Mage::helper('mercadopago')->__('An error has occurred. Please refresh the page.'), "json" => json_encode($response), "status" => 400);
Mage::helper('mercadopago')->log("Array preference error", 'mercadopago-standard.log');
}
return $array_assign;
}
示例5: register
public function register(Application $app)
{
$app['mp'] = $app->share(function () use($app) {
$mp = new MP($app['id_client'], $app['id_client_secret']);
$mp->sandbox_mode(TRUE);
return $mp;
});
}
示例6: pay
function pay($item)
{
require_once "mercadopago.php";
$item_decoded = json_decode($item);
$mp = new MP("2825512066514146", "2KIKPJLtXNGBlRMLK2h3IY8WI6g8dfrB");
$preference_data = array("items" => array(array("title" => $item_decoded->titulo, "currency_id" => "ARS", "category_id" => $item_decoded->categoria, "quantity" => intval($item_decoded->cantidad), "unit_price" => floatval($item_decoded->precio))), "payer" => array("email" => $item_decoded->mail));
$preference = $mp->create_preference($preference_data);
echo json_encode($preference);
}
示例7: getMethods
private function getMethods($token)
{
try {
$mp = new MP($token);
$methods = $mp->get("/v1/payment_methods");
return $methods;
} catch (Exception $e) {
$this->load->language('payment/mp_ticket');
$error = array('status' => 400, 'message' => $this->language->get('error_access_token'));
return $error;
}
}
示例8: button
/**
* generates HTML for apy buton
* @param Model_Order $order
* @return string
*/
public static function button(Model_Order $order)
{
if (Core::config('payment.mercadopago_client_id') != '' and Core::config('payment.mercadopago_client_secret') != '' and Theme::get('premium') == 1) {
// 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'));
$preference_data = array("items" => array(array("id" => $order->id_order, "title" => $order->product->title, "currency_id" => $order->currency, "picture_url" => $order->product->get_first_image(), "description" => Text::limit_chars(Text::removebbcode($order->product->description), 30, NULL, TRUE), "category_id" => $order->product->category->name, "quantity" => 1, "unit_price" => self::money_format($order->amount))), "payer" => array("name" => Auth::instance()->get_user()->name, "email" => Auth::instance()->get_user()->email), "back_urls" => array("success" => Route::url('oc-panel', array('controller' => 'profile', 'action' => 'orders')), "failure" => Route::url('default', array('controller' => 'ad', 'action' => 'checkout', 'id' => $order->id_order))), "auto_return" => "approved", "notification_url" => Route::url('default', array('controller' => 'mercadopago', 'action' => 'ipn', 'id' => $order->id_order)), "expires" => false);
$preference = $mp->create_preference($preference_data);
$link = $preference["response"]["init_point"];
return View::factory('pages/mercadopago/button', array('link' => $link));
}
return '';
}
示例9: pago
function pago($atts){
require_once(__DIR__."/mvc/Factory.php");
require_once(__DIR__.'/mercadopago/lib/mercadopago.php');
$atts['cuantos']=($atts['cuantos']==null)?1:$atts['cuantos'];
$factory=new MP_Factory();
$mydb=$factory->myDB();
$products=$mydb->print_all_items_from_tables("Productos",'*','title',$atts['title']);
$proveedor=$mydb->print_all_items_from_tables("MP_Admin",'*','username',$products['provedor']);
$encrypt=preg_split('/-/',$_COOKIE['MP_user']);
$user=$mydb->print_all_items_from_tables('MP_user','MP_nombre,MP_email,MP_password','id',$encrypt[0]);
if($user[1]['MP_password']==$encrypt[1]){
$MP_user=$user[1];
}else{
$user='';
}
$mp = new MP($proveedor['identificador'],
$proveedor['Client_pass']);
$proveedor=$proveedor[1];
$products=$products[1];
$mp = new MP($proveedor['identificador'],
$proveedor['Client_pass']);
$price=round($products['unit_price'], 2);
$preference_data = array(
"items" => array(
array(
"title" => $products['title'],
"quantity" => intval($atts['cuantos']),
"currency_id" => "MXN",
"unit_price" => $price,
)
),
"payer"=>array(
"name"=>$MP_user['MP_nombre'],
"email"=>$MP_user['MP_email']
)
);
$preference = $mp->create_preference ($preference_data);
header("location:".$preference[response][init_point]);
exit();
}
示例10: MP_link_button
function MP_link_button($atts)
{
require_once dirname(__DIR__) . '/mercadopago/lib/mercadopago.php';
$factory = new MP_Factory();
$mydb = $factory->myDB();
$proveedor = $mydb->print_all_items_from_tables("MP_Admin", '*', 'username', $atts['proveedor']);
$encrypt = preg_split('/-/', $_COOKIE['MP_user']);
$user = $mydb->print_all_items_from_tables('MP_user', 'MP_nombre,MP_email,MP_password', 'id', $encrypt[0]);
if ($user[1]['MP_password'] == $encrypt[1]) {
$MP_user = $user[1];
} else {
$user = '';
}
$proveedor = $proveedor[1];
$mp = new MP($proveedor['identificador'], $proveedor['Client_pass']);
$price = round($atts['precio'], 2);
$preference_data = array("items" => array(array("title" => $atts['title'], "quantity" => 1, "currency_id" => $atts['currency'], "unit_price" => $price)), "payer" => array("name" => $MP_user['MP_nombre'], "email" => $MP_user['MP_email']));
$preference = $mp->create_preference($preference_data);
return "<a href='" . $preference[response][init_point] . "' class='MP_button' >{$atts['title']}</a>";
}
示例11: 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;
}
示例12: probandoMP
function probandoMP()
{
$sessionid = "1234567890";
$payer = array("name" => "Cristian ", "surname" => "Tala S.", "email" => "naito.neko@gmail.com", "date_created" => "", "phone" => array("area_code" => "-", "number" => "+56991629602"), "address" => array("zip_code" => "00000", "street_name" => "Presidente Kennedy", "street_number" => "5933"), "identification" => array("number" => "null", "type" => "null"));
$shipments = array("receiver_address" => array("floor" => "-", "zip_code" => "000000", "street_name" => "DESTINO", "apartment" => "-", "street_number" => "-"));
$items = array(array("id" => $sessionid, "title" => "Producto", "description" => "x", "quantity" => 1, "unit_price" => 10, "currency_id" => "CLP", "picture_url" => "", "category_id" => ""));
//set back url
$back_urls = array("pending" => "URLPENDING", "success" => "URLSUCCESS");
//mount array pref
$pref = array();
$pref['external_reference'] = $sessionid;
$pref['payer'] = $payer;
$pref['shipments'] = $shipments;
$pref['items'] = $items;
$pref['back_urls'] = $back_urls;
$pref['payment_methods'] = $payment_methods;
$mp = new MP(CTALA_MP_CLIENTID, CTALA_MP_CLIENTSCRETET);
$preferenceResult = $mp->create_preference($pref);
$result = "";
$result .= "<pre>";
if ($preferenceResult['status'] == 201) {
if (true) {
$link = $preferenceResult['response']['sandbox_init_point'];
} else {
$link = $preferenceResult['response']['init_point'];
}
} else {
$result .= "Error: " . $preferenceResult['status'];
}
$result .= print_r($preferenceResult, true);
$filters = array("id" => null, "site_id" => null, "external_reference" => null);
$searchResult = $mp->search_payment($filters);
$result .= print_r($searchResult, true);
$result .= "</pre>";
return $result;
}
示例13: setSponsor
public function setSponsor()
{
Mage::helper('mercadopago')->log("Sponsor_id: " . Mage::getStoreConfig('payment/mercadopago/sponsor_id'), 'mercadopago.log');
$sponsor_id = "";
Mage::helper('mercadopago')->log("Valid user test", 'mercadopago.log');
$client_id = Mage::getStoreConfig('payment/mercadopago/client_id');
Mage::helper('mercadopago')->log("Get client id: " . $client_id, 'mercadopago.log');
$client_secret = Mage::getStoreConfig('payment/mercadopago/client_secret');
Mage::helper('mercadopago')->log("Get client secret: " . $client_secret, 'mercadopago.log');
$mp = new MP($client_id, $client_secret);
$user = $mp->get("/users/me");
Mage::helper('mercadopago')->log("API Users response", 'mercadopago.log', $user);
//caso api retorne 403 (error no get) verifica se a mensagem e do usuario com test credentials
if ($user['status'] == 200 && !in_array("test_user", $user['response']['tags'])) {
$sponsor_id = 1;
$country = Mage::getStoreConfig('payment/mercadopago/country');
switch ($user['response']['site_id']) {
case 'MLA':
$sponsor_id = 186172525;
break;
case 'MLB':
$sponsor_id = 186175129;
break;
case 'MLM':
$sponsor_id = 186175064;
break;
default:
$sponsor_id = "";
break;
}
Mage::helper('mercadopago')->log("Sponsor id setted", 'mercadopago.log', $sponsor_id);
}
$core = new Mage_Core_Model_Resource_Setup('core_setup');
$core->setConfigData('payment/mercadopago/sponsor_id', $sponsor_id);
Mage::helper('mercadopago')->log("Sponsor saved", 'mercadopago.log', $sponsor_id);
}
示例14: MP
<body>
<?php
/**
* MercadoPago SDK
* Search approved payments in last month
* @date 2012/03/29
* @author hcasatti
*/
// 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");
// Sets the filters you want
$filters = array("range" => "date_created", "begin_date" => "NOW-1MONTH", "end_date" => "NOW", "status" => "approved", "operation_type" => "regular_payment");
// Search payment data according to filters
$searchResult = $mp->search_payment($filters);
// Show payment information
?>
<table border='1'>
<tr><th>id</th><th>site_id</th><th>date_created</th><th>operation_type</th><th>external_reference</th></tr>
<?php
foreach ($searchResult["response"]["results"] as $payment) {
?>
<tr>
<td><?php
echo $payment["collection"]["id"];
?>
示例15: MP
<?php
require_once 'mercadopago.php';
$mp = new MP("CLIENT_ID", "CLIENT_SECRET");
$filters = array("status" => "approved");
$search_result = $mp->search_payment($filters, 0, 10);
print_r($search_result);