Skip to content

Commit 19a1813

Browse files
Dropping legacy support for metadata based actions (#294)
* improve action extraction * wip
1 parent 06c9c1a commit 19a1813

2 files changed

Lines changed: 14 additions & 14 deletions

File tree

src/FirstPayment/FirstPaymentHandler.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -96,19 +96,19 @@ protected function extractOwner()
9696
protected function extractActions()
9797
{
9898
$payment = Cashier::$paymentModel::findByPaymentId($this->molliePayment->id);
99-
100-
if (isset($payment) && ! is_null($payment->first_payment_actions)) {
101-
$actions = $payment->first_payment_actions;
102-
} else {
103-
$actions = $this->molliePayment->metadata->actions;
104-
}
105-
106-
return collect($actions)->map(function ($actionMeta) {
107-
return $actionMeta->handler::createFromPayload(
108-
object_to_array_recursive($actionMeta),
109-
$this->owner
110-
);
111-
});
99+
$actions = $payment?->first_payment_actions;
100+
101+
/*
102+
* For legacy reasons, the first_payment_actions value is (de)serialized on the Payment model as an object
103+
* instead of an array. This is handled by `collect()` just fine.
104+
*/
105+
return collect($actions)
106+
->map(function ($action) {
107+
return $action->handler::createFromPayload(
108+
object_to_array_recursive($action),
109+
$this->owner
110+
);
111+
});
112112
}
113113

114114
/**

src/Payment.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* @property int amount
2525
* @property int amount_refunded
2626
* @property int amount_charged_back
27-
* @property string first_payment_actions
27+
* @property object first_payment_actions // An object for legacy reasons
2828
* @property string mollie_mandate_id
2929
* @property \Laravel\Cashier\Order\Order order
3030
*

0 commit comments

Comments
 (0)