DotNet Desktop Application and CreatePayment

I work on a dotnet desktop application and I’m looking to Create Payments in my sandbox. This is not a web application and I therefore do not have a frontend or backend; it’s just one application that does it all.

I understand I need to use sqpaymentform but I can’t for the life of me figure out how I can do this without a front end application. Is there any way to host the page from a desktop application?

Hi @jacob.peacock welcome to the forums!

No, as far as I know there’s no way to do this without a web page of some sort as it uses a Javascript library, and requires Javascript to load and generate a nonce. If you had a web page, you probably could put it in some sort of web view in .NET, but the web page would still need to be created of course.

I decided to switch to the Hosted Checkout Page solution instead of sqpaymentform. Seemed like it might work for us because then I can just open a URL and handle the response.

But when I run CreateCheckout() I get back an “AUTHORIZATION_ERROR - You Have Insufficient Privileges” error. This happens only when I use an OAuth access token. I tried adding every privilege, getting a new access token but no luck. When I use the access token provided in my Sandbox credentials page, I do not receive the error.

So for CreateCheckout you need PAYMENTS_WRITE and ORDERS_WRITE. If you’re confident that you included those, could you provide your application id as well as the merchant id (or location id) of the OAuth access token you’re trying to use? I can take a look on my side to see what’s going on.

I copy and pasted every permission so I’m confident I include those.

I don’t believe I had to provide a location ID when I got my AuthCode to get the OAuth Access Token. I provided the Application ID (sandbox-sq0idb-iLI9ILHlSvfja2YXpNc5iw) and made sure I was logged into my SalesPad Test Account (rather than then default test account).

The only location I have in my sandbox is the default one which has an ID of RDR6TV79A0M9H.

Hmmm could you share the OAuth authorize url you’re creating? For that location/merchant account I only see 4 permissions: MERCHANT_PROFILE_READ, PAYMENTS_READ, PAYMENTS_WRITE, and PAYMENTS_WRITE_ADDITIONAL_RECIPIENTS, thus you’re missing ORDERS_WRITE to successfully call CreateCheckout.

Here ya go. Like I said, every permission :slight_smile:
https://connect.squareupsandbox.com/oauth2/authorize?client_id=sandbox-sq0idb-iLI9ILHlSvfja2YXpNc5iw&scope=BANK_ACCOUNTS_READ+CASH_DRAWER_READ+CUSTOMERS_READ+CUSTOMERS_WRITE+DEVICE_CREDENTIAL_MANAGEMENT+EMPLOYEES_READ+EMPLOYEES_WRITE+INVENTORY_READ+INVENTORY_WRITE+ITEMS_READ+ITEMS_WRITE+LOYALTY_READ+LOYALTY_WRITE+MERCHANT_PROFILE_READ+ORDERS_READ+ORDERS_WRITE+PAYMENTS_READ+PAYMENTS_WRITE+PAYMENTS_WRITE_ADDITIONAL_RECIPIENTS+PAYMENTS_WRITE_IN_PERSON+SETTLEMENTS_READ+TIMECARDS_READ+TIMECARDS_WRITE+TIMECARDS_SETTINGS_READ+TIMECARDS_SETTINGS_WRITE

I just realized I gave you the wrong Location ID. This is the correct one: AJDHSJH6XBCP9

Hmmm so now I’m really confused. The location you provided is a production location, but you’ve provided a sandbox oauth authorization link. If you’re trying to use production, you must use an OAuth production authorization link, as well as a production OAuth access token, as well as using the domain as “connect.squareup.com” instead of “connect.squareupsandbox.com”.

For that location, I do see you have the right permissions, so I suspect you’re either using the wrong domain or the wrong access token.

Ahhh this is making more sense to me now. I must have made the SalesPad app and assumed it would just use the default location in the sandbox. I didn’t realize it made a new location in Production.

Is there a way to make a new location in the Sandbox or is the default the only choice?

If you navigate to your developer apps page (https://developer.squareup.com/apps), and launch one of the sandbox test accounts then navigate to https://squareupsandbox.com/dashboard/locations, you should be able to create locations in your sandbox dashboard.