Last post Jul 08, 2019 01:02 AM by bruce (sqlwork.com)
Oct 22, 2016 02:07 PM|brajalalbrp|LINK
I want to add payment gateway from square.com in my c# mvc project. I already tried lots of things from google but unable to find proper solution.
Here is my controller code I already tried
public ActionResult Squre()
_transactionApi = new TransactionApi();
var client = new RestSharp.RestClient();
var request = new RestSharp.RestRequest("https://connect.squareup.com/v1/me/payments", RestSharp.Method.GET);
request.RequestFormat = RestSharp.DataFormat.Json;
request.AddHeader("Authorization", "Bearer sq0atp-zHuWWPD4ds9J6YoVlEoYZg");
var Response = client.Execute(request);
HttpWebResponse response = null;
string responseMessage = null;
response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
using (Stream stream = response.GetResponseStream())
using (StreamReader reader = new StreamReader(stream))
responseMessage = reader.ReadToEnd();
namespaces i have used mentioned below here
I want to make a payment gateway from square in my site. i need full tutorial for this can anyone help me please. What should i do??
Which things i have to modified in my code. Can anyone modify my code please or please give me the proper code
Oct 22, 2016 02:22 PM|Nasser Malik|LINK
All the help is available on their site
You can see sample here
Oct 22, 2016 02:30 PM|brajalalbrp|LINK
thank you for your reply . but sorry i can't understood the solution from this links,can you describe me in details please.
Oct 22, 2016 10:09 PM|KathyW|LINK
The links provide the details, including the code sample. If you are working in C#, follow the instructions on
https://github.com/square/connect-api-examples/tree/master/connect-examples/v2/csharp_payment and look at the downloaded files. (You can find the download link on
https://github.com/square/connect-api-examples, and you would only use the files in the folder corresponding to the example you are following, in csharp_payment)
Apr 30, 2017 02:22 PM|petespatio|LINK
I am trying to use the latest v2 and the sample code that references Money.ToCurrencyEnum doesn't seem to exist anymore. Do you know how to get around this?
Money amount = NewMoney(100, "USD");
public static Money NewMoney(int amount, string currency)
return new Money(amount, Money.ToCurrencyEnum(currency));
Jul 06, 2019 11:45 PM|georgeb1951|LINK
the example lacks an important element. here is the comment as it exists in the example
// Monetary amounts are specified in the smallest unit of the applicable currency.
// This amount is in cents. It's also hard-coded for $1.00,
// which isn't very useful.
I have to agree it isn't very useful and it's Square's own example..???
I have submitted 2 support request with them and have received no reply...
the question, for me, is how do I replace the hardcoded 100 with the total charge value form the form? in MVC5 C#
the code is in ProcessPament.cshtml.cs in the example.
Money amount = new Money(100, Money.CurrencyEnum.USD);
ANY help would be greatly appreciated TIA
Yours in frustration
Jul 08, 2019 01:02 AM|bruce (sqlwork.com)|LINK
did you even look at the source code?
onGetCardNonce(). presumably your UI would have a form field to identity the whats purchased, the unit count, the server should calc the amount, as if it was a post back value the user could hack it. if you must post back the amount, it should be encrypted.
the security feature of square, is that the credit card info does not go to your site, only the nonce (transaction identifier is sent to your site). your site uses this and the amount to do a charge.