COGWare.PeachRefunds 1.0.5

There is a newer version of this package available.
See the version list below for details.
dotnet add package COGWare.PeachRefunds --version 1.0.5                
NuGet\Install-Package COGWare.PeachRefunds -Version 1.0.5                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="COGWare.PeachRefunds" Version="1.0.5" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add COGWare.PeachRefunds --version 1.0.5                
#r "nuget: COGWare.PeachRefunds, 1.0.5"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install COGWare.PeachRefunds as a Cake Addin
#addin nuget:?package=COGWare.PeachRefunds&version=1.0.5

// Install COGWare.PeachRefunds as a Cake Tool
#tool nuget:?package=COGWare.PeachRefunds&version=1.0.5                

Peach Payments Transaction Refunds

Process refunds for transactions submitted via the Peach Payments payment gateway

Getting Started

Install the standard Nuget package into your .NET Core application.

Package Manager:
Install-Package COGWare.PeachRefunds -Version <version>

CLI:
dotnet add package --version <version> COGWare.PeachRefunds

Add Config

Add the PeachRefunds.IsProduction key to your settings file, eg:
<add key="PeachRefunds.IsProduction" value="false" />

Usage

With logging:

    // Create your logger from the logging framework's extensions package (in this case, NLog)
    var logger = LoggerFactory.Create(builder => builder.AddNLog()).CreateLogger<Program>();

    logger.LogInformation("starting");

    try {
        RefundResult? refundResult = await PeachPayments.RefundHelper.ProcessRefund(
            // An instance of the RefundConfig object containing details of the
            // Peach Payments entity that the original transaction was processed against.
            // These details are available in the Peach Payments Console. 
            new RefundConfig() {
                // Your merchant entityId.
                EntityId = "xyz123",
                // Your merchant secret.
                Secret = "123xyz"
            },
            // An instance of a Refund object representing the refund to be processed.
            new Refund() {
                // The amount to be refunded.
                Amount = 1.00,
                // Currency code.
                Currency = "ZAR",
                // Your refund identifier.
                Id = "1",
                // The original (Peach Payments) transactionId of the payment.
                TransactionId = "456xyz"
            },
            // optional logger
            logger);

        // Checks the status of the refund against the API response codes to 
        // determine if the refund can be considered successful.
        if(refundResult!.IsSuccessful) {
            // Update the status of the refund in your refund system.
            Console.WriteLine("Refund processed successfully! " +
                "Refund reference: '" + refundResult.Id + "'");
        } else {
            // Update the status of the refund in your refund system, optionally including the
            // return code and description for analysis and manual resolution (if necessary).
            Console.WriteLine("Refund failed: " +
                refundResult.Result!.Code + ", " +
                refundResult.Result!.Description);
        }
    } catch(Exception ex) {
        Console.WriteLine("ERROR: " + ex.Message);
    }

    logger.LogInformation("complete");

Without logging:

    try {
        RefundResult? refundResult = await PeachPayments.RefundHelper.ProcessRefund(
            // An instance of the RefundConfig object containing details of the
            // Peach Payments entity that the original transaction was processed against.
            // These details are available in the Peach Payments Console. 
            new RefundConfig() {
                // Your merchant entityId.
                EntityId = "xyz123",
                // Your merchant secret.
                Secret = "123xyz"
            },
            // An instance of a Refund object representing the refund to be processed.
            new Refund() {
                // The amount to be refunded.
                Amount = 1.00,
                // Currency code.
                Currency = "ZAR",
                // Your refund identifier.
                Id = "1",
                // The original (Peach Payments) transactionId of the payment.
                TransactionId = "456xyz"
            });

        // Checks the status of the refund against the API response codes to 
        // determine if the refund can be considered successful.
        if(refundResult!.IsSuccessful) {
            // Update the status of the refund in your refund system.
            Console.WriteLine("Refund processed successfully! " +
                "Refund reference: '" + refundResult.Id + "'");
        } else {
            // Update the status of the refund in your refund system, optionally including the
            // return code and description for analysis and manual resolution (if necessary).
            Console.WriteLine("Refund failed: " +
                refundResult.Result!.Code + ", " +
                refundResult.Result!.Description);
        }
    } catch(Exception ex) {
        Console.WriteLine("ERROR: " + ex.Message);
    }

Response object:

RefundResult

An object representing the response from the Peach Payments API.

  • Id:(String) - The Peach Payments transaction identifier for this specific refund.
  • ReferenceId: (String) - The original payment transaction identifier.
  • PaymentType: (String) - This will be "RF", denoting a refund.
  • Amount: (String) - The amount that was refunded.
  • Currency: (String) - The currency that the refund was processed in.
  • Descriptor: (String) - The merchant payment description.
  • MerchantTransactionId (String) - The original merchant transaction id.
  • Result (Object) - An object containing the refund response result.
    • Code (String) - The Peach Payments response code.
    • Description (String) - Description associated with the response code.
  • ResultDetail (Object) - An object containing the technical details of the refund
    • ConnectorTxID1 (String) - Downstream (credit card issuer) connection transaction identifier.
    • ConnectorTxID2 (String) - Additional downstream (credit card issuer) connection transaction identifier.
    • AuthorisationCode (String) - Downstream (credit card issuer) authorization code.
    • AcquirerReference (String) - Downstream (credit card issuer) reference.
    • AcquirerResponse (String) - Downstream (credit card issuer) response.
  • BuildNumber (String) - Peach Payments refund module build number.
  • Timestamp (DateTime) - When this refund was processed.
  • NDC (String) - No idea, will find out.
  • IsSuccessful (Boolean) - A flag indicating if the refund was successfully processed.

Logging:

Implements Microsoft.Extensions.Logging, so log away with any compatible logging framework,eg: NLog This package logs at DEBUG level.

Additional documentation

Feedback

I welcome comments, suggestions, feature requests and even honest criticism 😃

Want to show your appreciation?

That's mighty generous - thank you!
Buy me a coffee

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.1 210 6/10/2023
2.0.0 163 6/10/2023
1.0.7 181 5/27/2023
1.0.6 174 5/27/2023
1.0.5 178 5/19/2023
1.0.4 186 5/10/2023
1.0.3 163 5/5/2023
1.0.2 165 5/5/2023
1.0.1 170 5/4/2023
1.0.0 163 5/4/2023

Added logging capabilities via Microsoft.Extensions.Logging.