PHP code example of conekta / conekta-php

1. Go to this page and download the library: Download conekta/conekta-php 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/ */

    

conekta / conekta-php example snippets





Conekta\Api\CustomersApi;
use Conekta\ApiException;
use Conekta\Configuration;
use Conekta\Model\Customer;

// Configure authorization
/**
 * @var string $apiKey use private key for authentication
 * @link https://developers.conekta.com/reference/autenticaci%C3%B3n for more information
 */
$apiKey =  getenv("CONEKTA_API_KEY");
$config = Conekta\Configuration::getDefaultConfiguration()->setAccessToken($apiKey);

$apiInstance = new CustomersApi(null, $config);
$rq = new Customer([
    'name' => 'Franklin carrero',
    'email'=> '[email protected]',
    'phone' => '+5218181818181'
]);
try {
    $result = $apiInstance->createCustomer($rq);
    $json_string = json_encode($result, JSON_PRETTY_PRINT);
    print_r($json_string);
} catch (ApiException $e) {
    echo 'Exception when calling CustomersApi->createCustomer: ', $e->getMessage(), PHP_EOL;
}


json
{
  "repositories": [
    {
      "type": "vcs",
      "url": "https://github.com/conekta/conekta-php.git"
    }
  ],
  "