Is there a way to use two types of payment methods in a transaction on the market?

Asked

Viewed 786 times

12

For example I want to sell a product that includes membership and tuition, R$X,XX + R$X,XX automatic debit.

Example of automatic debit:

$preapproval_data = array(
        "payer_email" => "[email protected]",
        "back_url" => "http://www.google.com",
        "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);

Example of simple payment:

$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);

Would you have some way to create a transaction that includes the two payment methods?

  • 1

    Is there a way to do that? Of course there is. But I doubt that anyone will do it for you without you having shown that things have already tried you..

  • 1

    Exactly, it will be difficult to help people. Put there what you have tried that is easier.

1 answer

4


Unfortunately the current Free Market API does not yet allow multiple forms of payment per order, but you can manage this internally, and if necessary create two transactions for each order (do not recommend if it is not extremely important for your business, since you will have more complexity to manage billing, and may have problems with chargeback when any of the cards is refused).

If even with the above reservations it is interesting for you to apply the concept:

Change your order table by adding two columns to save the ids of the two transactions (easy way) or modify your modeling to support multiple forms of payment per order (difficult way, requires a new table containing the payment methods associated with the order 1/N), so if the customer chooses to pay with two cards, you will be able to record the data of both payments.

Note the fact that if one of the transactions is refused, the other must be hampered.

  • So Felipe, I guess "Is not possible" is always a valid answer, and even a "It is not recommended", but I think that, in these cases, at the very least, it is necessary to explain because is impossible, or not recommended. In fact, in this case I think the ideal would be for you to demonstrate how to create the two transactions internally for each order, and during this demonstration, explain why it is not recommended.

  • @gustavox the doubt it is about the integration the format of two transactions per order in general requires adaptations in the database I will follow your tip but I think it escapes the challenge

  • Cool Felipe, the more you improve your response, the greater the chance it will be well received by the community. I of you would still put some example code, even if it is just to illustrate a point.... Anyway, you were the only one who was willing to make an answer, and deserve at least my +1. Thanks.

  • I did the process in two steps same, first with the payment of the membership and then I made the process of payment of the subscription... until the moment this functional, I thank for the answers of vcs.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.