diff --git a/_build/config.inc.php b/_build/config.inc.php index 835f553..5068af3 100644 --- a/_build/config.inc.php +++ b/_build/config.inc.php @@ -7,7 +7,7 @@ return [ 'name' => 'mspMollie', 'name_lower' => 'mspmollie', - 'version' => '1.0.1', + 'version' => '2.0.0', 'release' => 'pl', // Install package to site right after build 'install' => true, diff --git a/_build/elements/settings.php b/_build/elements/settings.php index 9019a57..a283573 100644 --- a/_build/elements/settings.php +++ b/_build/elements/settings.php @@ -11,4 +11,9 @@ 'value' => '', 'area' => 'mspmollie_main', ], + 'currency' => [ + 'xtype' => 'textfield', + 'value' => '', + 'area' => 'mspmollie_main', + ], ]; \ No newline at end of file diff --git a/core/components/mspmollie/composer.json b/core/components/mspmollie/composer.json index e1c2d1f..781baf7 100644 --- a/core/components/mspmollie/composer.json +++ b/core/components/mspmollie/composer.json @@ -1,5 +1,5 @@ { "require": { - "mollie/mollie-api-php": "1.9.*" + "mollie/mollie-api-php": "2.*" } } diff --git a/core/components/mspmollie/model/payment.class.php b/core/components/mspmollie/model/payment.class.php index 8d935a7..4e2f7e3 100644 --- a/core/components/mspmollie/model/payment.class.php +++ b/core/components/mspmollie/model/payment.class.php @@ -23,10 +23,12 @@ function __construct(xPDOObject $object, $config = []) { parent::__construct($object, $config); - if (!class_exists('Mollie_API_Client')) { + if (!class_exists('MollieApiClient')) { require dirname(dirname(__FILE__)) . '/vendor/autoload.php'; } - $this->Mollie = new Mollie_API_Client; + $this->Mollie = new \Mollie\Api\MollieApiClient(); + + try { $this->Mollie->setApiKey($this->modx->getOption('mspmollie_api_key')); } catch (Mollie_API_Exception $e) { @@ -72,7 +74,10 @@ public function getPaymentLink(msOrder $order) } else { try { $payment = $this->Mollie->payments->create([ - 'amount' => $order->get('cost'), + "amount" => [ + "currency" => $this->modx->getOption('mspmollie_currency'), + "value" => number_format($order->get('cost'), 2, '.', '') + ], 'description' => 'Order #' . $order->get('num'), 'redirectUrl' => $this->modx->makeUrl($this->config['successId'], $order->get('context'), ['msorder' => $order->id], 'full'), 'webhookUrl' => rtrim($this->modx->getOption('site_url'), '/') . $this->config['paymentUrl'], @@ -92,7 +97,7 @@ public function getPaymentLink(msOrder $order) } return !empty($payment) - ? $payment->getPaymentUrl() + ? $payment->getCheckoutUrl() : ''; }