Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
..
Failed to load latest commit information.
Pages
wwwroot
.gitignore
Program.cs
README.md
Startup.cs
appsettings.Development.json
appsettings.json
bundleconfig.json
sqRazorSample.csproj
sqRazorSample.sln

README.md

Payment processing example: Csharp

This sample demonstrates processing card payments with Square Connect API, using the Square Connect C# client library and dotnet core.

Setup

Requirements

Setup your square account

  1. Login to Square Dashboard
  2. Create some items from Items Tab
  3. 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:

dotnet build

Provide required credentials

Open ./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:

dotnet run

Then you can visit:

http://localhost:5000
  • 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.