Exemple #1
0
        internal async Task <bool> RefundOrder()
        {
            PayPalCheckoutSdk.Payments.RefundRequest refundRequest = new PayPalCheckoutSdk.Payments.RefundRequest()
            {
                Amount = new PayPalCheckoutSdk.Payments.Money
                {
                    CurrencyCode = AppConst.Settings.PayPal.CurrencyCode,
                    Value        = Payment.RefundAmount.ToString("0.00")
                },
                NoteToPayer = Payment.Message
            };
            var request = new PayPalCheckoutSdk.Payments.CapturesRefundRequest(Payment.Reference);

            request.Prefer("return=representation");
            request.RequestBody(refundRequest);
            var response = await PayPalClient.client().Execute(request);

            var refund = response.Result <PayPalCheckoutSdk.Payments.Refund>();

            if (!refund.Status.Equals("COMPLETED"))
            {
                return(false);
            }
            if (Dispute != null)
            {
                Dispute.Messages.Add(new Message()
                {
                    Body       = $"{Dispute.CommunicationType} was closed",
                    IsCustomer = false
                });
                Dispute.Status = false;
            }
            return(true);
        }
Exemple #2
0
        public async static Task <HttpResponse> CapturesRefund(string captureId, string refundAmount)
        {
            var request = new PayPalCheckoutSdk.Payments.CapturesRefundRequest(captureId);

            request.Prefer("return=representation");
            var refundRequest = new PayPalCheckoutSdk.Payments.RefundRequest()
            {
                Amount = new PayPalCheckoutSdk.Payments.Money
                {
                    Value        = refundAmount,
                    CurrencyCode = "USD"
                }
            };

            request.RequestBody(refundRequest);
            var response = await PayPalClient.client().Execute(request);

            return(response);
        }