Mollie script

    • Mollie script

      Hallo,

      ik zit wat vast met de Mollie API. Ik ben dus bezig met betalingen aan te maken e.d. via mollie. Het werkte tot ik er wat checks op maakte (zoals redirect e.d.)
      Ik krijg geen error maar ook geen pagina, althans staat mijn error reporting aan.

      Wie kan me helpen?

      PHP Source Code

      1. <?php
      2. ini_set('display_errors', 1);
      3. ini_set('display_startup_errors', 1);
      4. error_reporting(E_ALL);
      5. echo h1('Credits kopen');
      6. require_once ''.$_SERVER['DOCUMENT_ROOT'].'/core/Mollie/API/Autoloader.php';
      7. $mollie = new Mollie_API_Client;
      8. $mollie->setApiKey('prive');
      9. // if empty get red ok
      10. if (empty($_GET['red'])) {
      11. try
      12. {
      13. $payment = $mollie->payments->create(
      14. array(
      15. 'amount' => 10.00,
      16. 'description' => '500 credits',
      17. 'redirectUrl' => 'http://'.$siteurl.'/?page=credits/mollie&red=ok',
      18. 'metadata' => array(
      19. 'order_id' => 'Order '.rand(0,10000).''
      20. )
      21. )
      22. );
      23. /*
      24. * Send the customer off to complete the payment.
      25. */
      26. if($_GET['accept'] == '1'){
      27. echo '<script type="text/javascript">
      28. window.location.href = "'.$payment->getPaymentUrl().'";
      29. </script>';
      30. //header("Location: " . $payment->getPaymentUrl());
      31. exit;
      32. }
      33. else{
      34. echo '<a href="?page=credits/mollie&accept=1">Klik hier om te betalen</a>.';
      35. }
      36. catch (Mollie_API_Exception $e)
      37. {
      38. echo "API call failed: " . htmlspecialchars($e->getMessage()) . " on field " + htmlspecialchars($e->getField());
      39. }
      40. }
      41. }
      42. elseif($_GET['red'] == 'ok'){
      43. // hier de ELSEIF red = ok
      44. $payment_id = $_POST["id"];
      45. $payment = $mollie->payments->get($payment_id);
      46. /*
      47. * The order ID saved in the payment can be used to load the order and update it's status
      48. */
      49. $order_id = $payment->metadata->order_id;
      50. if ($payment->isPaid())
      51. {
      52. /*
      53. * At this point you'd probably want to start the process of delivering the product to the customer.
      54. */
      55. echo goed('Betaling gelukt, credits zijn er bij geschreven.');
      56. //hier query
      57. }
      58. elseif (! $payment->isOpen())
      59. {
      60. /*
      61. * The payment isn't paid and isn't open anymore. We can assume it was aborted.
      62. */
      63. echo fout('Betaling mislukt');
      64. }
      65. }
      66. echo einde();
      67. ?>
      Laat alles zien