コード例 #1
0
        public RevokePaymentMethod_Result RevokePaymentMethod(RevokePaymentMethod_Details details)
        {
            StripeConfiguration.SetApiKey(secretKey);
            StripeDeleted delete = new StripeDeleted();

            try
            {
                var customerService = new StripeCustomerService();
                delete = customerService.Delete(details.CardToken);
            }
            catch (StripeException e)
            {
                return(new RevokePaymentMethod_Result()
                {
                    ErrorCode = e.StripeError.Code,
                    ErrorMessage = e.StripeError.Message
                });
            }
            return(new RevokePaymentMethod_Result()
            {
                ErrorMessage = delete.Deleted + "",
                isSuccess = delete.Deleted,
                TransactionIdentifier = delete.Id,
            });
        }
コード例 #2
0
        public static bool DeleteCoupon(String couponId)
        {
            var couponService = new StripeCouponService();

            try
            {
                StripeDeleted coupon = couponService.Delete(couponId);
                return(coupon.Deleted);
            }
            catch
            {
                return(false);
            }
        }
コード例 #3
0
ファイル: _fixtures.cs プロジェクト: tkhalifeh/stripe-dotnet
        public external_account_fixture()
        {
            Account = new StripeAccountService(Cache.ApiKey).Create(new StripeAccountCreateOptions
            {
                Country = "US",
                Type    = StripeAccountType.Custom
            });

            ExernalAccountCreateOptionsBankAccount = new StripeExternalAccountCreateOptions
            {
                ExternalAccountBankAccount = new StripeAccountBankAccountOptions
                {
                    AccountNumber = "000123456789",
                    Country       = "US",
                    Currency      = "usd",
                    RoutingNumber = "110000000"
                }
            };

            ExernalAccountBankAccountUpdateOptions = new StripeExternalAccountUpdateOptions
            {
                Metadata = new Dictionary <string, string>()
                {
                    { "key", "value" }
                }
            };

            ExernalAccountCardUpdateOptions = new StripeExternalAccountUpdateOptions
            {
                ExternalAccountCard = new StripeExternalAccountCardUpdateOptions
                {
                    ExpirationMonth = 01,
                    ExpirationYear  = 2028,
                    Name            = "Updated Name"
                }
            };

            var service = new StripeExternalAccountService(Cache.ApiKey);

            ExternalAccountCard = service.Create(Account.Id, new StripeExternalAccountCreateOptions
            {
                ExternalAccountTokenId = "tok_visa_debit"
            });
            ExternalAccountBankAccount        = service.Create(Account.Id, ExernalAccountCreateOptionsBankAccount);
            ExternalAccountBankAccountUpdated = service.Update(Account.Id, ExternalAccountBankAccount.Id, ExernalAccountBankAccountUpdateOptions);
            ExternalAccountCardUpdated        = service.Update(Account.Id, ExternalAccountCard.Id, ExernalAccountCardUpdateOptions);
            ExternalAccountRetrieved          = service.Get(Account.Id, ExternalAccountCard.Id);
            ExternalAccountList    = service.List(Account.Id);
            ExternalAccountDeleted = service.Delete(Account.Id, ExternalAccountBankAccount.Id);
        }
コード例 #4
0
        public void DeleteCustomer(string Api_Key, string customerId, ref string Response, ref string Errors, ref int ErrorCode)
        {
            try
            {
                StripeConfiguration.SetApiKey(Api_Key);

                var           customerService = new StripeCustomerService();
                StripeDeleted deletedCustomer = customerService.Delete(customerId);
                Response  = deletedCustomer.StripeResponse.ResponseJson;
                ErrorCode = 0;
            }
            catch (StripeException e)
            {
                ErrorCode = 1;
                Serializer  serializer  = new Serializer();
                StripeError stripeError = e.StripeError;
                Errors = serializer.Serialize <StripeError>(stripeError);
            }
        }
コード例 #5
0
        public ActionResult CancelSubscription(long userID)
        {
            string         customerID      = Convert.ToString(SessionController.UserSession.CustomerID);
            var            customerService = new StripeCustomerService();
            StripeCustomer stripeCustomer  = customerService.Get(customerID);

            var subscriptionID = stripeCustomer.Subscriptions.Data[0].Id;

            var subscriptionService = new StripeSubscriptionService();
            var status = subscriptionService.Cancel(subscriptionID, true); // optional cancelAtPeriodEnd flag

            SessionController.UserSession.IsPaid = false;

            //Delete the customer's card from stripe
            var           cardService = new StripeCardService();
            StripeCard    stripeCard  = cardService.Get(customerID, stripeCustomer.DefaultSourceId);
            StripeDeleted card        = cardService.Delete(customerID, stripeCard.Id);

            return(Json(status, JsonRequestBehavior.AllowGet));
        }