Skip to content

Instantly share code, notes, and snippets.

@iDavidMorales
Created August 24, 2018 20:50
Show Gist options
  • Save iDavidMorales/4afe91c64c2bd65766279418131145c9 to your computer and use it in GitHub Desktop.
Save iDavidMorales/4afe91c64c2bd65766279418131145c9 to your computer and use it in GitHub Desktop.
<?
header('Access-Control-Allow-Origin: *');
//require_once("lib/Conekta.php");
require_once("conekta-php/lib/Conekta.php");
\Conekta\Conekta::setApiKey("key_wCompRCWsQmjFvNNWgdGryQ");
\Conekta\Conekta::setApiVersion("2.0.0");
//$token_id=$_POST['token'];
try{
$order = \Conekta\Order::create(
array(
"line_items" => array(
array(
"name" => "Tacoss",
"unit_price" => 10000,
"quantity" => 12
)//first line_item
), //line_items
"shipping_lines" => array(
array(
"amount" => 15000,
"carrier" => "FEDEX"
)
), //shipping_lines - physical goods only
"currency" => "MXN",
"customer_info" => array(
"customer_id" => "cus_2j9UbTbPwVANCprzg"
), //customer_info
"shipping_contact" => array(
"address" => array(
"street1" => "Calle 123, int 2",
"postal_code" => "06100",
"country" => "MX"
)//address
), //shipping_contact - required only for physical goods
"metadata" => array("reference" => "129817324097", "more_info" => "la2lalalala"),
"charges" => array(
array(
"payment_method" => array(
"type" => "default"
) //payment_method - use customer's default - a card
//to charge a card, different from the default,
//you can indicate the card's source_id as shown in the Retry Card Section
) //first charge
) //charges
)//order
);
} 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