Skip to content

Instantly share code, notes, and snippets.

@dancameron
Created April 18, 2013 16:12
Show Gist options
  • Select an option

  • Save dancameron/5413998 to your computer and use it in GitHub Desktop.

Select an option

Save dancameron/5413998 to your computer and use it in GitHub Desktop.
MP Process

get_mp_link()

Using a create_preference() function within MP class.

Response

[18-Apr-2013 15:39:33] create preference response: Array
(
   [status] => 201
   [response] => Array
        (
            [collector_id] => 131258484
            [operation_type] => regular_payment
            [items] => Array
                (
                    [0] => Array
                        (
                            [id] => 
                            [title] => Prime Theme
                            [currency_id] => ARS
                            [picture_url] => http://prime.gbmu.dev/wp-content/themes/prime-theme-beta/img/logo.png
                            [description] => 1*Suggested Deal; 
                            [quantity] => 1
                            [unit_price] => 29
                        )

                )

            [payer] => Array
                (
                    [email] => localdevelopment@sproutventure.com
                    [name] => Daniel
                    [surname] => Cameron
                )

            [back_urls] => Array
                (
                    [failure] => 
                    [error] => http://prime.gbmu.dev/checkout/
                    [pending] => http://prime.gbmu.dev/checkout/?mp_payment=1
                    [cancel] => http://prime.gbmu.dev/cart/
                    [success] => http://prime.gbmu.dev/checkout/?mp_payment=1
                )

            [payment_methods] => Array
                (
                    [excluded_payment_methods] => Array
                        (
                        )

                    [excluded_payment_types] => Array
                        (
                        )

                    [installments] => 
                )

            [client_id] => 963
            [marketplace] => NONE
            [marketplace_fee] => 0
            [external_reference] => 234
            [additional_info] => 
            [expires] => 
            [expiration_date_from] => 
            [expiration_date_to] => 
            [date_created] => 2013-04-18T11:39:27.467-04:00
            [id] => 131258484-de4bae20-c12a-4c25-9b11-f9135c1a4612
            [init_point] => https://www.mercadopago.com/mla/checkout/pay?pref_id=131258484-de4bae20-c12a-4c25-9b11-f9135c1a4612
            [sandbox_init_point] => https://sandbox.mercadopago.com/mla/checkout/pay?pref_id=131258484-de4bae20-c12a-4c25-9b11-f9135c1a4612
        )

)

The [id] is saved internally as the "token" for GBS to reference later.

Redirect to sandbox_init_point

https://sandbox.mercadopago.com/mla/checkout/pay?pref_id=131258484-de4bae20-c12a-4c25-9b11-f9135c1a4612

Return to website and check payment status

At this point there's only the payment preference that was returned in the first step to query the MP API to get the payment status.

I've used search_payment with the "token" (or payment preference 'id') and get_payment_info with the same "token".

For example: https://api.mercadolibre.com/sandbox/collections/search?site_id=MLA&id=131258484-de4bae20-c12a-4c25-9b11-f9135c1a4612&offset=0&limit=0&access_token=APP_USR-360806205579652-041811-3744932449b19329de645e3690bcc2d8__N_D__-131258484 Will return http://s-v.me/OOFK

get_payment_info uri example: https://api.mercadolibre.com/sandbox/collections/notifications/131258484-de4bae20-c12a-4c25-9b11-f9135c1a4612&access_token=APP_USR-360806205579652-041811-3744932449b19329de645e3690bcc2d8__N_D__-131258484 Will return http://s-v.me/OOaf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment