feat: Payment Reversals Support #499
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.



This pull request introduces support for reversing payments in the SDK, allowing clients to return funds to customers by performing the appropriate payment action based on the payment's status. It adds new request and response models, updates the payments client interface and implementation, and provides comprehensive unit tests to validate the new functionality.
Payment reversal feature
ReverseAPaymentRequestandReverseAPaymentResponsemodels to represent the request and response for reversing a payment. These models include fields for internal references, metadata, and action identifiers. (src/CheckoutSdk/HandlePaymentsAndPayouts/Payments/POSTPaymentsIdReversals/Requests/ReverseAPaymentRequest/ReverseAPaymentRequest.cs,src/CheckoutSdk/HandlePaymentsAndPayouts/Payments/POSTPaymentsIdReversals/Responses/ReverseAPaymentResponse/ReverseAPaymentResponse.cs) [1] [2]IPaymentsClientinterface to include the newReverseAPaymentmethod, supporting optional request objects, idempotency keys, and cancellation tokens. (src/CheckoutSdk/Payments/IPaymentsClient.cs)ReverseAPaymentmethod inPaymentsClient, including parameter validation and API client integration for posting reversal requests. (src/CheckoutSdk/Payments/PaymentsClient.cs)OAuth scope extension
gateway:payment-cancellationsto theOAuthScopeenum to support authorization for payment reversals. (src/CheckoutSdk/OAuthScope.cs)Testing
HandleReversalsClientTestto verify successful reversals, error handling for invalid payment IDs, idempotency behavior, and cancellation token support. (test/CheckoutSdkTest/HandlePaymentsAndPayouts/Payments/POSTPaymentsIdReversals/HandleReversalsClientTest.cs)