public IActionResult Post([FromBody] PaymentModel payment) { // You can optionally create a customer first, attached this to patientID var charge = new StripeChargeCreateOptions { Amount = Convert.ToInt32(payment.Amount) * 100, //The default value is in cents, hence multply by 100 Currency = "ZAR", Description = "We Must bind the product details here", SourceTokenOrExistingSourceId = payment.Token }; var service = new StripeChargeService("sk-testxxxxxx");//api key try { //BONGA: I keep getting an error for the next line of code, will come back to it when we need to set up //var response = service.Capture(charge); //Record or do something with charge info } catch (StripeException ex) { StripeError stripeError = ex.StripeError; //handle error } return(OK(true));//will have to revisit this }
public IActionResult Post([FromBody] PaymentModel payment) { // only receive the token here, no credit card information is coming to the server at all. //You will want to make sure your API is using HTTPS and you provide any further authentication as necessary. // You can optionally create a customer first, and attached this to the CustomerId // var charge = new StripeChargeCreateOptions //{ // Amount = Convert.ToInt32(payment.Amount * 100), // In cents, not rands, times by 100 to convert // Currency = "zar", // or the currency you are dealing with // Description = "something awesome", // SourceTokenOrExistingSourceId = payment.Token //}; //var service = new StripeChargeService("sk_test_xxxxxxxxxxxxx"); try { // var response = service.Create(charge); // Record or do something with the charge information } catch (StripeException ex) { StripeError stripeError = ex.StripeError; // Handle error } // Ideally you would put in additional information, but you can just return true or false for the moment. return(Ok(true)); }
public Response Post(PaymentModel payment) { Response res = new Response(); // You can optionally create a customer first, and attached this to the CustomerId var charge = new ChargeCreateOptions { Amount = Convert.ToInt32(payment.Amount * 100), // In cents, not dollars, times by 100 to convert Currency = "usd", // or the currency you are dealing with Description = "something awesome", SourceId = payment.Token }; var service = new ChargeService("sk_test_LJ2dJvulsi1f4rsGrqLHCKGC00gP6buBnU"); try { var response = service.Create(charge); res.Status = 1; res.Message = response.Status; // Record or do something with the charge information } catch (StripeException ex) { StripeError stripeError = ex.StripeError; res.Status = 0; res.Message = ex.Message; // Handle error } // Ideally you would put in additional information, but you can just return true or false for the moment. return(res); }
public async Task Init() { IsBusy = true; PaymentModel vm = new PaymentModel() { CreditCard = new ISNogometniStadion.Model.CreditCardVM() { amount = Amount, CreditCardNumber = CreditCardNumber, CVV = CVV, ExpMonth = ExpMonth, ExpYear = ExpYear } }; StripeError e = await PaymentAPIService.Post <StripeError>(vm); Msg = e.Message; if (Msg == null) { Msg = "Neuspješna uplata"; } if (Msg == "Uspješna uplata") { Uspjesno = true; } else { Uspjesno = false; } }
public async void StripeProcess(string Token) { var charge = new StripeChargeCreateOptions { Amount = Convert.ToInt32(Total * 100), // In cents, not dollars, times by 100 to convert Currency = "usd", // or the currency you are dealing with Description = "StadiYUM Order", SourceTokenOrExistingSourceId = "tok_visa" }; var service = new StripeChargeService("sk_test_fMQSO85L4eNQWH7LEESCbY71"); try { var response = service.Create(charge); if (response.Paid) { manager.CartFinished(); await DisplayAlert("Order Confirmed", "Go to Orders to view status", "OK"); } // Record or do something with the charge information } catch (StripeException ex) { StripeError stripeError = ex.StripeError; DisplayAlert("Error", stripeError.Error, "OK"); // Handle error } // Ideally you would put in additional information, but you can just return true or false for the moment. }
private void btnPay_Click(string stripeToken) { string stripeCharge = ""; var myCharge = new StripeChargeCreateOptions { // convert the amount of £15.95 to pennies i.e. 1595 Amount = Convert.ToInt32(noofweeks.Value) * 480 * 100, Currency = "usd", // or whatever currency your dealing in Description = "121", // for example an order ID SourceTokenOrExistingSourceId = stripeToken, }; var chargeService = new StripeChargeService("sk_test_PJ6gMyIQDj3kl743NfGFzO1X"); try { chargeService.Create(myCharge); receipt.Visible = true; } catch (StripeException ex) { StripeError stripeError = ex.StripeError; // Handle error return; } // Successfully Authorised, do your post-succesful payment processing here... }
public IActionResult Post([FromBody] PaymentModel payment) { // You can optionally create a customer first, and attached this to the CustomerId var charge = new ChargeCreateOptions { Amount = Convert.ToInt32(payment.Amount * 100), // In cents, not dollars, times by 100 to convert Currency = "usd", // or the currency you are dealing with Description = "something awesome", Source = payment.Token }; var service = new ChargeService(); try { var api_options = new RequestOptions { ApiKey = "sk_test_P4flPzJBB89yG0N0Ghsm5Pzq00JmS8gy3L" }; var response = service.Create(charge, api_options); return(Ok(response.Paid)); // Record or do something with the charge information } catch (StripeException ex) { StripeError stripeError = ex.StripeError; // Handle error } // Ideally you would put in additional information, but you can just return true or false for the moment. return(Ok(true)); }
public IActionResult Post([FromBody] PaymentModel payment) { StripeConfiguration.ApiKey = "sk_test_1fkshXMQqrBjU8e4u7pghwAt001ToqSHEy"; // You can optionally create a customer first, and attached this to the CustomerId var charge = new ChargeCreateOptions { Amount = Convert.ToInt32(payment.Amount * 100), // In cents, not dollars, times by 100 to convert Currency = "mxn", // or the currency you are dealing with Description = "Algo bien HD", Source = payment.Token, }; //sk_test_1fkshXMQqrBjU8e4u7pghwAt001ToqSHEy //var service = new StripeChargeService("sk_test_xxxxxxxxxxxxx"); var service = new ChargeService(); try { var response = service.Create(charge); // Record or do something with the charge information return(Ok(response)); } catch (StripeException ex) { StripeError stripeError = ex.StripeError; // Handle error return(Ok(false)); } // Ideally you would put in additional information, but you can just return true or false for the moment. }
public string Post([FromBody] PaymentModel payment) { StripeConfiguration.ApiKey = ("pk_test_DaPhATJ0sS0GJYJnXbgubW6C00oJqhvxio"); var tokenOptions = new Stripe.TokenCreateOptions() { Card = new Stripe.CreditCardOptions() { Number = payment.CreditCard.CreditCardNumber, ExpYear = payment.CreditCard.ExpYear, ExpMonth = payment.CreditCard.ExpMonth, Cvc = payment.CreditCard.CVV } }; var tokenService = new Stripe.TokenService(); Stripe.Token stripeToken; try { stripeToken = tokenService.Create(tokenOptions); } catch (StripeException ex) { StripeError stripeError = ex.StripeError; return(stripeError.Message); } string token = stripeToken.Id; // This is the token // You can optionally create a customer first, and attached this to the CustomerId StripeConfiguration.ApiKey = ("sk_test_02wLfkfPFikWAuf5q8QwhcEb00RHbAsnJc"); var charge = new Stripe.ChargeCreateOptions { Amount = Convert.ToInt32(payment.CreditCard.amount * 100), // Ocekuje request u najmanjoj jedinici pa *100 da se pretvori Currency = "EUR", // or the currency you are dealing with Description = "Informacijski sistem za nogometni stadion", Source = token }; var service = new ChargeService(); try { var response = service.Create(charge); // Record or do something with the charge information } catch (StripeException ex) { StripeError stripeError = ex.StripeError; // Handle error return(stripeError.Message); } // Ideally you would put in additional information, but you can just return true or false for the moment0 StripeError stripeError1 = new StripeError() { Message = "Uspješna uplata" }; return(stripeError1.Message); }
internal static StripeException BuildStripeException(HttpStatusCode statusCode, string requestUri, string responseContent) { var stripeError = new StripeError(); if (requestUri.Contains("oauth")) { stripeError = Mapper <StripeError> .MapFromJson(responseContent); } else { stripeError = Mapper <StripeError> .MapFromJson(responseContent, "error"); } return(new StripeException(statusCode, stripeError, stripeError.Message)); }
public void RetreiveSubscriptionItem(string Api_key, string Subscription_Item_Id, ref string Response, ref string Errors, ref int ErrorCode) { try { StripeConfiguration.SetApiKey(Api_key); var stripeSubscriptionItemService = new StripeSubscriptionItemService(); var stripeSubscriptionItem = stripeSubscriptionItemService.Get(Subscription_Item_Id); Response = stripeSubscriptionItem.StripeResponse.ResponseJson; ErrorCode = 0; } catch (StripeException e) { ErrorCode = 1; Serializer serializer = new Serializer(); StripeError stripeError = e.StripeError; Errors = serializer.Serialize <StripeError>(stripeError); } }
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); } }
public void RetreivePlan(string Api_Key, string planId, ref string Response, ref string Errors, ref int ErrorCode) { try { StripeConfiguration.SetApiKey(Api_Key); var stripePlanService = new StripePlanService(); StripePlan stripePlan = stripePlanService.Get(planId); Response = stripePlan.StripeResponse.ResponseJson; ErrorCode = 0; } catch (StripeException e) { ErrorCode = 1; Serializer serializer = new Serializer(); StripeError stripeError = e.StripeError; Errors = serializer.Serialize <StripeError>(stripeError); } }
public void CancelSubscription(string Api_Key, string SubscriptionId, bool CancelAtPeriodEnd, ref string Response, ref string Errors, ref int ErrorCode) { try { StripeConfiguration.SetApiKey(Api_Key); var stripeSubscriptionService = new StripeSubscriptionService(); var stripeSubscription = stripeSubscriptionService.Cancel(SubscriptionId, CancelAtPeriodEnd); Response = stripeSubscription.StripeResponse.ResponseJson; ErrorCode = 0; } catch (StripeException e) { ErrorCode = 1; Serializer serializer = new Serializer(); StripeError stripeError = e.StripeError; Errors = serializer.Serialize <StripeError>(stripeError); } }
public void Balance(string Api_Key, ref string Response, ref string Errors, ref int ErrorCode) { try { StripeConfiguration.SetApiKey(Api_Key); var balanceService = new StripeBalanceService(); var balance = balanceService.Get(); var response = balance.StripeResponse; Response = response.ResponseJson; ErrorCode = 0; } catch (StripeException e) { ErrorCode = 1; Serializer serializer = new Serializer(); StripeError stripeError = e.StripeError; Errors = serializer.Serialize <StripeError>(stripeError); } }
private static StripeException BuildStripeException(StripeResponse response) { JObject jObject = null; try { jObject = JObject.Parse(response.Content); } catch (Newtonsoft.Json.JsonException) { return(BuildInvalidResponseException(response)); } // If the value of the `error` key is a string, then the error is an OAuth error // and we instantiate the StripeError object with the entire JSON. // Otherwise, it's a regular API error and we instantiate the StripeError object // with just the nested hash contained in the `error` key. var errorToken = jObject["error"]; if (errorToken == null) { return(BuildInvalidResponseException(response)); } var stripeError = errorToken.Type == JTokenType.String ? StripeError.FromJson(response.Content) : StripeError.FromJson(errorToken.ToString()); stripeError.StripeResponse = response; return(new StripeException( response.StatusCode, stripeError, stripeError.Message ?? stripeError.ErrorDescription) { StripeResponse = response, }); }
public IHttpActionResult Post([FromBody] Payment payment) { var charge = new StripeChargeCreateOptions { Amount = Convert.ToInt32(payment.Amount * 100), Currency = "usd", Description = "something awesome", SourceTokenOrExistingSourceId = payment.Token }; var service = new StripeChargeService("sekret_key"); try { var response = service.Create(charge); } catch (StripeException ex) { StripeError stripeError = ex.StripeError; } return(Ok(true)); }
public void UpdateSubscriptionItem(string Api_Key, string Subscription_Item_Id, string stripeSubscriptionItemUpdateOptionsJSON, ref string Response, ref string Errors, ref int ErrorCode) { try { StripeConfiguration.SetApiKey(Api_Key); Serializer serializer = new Serializer(); var stripeSubscriptionItemUpdateOptions = serializer.Deserialize <StripeSubscriptionItemUpdateOptions>(stripeSubscriptionItemUpdateOptionsJSON); var stripeSubscriptionItemService = new StripeSubscriptionItemService(); var stripeSubscriptionItem = stripeSubscriptionItemService.Update(Subscription_Item_Id, stripeSubscriptionItemUpdateOptions); Response = stripeSubscriptionItem.StripeResponse.ResponseJson; ErrorCode = 0; } catch (StripeException e) { ErrorCode = 1; Serializer serializer = new Serializer(); StripeError stripeError = e.StripeError; Errors = serializer.Serialize <StripeError>(stripeError); } }
public void CreatePlan(string Api_Key, string stripePlanCreateOptionsJSON, ref string Response, ref string Errors, ref int ErrorCode) { try { StripeConfiguration.SetApiKey(Api_Key); Serializer serializer = new Serializer(); StripePlanCreateOptions stripePlanCreateOptions = serializer.Deserialize <StripePlanCreateOptions>(stripePlanCreateOptionsJSON); var stripePlanService = new StripePlanService(); StripePlan stripePlan = stripePlanService.Create(stripePlanCreateOptions); Response = stripePlan.StripeResponse.ResponseJson; ErrorCode = 0; } catch (StripeException e) { ErrorCode = 1; Serializer serializer = new Serializer(); StripeError stripeError = e.StripeError; Errors = serializer.Serialize <StripeError>(stripeError); } }
public StripeException(HttpStatusCode httpStatusCode, StripeError stripeError, string message) : base(message) { this.HttpStatusCode = httpStatusCode; this.StripeError = stripeError; }