{"id":3376,"date":"2021-03-05T21:23:06","date_gmt":"2021-03-05T21:23:06","guid":{"rendered":"https:\/\/documents.openpay.mx\/?p=3376"},"modified":"2022-05-23T16:30:10","modified_gmt":"2022-05-23T16:30:10","slug":"op-form-charge","status":"publish","type":"post","link":"https:\/\/documents-mx-dev.opdevhm.com\/en\/docs\/op-form-charge.html","title":{"rendered":"Redirect"},"content":{"rendered":"
\n\t\t\t\t\t\t
\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t
\n\t\t\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t\t\tOtra forma de hacer cargos con tarjeta sin la necesidad de implementar un formulario de pago en tu sitio, es mediante la utilizaci\u00f3n de un formulario que Openpay proporciona.\n\nResumen de pasos:\n
    \n \t
  1. Create a charge that contains the attribute confirm<\/b> in false<\/b> and a url to which to address once the payment is completed.<\/li>\n \t
  2. Based on the response of the created charge, redirect the user to the url contained in the object payment_method returned.<\/li>\n \t
  3. That the client fill in the requested information and make the payment in the form.<\/li>\n \t
  4. If the payment was successful click on the continue button.<\/li>\n \t
  5. Payment is made.<\/li>\n<\/ol>\n

    Creation of the charge<\/h2>\n
    Example of creating a charge using the Openpay payment form.<\/blockquote>\n
    \n
    \n
     \n    $openpay<\/span> =<\/span> Openpay<\/span>::<\/span>getInstance<\/span>(<\/span>'mzdtln0bmtms6o3kck8f'<\/span>,<\/span> 'sk_e568c42a6c384b7ab02cd47d2e407cab'<\/span>);<\/span>\n    $customer<\/span> =<\/span> array<\/span><\/strong>(<\/span>\n        'name'<\/span> =><\/span> 'Mario'<\/span>,<\/span>\n        'last_name'<\/span> =><\/span> 'Benedetti Farrugia'<\/span>,<\/span>\n        'phone_number'<\/span> =><\/span> '1111111111'<\/span>,<\/span>\n        'email'<\/span> =><\/span> 'mario_benedetti@miempresa.mx'<\/span>);<\/span>\n    $chargeRequest<\/span> =<\/span> array<\/span>(<\/span>\n        \"method\"<\/span> :<\/span> \"card\"<\/span>,<\/span>\n        'amount'<\/span> =><\/span> 111<\/span>,<\/span>\n        'description'<\/span> =><\/span> 'Cargo desde terminal virtual de 111'<\/span>,<\/span>\n        'customer'<\/span> =><\/span> $customer<\/span>,<\/span>\n        'send_email'<\/span> =><\/span> false<\/span><\/strong>,<\/span>\n        'confirm'<\/span> =><\/span> false<\/span><\/strong>,<\/span>\n        'redirect_url'<\/span> =><\/span> 'http:\/\/www.openpay.mx\/index.html'<\/span>\n    )<\/span> ;<\/span>\n    $charge<\/span> =<\/span> $openpay<\/span>-><\/span>charges<\/span>-><\/span>create<\/span>(<\/span> $chargeRequest<\/span>);<\/span><\/code><\/pre>\n<\/figure>\n<\/div>\n

    Redirect to the Openpay form<\/h2>\nIf the call is correct then a response will be returned with a transaction object.<\/a> in the pending state represented in the language used.\n\nResponse:<\/strong>\n
    \n
    {<\/span>\n  \"id\"<\/span>:<\/span> \"trq7yrthx5vc4gtjdkwg\"<\/span>,<\/span>\n  \"authorization\"<\/span>:<\/span> null<\/span><\/strong>,<\/span>\n  \"method\"<\/span>:<\/span> \"card\"<\/span>,<\/span>\n  \"operation_type\"<\/span>:<\/span> \"in\"<\/span>,<\/span>\n  \"transaction_type\"<\/span>:<\/span> \"charge\"<\/span>,<\/span>\n  \"status\"<\/span>:<\/span> \"charge_pending\"<\/span>,<\/span>\n  \"conciliated\"<\/span>:<\/span> false<\/span><\/strong>,<\/span>\n  \"creation_date\"<\/span>:<\/span> \"2016-09-09T18:52:02-05:00\"<\/span>,<\/span>\n  \"operation_date\"<\/span>:<\/span> \"2016-09-09T18:52:02-05:00\"<\/span>,<\/span>\n  \"description\"<\/span>:<\/span> \"Cargo desde terminal virtual de 111\"<\/span>,<\/span>\n  \"error_message\"<\/span>:<\/span> null<\/span><\/strong>,<\/span>\n  \"amount\"<\/span>:<\/span> 111<\/span>,<\/span>\n  \"currency\"<\/span>:<\/span> \"MXN\"<\/span>,<\/span>\n  \"payment_method\"<\/span>:<\/span> {<\/span>\n    \"type\"<\/span>:<\/span> \"redirect\"<\/span>,<\/span>\n    \"url\"<\/span>:<\/span> \"https:\/\/sandbox-api.openpay.mx\/v1\/mexzhpxok3houd5lbvz1\/charges\/trq7yrthx5vc4gtjdkwg\/card_capture\"<\/span><\/em><\/strong>\n  },<\/span>\n  \"customer\"<\/span>:<\/span> {<\/span>\n    \"name\"<\/span>:<\/span> \"Mario\"<\/span>,<\/span>\n    \"last_name\"<\/span>:<\/span> \"Benedetti Farrugia\"<\/span>,<\/span>\n    \"email\"<\/span>:<\/span> \"mario_benedetti@miempresa.mx\"<\/span>,<\/span>\n    \"phone_number\"<\/span>:<\/span> \"1111111111\"<\/span>,<\/span>\n    \"creation_date\"<\/span>:<\/span> \"2016-09-09T18:52:02-05:00\"<\/span>,<\/span>\n    \"clabe\"<\/span>:<\/span> null<\/span><\/strong>,<\/span>\n    \"external_id\"<\/span>:<\/span> null<\/span><\/strong>\n  }<\/span>\n}<\/span><\/code><\/pre>\n<\/figure>\nRedirect the user to the url contained in the url attribute that is inside the payment_method object.\n\n\"Formulario\n

    Fill payment data<\/h2>\nThat the user fill in the requested information and click on Make payment<\/em><\/strong>\n\n\"Llenar\n

    Click on Continue<\/h2>\nIf the payment was successful the user clicked on Continue<\/em><\/strong>\n\n\"Pago\n\nThis redirects to the url that was provided when creating the charge (in the case of the Openpay page example), terminating the payment flow.\n\n\"Redirect\n
    Notes:<\/strong>\n