Skip to content

Instantly share code, notes, and snippets.

@iDavidMorales
Last active August 24, 2018 23:06
Show Gist options
  • Save iDavidMorales/37052ac5230463764106c2cff96e2c37 to your computer and use it in GitHub Desktop.
Save iDavidMorales/37052ac5230463764106c2cff96e2c37 to your computer and use it in GitHub Desktop.
<?
header('Access-Control-Allow-Origin: *');
//require_once("lib/Conekta.php");
$token_id = $_POST['token'];
require_once("conekta-php/lib/Conekta.php");
\Conekta\Conekta::setApiKey("key_wCompRCasdWsQmjFvNNWryQ");
\Conekta\Conekta::setApiVersion("2.0.0");
//$token_id=$_POST['token'];
try{
$customer = \Conekta\Customer::create(
array(
'name' => "Yosuel Cruz Ortiz",
'email' => "usuario@example.com",
'phone' => "+5215555555555",
//'plan_id' => "gold-plan",
'corporate' => true,
'antifraud_info' => array(
'account_created_at' => 1484040996,
'first_paid_at' => 1485151007
),
'payment_sources' => array(
'token_id' => "tok_test_visa_4242",// <----*
'type' => "card"
),
'shipping_contacts' => array(array(
'phone' => "+5215555555555",
'receiver' => "Marvin Fuller",
'between_streets' => "Morelos Campeche",
'address' => array(
'street1' => "Nuevo Leon 4",
'street2' => "fake street",
'city' => "Ciudad de Mexico",
'state' => "Ciudad de Mexico",
'country' => "MX",
'postal_code' => "06100",
'residential' => true
)
))
)
);
} catch (\Conekta\ProcessingError $error){
echo $error->getMessage();
} catch (\Conekta\ParameterValidationError $error){
echo $error->getMessage();
} catch (\Conekta\Handler $error){
echo $error->getMessage();
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment