0byt3m1n1
Path:
/
home
/
kassiope
/
www
/
cb
/
stripe
/
[
Home
]
File: webhook.php
<?php require(__DIR__.'/../vendor/autoload.php'); include(__DIR__."/../configuration.inc.php"); // You can find your endpoint's secret in your webhook settings //\Stripe\Stripe::setApiKey('sk_live_4wF2vEnOryvzN9batekvH2HA'); //$endpoint_secret = 'whsec_oOjWls4ZqpKXUS4qKVPBsyEfO0WBJFAo'; \Stripe\Stripe::setApiKey($stripe_api_key); $endpoint_secret = $stripe_webhook; //\Stripe\Stripe::setApiKey('sk_test_AWISx3PpQCLaEJUfNgFGz2w7'); // TEST //$endpoint_secret = 'whsec_iJd9dFtnfTAJuvxPC2CoXCgYx4W3yrsi'; // TEST $payload = @file_get_contents('php://input'); $sig_header = $_SERVER['HTTP_STRIPE_SIGNATURE']; $event = null; try { $event = \Stripe\Webhook::constructEvent( $payload, $sig_header, $endpoint_secret ); } catch(\UnexpectedValueException $e) { // Invalid payload http_response_code(400); exit(); } catch(\Stripe\Exception\SignatureVerificationException $e) { // Invalid signature http_response_code(400); exit(); } if ($event->type == "payment_intent.succeeded") { $intent = $event->data->object; $charges = \Stripe\Charge::all([ 'payment_intent' => $intent->id, 'limit' => 3, ]); $result = mysql_query_override("SELECT * FROM gaia_commandes WHERE intent_id = '".$intent->id."'"); $c = mysql_fetch_object_override($result); $commandeid = $c->id; // ******************************************** // $ret = "paiement ok"; /*$message = "Commande n° $order_id (paiement CB).\n" ."---------------------------------------------------------------------\n" ."Résumé de la commande :\n" ."\n" ."Numéro de la commande : $order_id\n" ."\n" ."Statut commande : ".$ret;*/ $message = "Nouvelle commande (n ".$commandeid.")"; //mail($support,"Nouvelle commande (n ".$commandeid.") :)", $message, "FROM:".$support); // ******************************************** // if($c) { $mail = get_static(353); $mailSubject = $mail['nom_'.$c->lang]; $mailObjet = mail_transform(2,$mail['description_'.$c->lang], intval($commandeid), 0 ); mail_confirm($c->email,$mailSubject,$mailObjet); mail_confirm($support,$mailSubject,$mailObjet); //mail_confirm('jsabat@wagaia.com',$mailSubject,$mailObjet); $statut = 3; $reca = mysql_query_override("select numero from gaia_commandes where a_timestamp like '".date('Y')."-%' order by numero desc "); $num = mysql_result_override($reca,0,'numero')+1; mysql_query_override("UPDATE gaia_commandes SET numero = '".$num."' WHERE id = '".$commandeid."'"); mysql_query_override("UPDATE gaia_commandes SET statut = '".$statut."' WHERE id = '".$commandeid."'"); //#################################################### $pos = stripos(mb_strtolower($c->type), 'mondial'); if($pos !== false) { $poids = $c->poids; $total = $c->montant; $cli = $c->prenom_ship.' '.$c->nom_ship; $adresse = substr($c->adresse_ship,0,35); $adresse2 = substr($c->adresse_ship,35,100); $telephone = $c->telephone_ship; $ville = $c->ville_ship; $cp = $c->zip_ship; $pays = $_SESSION['caddie']->pays; $point_relais = $c->point_relais_id; $point_relais_pays = 'FR'; $email = $c->email_ship; $num_dossier = $commandeid; include(__DIR__.'/../lib/fonctions/envoi_mondialrelay.php'); } } printf("OK: %s", $intent->id); http_response_code(200); exit(); } elseif ($event->type == "payment_intent.payment_failed") { mysql_query_override("UPDATE gaia_commandes SET statut = '6' WHERE id = '".$commandeid."'"); $intent = $event->data->object; $error_message = $intent->last_payment_error ? $intent->last_payment_error->message : ""; printf("Failed: %s, %s", $intent->id, $error_message); http_response_code(200); exit(); } ?>