Created
September 3, 2019 17:18
-
-
Save joelibaceta/c0ae0caacdb12c6d363a86e83cfb3abb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require 'vendor/autoload.php'; | |
$culqi = new Culqi\Culqi(array('api_key' => $_ENV["API_KEY"])); | |
// Generar el token de Tarjeta | |
// Esto debe realizarse con el checkout o CulqiJS | |
// Crear el Plan | |
$plan = $culqi->Plans->create( | |
array( | |
"name" => "Plan de Prueba", | |
"amount" => 2500, | |
"currency_code" => "PEN", | |
"interval" => "meses", | |
"interval_count" => 1, | |
"limit" => 12 | |
) | |
); | |
// Crear el Customer | |
$customer = $culqi->Customers->create( | |
array( | |
"address" => "av lima 123", | |
"address_city" => "lima", | |
"country_code" => "PE", | |
"email" => "www." . rand(5, 10000) ."@me.com", | |
"first_name" => "Will", | |
"last_name" => "Muro", | |
"metadata" => array("test"=>"test"), | |
"phone_number" => 899898999 | |
) | |
); | |
// Asociar una tarjeta a un Customer | |
$card = $culqi->Cards->create( | |
array( | |
"customer_id" => $customer->id, | |
"token_id" => $_ENV["CARD_TOKEN"] | |
) | |
); | |
// Realizar la suscripción | |
$culqi->Subscriptions->create( | |
array( | |
"card_id" => $card->id, | |
"plan_id" => $plan->id | |
) | |
); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment