Giter Site home page Giter Site logo

square / connect-api-examples Goto Github PK

View Code? Open in Web Editor NEW
385.0 46.0 790.0 51.55 MB

Code samples demonstrating the functionality of the Square Connect API

Home Page: https://developer.squareup.com/docs/sample-apps

Python 4.57% PHP 4.19% Ruby 6.97% Java 20.84% JavaScript 31.49% CSS 8.63% HTML 2.76% C# 1.38% Hack 0.13% Pug 5.59% Shell 0.01% EJS 5.16% Dockerfile 0.04% Procfile 0.01% TypeScript 8.24%

connect-api-examples's Introduction

Square Connect API Examples

This repository contains code samples demonstrating the functionality of the Square Connect API and templates to simplify use of our SDKs and APIs.

In this repository

  • connect-examples/oauth - samples demonstrating OAuth functionality
  • connect-examples/v1 - DEPRECATED: samples demonstrating Connect v1 functionality
  • connect-examples/v2 - samples demonstrating Connect v2 functionality
  • templates/ - code blocks and function definitions to simplify common usage

Getting help

Complete documentation for Square APIs is available at developer.squareup.com/docs.

If you have questions about Square Connect API features or implementation, you can ask for help on our Developer Forums or in our Discord community.

connect-api-examples's People

Contributors

alecsquare avatar azlee avatar barakj avatar brettstimmerman avatar bunnyc1986 avatar bwisem avatar danielni avatar dependabot[bot] avatar emmac3 avatar frojasg avatar goblinhorde avatar havenwood avatar hukid avatar jackg235 avatar jawspeak avatar jessdelacruzsantos avatar jlabanca avatar johnmaustin78 avatar mglombicki-square avatar mohan-v avatar mohsin-sq avatar mootrichard avatar mvanmane avatar okenshields avatar shaofu88 avatar squaregist avatar stephenbarlow avatar stephenjosey avatar tristansokol avatar zenmasterjobo 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

connect-api-examples's Issues

Missing client by that `client_id`

new to using oauth i copied the code OAuthhandler and im getting missing client id when ever i click on it, can i find an id somewhere or do i need to make an acount or something? anything helps thx

PHP Checkout code example has a bug

https://github.com/square/connect-api-examples/blob/master/connect-examples/v2/php_checkout/checkout.php#L32

I got an error when using the code provided. I had to nest another order property, and also include the location_id within the nested order property to make it work.

The working code for $request_body looks like this:

      $request_body = new \SquareConnect\Model\CreateCheckoutRequest(
          [
            "idempotency_key" => uniqid(),
            "order" => [
              "order" => [
                "location_id" => $location_id,
                "line_items" => [
                  [
                    "name" => "Item description",
                    "quantity" => "1",
                    "base_price_money" => [
                      "amount" => 500,
                      "currency" => "USD"
                    ]
                  ]
                ]
              ]
            ]
          ]
        );

Accessibility Issue: Cannot edit form fields using mobile screen readers

We noticed an accessibility issue when editing the Square Payment Form fields with a screen reader turned on. The first time through the form, it's not hard to select the four CC fields and enter data. However, if while editing, it can be impossible to select some of the fields with VoiceOver/TalkBack on. The really challenging part is that it sounds like you've selected it, but if you look at it you see that focus hasn't been moved to the field that was stated with VoiceOver.

Generate Nonce with API

Hello ,

We are testing your payment sdk , We have our own card reading device. Is there any api or any way so that we can generate nonce with the card information we get after swiping card to our reader? We are getting Track1 , Track2 , Track3 for magnetic card and UUID , ATR for IC card. We are testing it in Android application.

missing autoload.php

When i run this file (ouath/php), then a error generate missing 'vendor/autoload.php'. How can i fix this issue.

NodeJS ChargeRequest body setting incorrectly

I'm attempting to follow the docs outlines here for creating a charge, https://github.com/square/connect-javascript-sdk/blob/master/docs/TransactionsApi.md#charge. According to this, the docs show setting the body of .charge to an object following the properties found here, https://github.com/square/connect-javascript-sdk/blob/master/docs/ChargeRequest.md#idempotencykeys

I keep running into an issue where setting the object like such

const b = {
    card_nonce: nonce,
    amount_money: {
      amount: parseInt(amount),
      currency: 'USD',
    },
    idempotency_key: key,
  };

and then setting the charge like

const body = new SquareConnect.ChargeRequest(b);
transactionsApi.charge(square.locationID, body).then()

It will error out stating that the idempotency_key is not a string. When looking at the data being set in ChargeRequest, I'm seeing that prop data being set on the charge looks like

"data": {
                    "idempotency_key": {
                        "card_nonce": "e23hjedncsd",
                        "amount_money": {
                            "amount": 17500,
                            "currency": "USD"
                        },
                        "idempotency_key": "6bf315bf4386c743072a7a33a7ab79a42234214e106c377c36dd4bbf44c6c5a089b91e4af5fbac72643bbe44a86dc6e069a90fc51707e86dcb8a9a7266235279"
                    }
                },

Any help you can provide would be helpful. I'm not understanding why the charge API is setting the key incorrectly.

Random div element junk added to DOM

Some random div element (<div id="30713c77-4f4e-8793-4711-5cb26224444b"></div>) was added to my site's DOM after the transaction was successful. My web platform's code is extremely strict and this random div appeared as a modal. The id looks randomly generated and there are no other attributes to select the element without spending about an hour doing a lot of deductive JavaScript to find and hide this random div.

Should this div even be added to my site's DOM for any actually legitimate reason? If so why isn't it set to display: none; or at least something such as style="opacity: 0;"?

C# payment example

I am trying the C# example, i enter credit card information -
4532 7597 3454 5858
111
12/20
88888
When i press the submit query button i get -
Invalid applicationId

I don't see where in this example i enter my applicationID?

Please help.

Error when Running Maven with Java 10

I followed the instructions in the README to run connect-api-examples/connect-examples/v2/java_payment/ locally. The following command fails when Maven runs on Java 10:

SQUARE_APP_ID=replace_me` SQUARE_ACCESS_TOKEN=replace_me mvn spring-boot:run

Here is the full verbose output.

Output of java --version:

java 10 2018-03-20
Java(TM) SE Runtime Environment 18.3 (build 10+46)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10+46, mixed mode)

It worked fine when I ran maven with Java 8.

File or function missing

I have downloaded your sample code in local host. I have downloaded the code from this location. connect-api-examples/connect-examples/v2/php_payment/

After modifying in js file and php file if I run the code its giving me this error.
Warning: require(vendor/autoload.php): failed to open stream: No such file or directory in C:\xampp\htdocs\sq_payment_gateway\process-card.php on line 2

Fatal error: require(): Failed opening required 'vendor/autoload.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\sq_payment_gateway\process-card.php on line 2

Please provide us the vendor flder as well so that we can test a dummy transaction on localhost and then move to production.

If i comment out this line of code require 'vendor/autoload.php'; then its giving me this error.

Fatal error: Uncaught Error: Class 'SquareConnect\Configuration' not found in C:\xampp\htdocs\sq_payment_gateway\process-card.php:22 Stack trace: #0 {main} thrown in C:\xampp\htdocs\sq_payment_gateway\process-card.php on line 22

I tried a lot to find where is vendor folder but couldn't find it.

I hope you got the concern. Please provide us the missing file.

Order-Ahead Sample Application

Hi,

I am testing out the order ahead sample application and have already hit a problem.

On testing your credentials, I run the following command:

npm test
However I get the following arror. I have tried troubleshooting but hitting a wall. Any help is greatly appreciated.

`C:\Users\Michael Hilland>npm run seed
npm ERR! missing script: seed

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Michael Hilland\AppData\Roaming\npm-cache_logs\2020-11-28T17_29_04_639Z-debug.log`

Add Modifier Set Example

Improvement request

Most seller catalogs in F&B space will use modifier sets to customize F&B items. We should include an example of a modifier set in this codebase.

Charge error

I am using the v2 c# API.

When you call charge and you get an error such as VERIFY_AVS_FAILURE.
In this case the zip code was bad - 99999.

Do you have to change your idempotency_key to process the card after the zip code was corrected?

Card-nonce not show

I am using same code, But when I submit form then card-nonce show empty.
I am trying to various way but not working, Can I generate card-nonce manually?

node_orders-payments example is outdated

I am new to npm so please forgive if this is something I am doing wrong.

I downloaded the connect-api-examples/connect-examples/v2/node_orders-payments folder, put my sandbox credentials in the config.json file, and ran npm install. I get a lot of deprecated warnings including a mention of "insecure binaries". Could the example be updated so that I do not get these warnings please? This is the output of my npm install command:

D:\Users\Jonathan\Desktop\Programming\node_orders-payments>npm install
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated [email protected]: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated [email protected]: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
npm WARN deprecated [email protected]: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated [email protected]: https://github.com/lydell/resolve-url#deprecated

> [email protected] postinstall D:\Users\Jonathan\Desktop\Programming\node_orders-payments\node_modules\nodemon
> node bin/postinstall || exit 0

Love nodemon? You can now support the project via the open collective:
 > https://opencollective.com/nodemon/donate

npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

added 478 packages from 283 contributors and audited 479 packages in 19.164s

11 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities


D:\Users\Jonathan\Desktop\Programming\node_orders-payments>

How to transaction id after successful payment

The SDK throws an exception if a Connect endpoint responds with anything besides

a 200-level HTTP code. This block catches any exceptions that occur from the request.

try {

$result = $transactions_api->charge($location->getId(), $request_body);

file_put_contents("text.txt", $result);

//How to get Transaction , from above $result variation for saving db purpose

echo "<pre>";
print_r($result);
echo "</pre>";

} catch (\SquareConnect\ApiException $e) {
echo "Caught exception!
";
print_r("Response body:
");
echo "

";
var_dump($e->getResponseBody());
echo "
";
echo "
Response headers:
";
echo "
";
var_dump($e->getResponseHeaders());
echo "
";
}

how charge the credit card

Hi, in php_payment example how i can charge the credit card? i see you use only 2 parameters: amount and currency, but credit-card number, cvv, and expiry parameters is not used in any place in code.

"amount_money" => array (
"amount" => 100,
"currency" => "USD"
)

CORS Error when using NodeJS Connect V2 API for OAuth2 Access

Following the guide posted on Square's Developer documentation. I can run the Node OAuth 2 sample from here: (https://github.com/square/connect-api-examples/tree/master/connect-examples/oauth/node) just fine locally with the Sandbox. But when I try to run a similar setup in a local React app, the obtainToken method from the square-connect Node library throws the following error:

Refused to set unsafe header "User-Agent"

Access to XMLHttpRequest at 'https://connect.squareupsandbox.com/oauth2/token' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

client.js:772 POST https://connect.squareupsandbox.com/oauth2/token net::ERR_FAILED

Not sure how to overcome the CORS policy here. Could I get some assistance please?

Suggestion

Just a suggestion to use the LinkHeader object to parse link headers instead of the manual code....here is an example:

....Gemfile.....or any other way
gem 'link_header'

....Code!
url = LinkHeader.parse(response.headers[:link]).to_a.first.try(:first)

Improvement: Purchase history by customer_id

Expose an endpoint to list customer transactions and the list of items purchased in each transaction.

Example Documentation:

GET /v2/customers/{customer_id}/transactions

Lists transactions for a particular customer.

Max results per page: 50

Required permissions: CUSTOMERS_READ

How to submit payment with SqPaymentForm?

I run an application through which I allow clients to charge their customers via their gateway of choice, and Square has come up as a recommended option. I have thus been attempting to integrate for two weeks with no success. Your documentation appears to suggest that OAuth is the way to go, so I have created a link in my app that clients can trigger, then authorize Square as a gateway, which generates the token that I store. This works fine.

I am attempting to set up the payment form in my app from the PHP code samples here, with virtually no alteration save a token that I managed to generate. The sandbox token generates this reply:

Caught exception! Response body: object(stdClass)#9 (1) { ["errors"]=> array(1) { [0]=> object(stdClass)#10 (4) { ["category"]=> string(21) "INVALID_REQUEST_ERROR" ["code"]=> string(26) "MISSING_REQUIRED_PARAMETER" ["detail"]=> string(27) "Missing required parameter." ["field"]=> string(10) "card_nonce" } } }

That's crazy, since 'card_nonce' is a parameter that isn't in one way referenced in any of these files or documentation. The production token is even better, causing a 500 error as $location->getId() collapses as $location is returned false. Mind you, I DO have a location with the production token, so the reason for this one is just as baffling.

I'm also wondering where/when I am supposed to inject the shopping cart items... in the JS or the PHP response?

I have previously submitted two requests for assistance through the contact form, and one generated no response while the other took 48 hours to answer a question I didn't ask. I also noticed that no matter how hard I try, it is impossible for me to get anyone with Square on the phone. Therefore raising an issue on Github appears to be my only remaining option.

Update python examples to use the connect-python-sdk library

I'm getting some odd errors and looking for an example of how to use the library to make calls to the V1Transaction API's list_payment. The examples in this repo do not use the square-provided connect-python-sdk library so they don't transfer over well to one who is using the library.

zip code numeric pad for café orders

The Payment form for the Zip Code field defaults to the alpha keyboard. This is fine for international (Canadian) zip codes, but we are only supporting the US.
Is there a way that we can default to only show the numeric key pad? If not, can this be fixed please?
This is for both iOS and Android devices.

Backward logic on example-confirm-transaction.php

I'm not a PHP dev, so I could be wrong, but I'm pretty sure the conditional logic is backwards on line 36.

if (!$validTransaction) {
/* add code to print the order confirmation or redirect to an existing
confirmation page */
} else {
// We only get here if there's something hinky with the confirmation
// information (e.g., a mismatch between the checkout and order IDs) or
// Square Checkout encountered an unexpected card error.
/*
add code to print an error message and provide contact information
for follow-up
*/
exit;
}

if invalid transaction 
    show order confirmation
else 
    show error message

SqPaymentForm Not populating input fields in Wordpress Plugin

Hello i am integrating squareup api in my wordpress woocommerce site i set SqPaymentForm in my plugin
but it only shows form labels not input fields..something like this :

sqaure

i set it in my custom template it works fine but not in my plugin actually the problem is iframe not loading.

Setting the application id?

Hi Guys,

I am having a hard time modifying this in order to set the application_id?

I keep getting the following error:
Exception when calling TransactionsApi#charge com.squareup.connect.ApiException: {"errors":[{"category":"INVALID_REQUEST_ERROR","code":"NOT_FOUND","detail":"Card nonce not found in this production application environment. Please ensure an application ID belonging to the same environment is used to generate the nonce."}]}

I dont see where you guys are setting the appID in order for the application to be recognized by square and not get this error.

Any help would be awesome, thank you.

Here is my transaction code:
`@RequestMapping(value ="/charge", method = RequestMethod.PUT)
public ResponseEntity chargeNonce(@requestbody HashMap<String, String> nonce){

    ApiClient defaultClient = Configuration.getDefaultApiClient();

    // Configure OAuth2 access token for authorization: oauth2
    OAuth oauth2 = (OAuth) defaultClient.getAuthentication("oauth2");
    oauth2.setAccessToken(System.getenv("SQ_ACCESS_TOKEN"));

    System.out.println("SQ_ACCESS: " + System.getenv("SQ_ACCESS_TOKEN"));
    System.out.println("LOCATION: " + System.getenv("SQ_LOCATION_ID"));
    System.out.println("SQ_APP: " + System.getenv("SQUARE_APPLICATION_ID"));

    TransactionsApi apiInstance = new TransactionsApi();
    apiInstance.setApiClient(defaultClient);
    // String | The ID of the location to associate the created transaction with.
    String locationId = System.getenv("SQ_LOCATION_ID");
    // ChargeRequest | An object containing the fields to POST for the request.  See the corresponding object definition for field details.
    ChargeRequest body = new ChargeRequest();
    Money money = new Money();
    money.amount(Long.valueOf("1"));
    money.currency(Money.CurrencyEnum.USD);
    body.amountMoney(money);
    System.out.println(nonce.get("nonce"));
    body.cardNonce(nonce.get("nonce"));
    body.idempotencyKey(UUID.randomUUID().toString());
    try {
        ChargeResponse result = apiInstance.charge(locationId, body);
        System.out.println(result);
        return ResponseEntity.status(200).body(result);
    } catch (ApiException e) {
        System.err.println("Exception when calling TransactionsApi#charge");
        e.printStackTrace();
        return ResponseEntity.status(401).body("Exception when calling TransactionsApi#charge");
    }
}` 

Checkout completed, now what?

I can successfully send data to checkout API (php)
it redirects to square website with payment form and everything, but how can i set that square redirects to my website after payment successful at a specific link to mark the transaction has completed?

EDIT = found how to do it

Order-ahead app only in pug?

Hi would it be possible to use js instead of pug for the views? Looking to separate the products by category. Thanks

Can SqPaymentForm facilitate qualification for Square chargeback protection?

In the example on this repo that demonstrates a nodejs integration of SqPaymentForm.js, the user is presented with the minimum fields required for a transaction: Card Number; CVV; Billing Postcode; Expiry Date.

While this expedient form is great for a speedy integration, and a speedy transaction, is it possible to add more fields to the square payment form?

I would like the SqPaymentForm on my page to include billing address and/or shipping address, and buyer email address, as this would allow my websites transactions to qualify for Square Chargeback protection.

A secondary wish would be for the SqPaymentForm to facilitate the buyers given name, last name, and title, as this would be all the data that I really need to collect.

For example, will this give me an email input for the buyer_email_address with validity checking, if placed in a sq-payment-form div?

    div(class="sq-field sq-field--in-wrapper")
        label(class="sq-label") Email Address
        div(id="sq-buyer-email-address")

(along with some extension to the SqPaymentForm construction code..)

    paymentForm = new SqPaymentForm({
        applicationId: applicationId,
        locationId: locationId,

        inputClass: 'sq-input',
        inputStyles: _squareInputStyles,

        // Initialize a field for the buyers email address
        buyerEmailAddress: {
            elementId: 'sq-buyer-email-address'
        },
        ......

It would be brilliant news if SqPaymentForm can validate these fields also.

(At the moment I'm trying to process two forms in an angularjs application on one button press..)

Perhaps this is already possible, perhaps it is not?

Thanks :)

java.lang.IllegalStateException: The " sandbox-id" environment variable

squareAppId = mustLoadEnvironmentVariable(SQUARE_APP_ID_ENV_VAR);

    // Configure OAuth2 access token for authorization: oauth2
    OAuth oauth2 = (OAuth) squareClient.getAuthentication("oauth2");
    oauth2.setAccessToken(mustLoadEnvironmentVariable(SQUARE_ACCESS_TOKEN_ENV_VAR));

    squareLocation = lookupCardProcessingLocation();
}


private String mustLoadEnvironmentVariable(String name) {
   String value = System.getenv(name);
    if (value == null || value.length() == 0) {
        throw new IllegalStateException(
            String.format("The %s environment variable must be set", name));
    }

    return value;
}

===================================================================
java.lang.IllegalStateException:
String value = System.getenv(name);
------- here getting null value exception java code when calling
squareAppId = mustLoadEnvironmentVariable(SQUARE_APP_ID_ENV_VAR);
How can i get /* model.put("addId", squareAppId);*/ vallue of "squareAppId"

Request not authorized

I'm trying to get the node_orders-payments project working.

I set up my sandbox credentials and seeded the menu without an issue.

The entire order flow goes great. Then when I click "Pay with card" I get the error Request not authorized.

Looking at the network tab I can see it's making a call to https://pci-connect.squareupsandbox.com/v2/card-nonce and returning a 401 Unauthorized.

This is the request body that is sent to that endpoint.

card_data: { number: "4111111111111111", exp_month: 12, exp_year: 2021, cvv: "111", billing_postal_code: "98101" }
client_id: "REMOVED"
location_id: "REMOVED"
session_id: "REMOVED"
squarejs_version: "db4f5f246a"
website_url: "http://localhost:3000"

Confusion between nonce and IDs

There is some confusion between when to submit a card_nonce and when to instead submit the customer_card_id and customer_id.

I was submitting the nonce for saved cards without realizing that I should have been submitting customer_card_id and customer_id; if a server submits a nonce for a card already on file (for a saved user) Square should instead respond to not submit the nonce and to use the other two fields. That would save a lot of people a lot of frustration.

Perhaps a very basic flow chart? If you're not saving the customer's information submit the card_nonce. If you are submit the customer_card_id and customer_id.

Hi, Can you help me fix null ?

Hi, Can you help me fix null ?
I could not fix null.

Caught exception!
Response body:
C:\wamp64\www\study\square-php-payment\process-card.php:78:null
Response headers:
C:\wamp64\www\study\square-php-payment\process-card.php:80:null

in process-card.php

try {
$result = $transactions_api->charge($location_id, $request_body);
echo "

";
print_r($result);
echo "
";
} catch (\SquareConnect\ApiException $e) {
echo "Caught exception!
";
print_r("Response body:
");
echo "
"; var_dump($e->getResponseBody()); echo "
";
echo "
Response headers:
";
echo "
"; var_dump($e->getResponseHeaders()); echo "
";
}

IdempotencyKey expiration

We observe a case where two BatchChangeInventory requests with the same idempotencyKey resulted in two changes records, as a result, the quantity has been doubled.

Is there an expiration time for idempotencyKey?

AUTHENTICATION_ERROR

Hi Experts!

I am new to square payment gateway. I have a php website where i want to charge a card for payment. I have created account in square and created an application. Now i want to test in sandbox mode, so i do have sandbox access token and location-id so far I am successful in generating the form, but when i submit the form i get the below error:

category AUTHENTICATION_ERROR
code UNAUTHORIZED
detail This request could not be authorized.

in response, So kindly guide me through this issue.

I got above response from this below url via browser console
https://pci-connect.squareup.com/v2/card-nonce?_=1545914801170.7178

Regards,
Ali

Typo in Node.js documentation

On Node.js documentation, there is a typo stating respone rather than response in the last section of the document:

  try {
    const **respone** = await payments_api.createPayment(request_body);
    const json = JSON.stringify(**respone**);
    res.render('process-payment', {
      'title': 'Payment Successful',
      'result': json
    });
  } catch (error) {
    res.render('process-payment', {
      'title': 'Payment Failure',
      'result': error.**response**.text
    });
  }
});
...

Create Angular 2+ example

You had some old Angular JS (1) front-end code inside of your Rails example, but that seems to have been removed at some point. StackOverflow turns up a couple of scattered cases in which devs seem have issues with iframes and the need to create custom typings to use SqPaymentForm...can you please provide a working example for modern Angular apps?

Error 404 when DELETE a payment

I used the python sample code for listing payments and it worked great. I am wondering if deleting a payment is possible with version 1 API. I got error 404 with this code:

	connection = httplib.HTTPSConnection('connect.squareup.com')
	request_headers = {'Authorization': 'Bearer ' + access_token,
		'Accept':        'application/json',
		'Content-Type':  'application/json'}
	request_path = "/v1/" + locationID + "/payments/" + id
	connection.request('DELETE', request_path, '', request_headers)

Connect API C# Payment Example

I am trying to figure out what this error means.
Error calling Charge: {"errors":[{"category":"AUTHENTICATION_ERROR","code":"UNAUTHORIZED","detail":"This request could not be authorized."}]}

I get a valid nonce.
When i call the Charge method, I use my sandbox access token and a location ID that i get when i run the curl command to get the location id.
curl -H "Authorization: Bearer sandbox-sq0atb-emlxxxxxxxxxx" https://connect.squareup.com/v2/locations

    public static string Charge(string nonce)
    {
        Configuration.Default.AccessToken = "Authorization: Bearer sandbox-sq0atb-emlxxxxxxxxxx";

        // Every payment you process with the SDK must have a unique idempotency key.
        // If you're unsure whether a particular payment succeeded, you can reattempt
        // it with the same idempotency key without worrying about double charging
        // the buyer.
        string uuid = NewIdempotencyKey();

        // Monetary amounts are specified in the smallest unit of the applicable currency.
        // This amount is in cents. It's also hard-coded for $1.00,
        // which isn't very useful.
        Money amount = new Money(100, Money.CurrencyEnum.USD);

        ChargeRequest body = new ChargeRequest(AmountMoney: amount, IdempotencyKey: uuid, CardNonce: nonce);

        try
        {
            var response = _transactionsApi.Charge(_locationId2, body);
            return "Transaction complete\n" + response.ToJson();
        }
        catch (ApiException e)
        {
            return e.Message;
        }
    }

Regards

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.