action.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. global $_,$conf;
  3. switch($_['action']){
  4. case 'stripe_setting_save':
  5. Action::write(function(&$response){
  6. global $myUser,$_,$conf;
  7. User::check_access('stripe','configure');
  8. foreach(Configuration::setting('stripe') as $key=>$value){
  9. if(!is_array($value)) continue;
  10. $allowed[] = $key;
  11. }
  12. foreach ($_['fields'] as $key => $value) {
  13. if(in_array($key, $allowed))
  14. $conf->put($key,$value);
  15. }
  16. });
  17. break;
  18. case 'stripe_init_component':
  19. Action::write(function(&$response){
  20. try {
  21. global $myUser,$myFirm,$_;
  22. User::check_access('stripe','read');
  23. if(!isset($_['process']) || empty($_['process'])) throw new Exception("Aucune action pour procéder au paiement");
  24. $process = trim($_['process']);
  25. ob_start();
  26. require_once(__DIR__.SLASH.'stripe.component.php');
  27. $stream = ob_get_clean();
  28. $response['content'] = $stream;
  29. } catch (Exception $e) {
  30. $response['content'] = '<div class="w-100 text-danger text-center"><small>ERREUR AU CHARGEMENT<br>'.$e->getMessage().' ('.$e->getCode().')</small></div>';
  31. }
  32. });
  33. break;
  34. }
  35. ?>