Otra forma de hacer cargos con tarjeta sin la necesidad de implementar un formulario de pago en tu sitio, es mediante la utilización de un formulario que Openpay proporciona.
Resumen de pasos:
Create a charge that contains the attribute confirm in false and a url to which to address once the payment is completed.
Based on the response of the created charge, redirect the user to the url contained in the object payment_method returned.
That the client fill in the requested information and make the payment in the form.
If the payment was successful click on the continue button.
Payment is made.
Creation of the charge
Example of creating a charge using the Openpay payment form.
$openpay=Openpay::getInstance('mzdtln0bmtms6o3kck8f','sk_e568c42a6c384b7ab02cd47d2e407cab');$customer=array('name'=>'Mario','last_name'=>'Benedetti Farrugia','phone_number'=>'1111111111','email'=>'mario_benedetti@miempresa.mx');$chargeRequest=array("method":"card",'amount'=>111,'description'=>'Cargo desde terminal virtual de 111','customer'=>$customer,'send_email'=>false,'confirm'=>false,'redirect_url'=>'http://www.openpay.mx/index.html');$charge=$openpay->charges->create($chargeRequest);
Redirect to the Openpay form
If the call is correct then a response will be returned with a transaction object. in the pending state represented in the language used.
Response:
{"id":"trq7yrthx5vc4gtjdkwg","authorization":null,"method":"card","operation_type":"in","transaction_type":"charge","status":"charge_pending","conciliated":false,"creation_date":"2016-09-09T18:52:02-05:00","operation_date":"2016-09-09T18:52:02-05:00","description":"Cargo desde terminal virtual de 111","error_message":null,"amount":111,"currency":"MXN","payment_method":{"type":"redirect","url":"https://sandbox-api.openpay.mx/v1/mexzhpxok3houd5lbvz1/charges/trq7yrthx5vc4gtjdkwg/card_capture"},"customer":{"name":"Mario","last_name":"Benedetti Farrugia","email":"mario_benedetti@miempresa.mx","phone_number":"1111111111","creation_date":"2016-09-09T18:52:02-05:00","clabe":null,"external_id":null}}
Redirect the user to the url contained in the url attribute that is inside the payment_method object.
Fill payment data
That the user fill in the requested information and click on Make payment
Click on Continue
If the payment was successful the user clicked on Continue
This redirects to the url that was provided when creating the charge (in the case of the Openpay page example), terminating the payment flow.
Notes:
You can simulate different results using the cards Testing
Implement the Notifications to know the status of payments in real time