Skip to content

Commit

Permalink
feat: Add customer creation functionality
Browse files Browse the repository at this point in the history
This commit adds the ability to create a customer using the Conekta API. It includes changes to import necessary classes, configure authorization with an API key, and make a POST request to create a new customer. The code now uses the `CustomersApi` class instead of the deprecated `AntifraudApi`.
  • Loading branch information
fcarrero committed Nov 12, 2024
1 parent 31db051 commit 2ed0e78
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,33 +48,34 @@ Please follow the [installation procedure](#installation--usage) and then run th
<?php
require_once(__DIR__ . '/vendor/autoload.php');


use 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 = "key_xxxxx";
$apiKey = getenv("CONEKTA_API_KEY");
$config = Conekta\Configuration::getDefaultConfiguration()->setAccessToken($apiKey);


$apiInstance = new Conekta\Api\AntifraudApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$create_risk_rules_data = new \Conekta\Model\CreateRiskRulesData(); // \Conekta\Model\CreateRiskRulesData | requested field for blacklist rule
$accept_language = es; // string | Use for knowing which language to use

$apiInstance = new CustomersApi(null, $config);
$rq = new Customer([
'name' => 'Franklin carrero',
'email'=> 'mm@gmail.com',
'phone' => '+5218181818181'
]);
try {
$result = $apiInstance->createRuleBlacklist($create_risk_rules_data, $accept_language);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling AntifraudApi->createRuleBlacklist: ', $e->getMessage(), PHP_EOL;
$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;
}


```

## API Endpoints
Expand Down

0 comments on commit 2ed0e78

Please sign in to comment.