public ActionResult DeleteConfirmed(int id)
        {
            //Debug Purpose to see if we are getting the id
            Debug.WriteLine("I'm pulling data of " + id.ToString());

            //Get the specific Donation
            Donation donation = db.Donations.Find(id);

            //Refund the donated amount back to the user
            //Code Referenced from: https://stripe.com/docs/refunds
            StripeConfiguration.ApiKey = "sk_test_T3BF2ap8TTDpmetCKxF038r400HAf7zrj8";
            var refunds       = new RefundService();
            var refundOptions = new RefundCreateOptions
            {
                PaymentIntent = donation.donationReceiptId,
                Amount        = donation.donationAmount
            };
            var refund = refunds.Create(refundOptions);

            //Delete that specific Donation from the database
            db.Donations.Remove(donation);

            //Save the changes on the database
            db.SaveChanges();

            //Go back to the list of Donation to see the removed Donation
            return(RedirectToAction("Index"));
        }
Beispiel #2
0
        public void MixedRefundOneSfaContribution()
        {
            var sut = new RefundService();

            var testHistory = new List <Payment>
            {
                new Payment {
                    Amount = 50, FundingSource = FundingSourceType.Levy, SfaContributionPercentage = 1m
                },
                new Payment {
                    Amount = 45, FundingSource = FundingSourceType.CoInvestedSfa, SfaContributionPercentage = 0.9m
                },
                new Payment {
                    Amount = 5, FundingSource = FundingSourceType.CoInvestedEmployer, SfaContributionPercentage = 0.9m
                },
            };

            var actual = sut.GetRefund(-50, testHistory);

            actual.Should().HaveCount(2);
            actual.Single(x => x.EarningType == EarningType.CoInvested).Amount.Should().Be(-25);
            actual.Single(x => x.EarningType == EarningType.CoInvested).SfaContributionPercentage.Should().Be(0.9m);

            actual.Single(x => x.EarningType == EarningType.Levy).Amount.Should().Be(-25);
            actual.Single(x => x.EarningType == EarningType.Levy).SfaContributionPercentage.Should().Be(1m);
        }
Beispiel #3
0
        public void NoHistoryReturnsEmptyResult()
        {
            var sut    = new RefundService();
            var actual = sut.GetRefund(-100, new List <Payment>());

            actual.Should().BeEmpty();
        }
        static void Main(string[] args)
        {
            const bool   isSandbox       = false;
            const string transactionCode = "F3D9490291B54FA59F39B22AB9E76799";

            //const decimal refundValue = 150m;

            EnvironmentConfiguration.ChangeEnvironment(isSandbox);

            try
            {
                var credentials = PagSeguroConfiguration.GetAccountCredentials(isSandbox);

                // TODO: Substitute the code below with a valid transaction code for your transaction
                var result = RefundService.RequestRefund(credentials, transactionCode);
                //var result = RefundService.RequestRefund(credentials, transactionCode, refundValue);

                Console.WriteLine(result.ToString());

                Console.ReadKey();
            }
            catch (PagSeguroServiceException exception)
            {
                Console.WriteLine(exception.Message + "\n");

                foreach (var element in exception.Errors)
                {
                    Console.WriteLine(element + "\n");
                }
                Console.ReadKey();
            }
        }
Beispiel #5
0
        public ResultObj <int> PostRefund([FromBody] List <string> lstTradeNo)
        {
            if (lstTradeNo.Count == 0)
            {
                return(Content(1));
            }
            IRefund          irefund      = new RefundService();
            List <SaleModel> lstSaleModel = irefund.GetRefundOrder(lstTradeNo);

            if (lstSaleModel.Count == 0)
            {
                return(Content(1));
            }
            //支付宝
            var aPayData = from n in lstSaleModel
                           where n.PayInterface == "支付宝"
                           select n;

            if (aPayData.ToList <SaleModel>().Count > 0)
            {
                irefund.PostRefundA(aPayData.ToList <SaleModel>());
            }


            var wPayData = from m in lstSaleModel
                           where m.PayInterface == "微信"
                           select m;

            if (wPayData.ToList <SaleModel>().Count > 0)
            {
                irefund.PostRefundW(wPayData.ToList <SaleModel>());
            }
            return(Content(1));
        }
Beispiel #6
0
        static void getRefundsWithParameters()
        {
            // probar los parametros, no funciona bien
            // transaction es ok
            // client no funciona
            // amount es ok
            // created_at no funciona
            // count es ok

            Paymill.ApiKey = Properties.Settings.Default.ApiKey;
            Paymill.ApiUrl = Properties.Settings.Default.ApiUrl;
            RefundService refundService = Paymill.GetService <RefundService>();

            Console.WriteLine("Waiting request list refunds with parameters...");

            Filter filter = new Filter();

            filter.Add("count", 5);

            List <Refund> lstRefunds = refundService.GetRefunds(filter);

            foreach (Refund refund in lstRefunds)
            {
                Console.WriteLine(String.Format("RefundID:{0}", refund.Id));
            }

            Console.Read();
        }
Beispiel #7
0
 private void InitClient(Payment payment)
 {
     Client               = new StripeClient(payment.PaymentMethod.GetProperty(SecretKey).GetValue().ToString());
     ChargeService        = new ChargeService(Client);
     PaymentIntentService = new PaymentIntentService(Client);
     RefundService        = new RefundService(Client);
 }
Beispiel #8
0
        public RefundServiceTest(
            StripeMockFixture stripeMockFixture,
            MockHttpClientFixture mockHttpClientFixture)
            : base(stripeMockFixture, mockHttpClientFixture)
        {
            this.service = new RefundService(this.StripeClient);

            this.createOptions = new RefundCreateOptions
            {
                Amount   = 123,
                ChargeId = "ch_123",
            };

            this.updateOptions = new RefundUpdateOptions
            {
                Metadata = new Dictionary <string, string>
                {
                    { "key", "value" },
                },
            };

            this.listOptions = new RefundListOptions
            {
                Limit = 1,
            };
        }
        public IActionResult CancelOrder(int id)
        {
            OrderHeader orderHeader = _unitOfWork.OrderHeader.GetFirstOrDefault(u => u.Id == id);

            if (orderHeader.PaymentStatus == SD.StatusApproved)
            {
                var options = new RefundCreateOptions
                {
                    Amount = Convert.ToInt32(orderHeader.OrderTotal * 100),
                    Reason = RefundReasons.RequestedByCustomer,
                    Charge = orderHeader.TransactionId
                };
                var    service = new RefundService();
                Refund refund  = service.Create(options);

                orderHeader.OrderStatus   = SD.StatusRefunded;
                orderHeader.PaymentStatus = SD.StatusRefunded;
            }
            else
            {
                orderHeader.OrderStatus   = SD.StatusCancelled;
                orderHeader.PaymentStatus = SD.PaymentStatusRejected;
            }

            _unitOfWork.Save();
            return(RedirectToAction("Index"));
        }
Beispiel #10
0
        public ActionResult ValidateRefund(string OrderID, string TelePhone, string CodeStr)
        {
            var validateResult = new CodeService().ValidateCodeWithOutTime(TelePhone, CodeStr, Code_Type.Refund);

            if (!(validateResult != null && validateResult.status > 0))
            {
                ViewBag.tipStr = "验证申请授权错误";
            }

            var refundResult = new RefundService().SelectByID(OrderID);

            if (refundResult != null && refundResult.RefundStatus == (int)Order_Status.Refunding)
            {
                var RecordEntity = new RecordService().SelectByID(OrderID);
                ViewBag.OrderID     = RecordEntity != null ? RecordEntity.RecordID : OrderID;
                ViewBag.OrderNo     = RecordEntity != null ? RecordEntity.OrderNo : "";
                ViewBag.Amount      = RecordEntity != null ? RecordEntity.Amount : 0;
                ViewBag.Description = RecordEntity != null ? RecordEntity.Description : "";

                ViewBag.RefundAmount = refundResult.Amount;
                ViewBag.RefundRemark = refundResult.Remark;

                ViewBag.tipStr = "";
            }
            else
            {
                ViewBag.tipStr = "退款单已处理";
            }
            return(View());
        }
Beispiel #11
0
        public ActionResult Refund()
        {
            try
            {
                StripeConfiguration.ApiKey            = key;
                StripeConfiguration.MaxNetworkRetries = 2;

                var refunds       = new RefundService();
                var refundOptions = new RefundCreateOptions
                {
                    PaymentIntent = paymentIntent
                };
                var refund = refunds.Create(refundOptions);

                return(View("OrderStatus"));
            }
            catch (StripeException e)
            {
                var x = new
                {
                    status  = "Failed",
                    message = e.Message
                };
                return(this.Json(x));
            }
        }
Beispiel #12
0
        public string Refund(string toggleRefund)
        {   //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
            //sk_test_51Gzaa1HAh8lBnQxza9cOAzY7LbfgQ4FWX2sYqiuHsoVWJg4mNDppueQkAVd0XIPU4GhcrNBca8aemNgr24m4jDv200ooFw0Bhz
            StripeConfiguration.ApiKey = "sk_test_51Gzaa1HAh8lBnQxza9cOAzY7LbfgQ4FWX2sYqiuHsoVWJg4mNDppueQkAVd0XIPU4GhcrNBca8aemNgr24m4jDv200ooFw0Bhz";
            var msg = "";

            if (toggleRefund == "refund")
            {
                var refunds       = new RefundService();
                var refundOptions = new RefundCreateOptions
                {
                    PaymentIntent = "pi_1GzxFMHAh8lBnQxzpA2OSATN"
                };
                var refund = refunds.Create(refundOptions);
                msg = "Payment refunded successfully";
            }

            else if (toggleRefund == "cancelRefund")
            {
                var service = new PaymentIntentService();
                var options = new PaymentIntentCancelOptions {
                };
                var intent  = service.Cancel("pi_1GzxFMHAh8lBnQxzpA2OSATN", options);
                msg = "Payment refund cancelled";
            }
            //ViewBag.message = msg;
            return(msg);
        }
        public IActionResult OnPostOrderRefund(int orderId)
        {
            OrderHeader orderHeader = _unitOfWork.OrderHeader.GetFirstOrDefault(o => o.Id == orderId);

            //refund the amount
            //go to stripe and find the documentation in refund
            //copy the post call in refunds documentation
            // this is the code of refund
            var options = new RefundCreateOptions
            {
                Amount = Convert.ToInt32(orderHeader.OrderTotal * 100),
                Reason = RefundReasons.RequestedByCustomer,
                //something wrong with charge. I think that is ChargeId
                Charge = orderHeader.TransactionId
            };
            var service = new RefundService();

            //Refund refund = service.Create("myAPI coedes", refundOptions);
            Refund refund = service.Create(options);


            orderHeader.Status = SD.StatusRefunded;
            _unitOfWork.Save();

            return(RedirectToPage("OrderList"));
        }
        public async Task <IEnumerable <TransactionDTO> > Execute(PaymentModel payment)
        {
            var customer = await _paymentRepository.GetLastTransaction(payment.OrderId);

            var service = new RefundService();

            var options = new RefundCreateOptions
            {
                Charge = customer.ExternalId,
            };

            var orderInfo = new PaymentModel {
                UserId = customer.UserId, VendorId = customer.VendorId, OrderId = customer.OrderId, Amount = customer.Amount
            };

            var transaction = await _retryHelper.RetryIfThrown(async() =>
            {
                var result = await service.CreateAsync(options);
                var test   = _mappingProvider.GetMappingOperation(PaymentServiceConstants.PaymentMappingType.Stripe_Refund)
                             .Map(PaymentServiceConstants.PaymentType.Refund, orderInfo, result, result.Created);
                return(test);
            }, PaymentServiceConstants.PaymentType.Refund, orderInfo, PaymentServiceConstants.isSucceeded.Succeeded);

            return(await _paymentRepository.CreateTransactions(transaction));
        }
Beispiel #15
0
        public IActionResult CancelOrder(int id)
        {
            var orderHeader = _unitOfWork.OrderHeader.FirstOrDefault(c => c.Id == id);

            //We want refund if only the status was approved for the initial payment because if the status was for a delayed company we dont want to process a refund for them
            if (orderHeader.PaymentStatus == SD.StatusApproved)
            {
                var options = new RefundCreateOptions
                {
                    Amount = Convert.ToInt32(orderHeader.OrderTotal * 100),
                    Reason = RefundReasons.RequestedByCustomer,
                    Charge = orderHeader.TransactionId
                };
                var service = new RefundService();
                var refund  = service.Create(options);

                orderHeader.OrderStatus   = SD.StatusCancelled;
                orderHeader.PaymentStatus = SD.StatusCancelled;
            }
            else
            {
                orderHeader.OrderStatus   = SD.StatusCancelled;
                orderHeader.PaymentStatus = SD.StatusCancelled;
            }
            _unitOfWork.Save();
            return(RedirectToAction(nameof(Index)));
        }
Beispiel #16
0
        public IActionResult CancelOrder(int id)
        {
            // get order header
            OrderHeader orderHeader = _unitOfWork.OrderHeader.GetFirstOrDefault(u => u.Id == id);

            // if the order has been approved then it will need to be refunded
            if (orderHeader.PaymentStatus == SD.StatusApproved)
            {
                // create refund options
                var options = new RefundCreateOptions
                {
                    Amount = Convert.ToInt32(orderHeader.OrderTotal * 100),
                    Reason = RefundReasons.RequestedByCustomer,
                    Charge = orderHeader.TransactionId
                };

                var    service = new RefundService();
                Refund refund  = service.Create(options);

                // set orderHeader properties in line with a refund
                orderHeader.OrderStatus   = SD.StatusRefunded;
                orderHeader.PaymentStatus = SD.StatusRefunded;
            }
            else
            {
                // order was not approved so it will be cancelled
                orderHeader.OrderStatus   = SD.StatusCancelled;
                orderHeader.PaymentStatus = SD.StatusCancelled;
            }

            _unitOfWork.Save();

            return(RedirectToAction("Index"));
        }
        public IActionResult CancelOrder(int id)
        {
            OrderHeader orderHeader = _unitOfWork.OrderHeader.GetFirstOrDefault(u => u.Id == id);

            if (orderHeader.PaymentStatus == SD.StatusApproved)
            {
                //Stripe entities
                var options = new RefundCreateOptions
                {
                    Amount = Convert.ToInt32(orderHeader.OrderTotal * 100),
                    Reason = RefundReasons.RequestedByCustomer,
                    Charge = orderHeader.TransactionId
                };
                var    service = new RefundService();
                Refund refund  = service.Create(options);
                orderHeader.OrderStatus   = SD.StatusRefunded;
                orderHeader.PaymentStatus = SD.StatusRefunded;
                //after giving them the refund in stripe change the orderHeader niformation accordingly
            }
            //if unable to refund just cancel the order.
            else
            {
                orderHeader.OrderStatus   = SD.StatusCancelled;
                orderHeader.PaymentStatus = SD.StatusCancelled;
            }
            _unitOfWork.Save();
            return(RedirectToAction("Index"));
        }
Beispiel #18
0
        public async void chargeGroceryAmount()
        {
            try
            {
                StripeConfiguration.SetApiKey("sk_test_Q5wSnyXL03yN0KpPaAMYttOb");
                var options = new RefundCreateOptions
                {
                    ChargeId = jobChargeId
                };
                var    service = new RefundService();
                Refund refund  = service.Create(options);

                double amount = Convert.ToDouble(totalAmounts);


                var charge = new ChargeCreateOptions
                {
                    Amount     = Convert.ToInt32(amount * 100), // In cents, not dollars, times by 100 to convert
                    Currency   = "aud",                         // or the currency you are dealing with
                    CustomerId = "cus_Dxa4I8cQgAL7D7"           //Convert.ToString(userData["stripeCustomerId"]),
                };
                var services = new ChargeService();
                var response = services.Create(charge);

                await DisplayAlert("", "Successfully Charge Amount: " + amount, "Ok");
            }
            catch (Exception ex)
            {
                await DisplayAlert("", ExceptionManagement.LogException(ex), "Ok");
            }
        }
Beispiel #19
0
        public async Task CancelAndRecoverChargesAsync(ISubscriber subscriber)
        {
            if (!string.IsNullOrWhiteSpace(subscriber.GatewaySubscriptionId))
            {
                var subscriptionService = new SubscriptionService();
                await subscriptionService.CancelAsync(subscriber.GatewaySubscriptionId,
                                                      new SubscriptionCancelOptions());
            }

            if (string.IsNullOrWhiteSpace(subscriber.GatewayCustomerId))
            {
                return;
            }

            var customerService = new CustomerService();
            var customer        = await customerService.GetAsync(subscriber.GatewayCustomerId);

            if (customer == null)
            {
                return;
            }

            if (customer.Metadata.ContainsKey("btCustomerId"))
            {
                var transactionRequest = new Braintree.TransactionSearchRequest()
                                         .CustomerId.Is(customer.Metadata["btCustomerId"]);
                var transactions = _btGateway.Transaction.Search(transactionRequest);

                if ((transactions?.MaximumCount ?? 0) > 0)
                {
                    var txs = transactions.Cast <Braintree.Transaction>().Where(c => c.RefundedTransactionId == null);
                    foreach (var transaction in txs)
                    {
                        await _btGateway.Transaction.RefundAsync(transaction.Id);
                    }
                }

                await _btGateway.Customer.DeleteAsync(customer.Metadata["btCustomerId"]);
            }
            else
            {
                var chargeService = new ChargeService();
                var charges       = await chargeService.ListAsync(new ChargeListOptions
                {
                    CustomerId = subscriber.GatewayCustomerId
                });

                if (charges?.Data != null)
                {
                    var refundService = new RefundService();
                    foreach (var charge in charges.Data.Where(c => !c.Refunded))
                    {
                        await refundService.CreateAsync(new RefundCreateOptions { ChargeId = charge.Id });
                    }
                }
            }

            await customerService.DeleteAsync(subscriber.GatewayCustomerId);
        }
        public void TestNotify()
        {
            string _tmp = "1";
            var    ser  = new RefundService();

            ser.NotifyRefund("2015102253741655");
            Assert.IsTrue(!string.IsNullOrWhiteSpace(_tmp));
        }
Beispiel #21
0
            private static async Task <ApiResult <ApiRefundResponse> > BecauseAsync()
            {
                var createPaymentResult = await _alternativePaymentService.CreatePaymentAsync(PaymentRequest);

                await Task.Delay(2000);

                return(await RefundService.CreateRefundAsync(createPaymentResult.Value.Payment.ID.Value, RefundRequest));
            }
        public override async Task <ApiResult> RefundPaymentAsync(PaymentProviderContext <StripeCheckoutSettings> ctx)
        {
            try
            {
                // We can only refund a captured charge, so make sure we have one
                // otherwise there is nothing we can do
                var chargeId = ctx.Order.Properties["stripeChargeId"];
                if (string.IsNullOrWhiteSpace(chargeId))
                {
                    return(null);
                }

                var secretKey = ctx.Settings.TestMode ? ctx.Settings.TestSecretKey : ctx.Settings.LiveSecretKey;

                ConfigureStripe(secretKey);

                var refundService       = new RefundService();
                var refundCreateOptions = new RefundCreateOptions()
                {
                    Charge = chargeId
                };

                var refund = refundService.Create(refundCreateOptions);
                var charge = refund.Charge ?? await new ChargeService().GetAsync(refund.ChargeId);

                // If we have a subscription then we'll cancel it as refunding an ctx.Order
                // should effecitvely undo any purchase
                if (!string.IsNullOrWhiteSpace(ctx.Order.Properties["stripeSubscriptionId"]))
                {
                    var subscriptionService = new SubscriptionService();
                    var subscription        = await subscriptionService.GetAsync(ctx.Order.Properties["stripeSubscriptionId"]);

                    if (subscription != null)
                    {
                        subscriptionService.Cancel(ctx.Order.Properties["stripeSubscriptionId"], new SubscriptionCancelOptions
                        {
                            InvoiceNow = false,
                            Prorate    = false
                        });
                    }
                }

                return(new ApiResult()
                {
                    TransactionInfo = new TransactionInfoUpdate()
                    {
                        TransactionId = GetTransactionId(charge),
                        PaymentStatus = GetPaymentStatus(charge)
                    }
                });
            }
            catch (Exception ex)
            {
                _logger.Error(ex, "Stripe - RefundPayment");
            }

            return(ApiResult.Empty);
        }
Beispiel #23
0
        public override ApiResult RefundPayment(OrderReadOnly order, StripeCheckoutSettings settings)
        {
            try
            {
                // We can only refund a captured charge, so make sure we have one
                // otherwise there is nothing we can do
                var chargeId = order.Properties["stripeChargeId"];
                if (string.IsNullOrWhiteSpace(chargeId))
                {
                    return(null);
                }

                var secretKey = settings.TestMode ? settings.TestSecretKey : settings.LiveSecretKey;

                ConfigureStripe(secretKey);

                var refundService       = new RefundService();
                var refundCreateOptions = new RefundCreateOptions()
                {
                    Charge = chargeId
                };

                var refund = refundService.Create(refundCreateOptions);
                var charge = refund.Charge ?? new ChargeService().Get(refund.ChargeId);

                // If we have a subscription then we'll cancel it as refunding an order
                // should effecitvely undo any purchase
                if (!string.IsNullOrWhiteSpace(order.Properties["stripeSubscriptionId"]))
                {
                    var subscriptionService = new SubscriptionService();
                    var subscription        = subscriptionService.Get(order.Properties["stripeSubscriptionId"]);
                    if (subscription != null)
                    {
                        subscriptionService.Cancel(order.Properties["stripeSubscriptionId"], new SubscriptionCancelOptions
                        {
                            InvoiceNow = false,
                            Prorate    = false
                        });
                    }
                }

                return(new ApiResult()
                {
                    TransactionInfo = new TransactionInfoUpdate()
                    {
                        TransactionId = GetTransactionId(charge),
                        PaymentStatus = GetPaymentStatus(charge)
                    }
                });
            }
            catch (Exception ex)
            {
                Vendr.Log.Error <StripeCheckoutOneTimePaymentProvider>(ex, "Stripe - RefundPayment");
            }

            return(ApiResult.Empty);
        }
Beispiel #24
0
 public CoronaController(
     MemberContext database,
     UserManager <User> userManager,
     RefundService refundService)
 {
     _database      = database;
     _userManager   = userManager;
     _refundService = refundService;
 }
 public void Connect(string apiUrl, string apiKey)
 {
     PaymillWrapper.Paymill.ApiKey = apiKey;
     PaymillWrapper.Paymill.ApiUrl = apiUrl;
     clientService = Paymill.GetService<ClientService>();
     paymentService = Paymill.GetService<PaymentService>();
     transactionService = Paymill.GetService<TransactionService>();
     refundService = Paymill.GetService<RefundService>();
 }
Beispiel #26
0
        public async Task can_claim_refund()
        {
            uint timestamp = 1546871954;

            _bridge.NextBlockPlease(timestamp);

            DepositService depositService = new DepositService(_ndmBridge, _abiEncoder, _wallet, _contractAddress);
            Keccak         assetId        = Keccak.Compute("data asset");
            uint           expiryTime     = timestamp + 4;
            UInt256        value          = 1.Ether();
            uint           units          = 10U;

            byte[] salt = new byte[16];

            AbiSignature depositAbiDef = new AbiSignature("deposit",
                                                          new AbiBytes(32),
                                                          new AbiUInt(32),
                                                          new AbiUInt(96),
                                                          new AbiUInt(32),
                                                          new AbiBytes(16),
                                                          AbiType.Address,
                                                          AbiType.Address);

            byte[] depositData = _abiEncoder.Encode(AbiEncodingStyle.Packed, depositAbiDef, assetId.Bytes, units, value, expiryTime, salt, _providerAccount, _consumerAccount);
            Keccak depositId   = Keccak.Compute(depositData);

            Deposit deposit       = new Deposit(depositId, units, expiryTime, value);
            Keccak  depositTxHash = await depositService.MakeDepositAsync(_consumerAccount, deposit, 20.GWei());

            _bridge.IncrementNonce(_consumerAccount);
            TxReceipt depositTxReceipt = _bridge.GetReceipt(depositTxHash);

            TestContext.WriteLine("GAS USED FOR DEPOSIT: {0}", depositTxReceipt.GasUsed);
            Assert.AreEqual(StatusCode.Success, depositTxReceipt.StatusCode, $"deposit made {depositTxReceipt.Error} {Encoding.UTF8.GetString(depositTxReceipt.ReturnValue ?? new byte[0])}");

            // calls revert and cannot reuse the same state - use only for manual debugging
//            Assert.True(depositService.VerifyDeposit(deposit.Id), "deposit verified");

            RefundService refundService = new RefundService(_ndmBridge, _abiEncoder, _depositRepository,
                                                            _contractAddress, LimboLogs.Instance, _wallet);

            // it will not work so far as we do everything within the same block and timestamp is wrong

            _bridge.NextBlockPlease(expiryTime + 1);
            RefundClaim refundClaim   = new RefundClaim(depositId, assetId, units, value, expiryTime, salt, _providerAccount, _consumerAccount);
            UInt256     balanceBefore = _state.GetBalance(_consumerAccount);
            Keccak      refundTxHash  = await refundService.ClaimRefundAsync(_consumerAccount, refundClaim, 20.GWei());

            TxReceipt refundReceipt = _bridge.GetReceipt(refundTxHash);

            TestContext.WriteLine("GAS USED FOR REFUND CLAIM: {0}", refundReceipt.GasUsed);
            Assert.AreEqual(StatusCode.Success, refundReceipt.StatusCode, $"refund claim {refundReceipt.Error} {Encoding.UTF8.GetString(refundReceipt.ReturnValue ?? new byte[0])}");
            UInt256 balanceAfter = _state.GetBalance(_consumerAccount);

            Assert.Greater(balanceAfter, balanceBefore);
        }
Beispiel #27
0
        public async Task <Refund> CreateRefundAsync(string chargeId)
        {
            var options = new RefundCreateOptions
            {
                Charge = chargeId,
            };

            var service = new RefundService();

            return(await service.CreateAsync(options));
        }
        public async Task set_early_refund_ticket_should_fail_if_deposit_does_not_exits()
        {
            const RefundReason reason = RefundReason.DataDiscontinued;
            var ticket        = new EarlyRefundTicket(TestItem.KeccakA, 0, null);
            var refundService = new RefundService(_ndmBridge, _abiEncoder, _depositRepository, _contractAddress, LimboLogs.Instance);
            await refundService.SetEarlyRefundTicketAsync(ticket, reason);

            await _depositRepository.Received().GetAsync(ticket.DepositId);

            await _depositRepository.DidNotReceiveWithAnyArgs().UpdateAsync(null);
        }
        public StripeService(FurCoNZDbContext dbContext, IOptions <StripeSettings> options, IOrderService orderService, ILogger <StripeService> logger)
        {
            _dbContext            = dbContext;
            _options              = options;
            _orderService         = orderService;
            _logger               = logger;
            _paymentIntentService = new PaymentIntentService();

            _checkoutService = new SessionService();
            _chargeService   = new ChargeService();
            _refundService   = new RefundService();
        }
        public async Task <ActionResult> RefundPayment([FromBody] string chargeId) //Full Refund, we can set up amount in refund options for partial refund
        {
            var refunds       = new RefundService();
            var refundOptions = new RefundCreateOptions
            {
                Charge = chargeId
                         //Amount = 1000
            };
            var refund = await refunds.CreateAsync(refundOptions);

            return(new OkObjectResult(new { Success = "true" }));
        }
Beispiel #31
0
        public async Task <RefundDto> CreateRefund(RefundCreateDto dto)
        {
            var options = new RefundCreateOptions
            {
                ChargeId = dto.ChargeId,
                Amount   = dto.Amount,
                Reason   = RefundReasons.Fraudulent
            };
            var service = new RefundService();

            return(RefundMapper.MapRefundToRefundDto(await service.CreateAsync(options)));
        }