Prerequisites

  • Install and include one of the available libraries.
  • Use your own private key. If you don't already have your private key, you can get it here.

Step 1

Create one payment link.

The following snippet incorporates all of step 1. Copy and paste it into your sandbox and run the code in order to create a checkout object and send it by email or by SMS.

For more information on the different parts of the snippet please follow through the remainder of the tutorial.

Step 1.1

Associate a customer with payment link

If you want to create customers and associate them with the payment link then you can make the following two requests

Create the customer

Create payment link associated with that customer

Step 1.2

Share the url with your customer

In the response you can copy the attribute url with the customer to receive the payment.

Step 2.1

Optionally share it with a SMS message.

If you prefer we can send this url through our SMS service.

Step 2.2

Optionally share it with an email message

If you prefer we can send this url through our email service.

Step 3

Optionally receive the payment notification

If you have configured a webhook you will receive a charge.paid event when a payment is received.

[[exampler light

class WebhooksController < ApplicationController
  skip_before_filter :verify_authenticity_token 

  def receive
    data = JSON.parse(request.body.read)
    if data['type'] == 'charge.paid'
        msg = 'Tu pago ha sido comprobado'
        ExampleMailer.paid_email(data, msg)
      end
    end 

    render status: 200
  end
end
# N/A
$body = @file_get_contents('php://input');
$data = json_decode($body);
http_response_code(200); // Return 200 OK 

if ($data->type == 'charge.paid'){
  $msg = "Tu pago ha sido comprobado.";
  mail("fulanito##conekta.com","Pago confirmado",$msg);
}
//Using nodemailer
var data = typeof req.body == 'string' ? JSON.parse(req.body) : req.body; 

if (data.type == 'order.paid') {
  var mail = {
      from: me,
      to: you,
      subject: 'Pago comprobado',
      text: 'Tu pago ha sido confirmado.'
  };
  transporter.sendMail(mail, function(error, info){
      if(error){ return console.log(error); }
    });
}

import json 

data = json.loads(HttpRequest.body) 

if data.type == 'charge.paid':
  msg['Subject'] = 'Pago confirmado'
  msg['From'] = me
  msg['To'] = you 

  s = smtplib.SMTP('localhost')
  s.sendmail(me, [you], msg.as_string())
  s.quit()
end
import org.json.JSONObject;
  protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
      BufferedReader get_body = request.getReader(); 

      //Parse JSON
    }
using System.Net.Mail; 

public class ConektaWebhookController : Controller
    {
      MailMessage mail = new MailMessage(you, me); 

      [HttpPost]
      public ActionResult Index()
      {
          Stream req = Request.InputStream;
          req.Seek(0, System.IO.SeekOrigin.Begin); 

          string json = new StreamReader(req).ReadToEnd();
          var obj = JObject.Parse(json);
          var data = obj.SelectToken("data"); 

          if(data.Type == 'charge.paid'){
            mail.Subject = "Pago comprobado";
            mail.Body = "Tu pago ha sido confirmado.";
            client.Send(mail);
          } 

          return new HttpStatusCodeResult(HttpStatusCode.OK);
      }
  }

]]s