-
Notifications
You must be signed in to change notification settings - Fork 111
IPN Notifications
Joel Ibaceta edited this page Nov 29, 2018
·
5 revisions
MercadoPago API sends notifications from payments and subscriptions done. The notification comes with the following parameters:
-
topic: Identifies what kind of resource is
- merchant_order
- payment
- preapproval
- authorized_payment
-
id: Unique id of the notification
When you receive this notification you need to do a request to the appropiate endpoint to get the information of the merchant order or from a payment.
Merchant Order:
/merchant_orders/[ID]?access_token=[ACCESS_TOKEN]
Payment:
/v1/payments/[ID]?access_token=[ACCESS_TOKEN]
To simplify this flow, we provide a IPN Manager that will make the request to the endpoint thats appropriate. To use it you need to pass the request to the IPN Manager. Let's see how it works:
mercadopago.ipn.manage(request).then(function (response) {
console.log(response);
}).then(function (error) {
console.log(error);
});
The output will be:
mercadopagoIpnResponse {
body:
{ id: 2556382,
date_created: '2017-01-19T17:00:21.000-04:00',
date_approved: null,
date_last_updated: '2017-01-19T17:00:21.000-04:00',
money_release_date: null,
operation_type: 'regular_payment',
issuer_id: null,
payment_method_id: 'rapipago',
payment_type_id: 'ticket',
status: 'pending',
status_detail: 'pending_waiting_payment',
currency_id: 'ARS',
description: 'Descripción',
live_mode: false,
sponsor_id: null,
authorization_code: null,
collector_id: 239656545,
payer:
{ type: 'guest',
id: null,
email: 'test_user_3931694@testuser.com',
identification: [Object],
phone: [Object],
first_name: 'Test',
last_name: 'Test',
entity_type: null },
metadata: {},
order: {},
external_reference: null,
transaction_amount: 10,
transaction_amount_refunded: 0,
coupon_amount: 0,
differential_pricing_id: null,
deduction_schema: null,
transaction_details:
{ net_received_amount: 0,
total_paid_amount: 10,
overpaid_amount: 0,
external_resource_url: 'http://www.mercadopago.com/mla/sandbox/payments/ticket/helper?payment_method=rapipago',
installment_amount: 0,
financial_institution: null,
payment_method_reference_id: '2556383' },
fee_details: [],
captured: true,
binary_mode: false,
call_for_authorize_id: null,
statement_descriptor: null,
installments: 1,
card: {},
notification_url: null,
refunds: [] },
status: 200,
topic: 'payment'
}
Inside the response you will find the topic received on the request, so you dont need to get the value from it.