# Square Payments

{% hint style="danger" %}
**Disclaimers:**

Checkout Champ **does not** store any card details for merchants using Square's Payment Gateway

Square will work for One-time and recurring purchases

Square **will ONLY work** with landers that connect to Checkout Champ via **Direct API**. This will NOT work with Form-code landers or Order Entry.
{% endhint %}

* [How to Obtain Square Credentials](#how-to-obtain-square-credentials)
* [How to set up Square](#how-to-set-up-square)
* [Prerequisites](#prerequisites)
* [Checkout Page Changes](#checkout-page-changes)
* [Square SQPaymentForm JS Changes](#square-sqpaymentform-js-changes)
* [Alternative Implementation](#alternative-implementation)
* [Upsells with Square](#upsells-with-square)

***

### **How to Obtain Square Credentials** <a href="#how-to-obtain-square-credentials" id="how-to-obtain-square-credentials"></a>

**Step 1.** Go [here ](https://squareup.com/us/en/developers)and login to the Square Developer Dashboard using your Square credentials

**Step 2.** Once logged into the Developer Dashboard click **New Application**

<figure><img src="https://3790748257-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FT43PzcNjyZtWby9yrGd3%2Fuploads%2FWh8wex5bJnWEGBuS0SNT%2FUntitled.png?alt=media&#x26;token=615a4d2d-21cb-421c-8a52-0c1c76b89ef9" alt=""><figcaption></figcaption></figure>

**Step 3. Name** and **Create** your Application, Doing so gives you complete API access for your Square merchant account.

<figure><img src="https://3790748257-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FT43PzcNjyZtWby9yrGd3%2Fuploads%2FqmGkLfOnqnFsgyqKT2KQ%2FUntitled.png?alt=media&#x26;token=2db08dec-04a5-417b-8b4e-c5ef3e97f0a6" alt=""><figcaption></figcaption></figure>

**Step 4** Once you have created your Application, Navigate to the **Credentials** Section.&#x20;

&#x20;       **Step 4a: Make sure to turn Sandbox Mode OFF.**

<figure><img src="https://3790748257-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FT43PzcNjyZtWby9yrGd3%2Fuploads%2FhGdw16oMSiXwTTOVO8UN%2FUntitled.png?alt=media&#x26;token=18bf6a8f-f09e-483c-8ba4-d5414503fd28" alt=""><figcaption></figcaption></figure>

**Step 5.** Once you have turned off Sandbox Mode you will be able to access your **Application Id**

<figure><img src="https://3790748257-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FT43PzcNjyZtWby9yrGd3%2Fuploads%2F655O0F7ky34q7nuceB4C%2FUntitled.png?alt=media&#x26;token=ce160211-c452-4ee5-9e04-9d78d50b6d7b" alt=""><figcaption></figcaption></figure>

**Step 6.** Navigate to the Locations Section to uncover your **LocationId**

<figure><img src="https://3790748257-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FT43PzcNjyZtWby9yrGd3%2Fuploads%2FmYWaM2KJW8xRG4KrIaL6%2FUntitled.png?alt=media&#x26;token=6bc96f3e-bdff-43ca-a011-616838c93084" alt=""><figcaption></figcaption></figure>

Navigate to the OAuth Section to obtain your **ApplicationSecret** and to set your **Redirect URL** which is <https://api.checkoutchamp.com/oauth/square/>

<figure><img src="https://3790748257-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FT43PzcNjyZtWby9yrGd3%2Fuploads%2FwX2dxDRgXqfuZvSkZ8Ri%2FUntitled.png?alt=media&#x26;token=53cf3846-2614-437f-aa7a-6dc689e8d23d" alt=""><figcaption></figcaption></figure>

**Note: If you have any issues with these credentials, attempt to use legacy credentials and re-attempt your test.**

### **How to set up Square** <a href="#how-to-set-up-square" id="how-to-set-up-square"></a>

**Step 1**. Go to **Gateways** > **Gateway Integrations**

**Step 2**. Scroll down until you see **Square**

<figure><img src="https://3790748257-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FT43PzcNjyZtWby9yrGd3%2Fuploads%2FJNg96BXAdORMezxT7kgv%2Fimage.png?alt=media&#x26;token=a1fe046f-b9c4-4e4b-a628-3501a8c3a80c" alt=""><figcaption></figcaption></figure>

**Step 3**. Click the green **Activate** button to activate Square

<figure><img src="https://3790748257-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FT43PzcNjyZtWby9yrGd3%2Fuploads%2FBA15v24ezmyHUjBbLxnx%2Fimage.png?alt=media&#x26;token=6d8b7692-8d08-4418-b510-f3a449794797" alt=""><figcaption></figcaption></figure>

**Step 4**. Enter your **AccessToken** and **LocationId** in the General Details Section of the Create Gateway screen.

**Step 5**. Click the green **Create Gateway** button to save your changes and create the gateway.

<figure><img src="https://3790748257-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FT43PzcNjyZtWby9yrGd3%2Fuploads%2FF2Y0avKQ4AOUH40QBf7Y%2Fimage.png?alt=media&#x26;token=efae6c05-0512-412c-9514-415ff6c47701" alt=""><figcaption></figcaption></figure>

\
Once the **ApplicationId**, **Application Secret**, and **LocationId** are set, please hit the below link to authorize the CRM to access your Square account.

### **Prerequisites**

* Checkout page should be secure HTTPS. A non-secured call to the Square gateway will be rejected.
* "**Application Id**", which you will get from your Square gateway account.

**Reference:** [**https://developer.squareup.com/docs/get-started**](https://developer.squareup.com/docs/get-started)

* You can download the javascript/css files for the SQPaymentForm [here](https://github.com/konnektive/square)
* Once you have obtained the javascript/css files, place them in the same directory as your landing page code on your web server.

### **Checkout Page Changes** <a href="#checkout-page-changes" id="checkout-page-changes"></a>

**Step 1**: Add 3 hidden input fields in the checkout form. Square gateway reference:

`<input type='hidden' name='prepaidType' value='SQUARE'>`

&#x20;

Square gateway credit card reference:

`<input type='hidden' name='formCardNonce'id='formCardNonce' value=''>`

\
**It is important to note that you will need to pass the paysource=PREPAID and prepaidType=SQUARE when forming the Import Order call to Checkout Champ.**<br>

Square gateway credit card postal code reference:

`<input type='hidden'name='formCardNoncePostalCode'id='formCardNoncePostalCode' value=''>`

**formCardNonce** & **formCardNoncePostalCode** fields will be populated on successful submission of Square SQPaymentForm.

**Step 2**: Add the below script on your checkout page to open the SQPaymentForm.

**Note:** Billing postal code is mandatory.

```
<script>
// On checkout form submit
var cardNonce = {Set "formCardNonce" value}
var cardNoncePostalCode = {Set "formCardNoncePostalCode" value}
var billingPostalCode = {Set billing postal code value}
cardNonce = $.trim(cardNonce);
cardNoncePostalCode = $.trim(cardNoncePostalCode);
billingPostalCode = $.trim(billingPostalCode);

// Checkout form validation scripts
..
..
..
// Before return success
if(billingPostalCode == '' || cardNonce != '')
{
if($.trim(cardNoncePostalCode) != '' &&
($.trim(billingPostalCode) !=
$.trim(cardNoncePostalCode)))
{
alert('The postal code entered in the credit card form
mismatched with the billing
address. Please refresh the page and try again.')
return false;
}
// Submit the checkout form
}
else
{
var squareURL = {SQPaymentForm URL};

window.open(squareURL,'','height=500,width=500,left=100,top=100
,resizable=yes,scrollbars=no,toolbar=no,menubar=no,location=no
,directories=no, status=no');
}
</script>
```

### **Square SQPaymentForm JS Changes** <a href="#square-sqpaymentform-js-changes" id="square-sqpaymentform-js-changes"></a>

Replace the square application id in "applicationId" const in the JS file.\ <br>

### **Alternative Implementation** <a href="#alternative-implementation" id="alternative-implementation"></a>

If you would like to have Square's SQPaymentForm embedded onto your checkout page, you will have to follow Sqaure's documentation, found [**here**](https://developer.squareup.com/docs/payment-form/payment-form-walkthrough?q=embedded) and make the required changes to your lander to support this.\ <br>

### **Upsells with Square** <a href="#upsells-with-square" id="upsells-with-square"></a>

Add these hidden inputs to your upsell page code.\ <br>

`<input type='hidden' name='prepaidType' value='SQUARE'> <input type='hidden' name='formCardNonce' id='formCardNonce' value=''>`
