本文整理汇总了PHP中MP::sandbox_mode方法的典型用法代码示例。如果您正苦于以下问题:PHP MP::sandbox_mode方法的具体用法?PHP MP::sandbox_mode怎么用?PHP MP::sandbox_mode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MP
的用法示例。
在下文中一共展示了MP::sandbox_mode方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
});
}
示例2: 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;
示例3: retorno
public function retorno()
{
if (isset($_REQUEST['id'])) {
$id = $_REQUEST['id'];
$client_id = $this->config->get('mercadopago2_client_id');
$client_secret = $this->config->get('mercadopago2_client_secret');
$sandbox = $this->config->get('mercadopago2_sandbox') == 1 ? true : null;
//$checkdata = New Shop($client_id,$client_secret);
$mp = new MP($client_id, $client_secret);
$mp->sandbox_mode($sandbox);
//$dados = $checkdata->GetStatus($id);
$dados = $mp->get_payment_info($id);
$dados = $dados['response'];
$order_id = $dados['collection']['external_reference'];
$order_status = $dados['collection']['status'];
$this->load->model('checkout/order');
$order = $this->model_checkout_order->getOrder($order_id);
if ($order['order_status_id'] == '0') {
$this->model_checkout_order->confirm($order_id, $this->config->get('mercadopago_order_status_id'));
}
switch ($order_status) {
case 'approved':
$this->model_checkout_order->update($order_id, $this->config->get('mercadopago2_order_status_id_completed'));
break;
case 'pending':
$this->model_checkout_order->update($order_id, $this->config->get('mercadopago2_order_status_id_pending'));
break;
case 'in_process':
$this->model_checkout_order->update($order_id, $this->config->get('mercadopago2_order_status_id_process'));
break;
case 'reject':
$this->model_checkout_order->update($order_id, $this->config->get('mercadopago2_order_status_id_rejected'));
break;
case 'refunded':
$this->model_checkout_order->update($order_id, $this->config->get('mercadopago2_order_status_id_refunded'));
break;
case 'cancelled':
$this->model_checkout_order->update($order_id, $this->config->get('mercadopago2_order_status_id_cancelled'));
break;
case 'in_metiation':
$this->model_checkout_order->update($order_id, $this->config->get('mercadopago2_order_status_id_in_mediation'));
break;
default:
$this->model_checkout_order->update($order_id, $this->config->get('mercadopago2_order_status_id_pending'));
break;
}
echo "ID: " . $id . " - Status: " . $order_status;
}
}
示例4: dirname
<?php
//define( 'SHORTINIT', true );
require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/wp-load.php';
$payments_others = unserialize(get_option('carrental_available_payments_others'));
if (is_file(dirname(dirname(__FILE__)) . '/carrental-payments-mercadopago/mercadopago.php') && $payments_others && !empty($payments_others) && isset($payments_others['eway']) && $payments_others['eway']['enabled'] == 'yes') {
require_once dirname(dirname(__FILE__)) . '/carrental-payments-mercadopago/mercadopago.php';
$mp = new MP($payments_others['mercadopago']['client-id'], $payments_others['mercadopago']['client-secret']);
$mp->sandbox_mode(false);
try {
$response = $mp->get_payment($_GET['id']);
file_put_contents('mercadopago_ipn.log', print_r($response, true) . "\n\n-------------------------------------\n\n", FILE_APPEND);
} catch (Exception $e) {
file_put_contents('mercadopago_ipn.log', print_r($response, true) . "\n\n-------------------------------------\n\n", FILE_APPEND);
file_put_contents('mercadopago_ipn.log', 'ERROR: ' . $e->getMessage() . "\n\n-------------------------------------\n\n", FILE_APPEND);
exit;
}
//file_put_contents('mercadopago_ipn.log', print_r($response, true), FILE_APPEND . "\n\n-------------------------------------\n\n");
if ($response) {
if (isset($response['response']) && isset($response['response']['collection']) && isset($response['response']['collection']['status']) && $response['response']['collection']['status'] == 'approved') {
// IPN response was "VERIFIED"
list($payment_id, $lang) = explode('#', $response['response']['collection']['external_reference']);
$wpdb->query($wpdb->prepare('UPDATE ' . CarRental::$db['booking'] . ' SET `paid_online` = ' . (double) $response['response']['collection']['total_paid_amount'] . ', `status` = 1 WHERE MD5(CONCAT(`id_order`, %s, `email`)) = %s', CarRental::$hash_salt, $payment_id));
file_put_contents('mercadopago_ipn.log', '***VERIFIED*** - ' . $wpdb->prepare('UPDATE ' . CarRental::$db['booking'] . ' SET `paid_online` = ' . (double) $response['response']['collection']['total_paid_amount'] . ', `status` = 1 WHERE MD5(CONCAT(`id_order`, %s, `email`)) = %s', CarRental::$hash_salt, $payment_id), FILE_APPEND);
// Send e-mail
if (isset($lang) && !empty($lang)) {
$emailBody = get_option('carrental_reservation_email_' . $lang);
if ($emailBody == '') {
$emailBody = get_option('carrental_reservation_email_en_GB');
}
$emailSubject = get_option('carrental_reservation_email_subject_' . $lang);
示例5: fopen
}
break;
case "authorized_payment":
$payment_info = $mp->get_authorized_payment($_GET["id"]);
if ($payment_info["status"] == 200) {
print_r($payment_info);
}
break;
}
*/
if ($_GET["topic"] == "payment") {
$mp->sandbox_mode(true);
$payment_info = $mp->get_payment_info($_GET["id"]);
// Show payment information
if ($payment_info["status"] == 200) {
$arquivo = fopen('result_ipn.php', 'a');
fwrite($arquivo, "\n<tr><td>" . $payment_info["response"]["collection"]["id"] . "</td>");
fwrite($arquivo, "\n<td>" . $payment_info["response"]["collection"]["status"] . "</td>");
fwrite($arquivo, "\n<td>" . $payment_info["response"]["collection"]["status_detail"] . "</td>");
fwrite($arquivo, "\n<td>" . $payment_info["response"]["collection"]["transaction_amount"] . "</td>");
fwrite($arquivo, "\n</tr>");
$arquivo = fopen('result_ipn.php', 'a');
fwrite($arquivo, "\n<tr><td colspan='4'> RESPONSE COLLECTION : " . json_encode($payment_info) . "</td>");
fwrite($arquivo, "\n</tr>");
fclose($arquivo);
fclose($arquivo);
}
示例6: Gateway
include ROOTDIR . DIRECTORY_SEPARATOR . 'includes/gatewayfunctions.php';
include ROOTDIR . DIRECTORY_SEPARATOR . 'includes/invoicefunctions.php';
include "../gmp/mercadopago.php";
$gatewayModule = 'gmp';
# Enter your gateway module name here replacing template
/**
* Ensure that the module is active before attempting to run any code
*/
$gateway = new Gateway();
if (!$gateway->isActiveGateway($gatewayModule) || !$gateway->load($gatewayModule)) {
Terminus::getInstance()->doDie('Module not Active');
}
$GATEWAY = $gateway->getParams();
$mp = new MP($GATEWAY['client_id'], $GATEWAY['client_secret']);
if ($GATEWAY['testmode']) {
$mp->sandbox_mode(TRUE);
}
$payment_info = $mp->get_payment_info($_GET["id"]);
$debug = array('json' => json_encode($payment_info));
$status = "0";
if ($payment_info["status"] == 200) {
$data = $payment_info["response"]["collection"];
if (!$data["sandbox"] && "approved" == $data["status"]) {
$transactionId = $data["id"];
$invoiceId = $data["external_reference"];
$amount = (double) $data["transaction_amount"];
$fee = (double) $data["transaction_amount"] - (double) $data["net_received_amount"];
$status = "1";
}
}
if ($status == "1") {
示例7: retorno
public function retorno()
{
if (isset($this->request->get['collection_id'])) {
if ($this->request->get['collection_id'] == 'null') {
$order_id = $this->request->get['external_reference'];
$this->load->model('checkout/order');
$this->model_checkout_order->addOrderHistory($order_id, $this->config->get('mp_standard_order_status_id_' . $this->request->get['status']), date('d/m/Y h:i'));
return;
}
$ids = explode(',', $this->request->get['collection_id']);
$client_id = $this->config->get('mp_standard_client_id');
$client_secret = $this->config->get('mp_standard_client_secret');
$sandbox = $this->config->get('mp_standard_sandbox') == 1 ? true : null;
$mp = new MP($client_id, $client_secret);
$mp->sandbox_mode($sandbox);
foreach ($ids as $id) {
$resposta = $mp->get_payment_info($id);
$dados = $resposta['response'];
$order_id = $dados['collection']['external_reference'];
$order_status = $dados['collection']['status'];
$this->load->model('checkout/order');
$order = $this->model_checkout_order->getOrder($order_id);
if ($order['order_status_id'] == '0') {
$this->model_checkout_order->addOrderHistory($order_id, $this->config->get('mp_standard_order_status_id'));
}
switch ($order_status) {
case 'approved':
$this->model_checkout_order->addOrderHistory($order_id, $this->config->get('mp_standard_order_status_id_completed'), date('d/m/Y h:i') . ' - ' . $dados['collection']['payment_method_id'] . ' - ' . $dados['collection']['net_received_amount']);
break;
case 'pending':
$this->model_checkout_order->addOrderHistory($order_id, $this->config->get('mp_standard_order_status_id_pending'), date('d/m/Y h:i') . ' - ' . $dados['collection']['payment_method_id'] . ' - ' . $dados['collection']['net_received_amount']);
break;
case 'in_process':
$this->model_checkout_order->addOrderHistory($order_id, $this->config->get('mp_standard_order_status_id_process'), date('d/m/Y h:i') . ' - ' . $dados['collection']['payment_method_id'] . ' - ' . $dados['collection']['net_received_amount']);
break;
case 'reject':
$this->model_checkout_order->addOrderHistory($order_id, $this->config->get('mp_standard_order_status_id_rejected'), date('d/m/Y h:i') . ' - ' . $dados['collection']['payment_method_id'] . ' - ' . $dados['collection']['net_received_amount']);
break;
case 'refunded':
$this->model_checkout_order->addOrderHistory($order_id, $this->config->get('mp_standard_order_status_id_refunded'), date('d/m/Y h:i') . ' - ' . $dados['collection']['payment_method_id'] . ' - ' . $dados['collection']['net_received_amount']);
break;
case 'cancelled':
$this->model_checkout_order->addOrderHistory($order_id, $this->config->get('mp_standard_order_status_id_cancelled'), date('d/m/Y h:i') . ' - ' . $dados['collection']['payment_method_id'] . ' - ' . $dados['collection']['net_received_amount']);
break;
case 'in_metiation':
$this->model_checkout_order->addOrderHistory($order_id, $this->config->get('mp_standard_order_status_id_in_mediation'), date('d/m/Y h:i') . ' - ' . $dados['collection']['payment_method_id'] . ' - ' . $dados['collection']['net_received_amount']);
break;
default:
$this->model_checkout_order->addOrderHistory($order_id, $this->config->get('mp_standard_order_status_id_pending'), date('d/m/Y h:i') . ' - ' . $dados['collection']['payment_method_id'] . ' - ' . $dados['collection']['net_received_amount']);
break;
}
}
} else {
error_log('id não setado na compra!!!');
}
}
示例8: __construct
public function __construct($client_id, $client_secret, $sandbox)
{
$mp = new \MP($client_id, $client_secret);
$mp->sandbox_mode($sandbox);
$this->mp = $mp;
}
示例9: carrental_confirm_reservation
/**
* Booking 4/4
*/
public static function carrental_confirm_reservation()
{
$order_hash = self::save_booking($_POST);
if ((int) $_POST['paypal'] == 1 && (double) $_POST['total_rental'] > 0) {
$paypal = get_option('carrental_paypal');
$available_payments = unserialize(get_option('carrental_available_payments'));
if (isset($available_payments) && isset($available_payments['carrental-paypal-security-deposit']) && (double) $available_payments['carrental-paypal-security-deposit'] > 0) {
// if paypal security deposit is set
$_POST['total_rental'] = $_POST['total_rental'] * ((double) $available_payments['carrental-paypal-security-deposit'] / 100);
if (isset($available_payments['carrental-paypal-security-deposit-round'])) {
if ($available_payments['carrental-paypal-security-deposit-round'] == 'up') {
$_POST['total_rental'] = ceil($_POST['total_rental']);
} elseif ($available_payments['carrental-paypal-security-deposit-round'] == 'down') {
$_POST['total_rental'] = floor($_POST['total_rental']);
} else {
$_POST['total_rental'] = round($_POST['total_rental'], 2);
}
} else {
$_POST['total_rental'] = round($_POST['total_rental'], 2);
}
}
// Redirect to PayPal
$query = array();
$query['cmd'] = '_xclick';
$query['business'] = $paypal;
$query['email'] = $_POST['email'];
$query['item_name'] = 'Car Rental Reservation #' . $order_hash;
$query['quantity'] = 1;
$query['return'] = home_url() . '?page=carrental&payment=paypal&summary=' . $order_hash;
$query['item_number'] = $order_hash;
$query['custom'] = isset($_SESSION['carrental_language']) && !empty($_SESSION['carrental_language']) ? $_SESSION['carrental_language'] : 'en_GB';
$query['notify_url'] = CARRENTAL__PLUGIN_URL . 'paypal_ipn.php';
$query['cancel_return'] = $_SERVER['HTTP_REFERER'] . '&paymentError=1';
$query['amount'] = number_format((double) $_POST['total_rental'], 2, '.', '');
$query['currency_code'] = $_POST['currency_code'];
// Prepare query string
$query_string = http_build_query($query);
Header('Location: https://www.paypal.com/cgi-bin/webscr?' . $query_string);
return;
}
// is it eway payment?
if ($_POST['payment_option'] == 'eway' && (double) $_POST['total_rental'] > 0) {
$payments_others = unserialize(get_option('carrental_available_payments_others'));
if ($payments_others && !empty($payments_others) && isset($payments_others['eway']) && $payments_others['eway']['enabled'] == 'yes' && (double) $payments_others['eway']['security-deposit'] > 0) {
$_POST['total_rental'] = $_POST['total_rental'] * ((double) $payments_others['eway']['security-deposit'] / 100);
if (isset($payments_others['eway']['security-deposit-round'])) {
if ($payments_others['eway']['security-deposit-round'] == 'up') {
$_POST['total_rental'] = ceil($_POST['total_rental']);
} elseif ($payments_others['eway']['security-deposit-round'] == 'down') {
$_POST['total_rental'] = floor($_POST['total_rental']);
} else {
$_POST['total_rental'] = round($_POST['total_rental'], 2);
}
} else {
$_POST['total_rental'] = round($_POST['total_rental'], 2);
}
require_once dirname(dirname(__FILE__)) . '/carrental-payments-eway/RapidAPI.php';
$request = new eWAY\CreateAccessCodesSharedRequest();
$request->Payment->TotalAmount = number_format((double) $_POST['total_rental'], 2, '.', '') * 100;
// Amount is in cents, 100 = $1.00
//$request->Payment->CurrencyCode = 'AUD';//$_POST['currency_code'];
$request->Payment->InvoiceReference = $order_hash;
$request->Options->Option[] = isset($_SESSION['carrental_language']) && !empty($_SESSION['carrental_language']) ? $_SESSION['carrental_language'] : 'en_GB';
$request->RedirectUrl = CARRENTAL__PLUGIN_URL . 'eway_ipn.php';
$request->CancelUrl = $_SERVER['HTTP_REFERER'] . '&ewayError=1';
$service = new eWAY\RapidAPI($payments_others['eway']['api-key'], $payments_others['eway']['api-password']);
//print_r($request);die();
// Get the AccessCode
$result = $service->CreateAccessCodesShared($request);
if (!empty($result->Errors)) {
die(eWAY\ResponseCode::getMessage($result->Errors));
}
// Send the customer to eWAY to pay
header("Location: " . $result->SharedPaymentUrl);
exit;
}
}
// is it mercadopago payment?
if ($_POST['payment_option'] == 'mercadopago' && (double) $_POST['total_rental'] > 0) {
$payments_others = unserialize(get_option('carrental_available_payments_others'));
if ($payments_others && !empty($payments_others) && isset($payments_others['mercadopago']) && $payments_others['mercadopago']['enabled'] == 'yes' && (double) $payments_others['mercadopago']['security-deposit'] > 0) {
$_POST['total_rental'] = $_POST['total_rental'] * ((double) $payments_others['mercadopago']['security-deposit'] / 100);
if (isset($payments_others['mercadopago']['security-deposit-round'])) {
if ($payments_others['mercadopago']['security-deposit-round'] == 'up') {
$_POST['total_rental'] = ceil($_POST['total_rental']);
} elseif ($payments_others['mercadopago']['security-deposit-round'] == 'down') {
$_POST['total_rental'] = floor($_POST['total_rental']);
} else {
$_POST['total_rental'] = round($_POST['total_rental'], 2);
}
} else {
$_POST['total_rental'] = round($_POST['total_rental'], 2);
}
require_once dirname(dirname(__FILE__)) . '/carrental-payments-mercadopago/mercadopago.php';
$mp = new MP($payments_others['mercadopago']['client-id'], $payments_others['mercadopago']['client-secret']);
$sandbox = false;
$mp->sandbox_mode($sandbox);
//.........这里部分代码省略.........