Skip to content

Commit 83a723b

Browse files
committed
Handle PayPal subscription NotFound on cancel (incomplete payments)
1 parent d05ea1a commit 83a723b

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

cloud/src/LrmCloud.Api/Services/Billing/Providers/PayPalPaymentProvider.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,14 @@ public async Task CancelSubscriptionAsync(string subscriptionId)
164164
var response = await _httpClient.SendAsync(request);
165165
if (!response.IsSuccessStatusCode)
166166
{
167+
// If subscription doesn't exist in PayPal (e.g., incomplete/abandoned payment),
168+
// treat it as successfully cancelled - there's nothing to cancel
169+
if (response.StatusCode == System.Net.HttpStatusCode.NotFound)
170+
{
171+
_logger.LogWarning("PayPal subscription {SubscriptionId} not found - treating as cancelled", subscriptionId);
172+
return;
173+
}
174+
167175
var errorBody = await response.Content.ReadAsStringAsync();
168176
_logger.LogError("PayPal cancel subscription failed: {StatusCode} - {Body}",
169177
response.StatusCode, errorBody);

0 commit comments

Comments
 (0)