Skip to content

Commit

Permalink
Fix issue #136 for V1
Browse files Browse the repository at this point in the history
Update FirstPaymentBuilder.php
  • Loading branch information
ciungulete authored Oct 27, 2022
2 parents 6acdadc + 4388ca1 commit bbd7780
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/FirstPayment/FirstPaymentBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,17 +123,26 @@ 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);

$redirectUrl = $payload['redirectUrl'];

// 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 bbd7780

Please sign in to comment.