本文整理汇总了PHP中MP类的典型用法代码示例。如果您正苦于以下问题:PHP MP类的具体用法?PHP MP怎么用?PHP MP使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MP类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:sercba,项目名称:gmp,代码行数:18,代码来源:gmp.php
示例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()));
}
开发者ID:luanmpereira,项目名称:default-store,代码行数:35,代码来源:mercadopago_card.php
示例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()));
}
开发者ID:luanmpereira,项目名称:default-store,代码行数:32,代码来源:mercadopago_billet.php
示例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;
}
开发者ID:colombinis,项目名称:cart-magento,代码行数:25,代码来源:Payment.php
示例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;
});
}
开发者ID:frantorletti,项目名称:mercadopagoserviceprovider,代码行数:8,代码来源:MercadopagoServiceProvider.php
示例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);
}
开发者ID:arielcessario,项目名称:miprimersponsor,代码行数:9,代码来源:ac-mp.php
示例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;
}
}
开发者ID:BrunoCodeman,项目名称:cart-opencart,代码行数:12,代码来源:mp_ticket.php
示例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 '';
}
开发者ID:johnulist,项目名称:open-eshop,代码行数:19,代码来源:mercadopago.php
示例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();
}
开发者ID:xarkamx,项目名称:mercadopago,代码行数:42,代码来源:mercadoplugin.php
示例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>";
}
开发者ID:xarkamx,项目名称:mercadopago,代码行数:20,代码来源:grid_product.php
示例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;
}
开发者ID:colombinis,项目名称:cart-magento,代码行数:24,代码来源:PaymentMethods.php
示例12: probandoMP
function probandoMP()
{
$sessionid = "1234567890";
$payer = array("name" => "Cristian ", "surname" => "Tala S.", "email" => "[email protected]", "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;
}
开发者ID:NAITUSEIRL,项目名称:wc-ctala-mercadopago,代码行数:36,代码来源:WcMercadoPago.php
示例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);
}
开发者ID:colombinis,项目名称:cart-magento,代码行数:36,代码来源:Observer.php
示例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"];
?>
开发者ID:basekit,项目名称:mercadopago-sdk-php,代码行数:31,代码来源:search-approved-payments.php
示例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);
开发者ID:jrivera294,项目名称:code-examples,代码行数:7,代码来源:basic.php
示例16: 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
示例17: MP
<?php
include_once '../../../config/config.inc.php';
include_once 'mercadopago.php';
if (isset($_REQUEST['topic']) && isset($_REQUEST['id'])) {
$id = $_REQUEST['id'];
$client_id = Db::getInstance()->getRow("SELECT value FROM " . _DB_PREFIX_ . "configuration WHERE name = 'mercadopago_CLIENT_ID'");
$client_secret = Db::getInstance()->getRow("SELECT value FROM " . _DB_PREFIX_ . "configuration WHERE name = 'mercadopago_CLIENT_SECRET'");
$sandbox = Db::getInstance()->getRow("SELECT value FROM " . _DB_PREFIX_ . "configuration WHERE name = 'mercadopago_SANDBOX'");
$mp = new MP($client_id['value'], $client_secret['value']);
$mp->sandbox_mode($sandbox['value'] == "active" ? true : false);
$dados = $mp->get_payment_info($id);
$dados = $dados['response'];
$order_id = $dados['collection']['external_reference'];
$order_status = $dados["collection"]["status"];
switch ($order_status) {
case 'approved':
$nomestatus = "mercadopago_STATUS_1";
break;
case 'pending':
$nomestatus = "mercadopago_STATUS_0";
break;
case 'in_process':
$nomestatus = "mercadopago_STATUS_0";
break;
case 'reject':
$nomestatus = "mercadopago_STATUS_2";
break;
case 'refunded':
$nomestatus = "mercadopago_STATUS_2";
break;
开发者ID:mercadeoweb,项目名称:cart-prestashop,代码行数:31,代码来源:retorno.php
示例18: ini_set
<?php
ini_set('display_errors', 1);
ini_set('display_startup_erros', 1);
error_reporting(E_ALL);
require_once "lib/mercadopago.php";
// 5031 4332 1540 6351
$mp = new MP("3821444876288488", "1MsZwpHqFP2MDPh1d4IaXsIrUAbIXbjt");
print_r($_REQUEST);
$valor = rand(10, 350);
$preference = array("amount" => (double) $_REQUEST['amount'], "installments" => (int) $_REQUEST['installmentsOption'], "payment_method_id" => $_REQUEST['paymentMethod'], "currency_id" => "BRL", "card_token_id" => $_REQUEST['card_token_id'], "external_reference" => "my_order_1234", "items" => array(array("id" => "2133", "title" => "Titulo do produto", "description" => "Descricao ", "picture_url" => "http=>//2.bp.blogspot.com/-Zu-IpE01s5Y/TtEAy89fUzI/AAAAAAAAAXE/0_ZrT5SUbUQ/s1600/unicef.jpg", "category_id" => "others", "quantity" => 1, "unit_price" => (double) $_REQUEST['amount'])), "customer" => array("email" => "[email protected]", "first_name" => "name", "last_name" => "lastName", "phone" => array("area_code" => "011", "number" => "38882377"), "identification" => array("type" => "CPF", "number" => "19119119100"), "address" => array("zip_code" => "06541005", "street_name" => "Street name", "street_number" => 1), "registration_date" => "2014-06-28T16:53:03.176-04:00"), "shipments" => array("receiver_address" => array("zip_code" => "06541005", "street_name" => "Street name", "street_number" => 1, "floor" => "5", "apartment" => "c")));
$preferenceResult = $mp->invisible($preference);
?>
开发者ID:vvasconcellos,项目名称:mp2,代码行数:13,代码来源:response.php
示例19: error_reporting
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once "lib/mercadopago.php";
$mp = new MP("3821444876288488", "1MsZwpHqFP2MDPh1d4IaXsIrUAbIXbjt");
$arquivo = fopen('result_ipn.php', 'a');
fwrite($arquivo, "\n POST <? echo('<pre>'); ?> " . $_SERVER['REQUEST_URI'] . "<? echo('</pre>'); ?><br><br>");
fclose($arquivo);
switch ($_GET["topic"]) {
case "payment":
$payment_info = $mp->get_payment_info($_GET["id"]);
if ($payment_info["status"] == 200) {
$arquivo = fopen('result_ipn.php', 'a');
fwrite($arquivo, "\n<? echo('<pre>'); ?> " . json_encode($payment_info) . "<? echo('</pre>'); ?><br><hr><br>");
fclose($arquivo);
}
break;
case "preapproval":
$payment_info = $mp->get_preapproval_payment($_GET["id"]);
if ($payment_info["status"] == 200) {
$arquivo = fopen('result_ipn.php', 'a');
fwrite($arquivo, "\n<pre> " . json_encode($payment_info) . "</pre><br><hr><br>");
fclose($arquivo);
}
break;
case "authorized_payment":
$payment_info = $mp->get_authorized_payment($_GET["id"]);
if ($payment_info["status"] == 200) {
$arquivo = fopen('result_ipn.php', 'a');
fwrite($arquivo, "\n<pre> " . json_encode($payment_info) . "</pre><br><hr><br>");
开发者ID:vvasconcellos,项目名称:mp2,代码行数:31,代码来源:ipn.php
示例20: function_mercado_pago
function function_mercado_pago($seperator, $sessionid)
{
global $wpdb, $wpsc_cart;
//This grabs the purchase log id from the database
//that refers to the $sessionid
$purchase_log = $wpdb->get_row("SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `sessionid`= " . $sessionid . " LIMIT 1", ARRAY_A);
//This grabs the users info using the $purchase_log
// from the previous SQL query
$usersql = "SELECT `" . WPSC_TABLE_SUBMITED_FORM_DATA . "`.value,\n\t\t`" . WPSC_TABLE_CHECKOUT_FORMS . "`.`name`,\n\t\t`" . WPSC_TABLE_CHECKOUT_FORMS . "`.`unique_name` FROM\n\t\t`" . WPSC_TABLE_CHECKOUT_FORMS . "` LEFT JOIN\n\t\t`" . WPSC_TABLE_SUBMITED_FORM_DATA . "` ON\n\t\t`" . WPSC_TABLE_CHECKOUT_FORMS . "`.id =\n\t\t`" . WPSC_TABLE_SUBMITED_FORM_DATA . "`.`form_id` WHERE\n\t\t`" . WPSC_TABLE_SUBMITED_FORM_DATA . "`.`log_id`=" . $purchase_log['id'];
$userinfo = $wpdb->get_results($usersql, ARRAY_A);
// configs
$data = array();
$data['client_id'] = get_option('mercadopago_client_id');
$data['client_secret'] = get_option('mercadopago_client_secret');
$data['sucess'] = get_option('mercadopago_url_sucess');
$data['pending'] = get_option('mercadopago_url_pending');
$data['currency'] = get_option('mercadopago_currency');
$sandbox = get_option('mercadopago_sandbox') == "active" ? true : false;
$type_checkout = get_option('mercadopago_typecheckout');
$category = get_option('mercadopago_category');
// order info
$data['total'] = $wpsc_cart->total_price;
//client
$arr_info = array();
foreach ((array) $userinfo as $key => $value) {
$arr_info[$value['unique_name']] = $value['value'];
}
// products
foreach ($wpsc_cart->cart_items as $i => $Item) {
$data['PROD_NAME' . $i] = $Item->product_name;
$data['PROD_TOTAL' . $i] = number_format($Item->unit_price, 2);
$data['PROD_NUMBER' . $i] = $i;
$data['PROD_QTY' . $i] = $Item->quantity;
$data['prod'] .= $Item->product_name . '*' . $Item->quantity;
if ($Item->thumbnail_image) {
foreach ($Item->thumbnail_image as $key => $Image) {
if ($key == 'guid') {
$data['image' . $i] = $Image;
}
}
} else {
$data['image0'] = 'https://www.mercadopago.com/org-img/MP3/home/logomp3.gif';
}
}
// exclude methods
$shippingpostcode = array_key_exists("shippingpostcode", $arr_info) && $arr_info['shippingpostcode'] != "" ? $arr_info['shippingpostcode'] : "uninformed";
$shippingaddress = array_key_exists("shippingaddress", $arr_info) && $arr_info['shippingaddress'] != "" ? $arr_info['shippingaddress'] : "uninformed";
$shippingcity = array_key_exists("shippingcity", $arr_info) && $arr_info['shippingcity'] != "" ? $arr_info['shippingcity'] : "uninformed";
$shippingstate = array_key_exists("shippingstate", $arr_info) && $arr_info['shippingstate'] != "" ? $arr_info['shippingstate'] : "uninformed";
$shippingcountry = array_key_exists("shippingcountry", $arr_info) && $arr_info['shippingcountry'] != "" ? $arr_info['shippingcountry'] : "uninformed";
$shipments = array("receiver_address" => array("floor" => "-", "zip_code" => $shippingpostcode, "street_name" => $shippingaddress . " - " . $shippingcity . " - " . $shippingstate . " - " . $shippingcountry, "apartment" => "-", "street_number" => "-"));
$billingpostcode = array_key_exists("billingpostcode", $arr_info) && $arr_info['billingpostcode'] != "" ? $arr_info['billingpostcode'] : "uninformed";
$billingaddress = array_key_exists("billingaddress", $arr_info) && $arr_info['billingaddress'] != "" ? $arr_info['billingaddress'] : "uninformed";
$billingcity = array_key_exists("billingcity", $arr_info) && $arr_info['billingcity'] != "" ? $arr_info['billingcity'] : "uninformed";
$billingstate = array_key_exists("billingstate", $arr_info) && $arr_info['billingstate'] != "" ? $arr_info['billingstate'] : "uninformed";
$billingcountry = array_key_exists("billingcountry", $arr_info) && $arr_info['billingcountry'] != "" ? $arr_info['billingcountry'] : "uninformed";
$billingphone = array_key_exists("billingphone", $arr_info) && $arr_info['billingphone'] != "" ? $arr_info['billingphone'] : "uninformed";
$payer = array("name" => $data['billingfirstname'], "surname" => $data['billinglastname'], "email" => $data['email'], "date_created" => "", "phone" => array("area_code" => "-", "number" => $billingphone), "address" => array("zip_code" => $billingpostcode, "street_name" => $billingaddress . " - " . $billingcity . " - " . $billingstate . " - " . $billingcountry, "street_number" => "-"), "identification" => array("number" => "null", "type" => "null"));
$items = array(array("id" => $sessionid, "title" => $data['PROD_NAME0'], "description" => $data['PROD_NAME0'] . " x " . $data['PROD_QTY0'], "quantity" => 1, "unit_price" => $data['total'], "currency_id" => $data['currency'], "picture_url" => $data['image0'], "category_id" => $category));
//excludes_payment_methods
$exclude = get_option('mercadopago_methods');
$installments = (int) get_option('mercadopago_limit_payments');
if ($exclude != '') {
//case exist exclude methods
$methods_excludes = preg_split("/[\\s,]+/", $exclude);
$excludemethods = array();
foreach ($methods_excludes as $exclude) {
if ($exclude != "") {
$excludemethods[] = array('id' => $exclude);
}
}
$payment_methods = array("installments" => $installments, "excluded_payment_methods" => $excludemethods);
} else {
//case not exist exclude methods
$payment_methods = array("installments" => $installments);
}
//set back url
$back_urls = array("pending" => $data['pending'], "success" => $data['sucess']);
//mount array pref
$pref = array();
$
|
请发表评论