private void CreateRefund(Transaction t) { Stripe.Configuration.SetApiKey(Settings.StripeApiKey); var chargeService = new StripeChargeService(); StripeCharge stripeCharge = chargeService.Refund(t.PreviousTransactionNumber, (int)(t.Amount * 100)); if (stripeCharge.Id.Length > 0) { t.Result.Succeeded = true; t.Result.ReferenceNumber = stripeCharge.Id; } else { t.Result.Succeeded = false; t.Result.ResponseCode = "FAIL"; t.Result.ResponseCodeDescription = "Stripe Failure"; } }
public override ApiInfo RefundPayment( Order order, IDictionary<string, string> settings ) { try { order.MustNotBeNull( "order" ); settings.MustNotBeNull( "settings" ); settings.MustContainKey( "mode", "settings" ); settings.MustContainKey( settings[ "mode" ] + "_secret_key", "settings" ); StripeChargeService chargeService = new StripeChargeService( settings[ settings[ "mode" ] + "_secret_key" ] ); StripeCharge charge = chargeService.Refund( order.TransactionInformation.TransactionId ); return new ApiInfo( charge.Id, GetPaymentState( charge ) ); } catch ( Exception exp ) { LoggingService.Instance.Log( exp, "Stripe(" + order.OrderNumber + ") - RefundPayment" ); } return null; }
private StripeCharge PerformStripeRefund() { try { PaymentGateway pg = new PaymentGateway(); var merchant = pg.GetMerchant(invoice.MerchantId); var voice = pg.GetDisplayInvoice(invoice.InvoiceId); int amountInCentsTotalRefund = Convert.ToInt32((invoice.FinancialData.RefundAmount) * 100); var chargeService = new StripeChargeService(merchant.StripeConnectToken); StripeCharge stripeCharge = chargeService.Refund(voice.CustomerId, amountInCentsTotalRefund); invoice.PaymentProviderRefundedId = stripeCharge.Id; return stripeCharge; } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } return null; }