adebisi-fa / paystack-dotnet

PayStack API for .Net Developers!
http://developers.paystack.co/docs
MIT License
37 stars 37 forks source link

Refund via this SDK #23

Closed ShrewdMensch closed 2 years ago

ShrewdMensch commented 2 years ago

Hello, How can I trigger a refund via this SDK? I have scanned through the SDK docs etc, I did not find any Method that seems to handle a refund.

Please, kindly assist. Thanks.

adebisi-fa commented 2 years ago

Hello @ShrewdMensch,

From the Create Refund documentation, the following should work:

var transactionId = 'qufywna9w9a5d8v'; // the Id of the transaction to refund.
var _api = new PayStackApi(...);
var result =  _api.Post<ApiResponse<dynamic>, dynamic>(
      "/refund", 
      new {
        transaction = transactionId,
        // optional, if specified (for a partial refund) must be 
        //   less than or equal to the transaction amount.
        amount = 5000,
        currency = "NGN", // optional
        customer_note = "I want to reduce my order item quantity.", // optional
        merchant_note = "Customer reduced order quantity, so we are refunding." // optional
      }
    );

if (result.Status) {
    /* 
     use result.Data to access response values, for example:
     result.Data.transaction object
     result.Data.status  // to get the refund status
   */
}

Hope this helps.

Foluso.

adebisi-fa commented 2 years ago

This will be closed, now.

Kindly re-open, if the suggestion didn't work, or if there is any further comment on the subject .

Thank you.