Payment processing example: Csharp
This sample demonstrates processing card payments with Square Connect API, using the Square Connect C# client library and dotnet core.
- Download and install .net core 2.0
- Signup a Square account from Square website
- You have learned the basics from Square Developer Docs
Setup your square account
- Login to Square Dashboard
- Create some items from Items Tab
- Go to Square Developer Portal and create a new application.
Build the project
After cloning this sample project to local, open command line tool, and from the project root directory run:
Provide required credentials
./appsettings.json and replace "AccessToken", "LocationId" and "ApplicationId" with the ids you get from your square application created in Square Developer Portal.
WARNING: never upload
appsettings.json with your credentials/access_token.
If you're just testing things out, it's recommended that you use your sandbox credentials for now. See this article for more information on the API sandbox.
Running the sample
Run the command from the project root directory:
Then you can visit:
You'll see a simple payment form that will charge $1.00.
You can test a valid credit card transaction by providing the following card information in the form:
- Card Number 4532 7597 3454 5858
- Card CVV 111
- Card Expiration (Any time in the future)
- Card Postal Code (Any valid US postal code)
You can find more testing values in this article
Note that if you are not using your sandbox credentials and you enter real credit card information, YOU WILL CHARGE THE CARD.