Skip to content

Commit

Permalink
refactor: add description parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
glaubersilva committed Aug 30, 2024
1 parent d56d3ac commit bee429a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/OffSiteGateway/Gateway/OffSiteCheckoutPageSimulation.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,12 @@ private function loadOffSiteGatewaySimulationMarkup()
<div class="container">
<h1>Off-site Checkout Page Simulation</h1>
<p>
Donation amount:<strong><?php
echo isset($_GET['amount']) ? $_GET['amount']['currency'] . ' ' . $_GET['amount']['value'] : 0; ?></strong>
Donation amount: <strong><?php
echo isset($_GET['amount']) ? $_GET['amount']['currency'] . ' ' . $_GET['amount']['value'] : ' 0'; ?></strong>
</p>
<p>
Description: <strong><?php
echo $_GET['description'] ?? ' -'; ?></strong>
</p>
<hr />
<p>
Expand Down
7 changes: 5 additions & 2 deletions src/OffSiteGateway/Gateway/OffSiteGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,15 @@ public function createPayment(Donation $donation, $gatewayData): RedirectOffsite
$donation->gatewayTransactionId = $payment->id;
$donation->save();

/**
* This is necessary to make the off-site checkout page simulation work;
* In real-world integrations, this parameter isn't necessary.
*/
$paymentParameters['off-site-gateway-simulation'] = true;

$redirectUrl = add_query_arg($paymentParameters, home_url());

return new RedirectOffsite($redirectUrl);
//return new RedirectOffsite(add_query_arg('off-site-gateway-simulation', true, home_url()));
} catch (Exception $e) {
$donation->status = DonationStatus::FAILED();
$donation->save();
Expand Down Expand Up @@ -165,7 +168,7 @@ public function getPaymentParameters(Donation $donation, $gatewayData): array
'value' => $donation->amount->formatToDecimal(),
'currency' => $donation->amount->getCurrency()->getCode(),
],
//'description' => MollieApi::getPaymentDescription($donation),
'description' => $donation->formTitle,
'returnUrl' => $this->getPaymentsReturnURL($donation, $gatewayData),
'cancelUrl' => $this->getPaymentsCancelURL($donation, $gatewayData),
'webhookUrl' => $this->getPaymentsWebhookUrl($donation),
Expand Down

0 comments on commit bee429a

Please sign in to comment.