Giter Site home page Giter Site logo

square / connect-api-specification Goto Github PK

View Code? Open in Web Editor NEW
70.0 25.0 40.0 4.17 MB

This repository contains the OpenAPI specification as well as templates for generating SDKs for Square's APIs

Home Page: https://squareup.com/developers

License: Apache License 2.0

Makefile 0.08% Shell 2.83% Java 0.18% Mustache 96.91%
swagger sdk openapi-specification openapi

connect-api-specification's Introduction

Connecting to the Square API

This is the project that generates API clients for connecting to the public Square API. You probably want to just use one of the clients that are pre-built in a language of your choice:

The Connect Examples are working sample applications that you can copy from to build your own.

Connect API Specifications

This repository contains the specifications for generating client SDKs with Swagger/OpenAPI.

The canonical specification is defined in api.json. The templates for our supported SDKs are located in swagger-templates. The configuration for each SDK (e.g. name of the library, version number, etc.) are located in swagger-config.

Configure a new language

Generating an SDK for a new language is possible. You'll need to have a working version of swagger-codegen and follow these steps:

  1. Check if Swagger Codegen supports the language by running:
    swagger-codegen langs
  2. If the language is supported, note swagger's name for it. We'll call it {lang}
  3. Add a configuration file on swagger-config named config-{lang}.json. You can check this template.
  4. Create a directory on swagger-templates named {lang}. Generation scripts expect to have a folder even if no custom templates are included:
    mkdir $lang
  5. (Optional) Add custom templates for your generator. Check Swagger Codegen Readme.

Contributing

See CONTRIBUTING.md.

License

Copyright 2016 - 2021 Square, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

connect-api-specification's People

Contributors

alecholmes avatar alecsquare avatar bunnyc1986 avatar dange42 avatar daphnechiu avatar deanpapastrat avatar dotspencer avatar drbyte avatar gkchestertron avatar hukid avatar jackdanger avatar jawspeak avatar jessdelacruzsantos avatar jessemartin avatar jguze avatar joanc-sq avatar lindzeng avatar longboardcat avatar mikekono avatar mikeralphson avatar mohsin-sq avatar okenshields avatar shaofu88 avatar steefan-square avatar stephenbarlow avatar ti55987 avatar tristansokol avatar yonpols avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

connect-api-specification's Issues

High Priority: Unable to create nonce on additional domains

Due to what I'm guessing are server side headers being set for only the primary domain name on the account I am unable to have my customer's domains obtain a nonce. Load the following URL (all test/sandbox only) and fill in any card information that passes basic validation. When submitting the form it will spawn an error in the web developer console (I test with Gecko/Firefox/Waterfox).

https://www
fixedfirefox
com/admin/square.php

The error message in Firefox is:

Invalid postMessage origin: "https _ www _ fixedfirefox.com"

According to Tristan there is no domain name or other URL limitation for hosting the form. Clients will have absolutely zero access to the server, have zero access/control over anything sensitive and everything on all domains is SSL without exception. If this does not get fixed it will dump about two to four weeks of unforseen work for me. :-\

Here is the SO URL from yesterday:

https://stackoverflow.com/questions/47270464/add-domain-access-to-square-api?noredirect=1#comment81492740_47270464

Minor: JavaScript Warnings sans Clear Documentation

One of my goals as a developer is to leave no stone unturned and thus I live a second life in the web console of browsers (predominately Gecko/Firefox/Waterfox's Web Console). I am not sure how to define the following (even if left empty or with the default values) to stop these errors from spawning:

Onload:

ReferenceError: reference to undefined property "fireOnResizeEnd" paymentform:1:21234
ReferenceError: reference to undefined property "excludeCanvas" f.js:1:862
ReferenceError: reference to undefined property "maxTouchPoints"

Blur or Focus (ZIP input?)
ReferenceError: reference to undefined property "_keyUpTimer" iframe:31:11943
ReferenceError: reference to undefined property "_keyUpTimer"

Keep in mind that because of the Gecko/Firefox XML parser bug I'm forced to load the form on a page within an iframe.

How do I quiet these issues from appearing in the web console? If possible could the documentation please be updated to reflect what is required?

Getting error in ruby-sdk 2.0.1.

I'm getting following error message when I installed version 2.0.1 with bundler.
2.0.0 works fine so seems like require of models.* is causing this.
Any clues?

/Users/takeshi/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/square_connect-2.0.1/lib/square_connect.rb:20:in `require': cannot load such file -- models.Address (LoadError)
	from /Users/takeshi/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/square_connect-2.0.1/lib/square_connect.rb:20:in `<top (required)>'
	from /Users/takeshi/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/runtime.rb:91:in `require'
	from /Users/takeshi/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/runtime.rb:91:in `block (2 levels) in require'
	from /Users/takeshi/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/runtime.rb:86:in `each'
	from /Users/takeshi/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/runtime.rb:86:in `block in require'
	from /Users/takeshi/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/runtime.rb:75:in `each'
	from /Users/takeshi/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/runtime.rb:75:in `require'
	from /Users/takeshi/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler.rb:106:in `require'
	from /Users/takeshi/Documents/telework_center/config/application.rb:7:in `<top (required)>'
	from /Users/takeshi/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/railties-4.2.7/lib/rails/commands/commands_tasks.rb:141:in `require'
	from /Users/takeshi/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/railties-4.2.7/lib/rails/commands/commands_tasks.rb:141:in `require_application_and_environment!'
	from /Users/takeshi/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/railties-4.2.7/lib/rails/commands/commands_tasks.rb:128:in `generate_or_destroy'
	from /Users/takeshi/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/railties-4.2.7/lib/rails/commands/commands_tasks.rb:50:in `generate'
	from /Users/takeshi/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/railties-4.2.7/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
	from /Users/takeshi/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/railties-4.2.7/lib/rails/commands.rb:17:in `<top (required)>'
	from bin/rails:4:in `require'
	from bin/rails:4:in `<main>'

No documentation for v1 Pagination.

Starting in 2.2.1, there have been helper methods to extract the pagination tokens from the v1 responses ie, getV1BatchTokenFromHeaders() in PHP. There doesn't seem to be any documentation to show developers that this function exists.

Generic `Reason` not defined. should be more specific

Type Reason doesn't exist but is referenced several times. For example:

property reason on method GiftCardActivityAdjustDecrement should be GiftCardActivityAdjustDecrementReason not Reason.

property reason on method GiftCardActivityAdjustIncrement should be GiftCardActivityAdjustIncrementReason not Reason

same is true for GiftCardActivityBlock, GiftCardActivityClearBalance, GiftCardActivityDeactivate, and GiftCardActivityUnblock

Maximum valid Money amount off by an order of magnitude (missing a `9` digit)

Hi there,

I originally reported this issue with one of the downstream generated SDK libraries:

square/connect-python-sdk#69

But after some digging into how Swagger API specs work, I found the corresponding underlying origin of the problem in the Connect API Specification for the Money model here:

Money Model missing a 9

I've run into "legitimate" responses from the Square Connect API V2 transactions listing tender cash_details field where the buyer_tendered_money amount was 999999999 (nine-nines) rather than 99999999 (eight-nines), resulting in the deserialization of the response from the connect API failing, causing a whole page of otherwise legitimate transactions results to be discarded.

Hopefully this is a quick patch fix (happy to submit a PR to resolve this).

api.json doesn't pass swagger spec validation

I used https://github.com/square/connect-api-specification/blob/1619654739714a5b8cfe6c5b059aad67a411b482/api.json and pasted it into https://editor.swagger.io/

The following errors showed up. Note all but 1 are from the V1 endpoints:

Semantic error at paths./v1/me/locations.get.operationId
Operations must have unique operationIds.
   Jump to line 1292

Semantic error at paths./v1/{location_id}/refunds.get.operationId
Operations must have unique operationIds.
   Jump to line 2114

Semantic error at paths./v1/{location_id}/refunds.post.operationId
Operations must have unique operationIds.
   Jump to line 2175

Schema error at definitions['CatalogObject']
should NOT have additional properties
additionalProperty: example_type
   Jump to line 5983

Schema error at definitions['v1Variation'].properties['user_data'].required
should be array
   Jump to line 11662

Spec has not been updated for version 2022-12-14

Hello!

We generate a Swift client from these specs and when attempting to update it to the latest version, noticed that even though was a PR (#187) to update the spec to version 2022-12-14, only the examples in the JSON were updated.

The API and models still reflect version 2022-11-16 and the new RetrieveTokenStatus endpoint is not present:

image

ExternalSquareProduct

ApplicationDetails has the property square_product which references it's definition from ExternalSquareProduct.

Looking through the JSON though there is only ApplicationDetailsExternalSquareProduct which contains no properties.

Is ExternalSquareProduct missing?

Firefox XML Parser Iframe not working

For now I've gone the cheap route and am sticking the form in an iframe element though it does make my code much more convoluted and I am unable to properly integrate the credit card iframe elements in to my code properly. IE and Chrome display the iframe elements just fine.

I code everything in XHTML5 now (HTML5 + XML parser). I prefer the XML parser because it's strict and will spawn error messages if I get sloppy. The Gecko rendering engine (Firefox though I'm forced to migrate to Waterfox due to Mozilla committing suicide come mid-November) handles XML errors best.

The fourth line in the code below sends the XML parse header. If you comment it out when testing Firefox will work however I can not degrade my entire platform because of such a specific bug.

I'm not sure why this bug is triggering. It happens on both local and live test environments (e.g. 127.0.0.1, localhost and example.com). There seems to be some issue popping up in the web console. If you guys need any additional information please let me know.

The code below is the same found on this page however I've attempted to minimize it while still keeping it reasonable readable.

<?php
if (stristr($_SERVER['HTTP_ACCEPT'],'application/xhtml+xml'))
{
 header('Content-Type: application/xhtml+xml; charset=UTF-8');
 echo '<?xml version="1.0" encoding="UTF-8"?>'."\n";
}
?><!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Square Payment Form Test</title>
<style type="text/css">
iframe {margin: 10px; outline: #f0f solid 10px;}
.sq-input {border: 1px solid rgb(223, 223, 223); outline-offset: -2px; margin-bottom: 5px;}
.sq-input--focus {outline: 5px auto rgb(59, 153, 252);}
.sq-input--error {outline: 5px auto rgb(255, 97, 97);}
.button-apple-pay {background-color: black; background-image: -webkit-named-image(apple-pay-logo-white); background-position: 50% 50%; background-repeat: no-repeat; background-size: 100% 60%; border-radius: 5px; display: none; max-height: 64px; min-height: 40px; min-width: 200px; padding: 0;}
</style>
<script type="application/javascript" src="https://js.squareup.com/v2/paymentform"></script>
<script type="application/javascript">
//<![CDATA[
var applicationId = 'REPLACE_ME';
var locationId = 'REPLACE_ME';

if (applicationId == '') {alert('You need to provide a value for the applicationId variable.');}

var paymentForm = new SqPaymentForm({
 applicationId: applicationId,
 locationId: locationId,
 inputClass: 'sq-input',
 inputStyles: [{fontSize: '15px'}],
 cardNumber: {elementId: 'sq-card-number', placeholder: '•••• •••• •••• ••••'},
 cvv: {elementId: 'sq-cvv', placeholder: 'CVV'},
 expirationDate: {elementId: 'sq-expiration-date', placeholder: 'MM/YY'},
 postalCode: {elementId: 'sq-postal-code'},
 applePay: {elementId: 'sq-apple-pay'},
 callbacks: {methodsSupported: function (methods) {if (methods.applePay === true) {var element = document.getElementById('sq-apple-pay'); element.style.display = 'inline-block';}},
  createPaymentRequest: function () { return { requestShippingAddress: true, currencyCode: 'USD', countryCode: 'US', total: { label: '{{ MERCHANT NAME }}', amount: '{{TOTAL AMOUNT}}', pending: false, }, lineItems: [ { label: 'Subtotal', amount: '{{SUBTOTAL AMOUNT}}', pending: false, }, { label: 'Shipping', amount: '{{SHIPPING AMOUNT}}', pending: true, }, { label: 'Tax', amount: '{{TAX AMOUNT}}', pending: false,}]};},
  cardNonceResponseReceived: function(errors, nonce, cardData) {if (errors) {console.log('Encountered errors:'); errors.forEach(function(error) {console.log(' ' + error.message);}); return;} else {alert('Nonce received: ' + nonce); document.getElementById('card-nonce').value = nonce; document.getElementById('nonce-form').submit(); submitPayment(nonce);}},
  unsupportedBrowserDetected: function() {},
  inputEventReceived: function(inputEvent) {switch (inputEvent.eventType) {case 'focusClassAdded': break; case 'focusClassRemoved': break; case 'errorClassAdded': break; case 'errorClassRemoved': break; case 'cardBrandChanged': break; case 'postalCodeChanged': break;}},
  paymentFormLoaded: function() {}
 }
 });
function requestCardNonce(event) {event.preventDefault(); paymentForm.requestCardNonce();}
//]]>
</script>
</head>

<body>

<button id="sq-apple-pay" class="button-apple-pay"></button>

<label>Card Number</label>
<div id="sq-card-number"></div>
<label>CVV</label>
<div id="sq-cvv"></div>
<label>Expiration Date</label>
<div id="sq-expiration-date"></div>
<label>Postal Code</label>
<div id="sq-postal-code"></div>

<form id="nonce-form" novalidate="true" action="REPLACE_ME" method="post">
<fieldset>
<input type="hidden" id="card-nonce" name="nonce" />
<input type="submit" onclick="requestCardNonce(event)" />
</fieldset>
</form>

</body>
</html>

ProductType is missing RESTAURANT

I'm getting device.code.paired webhook requests where the data.object.device_code.product_type is "RESTAURANT". The spec only has "TERMINAL_API" as an enum for ProductType.

(I hope this is helpful. I LOVE that you guys publish this api spec--I generated a swift API from it to use with my Vapor 4 backend. Awesome!!!)

{
    "created_at": "2021-01-27T21:12:22.326Z",
    "data": {
        "id": "XXXXXXXXXXXX",
        "object": {
            "device_code": {
                "code": "XXXXXXXXXXX",
                "created_at": "2021-01-27T21:11:53.000Z",
                "device_id": "DEVICE_INSTALLATION_ID:XXXXXXXXXXX",
                "id": "XXXXXXXXXXX",
                "location_id": "XXXXXXXXXXX",
                "name": "iPad5",
                "paired_at": "2021-01-27T21:12:16.000Z",
                "product_type": "RESTAURANT",
                "status": "PAIRED",
                "status_changed_at": "2021-01-27T21:12:16.000Z"
            }
        },
        "type": "device.code"
    },
    "event_id": "XXXXXXXXXXXXXXXXXXXXXXXXXX",
    "location_id": "XXXXXXXXXXX",
    "merchant_id": "XXXXXXXXXXX",
    "type": "device.code.paired"
}

Wrong error message for expired nonce suggests nonce not set when it is

Using the API v2 I kept resubmitting the same form details (to create a card for reoccurring charges) while ironing out bugs. I eventually hit error bedrock with the following error returned. Thankfully it did not take me long to realize that this error was returned due to resubmitting the same nonce.

[errors] => Array
(
 [0] => stdClass Object
 (
  [category] => INVALID_REQUEST_ERROR
  [code] => MISSING_REQUIRED_PARAMETER
  [detail] => Field must be set
  [field] => card_nonce
 )
)

It's be super-snazzy if the server could please be set to return a specific error message that the nonce has expired instead of suggesting that it is not set. My JSON request (obviously) included the nonce so at first it was a bit confusing.

SQUARE_GIFT_CARD_V2 tender type throws error in ruby #list_payments

The tender type validator in the ruby gem throws a RuntimeError when the API returns SQUARE_GIFT_CARD_V2 as a tender.

/home/brundage/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/square_connect-2.6.0.192/lib/square_connect/models/v1_tender.rb:210:in 'card_brand=': invalid value (SQUARE_GIFT_CARD_V2) for 'card_brand', must be one of ["OTHER_BRAND", "VISA", "MASTER_CARD", "AMERICAN_EXPRESS", "DISCOVER", "DISCOVER_DINERS", "JCB", "CHINA_UNIONPAY", "SQUARE_GIFT_CARD"]. (ArgumentError)

Code from square_connect/models/v1_tender.rb version 2.6.0 line 210

    # Custom attribute writer method checking allowed values (enum).
    # @param [Object] card_brand Object to be assigned
    def card_brand=(card_brand)
      validator = EnumAttributeValidator.new('String', ["OTHER_BRAND", "VISA", "MASTER_CARD", "AMERICAN_EXPRESS", "DISCOVER", "DISCOVER_DINERS", "JCB", "CHINA_UNIONPAY", "SQUARE_GIFT_CARD"])
      unless validator.valid?(card_brand)
        fail ArgumentError, "invalid value (#{card_brand}) for 'card_brand', must be one of #{validator.allowable_values}."
      end
      @card_brand = card_brand
    end

(modified by me to show the returned card_brand)

PHP SDK Contains Invalid DocBlocks Causing IDE-Errors

Hey all, the V1 api classes in the PHP SDK all have the method list{model}ithHttpInfo, whose docblock contains the following return declaration:

/**
 * @return Array of \SquareConnect\Model\V1Item[], HTTP status code, HTTP response headers (array of strings)
 */

This is invalid syntax and is telling static-analysis tools/PHPStorm that the return type of this method is SquareConnect\Api\Array, causing all sorts of issues. Can these docblocks be updated to the valid form please? Example below:

/**
 * @return array Array of \SquareConnect\Model\V1Item[], HTTP status code, HTTP response headers (array of strings)
 */

Incorrect context error message for mixed live/sandbox credentials

I performed a test thinking I had changed all variables to the live credentials from the sandbox credentials. I changed the server-stored settings though not the client stored settings:

SERVER location id and token for live.
CLIENT: applicationId and locationId were sandbox

I received the following error:

[0] => Array
(
[category] => INVALID_REQUEST_ERROR
[code] => NOT_FOUND
[detail] => Resource not found.
[field] => card_nonce
)

I corrected the issues after noticing that the nonce was set and matched in the post from my server to yours what your server initially sent to my client browser first. An improvement in mixed credentials error handling would be appreciated by some others in the future.

Empty Response to List Customers

I've spent some time trying to determine why the list customers request wouldn't work and as it turns out it Square's server doesn't like IP addresses (local testing) or localhost (exact same code worked perfectly on my live domain). This was not in the documentation as a requirement and Square's response was empty. There should be some sort of error message about ensuring that tests for whatever features are done from live domains. My local tests were via HTTPS.

Firefox, Palemoon and Waterfox / Content Security Policy

I was doing some last audits and discovered that numerous Gecko based browsers are failing some Content Security Policies.

Waterfox 56.2.2: Fail
Palemoon 28.0 (Last major update release on August 16, 2018 to Gecko 56/Firefox 56)
Firefox 52 ESR: Fail
Firefox 57: Fail
Firefox 58: Pass
Firefox 61: Pass

Apparently Gecko 57 and older handle (or outright don't) Content-Security-Policy differently than Gecko 58+. Everyone using Palemoon or Waterfox is doing so because of Mozilla's outright anti-end user hostility over the past few years; the ability to control our browsing environment (our work environment) is more important than blindly copying Google. These browsers are all up to date.

The developer console returns several errors such as the following:

Content Security Policy: The page’s settings blocked the loading of a resource at blob:https://pci-connect.squareup.com/43bee71b-99a1-4ecc-bc8c-a7725e43e49a (“script-src 'unsafe-inline' https://pay.google.com https://www.gstatic.com https://js.squareup.com”).

According to Can-I-Use Content Security Policy 1.0 is supported by Gecko 56 and Content Security Policy 2.0 supports everything except plugins. So this will likely be some sort of minor bug. I would try to offer more insight though I've actually avoided implementing this header in to my platform due to it's excessive complexity and lack of demand from my customer base at the moment. So this looks like it's entirely out of my hands. Could we please get a quick reproduction confirmation?

Besides an unrelated bug I just fixed it appears that my sandbox is able to still work, at least in Waterfox 56. There may be some unknown / non-verbal after effects caused from this bug.

Inventory v2 api?

Hello, I was wondering if there was an updated swagger doc somewhere which includes the /v2/inventory/ endpoints.

I guess I'm looking in the wrong place or this is out of date.

Thanks!

Invalid $ref values

"#/definitions/LocationCustomAttributeDeleteResponse"
"#/definitions/LocationCustomAttributeDeleteRequest"

and more are invalid refs in the spec. Why is this happening?

Several of the new types are missing their prefixes

A bunch of the new types have broken references. I believe every case is because they are missing prefix. For example, instead of just Policy it should be CheckoutLocationSettingsPolicy

This commit on my forked version is an easy way to see which ones are broken:
Flash-Order@8fa6212

Does anyone at Square even care though? I've posted about stuff like this before and don't hear anything back.

Silent Error: Firefox/Waterfox not loading iframe "form fields"; Opera 12.1 & Chrome work

I've come across a reason to delve back in to the code for accepting payments with Square. Previously I ran out of time and could not verify that Firefox/Waterfox worked with XHTML. As of Sunday January 13th, the form works when served on a page of the type application/xhtml+xml. Since my web platform loads as XML (application/xhtml+xml) I decided to merge the payment form on to the page itself (instead of loading it as a text/html page in an iframe).

Unfortunately I've encountered a silent error. Waterfox does not load the iframe "form fields" and I've verified it in Firefox 61 that the form fields do not load in that browser either (both are Gecko browsers). I then tried Chrome 71 and Opera 12.1 as they both have different rendering engines that are likely to help me uncover any bugs. No, I won't test Opera 15+ because that's just another copy of Chrome.

Opera 12.1 does spawn a JavaScript error though still manages to load the iframe form fields.

Chrome 71 doesn't spawn any JavaScript errors and loads the iframe form fields.

To help expedite troubleshooting here are the var sqPaymentForm = new SqPaymentForm(...); for Chrome and Firefox/Waterfox:

Chrome's version of the new SqPaymentForm JavaScript object:

build: ƒ ()
clientController: C {options: {…}, env: {…}, errorLogger: a, callbacks: {…}, formId: "253bcae6-1b4f-9619-fae5-6956e362dcb6", …}
env: {name: "production", googlePayEnv: "PRODUCTION", masterpassJsUrl: "https://static.masterpass.com/integration/merchant.js", jsUrl: ƒ, serviceUrl: ƒ}
errorLogger: a {options: {…}, env: {…}, source: "SqPaymentForm", applicationId: "sandbox-sq0idp-jm0yK1mgWBMyV3lgfW9XIQ", ignoreError: 0, …}
options: {applicationId: "sandbox-sq0idp-jm0yK1mgWBMyV3lgfW9XIQ", locationId: "CBASEEum0KeFu_h-4VA4OWaV3F8gAQ", applePay: {…}, callbacks: {…}, cardNumber: {…}, …}
_handleDomContentLoaded: null
__proto__: Object

Waterfox/Firefox's version of the new SqPaymentForm JavaScript object:

_handleDomContentLoaded: function ()
​
clientController: Object { options: {…}, formId: "d917ecd5-c085-de21-c041-424226d69515", hash: "eyJzIjoiMzA4YjczMzJjMjk0NzJiMGVjMjc4YTcxMGRjZGMwODNjZDkyZDM0OSJ9", … }
​
env: Object { name: "production", googlePayEnv: "PRODUCTION", masterpassJsUrl: "https://static.masterpass.com/integration/merchant.js", … }
​
errorLogger: Object { source: "SqPaymentForm", applicationId: "sandbox-sq0idp-jm0yK1mgWBMyV3lgfW9XIQ", ignoreError: 0, … }
​
options: Object { applicationId: "sandbox-sq0idp-jm0yK1mgWBMyV3lgfW9XIQ", locationId: "CBASEEum0KeFu_h-4VA4OWaV3F8gAQ", inputClass: "sq-input", … }
​
<prototype>: Object { build: build()
, destroy: destroy(), requestCardNonce: requestCardNonce(), … }

And the code that created the object itself:

var sqPaymentForm = new SqPaymentForm(
{
 applicationId: 'sandbox-123',
 locationId: 'CBASE_xyz',
 applePay: {elementId: 'sq-apple-pay'},
 callbacks:
 {
  methodsSupported: function (methods)
  {
   if (methods.applePay && methods.applePay === true) {var element = document.getElementById('pay-button-area'); element.style.display = 'block';}
  },
  cardNonceResponseReceived: function(errors, nonce, cardData)
  {
   if (errors)
   {
    var errorDiv = document.getElementById('errors');
    errorDiv.innerHTML = '';
    errors.forEach(function(error) {var p = document.createElement('p'); p.innerHTML = error.message; errorDiv.appendChild(p);});
   }
   else
   {
    id_('card-nonce-submit').setAttribute('disabled','true');
    id_('card_brand').value = cardData.card_brand;
    id_('cc_end').value = cardData.last_4;
    id_('cc_month').value = cardData.exp_month;
    id_('cc_year').value = cardData.exp_year;
    id_('zip').value = cardData.billing_postal_code;
    document.getElementById('card-nonce').value = nonce;
    payment_submit();
   }
  },
  unsupportedBrowserDetected: function() {console.log('Error: unsupported browser.');},
  createPaymentRequest: function ()
  {
   return {currencyCode: 'USD', countryCode: 'US', requestShippingAddress: false, total: {amount: '1.00', label: 'JAB Creations', pending: false},lineItems: [{amount: '1.00', label: 'Subtotal', pending: false},{amount: '0.00', label: 'Tax', pending: false}]};
  },
 },
 cardNumber: {elementId: 'sq-card-number', placeholder: '0000 0000 0000 0000'},
 cvv: {elementId: 'sq-cvv', placeholder: 'CVV'},
 env: {},
 excludeCanvas: {},
 expirationDate: {elementId: 'sq-expiration-date', placeholder: 'MM/YY'},
 inputClass: 'sq-input',
 inputStyles: [
 // Because this object provides no value for mediaMaxWidth or mediaMinWidth, these styles apply for screens of all sizes, unless overridden by another/ input style below.
 {
  backgroundColor: 'transparent',
  color: localStorage.getItem('input_style_color'),
  fontFamily: 'sans-serif',//localStorage.getItem('input_style_font-family')
  fontSize: '18px',//localStorage.getItem('input_style_font-size'),
  fontWeight: 'bold',//localStorage.getItem('input_style_font-weight')
  lineHeight: '18px',//localStorage.getItem('input_style_line-height'),
  padding: '0'
 },
 // These styles are applied to inputs ONLY when the screen width is 400px
 // or smaller. Note that because it doesn't specify a value for padding,
 // the padding value in the previous object is preserved.
 {
  mediaMaxWidth: '400px',
  fontSize: '48px',
  lineHeight: '18px'
 }],
 maxTouchPoints: {},
 inputEventReceived: function(inputEvent)
 {
  switch (inputEvent.eventType)
  {
   case 'focusClassAdded':
   // Handle as desired
   console.log(document.getElementsByClassName('sq-input--focus')[0]);
   break;

   case 'focusClassRemoved':
   // Handle as desired
   console.log(document.getElementsByClassName('sq-input--focus')[0]);
   break;

   case 'errorClassAdded':
   // Handle as desired
   break;

   case 'errorClassRemoved':
   // Handle as desired
   break;

   case 'cardBrandChanged':
   // Handle as desired
   break;

   case 'postalCodeChanged':
   // Handle as desired
   break;
  }
 },
 postalCode: {elementId: 'sq-postal-code', placeholder: 'Postal Code'}
});

With a silent error combined with third part code I'm at an impasse. I have some limited time to debug this week and maybe next weekend. Any help would be greatly appreciated.

formnovalidate Not Honored

I discovered that the API does not correctly support the formnovalidate attribute on submit buttons:

<input formnovalidate="true" type="submit" value="Pay More Later" />

Case: I may opt to provide a discount for payment up-front or they can disregard the discount and pay in full within the next 30 days.

I imagine that this should be an easy fix.

Question about generate-sdk

I've been using this as a tutorial of sorts while I mess with swagger-codegen for the first time. When I run the generate-sdk shell script for php, I don't appear to get a generated ApiClient.php file that is then shown in the connect-php-sdk example:

require 'vendor/autoload.php';

$access_token = 'YOUR_ACCESS_TOKEN';
# setup authorization
$api_config = new \SquareConnect\Configuration();
$api_config->setHost("https://connect.squareup.com");
$api_config->setAccessToken($access_token);
$api_client = new \SquareConnect\ApiClient($api_config);
# create an instance of the Location API
$locations_api = new \SquareConnect\Api\LocationsApi($api_client);

Is that file supposed to be generated by swagger-codegen? If so, what might I be doing wrong?

invalid ref

Somehow the "delivery_method" property on type "Invoice" is messed up it shows:

"$ref": "#/definitions/invoice_delivery_methodInvoiceDeliveryMethod"

it should be:

"$ref": "#/definitions/InvoiceDeliveryMethod"

I know this is generated so something upstream must not be to convention because that ref is invalid

Minor: create user; country returns "ZZ"

Likely a minor bug / some sort of placeholder but the country returned was "ZZ" (without quotes). Personal data obfuscated though reference_id was not. Not sure if there are shadow copies as I'll likely be purging this user for unrelated reasons. AFAIK this does not effect anything. This is on a sandboxed account/user/etc.

Array
(
[customer] => Array
(
[id] => 123
[created_at] => 2017-11-09T12:44:32.845Z
[updated_at] => 2017-11-09T12:44:32.845Z
[given_name] => A
[family_name] => B
[email_address] => [email protected]
[address] => Array
(
[address_line_1] => 123 Main Street
[address_line_2] =>
[country] => ZZ
)
[reference_id] => 1510231472
[preferences] => Array
(
[email_unsubscribed] =>
)
)
)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.