action.php 1.0 KB

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