Skip to content

Commit 6a3941d

Browse files
committed
Merge branch 'develop-v5' into v5
2 parents 756a42d + 14bd504 commit 6a3941d

File tree

5 files changed

+25
-12
lines changed

5 files changed

+25
-12
lines changed

CHANGELOG.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).
66

7-
## 5.2.0 - Unpublished
7+
## 5.2.1 - 2025-01-10
8+
### Fixed
9+
- Added missing form handle
10+
11+
## 5.2.0 - 2025-01-04
812
### Added
913
- Support for using a different API key per form
1014
### Fixed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"minimum-stability": "alpha",
44
"description": "Easily accept payments with Mollie Payments",
55
"type": "craft-plugin",
6-
"version": "5.2.0",
6+
"version": "5.2.1",
77
"keywords": [
88
"craft",
99
"cms",

src/controllers/PaymentController.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,9 @@ public function actionCheckTransactionStatus($id, $redirect)
262262
{
263263
try {
264264
$transaction = MolliePayments::getInstance()->transaction->getTransactionbyId($id);
265-
$molliePayment = MolliePayments::getInstance()->mollie->getStatus($id);
265+
$element = Payment::findOne(['id' => $transaction->payment]);
266+
$form = MolliePayments::getInstance()->forms->getFormByid($element->formId);
267+
$molliePayment = MolliePayments::getInstance()->mollie->getStatus($id, $form->handle);
266268
if ($transaction->status !== $molliePayment->status) {
267269
MolliePayments::getInstance()->transaction->updateTransaction($transaction, $molliePayment);
268270
return $this->asSuccess("Transaction status updated", [], $redirect);

src/controllers/SubscriptionController.php

+14-8
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@ public function actionSubscribe()
8181
$subscription->customerId = $subscriber->customerId;
8282

8383
if (!$subscription->validate()) {
84-
// TODO Remove this before release
85-
dd($subscription->getErrors());
8684
// Send the payment back to the template
8785
Craft::$app->getUrlManager()->setRouteParams([
8886
'subscription' => $subscription,
@@ -160,10 +158,11 @@ public function actionRedirect()
160158

161159
$redirect = $request->getQueryParam('redirect');
162160
$element = Subscription::findOne(['uid' => $uid]);
161+
$form = MolliePayments::getInstance()->forms->getFormByid($element->formId);
163162
$transaction = MolliePayments::$plugin->transaction->getTransactionbyPayment($element->id);
164163

165164
try {
166-
$molliePayment = MolliePayments::$plugin->mollie->getStatus($transaction->id);
165+
$molliePayment = MolliePayments::$plugin->mollie->getStatus($transaction->id, $form->handle);
167166
$this->redirect(UrlHelper::url($redirect, ['subscription' => $uid, 'status' => $molliePayment->status]));
168167
} catch (\Exception $e) {
169168
throw new NotFoundHttpException('Payments not found', '404');
@@ -178,7 +177,9 @@ public function actionWebhook(): void
178177
{
179178
$id = Craft::$app->getRequest()->getRequiredParam('id');
180179
$transaction = MolliePayments::getInstance()->transaction->getTransactionbyId($id);
181-
$molliePayment = MolliePayments::getInstance()->mollie->getStatus($id);
180+
$element = Subscription::findOne(['id' => $transaction->payment]);
181+
$form = MolliePayments::getInstance()->forms->getFormByid($element->formId);
182+
$molliePayment = MolliePayments::getInstance()->mollie->getStatus($id, $form->handle);
182183

183184
// If we have a subscription id, the payment belongs to an active subscription
184185
// So we need to create a new transaction for it.
@@ -283,7 +284,7 @@ public function actionGetSubscribers()
283284
$page = $this->request->getQueryParam('page', 1);
284285
$baseUrl = 'mollie-payments/subscription/get-subscribers';
285286
$data = MolliePayments::getInstance()->subscriber->getAllSubscribers();
286-
$subscribers = collect($data)->map(function($subscriber) {
287+
$subscribers = collect($data)->map(function ($subscriber) {
287288
return [
288289
'title' => $subscriber->email,
289290
'id' => $subscriber->customerId,
@@ -335,8 +336,13 @@ public function actionGetSubscribers()
335336

336337
public function actionDeleteSubscriber()
337338
{
338-
MolliePayments::getInstance()->mollie->deleteCustomer($this->request->getRequiredBodyParam('id'));
339-
MolliePayments::getInstance()->subscriber->deleteById($this->request->getRequiredBodyParam('id'));
340-
return $this->asJson(['success' => true]);
339+
try {
340+
MolliePayments::getInstance()->mollie->deleteCustomer($this->request->getRequiredBodyParam('id'));
341+
MolliePayments::getInstance()->subscriber->deleteById($this->request->getRequiredBodyParam('id'));
342+
return $this->asJson(['success' => true]);
343+
} catch(\Throwable $e) {
344+
Craft::error($e->getMessage(), MolliePayments::class);
345+
return $this->asJson(['success' => false]);
346+
}
341347
}
342348
}

src/elements/Subscription.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ public function getCustomer(): Customer|null
213213
if (!$this->customerId) {
214214
return null;
215215
}
216-
return MolliePayments::getInstance()->mollie->getCustomer($this->customerId);
216+
$form = $this->getForm();
217+
return MolliePayments::getInstance()->mollie->getCustomer($this->customerId, $form->handle);
217218
}
218219

219220
// Public Methods

0 commit comments

Comments
 (0)