Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update echeck status when rejected by Paypal #11832

Merged
merged 5 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions app/Libraries/Payments/PaymentProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,6 @@ public function rejected()
// the whole transaction doesn't make it explode.
$this->signature->assertValid();

$order = $this->getOrder();

datadog_increment('store.payments.rejected', ['provider' => $this->getPaymentProvider()]);
}

Expand Down
10 changes: 10 additions & 0 deletions app/Libraries/Payments/PaypalPaymentProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ public function getNotificationTypeRaw(): string
return $this['payment_status'] ?? $this['txn_type'];
}

public function rejected()
{
parent::rejected();

$order = $this->getOrder();
if ($this->params['payment_type'] === 'echeck') {
$order->update(['tracking_code' => Order::ECHECK_DENIED]);
}
}

public function validateTransaction(): bool
{
$this->signature->assertValid();
Expand Down
6 changes: 1 addition & 5 deletions app/Models/Store/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class Order extends Model
use SoftDeletes;

const ECHECK_CLEARED = 'ECHECK CLEARED';
const ECHECK_DENIED = 'ECHECK DENIED';
const ORDER_NUMBER_REGEX = '/^(?<prefix>[A-Za-z]+)-(?<userId>\d+)-(?<orderId>\d+)$/';
const PENDING_ECHECK = 'PENDING ECHECK';

Expand Down Expand Up @@ -436,11 +437,6 @@ public function isPaidOrDelivered(): bool
return in_array($this->status, [static::STATUS_PAID, static::STATUS_DELIVERED], true);
}

public function isPendingEcheck(): bool
{
return $this->tracking_code === static::PENDING_ECHECK;
}

public function isShipped(): bool
{
return $this->status === static::STATUS_SHIPPED;
Expand Down
1 change: 1 addition & 0 deletions resources/lang/en/store.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
'contact' => 'Contact:',
'date' => 'Date:',
'echeck_delay' => 'As your payment was an eCheck, please allow up to 10 extra days for the payment to clear through PayPal!',
'echeck_denied' => 'The eCheck payment was rejected by PayPal.',
'hide_from_activity' => 'osu!supporter tags in this order are not displayed in your recent activities.',
'sent_via' => 'Sent Via:',
'shipping_to' => 'Shipping To:',
Expand Down
14 changes: 12 additions & 2 deletions resources/views/store/orders/_status.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the GNU Affero General Public License v3.0.
See the LICENCE file in the repository root for full licence text.
--}}
@php
use App\Models\Store\Order;

$echeckStatus = match ($order->tracking_code) {
Order::ECHECK_DENIED => 'echeck_denied',
Order::PENDING_ECHECK => 'echeck_delay',
default => null,
};
@endphp

<div class="store-page">
<h3 class="store-text store-text--title">{{ osu_trans('store.order.status.title') }}</h3>

Expand Down Expand Up @@ -56,9 +66,9 @@
</p>
@endif

@if ($order->isPendingEcheck())
@if ($echeckStatus !== null)
<p>
{{ osu_trans('store.invoice.echeck_delay') }}
{{ osu_trans("store.invoice.{$echeckStatus}") }}
</p>
@endif
@endif
Expand Down