PHP code example of sairoko12 / conekta-php-namespaces

1. Go to this page and download the library: Download sairoko12/conekta-php-namespaces library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sairoko12 / conekta-php-namespaces example snippets


\Conekta\Conekta::setApiKey('1tv5yJp3xnVZ7eK67m4h');
try {
  $charge = \Conekta\Charge::create(array(
    "amount"=> 51000,
    "currency"=> "MXN",
    "description"=> "Pizza Delivery",
    "reference_id"=> "orden_de_id_interno",
    "card"=> $_POST['conektaTokenId']
    //"tok_a4Ff0dD2xYZZq82d9"
  ));
} catch (Conekta_Error $e) {
  echo $e->getMessage(); //Dev Message
  echo $e->message_to_purchaser;
  //El pago no pudo ser procesado
}

{
  "id": "5286828b8ee31e64b7001739",
  "livemode": false,
  "created_at": 1384546955,
  "status": "paid",
  "currency": "MXN",
  "description": "Some desc",
  "reference_id": null,
  "failure_code": null,
  "failure_message": null,
  "object": "charge",
  "amount": 2000,
  "fee": 371,
  "payment_method": {
    "name": "Mario Moreno",
    "exp_month": "05",
    "exp_year": "15",
    "auth_code": "861491",
    "object": "card_payment",
    "last4": "4242",
    "brand": "visa"
  },
  "details": {
    "name": null,
    "phone": null,
    "email": null,
    "line_items": []
  }
}