Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion _build/config.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions _build/elements/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,9 @@
'value' => '',
'area' => 'mspmollie_main',
],
'currency' => [
'xtype' => 'textfield',
'value' => '',
'area' => 'mspmollie_main',
],
];
2 changes: 1 addition & 1 deletion core/components/mspmollie/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"require": {
"mollie/mollie-api-php": "1.9.*"
"mollie/mollie-api-php": "2.*"
}
}
13 changes: 9 additions & 4 deletions core/components/mspmollie/model/payment.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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'],
Expand All @@ -92,7 +97,7 @@ public function getPaymentLink(msOrder $order)
}

return !empty($payment)
? $payment->getPaymentUrl()
? $payment->getCheckoutUrl()
: '';
}

Expand Down