Skip to content

Commit

Permalink
Fix issue mollie#136
Browse files Browse the repository at this point in the history
  • Loading branch information
ag84ark committed Oct 25, 2022
1 parent c522380 commit 453e737
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/FirstPayment/FirstPaymentBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,19 +125,30 @@ public function getMolliePayload()
public function create()
{
$payload = $this->getMolliePayload();
$untouchedRedirectUrl = $payload['redirectUrl'];
$payload['redirectUrl'] = Str::replace(
'{payment_id}',
'---payment_id---', // In order to pass Mollie validation
$payload['redirectUrl']
);

/** @var CreateMolliePayment $createMolliePayment */
$createMolliePayment = app()->make(CreateMolliePayment::class);
$this->molliePayment = $createMolliePayment->execute($payload);

Cashier::$paymentModel::createFromMolliePayment($this->molliePayment, $this->owner, $this->actions->toPlainArray());

$redirectUrl = $payload['redirectUrl'];
Cashier::$paymentModel::createFromMolliePayment(
$this->molliePayment,
$this->owner,
$this->actions->toPlainArray()
);

// Parse and update redirectUrl
if (Str::contains($redirectUrl, '{payment_id}')) {
$redirectUrl = Str::replaceArray('{payment_id}', [$this->molliePayment->id], $redirectUrl);
$this->molliePayment->redirectUrl = $redirectUrl;
if (Str::contains($untouchedRedirectUrl, '{payment_id}')) {
$this->molliePayment->redirectUrl = Str::replace(
'{payment_id}',
$this->molliePayment->id,
$untouchedRedirectUrl
);

/** @var UpdateMolliePayment $updateMolliePayment */
$updateMolliePayment = app()->make(UpdateMolliePayment::class);
Expand Down

0 comments on commit 453e737

Please sign in to comment.