COGWare.PeachRefunds
1.0.5
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
<PackageReference Include="COGWare.PeachRefunds" Version="1.0.5" />
paket add COGWare.PeachRefunds --version 1.0.5
#r "nuget: COGWare.PeachRefunds, 1.0.5"
// 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 😃
- Github Repo
- Email: lance@cogware.co.za
Want to show your appreciation?
That's mighty generous - thank you!
Buy me a coffee
Product | Versions 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. |
-
net6.0
- Microsoft.Extensions.Logging (>= 7.0.0)
- Newtonsoft.Json (>= 13.0.3)
- RestSharp (>= 110.2.0)
- System.Configuration.ConfigurationManager (>= 7.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Added logging capabilities via Microsoft.Extensions.Logging.