How do I use a newly created merchant_order for the user to make his payment?

0

I am developing a platform where the client will have the possibility to pay their dues of the plan that has been assigned to them. A seller is also assigned to this user, each vendor has his Mercado Pago account. Up to now the idea is to generate the payments with the client_id and secret_id of each vendor, so that the client pays directly to this vendor.

The problem arises in that I do not want to generate a preference for each user, since in the MP platform I will have the items to pay (ex: Plan 1, Plan 2, Plan 3), previously generated.

I found that Merchant order serves to link these preferences by their id and also add external references that I need in the API when I receive MercadoPago notification (IPN) to validate this payment.

The problem is that you use: $ mp- > post ('/ merchant_orders', $ merchant_order_data); to create the reference, but it does not return a payment link like the create_preference () method does.

How can I use merchant_order to link the tools that each vendor has created on their MP platform?

My code:

$merchant_order_data = array(...);

$merchant_order_info = $mp->get("/merchant_orders/" + merchant_order_data->id, false);

return response($merchant_order_info);

^ This returns a json with the data.

THANK YOU!

    
asked by Manuel Bruña 02.02.2017 в 16:36
source

2 answers

0

I was looking and found two things:

  • The merchant_orders are new and are not yet fully documented, creating a merchant_order does not work because in the end you have to link them to a preference_order and you end up on a redundant path.

  • The preference_order, in opposition to my thinking, is not replicated in the platform, so you can create infinities (volatile payment buttons) without the system listing them in the panel.

  • For the reason of case 2, choose to create the preferences with the client_id and client_secret of each MP account, in the database I keep the data that is generated, such as the link and payment amounts, plus I add data of external reference (external_referer) and the link to where I want the IPN to do, with the Id of the seller, when the IPN hits that link, the id of the merchant or of the payment with the credentials of the seller is reviewed.

    On the platform I return the payment link for the client to pay, then I wait for the IPN to show on the screen the status of the payment.

        
    answered by 03.02.2017 / 14:33
    source
    0

    If you are using IPNs when you create a preference, you receive a notification with the id of the% associated%, with this id you can consult the endpoint / merchant_orders /: id in whose answer you will find merchant_order that identifies the initial preference in which you can consult about the value of preference_id that you assigned.

        
    answered by 02.02.2017 в 19:59