本文整理汇总了PHP中MP::post方法的典型用法代码示例。如果您正苦于以下问题:PHP MP::post方法的具体用法?PHP MP::post怎么用?PHP MP::post使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MP
的用法示例。
在下文中一共展示了MP::post方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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()));
}
示例2: 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()));
}
示例3: MP
<?php
require_once 'mercadopago.php';
$mp = new MP('ACCESS_TOKEN');
$payment_data = array("transaction_amount" => 100, "token" => "ff8080814c11e237014c1ff593b57b4d", "description" => "Title of what you are paying for", "installments" => 1, "payer" => array("id" => "12345678"));
$payment = $mp->post("/v1/payments", $payment_data);
示例4: 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);
示例5: MP
<?php
require_once 'mercadopago.php';
$mp = new MP("ACCESS_TOKEN");
$customer = array("email" => "your.payer@email");
$saved_customer = $mp->get("/v1/customers/search", $customer);
$customer_id = $saved_customer["response"]["id"];
$card = $mp->post("/v1/customers/" . $customer_id . "/cards", array("token" => "ff8080814c11e237014c1ff593b57b4d"));
print_r($card);
示例6: createCard
private function createCard($token)
{
$country = $this->config->get('mp_transparente_country');
if ($country != "MPE") {
$id = $this->getCustomerId();
$access_token = $this->config->get('mp_transparente_access_token');
$mp = new MP($access_token);
$card = $mp->post("/v1/customers/" . $id . "/cards", array("token" => $token));
return $card;
}
}
示例7: MP
<?php
require_once 'mercadopago.php';
$mp = new MP("ACCESS_TOKEN");
$customer = $mp->post("/v1/customers", array("email" => "test@test.com"));
print_r($customer);
示例8: MP
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once "lib/mercadopago.php";
$mp = new MP("APP_USR-6637655320562965-033110-3f688757fc570ebb8aa273bd614da586__LD_LB__-95095923");
$public_key = "APP_USR-596d5be0-0aae-44fe-aadf-64412d5e2941";
$cardata = array("card_number" => "4766081158832200", "security_code" => "123", "expiration_month" => 05, "expiration_year" => 2018, "cardholder" => array("name" => "JOAO ALMEIDA", "identification" => array("number" => "22488578029", "type" => "CPF")));
$Result = MPRestClient::post("/v1/card_tokens?public_key={$public_key}", $cardata);
echo "<H3> 1 - Tokenization credit card </H3>";
echo "<br>Card_token: " . $Result["response"]["id"];
echo "<br>Status: " . $Result["response"]["status"];
echo "<br>Card_Holder: " . $Result["response"]["cardholder"]["name"];
echo "<hr>";
echo "<pre>";
print_r($Result);
echo "</pre>";
$payment_preference = array("token" => $Result["response"]["id"], "installments" => 1, "transaction_amount" => 7.49, "description" => "Teste payments v1", "payment_method_id" => "visa", "statement_descriptor" => "EBANX", "binary_mode" => true, "payer" => array("email" => "victor_vhv99@gmail.com"), "additional_info" => array("items" => array(array("id" => "1234", "title" => "Produto Teste", "description" => "Produto Teste novo", "picture_url" => "https=>//google.com.br/images?image.jpg", "category_id" => "others", "quantity" => 1, "unit_price" => 12.3)), "payer" => array("first_name" => "", "last_name" => "", "registration_date" => "", "phone" => array("area_code" => "", "number" => ""), "address" => array("zip_code" => "", "street_name" => "", "street_number" => "")), "shipments" => array("receiver_address" => array("zip_code" => "", "street_name" => "", "street_number" => "", "floor" => "0", "apartment" => "0"))));
$response_payment = $mp->post("/v1/payments", $payment_preference);
echo "<H3> 2 - Post Payment </H3>";
echo "<br>Payment_Id: " . $response_payment["response"]["id"];
echo "<br>Status: " . $response_payment["response"]["status"];
echo "<br>Status_detail: " . $response_payment["response"]["status_detail"];
echo "<br>Descriptor: " . $response_payment["response"]["statement_descriptor"];
echo "<pre>";
print_r($response_payment);
echo "</pre>";
?>
</body>
</html>
示例9: MP
<?php
ini_set('display_errors', 1);
ini_set('display_startup_erros', 1);
error_reporting(E_ALL);
require_once "lib/mercadopago.php";
$mp = new MP("APP_USR-6637655320562965-033110-3f688757fc570ebb8aa273bd614da586__LD_LB__-95095923");
$payment_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" => "victorvthv@gmail.com", "first_name" => "", "last_name" => "", "phone" => array("area_code" => "", "number" => ""), "identification" => array("type" => "", "number" => ""), "address" => array("zip_code" => "", "street_name" => "", "street_number" => ""), "registration_date" => ""), "shipments" => array("receiver_address" => array("zip_code" => "", "street_name" => "", "street_number" => "", "floor" => "", "apartment" => "")));
$response_payment = $mp->post("/checkout/custom/create_payment", $payment_preference);
echo "<pre> <H1> 2 - Post Payment </H1>";
print_r($response_payment);
echo "</pre>";
?>
示例10: MP
<?php
ini_set('display_errors', 1);
ini_set('display_startup_erros', 1);
error_reporting(E_ALL);
require_once "lib/mercadopago.php";
$mp = new MP("Set your access token long live");
$email_buyer = "test_user_28757719@testuser.com";
$payment_preference = array("token" => $_REQUEST['token'], "installments" => 1, "transaction_amount" => round((double) $_REQUEST['amount'], 2), "external_reference" => "order code 1234xxxx", "binary_mode" => true, "description" => "Teste payments v1", "payment_method_id" => $_REQUEST['paymentMethodId'], "statement_descriptor" => "*MEUTESTE", "binary_mode" => true, "payer" => array("email" => $email_buyer), "additional_info" => array("items" => array(array("id" => "1234", "title" => "Aqui coloca os itens do carrinho", "description" => "Produto Teste novo", "picture_url" => "https://google.com.br/images?image.jpg", "category_id" => "others", "quantity" => 1, "unit_price" => round((double) $_REQUEST['amount'], 2))), "payer" => array("first_name" => "João", "last_name" => "Silva", "registration_date" => "2014-06-28T16:53:03.176-04:00", "phone" => array("area_code" => "5511", "number" => "3222-1000"), "address" => array("zip_code" => "05303-090", "street_name" => "Av. Queiroz Filho", "street_number" => "213")), "shipments" => array("receiver_address" => array("zip_code" => "05303-090", "street_name" => "Av. Queiroz Filho", "street_number" => "213", "floor" => "0", "apartment" => "0"))));
$response_payment = $mp->post("/v1/payments/", $payment_preference);
echo "<h3> ==== 1st Payment ===== </h3>";
echo "Payment Status:" . $response_payment["response"]["status"] . " - " . $response_payment["response"]["status_detail"];
// Check if user exist
echo "<h3> ==== Check if user exist ===== </h3>";
$check_user_exists = $mp->get("/v1/customers/search?email={$email_buyer}");
$id_user = $check_user_exists["response"]["results"][0]["id"];
if (!isset($id_user)) {
echo "<h3> ==== Create user ===== </h3>";
$user_preference = array("email" => $email_buyer, "first_name" => "João", "last_name" => "Silva");
$create_users = $mp->post("/v1/customers/", $user_preference);
print_r($create_users);
$id_user = $create_users["response"]["id"];
}
echo "<h3> ==== Create card ===== (Save in your datamodel) </h3>";
$card_preference = array("token" => $_REQUEST['token']);
$create_card = $mp->post("/v1/customers/{$id_user}/cards", $card_preference);
echo "<pre>";
print_r($create_card);
echo "</pre>";
$card_id = $create_card["response"]["id"];
$bandeira = $create_card["response"]["payment_method"]["id"];
示例11: MP
<?php
ini_set('display_errors', 1);
ini_set('display_startup_erros', 1);
error_reporting(E_ALL);
require_once "lib/mercadopago.php";
$mp = new MP("Set your access token long live");
$public_key = "Set your public key";
$card_id = $_GET['card_id'];
$id_user = $_GET['payer_id'];
$bandeira = $_GET['bandeira'];
$card_preference = array("card_id" => $card_id);
$card_token = $mp->post("/v1/card_tokens?public_key={$public_key}", $card_preference);
//print_r($card_token);
$payment_preference = array("token" => $card_token["response"]["id"], "installments" => 1, "transaction_amount" => 10.0, "external_reference" => "order code 1234xxxx", "binary_mode" => true, "description" => "Teste Recurring v1", "payment_method_id" => $bandeira, "statement_descriptor" => "*MEUTESTE", "binary_mode" => true, "payer" => array("id" => $id_user), "additional_info" => array("items" => array(array("id" => "1234", "title" => "Aqui coloca os itens do carrinho", "description" => "Produto Teste novo", "picture_url" => "https://google.com.br/images?image.jpg", "category_id" => "others", "quantity" => 1, "unit_price" => 10.0)), "payer" => array("first_name" => "João", "last_name" => "Silva", "registration_date" => "2014-06-28T16:53:03.176-04:00", "phone" => array("area_code" => "5511", "number" => "3222-1000"), "address" => array("zip_code" => "05303-090", "street_name" => "Av. Queiroz Filho", "street_number" => "213")), "shipments" => array("receiver_address" => array("zip_code" => "05303-090", "street_name" => "Av. Queiroz Filho", "street_number" => "213", "floor" => "0", "apartment" => "0"))));
$response_payment = $mp->post("/v1/payments/", $payment_preference);
echo "<h3> ==== Recurring Payment ===== </h3>";
echo "Payment Status:" . $response_payment["response"]["status"] . " - " . $response_payment["response"]["status_detail"];
echo "<pre>";
print_r($response_payment);
echo "</pre>";
?>