### Installing PHP SDK Dependencies with Composer Source: https://github.com/chipasia/chip-php-sdk/blob/main/examples/README.md This command uses Composer, a dependency manager for PHP, to install all required libraries and packages for the CHIP PHP SDK. It ensures that all necessary components are available before running the application. ```Bash composer install ``` -------------------------------- ### Running PHP Development Server Locally Source: https://github.com/chipasia/chip-php-sdk/blob/main/examples/README.md This command starts a built-in PHP development server, making the application accessible locally at `localhost:7001`. This is useful for testing and debugging, especially when combined with tools like ngrok for external access to callback and webhook endpoints. ```Bash php -S localhost:7001 ``` -------------------------------- ### Creating a Purchase with Chip PHP SDK Source: https://github.com/chipasia/chip-php-sdk/blob/main/README.md This example demonstrates how to initialize the Chip API and create a new purchase. It sets up client details, product information, and defines redirect/callback URLs, then uses `createPurchase` to generate a checkout URL for redirection. ```PHP email = 'test@example.com'; $purchase = new \Chip\Model\Purchase(); $purchase->client = $client; $details = new \Chip\Model\PurchaseDetails(); $product = new \Chip\Model\Product(); $product->name = 'Test'; $product->price = 100; $details->products = [$product]; $purchase->purchase = $details; $purchase->brand_id = $config['brand_id']; $purchase->success_redirect = 'https://yourdomain.com/redirect.php?success=1'; $purchase->success_callback = 'https://yourdomain.com/callback.php?success=0'; $purchase->failure_redirect = 'https://yourdomain.com/redirect.php?success=0'; $result = $chip->createPurchase($purchase); if ($result && $result->checkout_url) { // Redirect user to checkout header("Location: " . $result->checkout_url); exit; } ``` -------------------------------- ### Installing Chip PHP SDK with Composer Source: https://github.com/chipasia/chip-php-sdk/blob/main/README.md These commands are used to install or update the Chip PHP SDK and its dependencies after configuring the `composer.json` file. `composer install` installs dependencies from `composer.lock`, while `composer update` resolves and updates them to their latest compatible versions. ```Bash composer install # OR composer update ``` -------------------------------- ### Configuring Composer for Chip PHP SDK Source: https://github.com/chipasia/chip-php-sdk/blob/main/README.md This snippet shows how to configure your `composer.json` file to include the Chip PHP SDK. It adds a VCS repository for the SDK and specifies the required package and version, enabling Composer to locate and install the library. ```PHP "repositories": [ ... { "type": "vcs", "url": "git@github.com:CHIPAsia/chip-php-sdk.git" } ], "require": { "chip/chip-sdk-php": "^1.0" } ``` -------------------------------- ### Configuring CHIP PHP SDK Credentials Source: https://github.com/chipasia/chip-php-sdk/blob/main/examples/README.md This PHP array defines the essential configuration parameters for the CHIP PHP SDK, including `brand_id`, `api_key`, `endpoint`, `basedUrl`, and `webhook_public_key`. These values must be replaced with actual credentials obtained from the CHIP Merchant Portal's Developer section to ensure proper API communication and webhook verification. ```PHP // config.php '<>', 'api_key' => '<>', 'endpoint' => 'https://gate.chip-in.asia/api/v1/', 'basedUrl' => '<>', 'webhook_public_key' => "<>" ]; ``` -------------------------------- ### Running Tests for Chip PHP SDK Source: https://github.com/chipasia/chip-php-sdk/blob/main/README.md This command executes the PHPUnit test suite for the Chip PHP SDK. It runs all tests located in the `tests` directory, ensuring the library's functionality and stability. ```Bash ./vendor/bin/phpunit tests ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.