Skip to main content

Squareup API Integration PHP. List squareup customers using php

 

Step 1: Download Composer and dependencies

This application requires the PHP Square SDK as well as DotEnv for reading environment variables, which you install via Composer.

First, download Composer in this directory with the instructions on this page.

After you've downloaded Composer, install the dependencies with the following command from this directory:

php composer.phar install

Step 2: Get your credentials and set the redirect URL:

  1. Open the Developer Dashboard.

  2. Choose Open on the card for an application.

  3. At the top of the page, set the dashboard mode to Sandbox.

  4. Choose OAuth in the left navigation pane. The OAuth page is shown.

  5. In the Sandbox Redirect URL box, enter the URL for the callback you will implement to complete the OAuth flow: http://localhost:8000/sandbox_callback.php

    This example uses localhost in the Square Sandbox. You can use HTTP for localhost but an actual web server implementation must use HTTPS.

  6. in the Sandbox Application ID box, copy the application ID.

  7. In the Sandbox Application Secret box, choose Show, and then copy the application secret.

  8. Click Save.

  9. Create the sandbox_config.php file and add the following code. Follow the instructions in the file to replace the appropriate REPLACE_ME placeholders with the Sandbox application ID and Sandbox application secret. The file should look like the following:

  10. <?php

    require 'vendor/autoload.php';



    use Square\SquareClient;
    use Square\Exceptions\ApiException;
    use Square\Models\CreateCustomerRequest;
    use Square\Environment;

    $client = new SquareClient([
       'accessToken' => 'your access token',
         "environment" => Environment::SANDBOX
    ]);

    //$customersApi = $client->getCustomersApi();

    $api_response = $client->getCustomersApi()->listCustomers();

    if ($api_response->isSuccess()) {
        $result = $api_response->getResult();
    } else {
        $errors = $api_response->getErrors();
    }
    echo json_encode($result);
  11. This will show the list of customers in your sandbox account

Comments

Popular posts from this blog

Rich Text Editor

Implementing jQuery Text Editor in Textarea You might have seen text editor in many comment form ex.Wordpress.org. It is having a rich text editor in their review comment form. The rich text editor helps to create the content where, you can easily bold the text or make it  italics, adjust the font size. You can format your text in one click.you can insert an images and smilies also. In this tutorial, we are going to share a file that creates Text Editor using jQuery/JavaScript/HTML. Clik the following link to view the Text editor http://www.formget.com/implementing-jquery-text-editor-in-textarea/

Difference between php5 and php7

  Feature Php7 Php5 Performance Performance speed is double. Average requests per second are 44 when it is 22 in php5. Performance is low compared to php7. Return type You can declare the return type. Example – public function productName (int $id) : String { return “default”; } No provision for return type declaration Exception handling Major errors have been changed to exceptions making them easier to catch. To handle fatal errors was a difficult task for developers. Group use declaration Using the use of declarations makes the code more readable and compact. use pkg\utility\{ClassA, ClassB, ClassC as C}; Similarly, functions and constants can be declared using group use. Individual declarations for common namespaces. For example – use pkg\utility\ClassA; use pkg\utility\ClassB; use pkg\utility\ClassC; Support for 64-bit Supports 64-bit integers and large files. It doesn't support 64-bit integer. Anonymous class A developer can create an anonymous class for a one-off use, rather ...