34 lines
818 B
PHP
34 lines
818 B
PHP
<?php
|
|
/**
|
|
* Ejemplo 2
|
|
* Como crear un charge a una tarjeta usando Culqi PHP.
|
|
*/
|
|
|
|
try {
|
|
// Usando Composer (o puedes incluir las dependencias manualmente)
|
|
require '../vendor/autoload.php';
|
|
|
|
// Configurar tu API Key y autenticación
|
|
$SECRET_KEY = "{SECRET KEY}";
|
|
$culqi = new Culqi\Culqi(array('api_key' => $SECRET_KEY));
|
|
|
|
// Creando Cargo a una tarjeta
|
|
$charge = $culqi->Charges->create(
|
|
array(
|
|
"amount" => 1000,
|
|
"capture" => true,
|
|
"currency_code" => "PEN",
|
|
"description" => "Venta de prueba",
|
|
"installments" => 0,
|
|
"email" => "test@culqi.com",
|
|
"metadata" => array("test"=>"test"),
|
|
"source_id" => "{token_id}"
|
|
)
|
|
);
|
|
// Respuesta
|
|
echo json_encode($charge);
|
|
|
|
} catch (Exception $e) {
|
|
echo json_encode($e->getMessage());
|
|
}
|