2018-03-10 23:50:41 +01:00
< ? php
2020-10-01 12:14:50 +02:00
/* Copyright ( C ) 2018 - 2020 Thibault FOUCART < support @ ptibogxiv . net >
* Copyright ( C ) 2018 Frédéric France < frederic . france @ netlogic . fr >
2018-03-10 23:50:41 +01:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2018-03-10 23:50:41 +01:00
*/
2021-02-26 18:58:34 +01:00
if ( ! defined ( 'NOLOGIN' )) {
define ( " NOLOGIN " , 1 ); // This means this output page does not require to be logged.
}
if ( ! defined ( 'NOCSRFCHECK' )) {
define ( " NOCSRFCHECK " , 1 ); // We accept to go on this page from external web site.
}
if ( ! defined ( 'NOIPCHECK' )) {
define ( 'NOIPCHECK' , '1' ); // Do not check IP defined into conf $dolibarr_main_restrict_ip
}
if ( ! defined ( 'NOBROWSERNOTIF' )) {
define ( 'NOBROWSERNOTIF' , '1' );
}
2018-03-10 23:50:41 +01:00
2020-04-10 10:59:32 +02:00
$entity = ( ! empty ( $_GET [ 'entity' ]) ? ( int ) $_GET [ 'entity' ] : ( ! empty ( $_POST [ 'entity' ]) ? ( int ) $_POST [ 'entity' ] : 1 ));
2021-02-26 18:58:34 +01:00
if ( is_numeric ( $entity )) {
define ( " DOLENTITY " , $entity );
}
2018-03-10 23:50:41 +01:00
2018-11-05 10:44:37 +01:00
require '../../main.inc.php' ;
2018-08-13 12:22:51 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php' ;
2018-03-10 23:50:41 +01:00
require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/class/ccountry.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php' ;
2019-04-26 10:48:38 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php' ;
2020-03-13 03:07:28 +01:00
require_once DOL_DOCUMENT_ROOT . '/includes/stripe/stripe-php/init.php' ;
2019-04-26 10:48:38 +02:00
require_once DOL_DOCUMENT_ROOT . '/stripe/class/stripe.class.php' ;
2018-03-10 23:50:41 +01:00
2021-02-26 18:58:34 +01:00
if ( empty ( $conf -> stripe -> enabled )) {
accessforbidden ( '' , 0 , 0 , 1 );
}
2018-11-05 10:44:37 +01:00
2019-04-24 20:21:03 +02:00
2018-03-10 23:50:41 +01:00
// You can find your endpoint's secret in your webhook settings
2021-02-26 18:58:34 +01:00
if ( isset ( $_GET [ 'connect' ])) {
if ( isset ( $_GET [ 'test' ])) {
2020-04-10 10:59:32 +02:00
$endpoint_secret = $conf -> global -> STRIPE_TEST_WEBHOOK_CONNECT_KEY ;
2018-03-10 23:50:41 +01:00
$service = 'StripeTest' ;
2018-11-05 10:44:37 +01:00
$servicestatus = 0 ;
2020-05-21 15:05:19 +02:00
} else {
2020-04-10 10:59:32 +02:00
$endpoint_secret = $conf -> global -> STRIPE_LIVE_WEBHOOK_CONNECT_KEY ;
2018-03-10 23:50:41 +01:00
$service = 'StripeLive' ;
2020-10-31 14:32:18 +01:00
$servicestatus = 1 ;
2018-03-10 23:50:41 +01:00
}
2020-05-21 15:05:19 +02:00
} else {
2021-02-26 18:58:34 +01:00
if ( isset ( $_GET [ 'test' ])) {
2020-04-10 10:59:32 +02:00
$endpoint_secret = $conf -> global -> STRIPE_TEST_WEBHOOK_KEY ;
2018-03-10 23:50:41 +01:00
$service = 'StripeTest' ;
2018-11-05 10:44:37 +01:00
$servicestatus = 0 ;
2020-05-21 15:05:19 +02:00
} else {
2020-04-10 10:59:32 +02:00
$endpoint_secret = $conf -> global -> STRIPE_LIVE_WEBHOOK_KEY ;
2018-03-10 23:50:41 +01:00
$service = 'StripeLive' ;
2018-11-05 10:44:37 +01:00
$servicestatus = 1 ;
2018-03-10 23:50:41 +01:00
}
}
2018-11-01 23:20:28 +01:00
2021-02-26 18:58:34 +01:00
if ( empty ( $endpoint_secret )) {
2020-10-31 14:32:18 +01:00
print 'Error: Setup of module Stripe not complete for mode ' . $service . '. The WEBHOOK_KEY is not defined.' ;
http_response_code ( 400 ); // PHP 5.4 or greater
exit ();
2019-04-24 20:21:03 +02:00
}
2021-10-30 17:19:46 +02:00
if ( ! empty ( $conf -> global -> STRIPE_USER_ACCOUNT_FOR_ACTIONS )) {
// We set the user to use for all ipn actions in Dolibarr
$user = new User ( $db );
$user -> fetch ( $conf -> global -> STRIPE_USER_ACCOUNT_FOR_ACTIONS );
$user -> getrights ();
} else {
print 'Error: Setup of module Stripe not complete for mode ' . $service . '. The STRIPE_USER_ACCOUNT_FOR_ACTIONS is not defined.' ;
http_response_code ( 400 ); // PHP 5.4 or greater
exit ();
}
// TODO Add a check on a security key
2019-04-24 20:21:03 +02:00
/*
* Actions
*/
2018-03-10 23:50:41 +01:00
$payload = @ file_get_contents ( " php://input " );
$sig_header = $_SERVER [ " HTTP_STRIPE_SIGNATURE " ];
$event = null ;
$error = 0 ;
try {
$event = \Stripe\Webhook :: constructEvent ( $payload , $sig_header , $endpoint_secret );
2020-05-21 15:05:19 +02:00
} catch ( \UnexpectedValueException $e ) {
2018-03-10 23:50:41 +01:00
// Invalid payload
http_response_code ( 400 ); // PHP 5.4 or greater
exit ();
2020-04-10 10:59:32 +02:00
} catch ( \Stripe\Error\SignatureVerification $e ) {
2018-03-10 23:50:41 +01:00
// Invalid signature
http_response_code ( 400 ); // PHP 5.4 or greater
exit ();
}
// Do something with $event
$langs -> load ( " main " );
2018-09-12 18:37:24 +02:00
2018-03-10 23:50:41 +01:00
2021-02-26 18:58:34 +01:00
if ( ! empty ( $conf -> multicompany -> enabled ) && ! empty ( $conf -> stripeconnect -> enabled ) && is_object ( $mc )) {
2018-03-10 23:50:41 +01:00
$sql = " SELECT entity " ;
2020-04-25 13:52:07 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . " oauth_token " ;
2020-10-01 12:14:50 +02:00
$sql .= " WHERE service = ' " . $db -> escape ( $service ) . " ' and tokenstring LIKE '% " . $db -> escape ( $event -> account ) . " %' " ;
2018-03-10 23:50:41 +01:00
2020-04-25 13:52:07 +02:00
dol_syslog ( get_class ( $db ) . " ::fetch " , LOG_DEBUG );
2018-03-10 23:50:41 +01:00
$result = $db -> query ( $sql );
2021-02-26 18:58:34 +01:00
if ( $result ) {
if ( $db -> num_rows ( $result )) {
2018-03-10 23:50:41 +01:00
$obj = $db -> fetch_object ( $result );
2020-04-25 13:52:07 +02:00
$key = $obj -> entity ;
2020-05-21 15:05:19 +02:00
} else {
2020-04-25 13:52:07 +02:00
$key = 1 ;
2018-03-10 23:50:41 +01:00
}
2020-05-21 15:05:19 +02:00
} else {
2020-04-25 13:52:07 +02:00
$key = 1 ;
2018-03-10 23:50:41 +01:00
}
2020-04-25 13:52:07 +02:00
$ret = $mc -> switchEntity ( $key );
2018-03-10 23:50:41 +01:00
}
// list of action
2020-04-25 13:52:07 +02:00
$stripe = new Stripe ( $db );
2019-04-24 20:21:03 +02:00
// Subject
$societeName = $conf -> global -> MAIN_INFO_SOCIETE_NOM ;
2021-02-26 18:58:34 +01:00
if ( ! empty ( $conf -> global -> MAIN_APPLICATION_TITLE )) {
$societeName = $conf -> global -> MAIN_APPLICATION_TITLE ;
}
2019-04-24 20:21:03 +02:00
2019-09-23 19:29:18 +02:00
dol_syslog ( " ***** Stripe IPN was called with event->type = " . $event -> type );
2019-04-24 20:21:03 +02:00
2018-03-10 23:50:41 +01:00
if ( $event -> type == 'payout.created' ) {
2020-04-25 13:52:07 +02:00
$error = 0 ;
2018-03-10 23:50:41 +01:00
2020-04-25 13:52:07 +02:00
$result = dolibarr_set_const ( $db , $service . " _NEXTPAYOUT " , date ( 'Y-m-d H:i:s' , $event -> data -> object -> arrival_date ), 'chaine' , 0 , '' , $conf -> entity );
2018-03-10 23:50:41 +01:00
2021-02-26 18:58:34 +01:00
if ( $result > 0 ) {
2020-10-31 14:32:18 +01:00
$subject = $societeName . ' - [NOTIFICATION] Stripe payout scheduled' ;
if ( ! empty ( $user -> email )) {
$sendto = dolGetFirstLastname ( $user -> firstname , $user -> lastname ) . " < " . $user -> email . " > " ;
} else {
$sendto = $conf -> global -> MAIN_INFO_SOCIETE_MAIL . '" <' . $conf -> global -> MAIN_INFO_SOCIETE_MAIL . '>' ;
}
$replyto = $sendto ;
$sendtocc = '' ;
if ( ! empty ( $conf -> global -> ONLINE_PAYMENT_SENDEMAIL )) {
$sendtocc = $conf -> global -> ONLINE_PAYMENT_SENDEMAIL . '" <' . $conf -> global -> ONLINE_PAYMENT_SENDEMAIL . '>' ;
}
$message = " A bank transfer of " . price2num ( $event -> data -> object -> amount / 100 ) . " " . $event -> data -> object -> currency . " should arrive in your account the " . dol_print_date ( $event -> data -> object -> arrival_date , 'dayhour' );
$mailfile = new CMailFile (
$subject ,
$sendto ,
$replyto ,
$message ,
array (),
array (),
array (),
$sendtocc ,
'' ,
0 ,
- 1
);
$ret = $mailfile -> sendfile ();
http_response_code ( 200 ); // PHP 5.4 or greater
return 1 ;
2020-05-21 15:05:19 +02:00
} else {
2018-03-10 23:50:41 +01:00
$error ++ ;
2019-04-24 20:21:03 +02:00
http_response_code ( 500 ); // PHP 5.4 or greater
2018-03-10 23:50:41 +01:00
return - 1 ;
}
2020-05-21 15:05:19 +02:00
} elseif ( $event -> type == 'payout.paid' ) {
2018-03-10 23:50:41 +01:00
global $conf ;
2020-04-10 10:59:32 +02:00
$error = 0 ;
$result = dolibarr_set_const ( $db , $service . " _NEXTPAYOUT " , null , 'chaine' , 0 , '' , $conf -> entity );
2021-02-26 18:58:34 +01:00
if ( $result ) {
2018-03-10 23:50:41 +01:00
$langs -> load ( " errors " );
$dateo = dol_now ();
$label = $event -> data -> object -> description ;
2020-04-10 10:59:32 +02:00
$amount = $event -> data -> object -> amount / 100 ;
$amount_to = $event -> data -> object -> amount / 100 ;
2018-03-10 23:50:41 +01:00
require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php' ;
2020-04-10 10:59:32 +02:00
$accountfrom = new Account ( $db );
2018-03-10 23:50:41 +01:00
$accountfrom -> fetch ( $conf -> global -> STRIPE_BANK_ACCOUNT_FOR_PAYMENTS );
2020-04-10 10:59:32 +02:00
$accountto = new Account ( $db );
2018-11-01 23:20:28 +01:00
$accountto -> fetch ( $conf -> global -> STRIPE_BANK_ACCOUNT_FOR_BANKTRANSFERS );
2018-03-10 23:50:41 +01:00
2021-02-26 18:58:34 +01:00
if (( $accountto -> id != $accountfrom -> id ) && empty ( $error )) {
2020-04-10 10:59:32 +02:00
$bank_line_id_from = 0 ;
$bank_line_id_to = 0 ;
$result = 0 ;
2018-03-10 23:50:41 +01:00
// By default, electronic transfert from bank to bank
2020-04-10 10:59:32 +02:00
$typefrom = 'PRE' ;
$typeto = 'VIR' ;
2021-02-26 18:58:34 +01:00
if ( ! $error ) {
$bank_line_id_from = $accountfrom -> addline ( $dateo , $typefrom , $label , - 1 * price2num ( $amount ), '' , '' , $user );
}
if ( ! ( $bank_line_id_from > 0 )) {
$error ++ ;
}
if ( ! $error ) {
$bank_line_id_to = $accountto -> addline ( $dateo , $typeto , $label , price2num ( $amount ), '' , '' , $user );
}
if ( ! ( $bank_line_id_to > 0 )) {
$error ++ ;
}
2020-04-10 10:59:32 +02:00
2021-02-26 18:58:34 +01:00
if ( ! $error ) {
$result = $accountfrom -> add_url_line ( $bank_line_id_from , $bank_line_id_to , DOL_URL_ROOT . '/compta/bank/line.php?rowid=' , '(banktransfert)' , 'banktransfert' );
}
if ( ! ( $result > 0 )) {
$error ++ ;
}
if ( ! $error ) {
$result = $accountto -> add_url_line ( $bank_line_id_to , $bank_line_id_from , DOL_URL_ROOT . '/compta/bank/line.php?rowid=' , '(banktransfert)' , 'banktransfert' );
}
if ( ! ( $result > 0 )) {
$error ++ ;
}
2018-03-10 23:50:41 +01:00
}
2019-04-24 20:21:03 +02:00
$subject = $societeName . ' - [NOTIFICATION] Stripe payout done' ;
2018-11-05 10:44:37 +01:00
if ( ! empty ( $user -> email )) {
2020-04-10 10:59:32 +02:00
$sendto = dolGetFirstLastname ( $user -> firstname , $user -> lastname ) . " < " . $user -> email . " > " ;
2018-11-05 10:44:37 +01:00
} else {
$sendto = $conf -> global -> MAIN_INFO_SOCIETE_MAIL . '" <' . $conf -> global -> MAIN_INFO_SOCIETE_MAIL . '>' ;
}
$replyto = $sendto ;
$sendtocc = '' ;
if ( ! empty ( $conf -> global -> ONLINE_PAYMENT_SENDEMAIL )) {
$sendtocc = $conf -> global -> ONLINE_PAYMENT_SENDEMAIL . '" <' . $conf -> global -> ONLINE_PAYMENT_SENDEMAIL . '>' ;
}
2018-11-01 23:20:28 +01:00
2020-04-10 10:59:32 +02:00
$message = " A bank transfer of " . price2num ( $event -> data -> object -> amount / 100 ) . " " . $event -> data -> object -> currency . " has been done to your account the " . dol_print_date ( $event -> data -> object -> arrival_date , 'dayhour' );
2018-11-05 10:44:37 +01:00
2020-10-31 14:32:18 +01:00
$mailfile = new CMailFile (
2018-11-05 10:44:37 +01:00
$subject ,
$sendto ,
$replyto ,
$message ,
array (),
array (),
array (),
$sendtocc ,
'' ,
0 ,
- 1
2021-02-26 18:58:34 +01:00
);
2018-11-05 10:44:37 +01:00
$ret = $mailfile -> sendfile ();
2018-03-10 23:50:41 +01:00
2021-10-30 17:19:46 +02:00
http_response_code ( 200 );
2018-03-10 23:50:41 +01:00
return 1 ;
2020-05-21 15:05:19 +02:00
} else {
2018-03-10 23:50:41 +01:00
$error ++ ;
2021-10-30 17:19:46 +02:00
http_response_code ( 500 );
2018-03-10 23:50:41 +01:00
return - 1 ;
}
2020-05-21 15:05:19 +02:00
} elseif ( $event -> type == 'customer.source.created' ) {
2018-03-10 23:50:41 +01:00
//TODO: save customer's source
2020-05-21 15:05:19 +02:00
} elseif ( $event -> type == 'customer.source.updated' ) {
2018-03-10 23:50:41 +01:00
//TODO: update customer's source
2020-05-21 15:05:19 +02:00
} elseif ( $event -> type == 'customer.source.delete' ) {
2018-03-10 23:50:41 +01:00
//TODO: delete customer's source
2020-05-21 15:05:19 +02:00
} elseif ( $event -> type == 'customer.deleted' ) {
2020-10-31 14:32:18 +01:00
$db -> begin ();
$sql = " DELETE FROM " . MAIN_DB_PREFIX . " societe_account WHERE key_account = ' " . $db -> escape ( $event -> data -> object -> id ) . " ' and site='stripe' " ;
$db -> query ( $sql );
$db -> commit ();
2020-05-21 15:05:19 +02:00
} elseif ( $event -> type == 'payment_intent.succeeded' ) { // Called when making payment with PaymentIntent method ($conf->global->STRIPE_USE_NEW_CHECKOUT is on).
2019-06-07 12:41:37 +02:00
// TODO: create fees
// TODO: Redirect to paymentok.php
2020-05-21 15:05:19 +02:00
} elseif ( $event -> type == 'payment_intent.payment_failed' ) {
2020-10-31 14:32:18 +01:00
// TODO: Redirect to paymentko.php
2021-02-26 18:58:34 +01:00
} elseif ( $event -> type == 'checkout.session.completed' ) { // Called when making payment with new Checkout method ($conf->global->STRIPE_USE_NEW_CHECKOUT is on).
2019-06-07 12:41:37 +02:00
// TODO: create fees
// TODO: Redirect to paymentok.php
2020-05-21 15:05:19 +02:00
} elseif ( $event -> type == 'payment_method.attached' ) {
2019-06-16 17:08:23 +02:00
require_once DOL_DOCUMENT_ROOT . '/societe/class/companypaymentmode.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/societe/class/societeaccount.class.php' ;
$societeaccount = new SocieteAccount ( $db );
$companypaymentmode = new CompanyPaymentMode ( $db );
$idthirdparty = $societeaccount -> getThirdPartyID ( $db -> escape ( $event -> data -> object -> customer ), 'stripe' , $servicestatus );
2021-02-26 18:58:34 +01:00
if ( $idthirdparty > 0 ) { // If the payment mode is on an external customer that is known in societeaccount, we can create the payment mode
2019-06-16 17:08:23 +02:00
$companypaymentmode -> stripe_card_ref = $db -> escape ( $event -> data -> object -> id );
$companypaymentmode -> fk_soc = $idthirdparty ;
$companypaymentmode -> bank = null ;
$companypaymentmode -> label = null ;
$companypaymentmode -> number = $db -> escape ( $event -> data -> object -> id );
$companypaymentmode -> last_four = $db -> escape ( $event -> data -> object -> card -> last4 );
$companypaymentmode -> card_type = $db -> escape ( $event -> data -> object -> card -> branding );
$companypaymentmode -> proprio = $db -> escape ( $event -> data -> object -> billing_details -> name );
$companypaymentmode -> exp_date_month = $db -> escape ( $event -> data -> object -> card -> exp_month );
$companypaymentmode -> exp_date_year = $db -> escape ( $event -> data -> object -> card -> exp_year );
$companypaymentmode -> cvn = null ;
$companypaymentmode -> datec = $db -> escape ( $event -> data -> object -> created );
$companypaymentmode -> default_rib = 0 ;
$companypaymentmode -> type = $db -> escape ( $event -> data -> object -> type );
$companypaymentmode -> country_code = $db -> escape ( $event -> data -> object -> card -> country );
$companypaymentmode -> status = $servicestatus ;
$db -> begin ();
2021-02-26 18:58:34 +01:00
if ( ! $error ) {
2019-06-16 17:08:23 +02:00
$result = $companypaymentmode -> create ( $user );
2021-02-26 18:58:34 +01:00
if ( $result < 0 ) {
2019-06-16 17:08:23 +02:00
$error ++ ;
}
}
2021-02-26 18:58:34 +01:00
if ( ! $error ) {
2019-06-16 17:08:23 +02:00
$db -> commit ();
2020-05-21 15:05:19 +02:00
} else {
2019-06-16 17:08:23 +02:00
$db -> rollback ();
}
}
2020-05-21 15:05:19 +02:00
} elseif ( $event -> type == 'payment_method.updated' ) {
2019-06-16 17:08:23 +02:00
require_once DOL_DOCUMENT_ROOT . '/societe/class/companypaymentmode.class.php' ;
$companypaymentmode = new CompanyPaymentMode ( $db );
$companypaymentmode -> fetch ( 0 , '' , 0 , '' , " AND stripe_card_ref = ' " . $db -> escape ( $event -> data -> object -> id ) . " ' " );
$companypaymentmode -> bank = null ;
$companypaymentmode -> label = null ;
$companypaymentmode -> number = $db -> escape ( $event -> data -> object -> id );
$companypaymentmode -> last_four = $db -> escape ( $event -> data -> object -> card -> last4 );
$companypaymentmode -> proprio = $db -> escape ( $event -> data -> object -> billing_details -> name );
$companypaymentmode -> exp_date_month = $db -> escape ( $event -> data -> object -> card -> exp_month );
$companypaymentmode -> exp_date_year = $db -> escape ( $event -> data -> object -> card -> exp_year );
$companypaymentmode -> cvn = null ;
$companypaymentmode -> datec = $db -> escape ( $event -> data -> object -> created );
$companypaymentmode -> default_rib = 0 ;
$companypaymentmode -> type = $db -> escape ( $event -> data -> object -> type );
$companypaymentmode -> country_code = $db -> escape ( $event -> data -> object -> card -> country );
$companypaymentmode -> status = $servicestatus ;
$db -> begin ();
2021-02-26 18:58:34 +01:00
if ( ! $error ) {
2019-06-16 17:08:23 +02:00
$result = $companypaymentmode -> update ( $user );
2021-02-26 18:58:34 +01:00
if ( $result < 0 ) {
2019-06-16 17:08:23 +02:00
$error ++ ;
}
}
2021-02-26 18:58:34 +01:00
if ( ! $error ) {
2019-06-16 17:08:23 +02:00
$db -> commit ();
2020-05-21 15:05:19 +02:00
} else {
2019-06-16 17:08:23 +02:00
$db -> rollback ();
}
2020-05-21 15:05:19 +02:00
} elseif ( $event -> type == 'payment_method.detached' ) {
2019-06-16 17:08:23 +02:00
$db -> begin ();
2021-03-30 19:12:07 +02:00
$sql = " DELETE FROM " . MAIN_DB_PREFIX . " societe_rib WHERE number = ' " . $db -> escape ( $event -> data -> object -> id ) . " ' and status = " . (( int ) $servicestatus );
2019-06-16 17:08:23 +02:00
$db -> query ( $sql );
$db -> commit ();
2020-05-21 15:05:19 +02:00
} elseif ( $event -> type == 'charge.succeeded' ) {
2020-10-31 14:32:18 +01:00
// TODO: create fees
// TODO: Redirect to paymentok.php
2020-05-21 15:05:19 +02:00
} elseif ( $event -> type == 'charge.failed' ) {
2020-10-31 14:32:18 +01:00
// TODO: Redirect to paymentko.php
2020-05-21 15:05:19 +02:00
} elseif (( $event -> type == 'source.chargeable' ) && ( $event -> data -> object -> type == 'three_d_secure' ) && ( $event -> data -> object -> three_d_secure -> authenticated == true )) {
2019-09-23 19:29:18 +02:00
// This event is deprecated.
2018-03-10 23:50:41 +01:00
}
2019-04-24 20:21:03 +02:00
2021-10-30 17:19:46 +02:00
http_response_code ( 200 );