Question:
For example I want to sell a product that includes membership and monthly fee, R$X,XX + R$X,XX automatic debit.
Automatic debit example:
$preapproval_data = array(
"payer_email" => "teste@email.com",
"back_url" => "http://www.google.com.br",
"reason" => "TESTE",
"external_reference" => "OP-1234",
"auto_recurring" => array(
"frequency" => 1,
"frequency_type" => "months",
"transaction_amount" => 0.5,
"currency_id" => "BRL",
"start_date" => "2016-09-20T20:58:11.778-03:00"
)
);
$preference = $mp->create_preapproval_payment($preapproval_data);
Simple payment example:
$preference_data = array(
"reason" => "Adesão",
"items" => array(
array(
"title" => "Adesão",
"currency_id" => "BRL",
"category_id" => "",
"quantity" => 1,
"unit_price" => 100
)
),
"payment_methods" => array(
"installments" => 24
)
);
$preference = $mp->create_preference($preference_data);
Is there any way to create a transaction that includes both payment methods ?
Answer:
Unfortunately, Mercado Livre's current API does not yet allow multiple payment methods per order, however you can manage this internally, and if necessary create two transactions for each order (I do not recommend it if it is not extremely important for your business, as you will have more complexity to manage billing, and you may have problems with chargebacks when any of your cards are declined).
If, even with the above reservations, it is interesting for you to apply the concept:
Change your order table by adding two columns to store the ids
of the two transactions ( easy way ) or modify your modeling to support multiple payment methods per order ( hard way, requires a new table containing the payment methods associated with order 1/N ), so if the customer chooses to pay with two cards, you will be able to record the details of both payments.
Please note that if one of the transactions is declined, the other must be reversed.