我对Mercado Pago QR POS集成有一些问题。使用mercado pago应用程序扫描时,收到错误消息“请重试或重试”。
参考链接-> https://www.mercadopago.com.mx/developers/en/guides/instore-payments/qr-payments/qr-pos/
这是我的代码。
$mercado_config = self::getMercadoPagoSettings($machine_id);
if (empty($mercado_config['access_token'])) {
$mercadopago = new MP($mercado_config['client_id'], $mercado_config['client_secret']);
} else {
$mercadopago = new MP($mercado_config['access_token']);
}
$data = [
"name" => "Mercado Pago QR POS",
"fixed_amount" => true,
"category" => null,
"store_id" => null,
"external_id" => "1000002"
];
$pos_result = $mercadopago->post([
"uri" => "/pos",
"data" => $data
]);
if ($pos_result['status'] == 201) { //means created
$pos_data = $pos_result['response'];
} else {
$callback_response = $callback_response = self::make_error($pos_result['status'], $pos_result['message']);
return false;
}
//start created an order with pending payment
$vpns = $encap_data['dynamic_data']['product_vpn'];
$vpn_prices = $encap_data['dynamic_data']['product_price'];
$split_vpn = explode(',', $vpns);
$split_price = explode(',', $vpn_prices);
$item = [];
foreach ($split_vpn as $key => $id) {
$info = Product::getMachineProduct($id, $machine_id);
$item[] = [
"id" => $info['id'],
"title" => $info['description'],
"quantity" => 1,
"currency_id" => "MXN",
"unit_price" => (float)$split_price[$key]
];
}
$payment_data = [
"transaction_amount" => $encap_data['trade_amount'],
"external_reference" => $encap_data['trade_no'],
"notification_url" => baseUrl(true) . self::API_CALLBACK_URL,
"items" => $item
];
$result = $mercadopago->post([
"uri" => sprintf("/mpmobile/instore/qr/%s/%s", $mercado_config['collector_id'], $pos_data['external_id']),
"data" => $payment_data
]);
这是$ pos_result为json格式的结果。
{
"id": 796827,
"qr": {
"image": "https://www.mercadopago.com/instore/merchant/qr/796827/c489565e98754353871d1099e88cd9f7fb1f896a7a30444ea076e59b04103635.png",
"template_document": "https://www.mercadopago.com/instore/merchant/qr/796827/template_c489565e98754353871d1099e88cd9f7fb1f896a7a30444ea076e59b04103635.pdf",
"template_image": "https://www.mercadopago.com/instore/merchant/qr/796827/template_c489565e98754353871d1099e88cd9f7fb1f896a7a30444ea076e59b04103635.png"
},
"status": "active",
"date_created": "2019-04-02T23:39:45.000-04:00",
"date_last_updated": "2019-04-02T23:39:45.000-04:00",
"uuid": "c489565e98754353871d109.......7a30444ea076e59b04103635",
"compatible_id": "75324bc51a60f0284bc87aa9cd34503........1e3d9e91f4e3c3382f9d9ccf36e846264a9a44fefa13066652a4325db0e241b71618182cc005077b793",
"user_id": 413200152,
"name": "Mercado Pago QR POS",
"fixed_amount": true,
"external_id": "1000002"
}
这是$ result以json格式的结果。
{
"id": "413200152-b6dafb77-a0b2-4b56-a1ea-dac03b69ebc2",
"items": [
{
"id": "54656",
"title": "Cheezels",
"quantity": 1,
"currency_id": "MXN",
"unit_price": 1,
"description": "",
"picture_url": ""
}
],
"collector_id": 413200152,
"collector": {},
"total_amount": 1,
"amount": 1,
"external_reference": "482-8888",
"operation_type": "regular_payment",
"payment_methods": {
"excluded_payment_methods": [
{
"id": ""
}
],
"excluded_payment_types": [
{
"id": "ticket"
},
{
"id": "atm"
},
{
"id": "digital_currency"
}
]
},
"marketplace": "NONE",
"marketplace_fee": 0,
"notification_url": "https://043d9f42.ngrok.io/v2/admin/vdps/default/mercado_payment_notifier",
"back_urls": {
"success": "",
"pending": "",
"failure": ""
},
"payer": {
"id": 0,
"email": "",
"identification": {
"number": "",
"type": ""
},
"address": {
"primary": false,
"zip": ""
},
"phone": {
"area_code": "",
"number": ""
}
},
"expires": false,
"additional_info": "",
"site_id": "MLM"
}
我已经尝试过几次了,但是还是行不通。如何整合QR POS方法是否正确?非常感谢您的帮助。提前致谢。让我知道是否需要任何信息。
应用程序的输出。 Mercado Libre Apps