### Install Dependencies and Start Development Server Source: https://github.com/automattic/woocommerce-payments/blob/develop/AGENTS.md Install project dependencies and start the development server with hot module replacement for rapid frontend development. ```bash npm install npm start ``` -------------------------------- ### Install Dependencies and Start Environment Source: https://github.com/automattic/woocommerce-payments/blob/develop/docker/README.md Run these commands to install project dependencies and start the WordPress container with the site configured. Use `npm run up:recreate` for the initial setup or when significant changes require a fresh configuration. ```bash npm install npm run up:recreate npm run build:client ``` -------------------------------- ### Start Docker development environment Source: https://github.com/automattic/woocommerce-payments/blob/develop/README.md Quick start commands to install dependencies and initialize the WordPress Docker environment. ```bash npm install # Install dependencies npm run up:recreate # Start WordPress and run setup (auto-starts infrastructure if needed) ``` -------------------------------- ### Install dependencies and build Source: https://github.com/automattic/woocommerce-payments/blob/develop/README.md Commands to install project dependencies and build the client-side assets. ```bash npm install composer install npm run build:client ``` ```bash npm start ``` -------------------------------- ### GET /setup_intentions/{id} Source: https://github.com/automattic/woocommerce-payments/blob/develop/includes/core/server/request/class-get-setup-intention.md Retrieves a setup intention using the provided identifier. ```APIDOC ## GET /setup_intentions/{id} ### Description Retrieves a setup intention from the server. ### Method GET ### Endpoint /setup_intentions/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The identifier of the setup intention, must be in the `seti_XXX` format. ### Request Example $request = Get_Setup_Intention::create( $id ); $request->send(); ``` -------------------------------- ### Start Local WordPress Environment Source: https://github.com/automattic/woocommerce-payments/blob/develop/AGENTS.md Commands to manage the local Dockerized WordPress environment. Use `npm run up:recreate` for first-time setup and `npm run up` for subsequent starts. `npm run watch` is used for regenerating assets during local development. ```bash npm run up:recreate npm run up npm run watch ``` -------------------------------- ### Quick Start Workflow Commands Source: https://github.com/automattic/woocommerce-payments/blob/develop/tests/qit/LOCAL_DEVELOPMENT.md A sequence of commands to start the environment, run tests, and clean up. ```bash # 1. Start the environment (one-time setup) npm run test:qit-e2e-up # 2. Source environment variables (run in each new terminal) source "$(./vendor/bin/qit env:source)" # 3. Navigate to test package cd tests/qit/test-package # 4. Run tests with Playwright npx playwright test --ui # 5. Reset database between runs (optional, restores post-setup state) npm run test:qit-e2e-reset # 6. When done, stop the environment npm run test:qit-e2e-down ``` -------------------------------- ### Create and Confirm Setup Intention Request Source: https://github.com/automattic/woocommerce-payments/blob/develop/includes/core/server/request/class-create-and-confirm-setup-intention.md Demonstrates the instantiation, parameter configuration, and execution of a setup intention request. ```php $request = Create_and_Confirm_Setup_Intention::create(); $request->set_customer( $customer_id ); $request->set_metadata( $metadata ); $request->set_payment_method( $payment_method_id ); $request->set_payment_method_types( $payment_method_types ); $request->set_mandate_data( $mandate_data ); $request->assign_hook( 'wcpay_create_and_confirm_setup_intent_request' ); $request->set_hook_args( $payment_information, $save_in_platform_account, $save_payment_method_to_platform ); $request->send(); ``` -------------------------------- ### Install Dependencies Source: https://github.com/automattic/woocommerce-payments/blob/develop/docker/README.md Installs all necessary project dependencies using npm. ```bash npm install ``` -------------------------------- ### Install Composer Dependencies Source: https://github.com/automattic/woocommerce-payments/blob/develop/CONTRIBUTING.md Run this command in the plugin directory to install PHP dependencies required for linting and development. ```bash $ composer install ``` -------------------------------- ### Start Docker Environment Source: https://github.com/automattic/woocommerce-payments/blob/develop/CONTRIBUTING.md Starts the Dockerized local development environment for WordPress and related services. This command also recreates containers if necessary. ```bash npm run up:recreate ``` -------------------------------- ### Create a New Git Worktree Source: https://github.com/automattic/woocommerce-payments/blob/develop/docker/README.md Steps to create a new Git worktree, navigate into it, install dependencies, set up the worktree-specific configuration (including port and ID), and start the WordPress container. ```bash git worktree add ../my-feature-branch feature-branch cd ../my-feature-branch npm install npm run worktree:setup npm run up:recreate ``` -------------------------------- ### Setup Jurassic Tube Client Source: https://github.com/automattic/woocommerce-payments/blob/develop/docker/README.md Installs the Jurassic Tube client, generates SSH keys, and configures a subdomain for exposing your local site. This is recommended for A8C employees. ```bash npm run tube:setup ``` -------------------------------- ### Start QIT Environment Source: https://github.com/automattic/woocommerce-payments/blob/develop/tests/qit/LOCAL_DEVELOPMENT.md Initializes the Docker containers and configures the test environment. ```bash npm run test:qit-e2e-up ``` -------------------------------- ### Install WordPress Unit Test Library Source: https://github.com/automattic/woocommerce-payments/blob/develop/tests/README.md Installs WordPress and the WP Unit Test library. Replace placeholders with your database credentials. Use '127.0.0.1' for DB host if 'localhost' fails. ```bash $ bin/install-wp-tests.sh [db-host] ``` -------------------------------- ### Start E2E Test Docker Containers Source: https://github.com/automattic/woocommerce-payments/blob/develop/AGENTS.md Start the Docker containers that host the E2E testing environment, ensuring all services are running. ```bash npm run test:e2e-up ``` -------------------------------- ### Create Terminal Intent Response Example Source: https://github.com/automattic/woocommerce-payments/blob/develop/docs/rest-api/source/includes/wp-api-v3/order.md Example JSON response when a terminal intent is successfully created. ```json { "id": "pi_ZZZZZZZZZZZZZZZZAAAAAAAA" } ``` -------------------------------- ### Create and Confirm Setup Intention Source: https://github.com/automattic/woocommerce-payments/blob/develop/includes/core/server/request/class-create-and-confirm-setup-intention.md Constructs and sends a request to create and confirm a setup intention using the WooCommerce Payments server request class. ```APIDOC ## Create and Confirm Setup Intention ### Description The `Create_and_Confirm_Setup_Intention` class is used to construct and send a request for creating and confirming a setup intention. ### Parameters - **customer** (string) - Required - The ID of the customer. - **description** (array) - Optional - Metadata associated with the request. - **payment_method** (string) - Optional - The ID of the payment method. - **payment_method_types** (string) - Optional - The types of payment methods to be used. - **mandata_data** (array) - Optional - Mandate data for the setup intention. ### Filter - **Name**: `wcpay_create_and_confirm_setup_intent_request` - **Arguments**: - `WCPay\Payment_Information $payment_information` - `bool $save_in_platform_account` - `bool $save_payment_method_to_platform` ### Request Example ```php $request = Create_and_Confirm_Setup_Intention::create(); $request->set_customer( $customer_id ); $request->set_metadata( $metadata ); $request->set_payment_method( $payment_method_id ); $request->set_payment_method_types( $payment_method_types ); $request->set_mandate_data( $mandate_data ); $request->assign_hook( 'wcpay_create_and_confirm_setup_intent_request' ); $request->set_hook_args( $payment_information, $save_in_platform_account, $save_payment_method_to_platform ); $request->send(); ``` ``` -------------------------------- ### Standard Mock Request Example Source: https://github.com/automattic/woocommerce-payments/blob/develop/includes/core/server/CONTRIBUTING.md This example demonstrates a standard mock request, expecting a single API call and setting a method with specific arguments. ```php $mock_response = [ // add mock response here... ]; $request = $this->mock_wcpay_request( List_Documents::class, 1, null, $mock_response ); $request ->expects( $this->once() ) ->method( 'set_type_is' ) ->with( 'bill' ); ``` -------------------------------- ### Authorization Summary Response Example Source: https://github.com/automattic/woocommerce-payments/blob/develop/docs/rest-api/source/includes/wp-api-v3/authorization.md Example JSON response for the authorization summary. It provides aggregated data like the number of authorizations and their total value. ```json { "count": 3, "currency": "usd", "total": 5400, "all_currencies": [ "usd" ] } ``` -------------------------------- ### Customer Payment Methods Response Example (JSON) Source: https://github.com/automattic/woocommerce-payments/blob/develop/docs/rest-api/source/includes/wp-api-v3/customer.md This is an example of a successful JSON response when retrieving a customer's payment methods. It includes details like payment type, billing information, and card specifics. ```json [ { "id": "pm_1AxXc2a5dGhIZQYPlaLbKj1Z", "type": "card", "billing_details": { "address": { "city": "Los Angeles", "country": "US", "line1": "123 Anywhere St", "line2": null, "postal_code": "90002", "state": "CA" }, "email": "john.doe@example.com", "name": "John Doe", "phone": null }, "card": { "brand": "visa", "last4": "1122", "exp_month": 10, "exp_year": 2028 } }, { "id": "pm_2BcYd3e6hKjZLQWQmMnOjK45", "type": "card", "billing_details": { "address": { "city": "New York", "country": "US", "line1": "456 Broadway Ave", "line2": null, "postal_code": "10012", "state": "NY" }, "email": "jane.smith@example.com", "name": "Jane Smith", "phone": null }, "card": { "brand": "mastercard", "last4": "3344", "exp_month": 12, "exp_year": 2027 } } ] ``` -------------------------------- ### Perform First-Time E2E Environment Setup Source: https://github.com/automattic/woocommerce-payments/blob/develop/AGENTS.md Initialize the end-to-end testing environment, including generating configuration files and setting up necessary Docker containers. ```bash npm run test:e2e-setup ``` -------------------------------- ### Start Tunnel in Worktree Source: https://github.com/automattic/woocommerce-payments/blob/develop/AGENTS.md Steps to start an SSH tunnel for a worktree. Ensure the worktree has a port assigned via `npm run worktree:setup` and Docker is running (`npm run up`). The tunnel command `npm run tube:start` is worktree-aware and handles configuration automatically. ```bash # 1. Ensure worktree has a port assigned npm run worktree:setup # 2. Ensure Docker is running npm run up # 3. Start tunnel (auto-copies config from main repo if needed) npm run tube:start ``` -------------------------------- ### Composer GitHub OAuth error message Source: https://github.com/automattic/woocommerce-payments/blob/develop/README.md Example of the error output when GitHub API rate limits are reached during composer installation. ```text Loading composer repositories with package information GitHub API limit (0 calls/hr) is exhausted, could not fetch https://api.github.com/repos/automattic/woocommerce-subscriptions-core. Create a GitHub OAuth token to go over the API rate limit. You can also wait until ? for the rate limit to reset. Head to https://github.com/settings/tokens/new?scopes=repo&description=Composer+XXXXXX to retrieve a token. It will be stored in "/Users/yourname/.composer/auth.json" for future use by Composer. ``` -------------------------------- ### Create and send a setup intention request Source: https://github.com/automattic/woocommerce-payments/blob/develop/includes/core/server/request/class-create-setup-intention.md Initializes the request object, sets the required customer and payment method parameters, and executes the request. ```php $request = Create_Setup_Intention::create(); $request->set_customer( $customer_id ); $request->set_payment_method_types( $payment_methods ); $request->send(); ``` -------------------------------- ### Create and Send Get_Setup_Intention Request Source: https://github.com/automattic/woocommerce-payments/blob/develop/includes/core/server/request/class-get-setup-intention.md Use the `create()` method to instantiate the request, providing the item ID in `seti_XXX` format. The `send()` method then dispatches the request. ```php $request = Get_Setup_Intention::create( $id ); $request->send(); ``` -------------------------------- ### Start Jurassic Tube SSH Tunnel Source: https://github.com/automattic/woocommerce-payments/blob/develop/AGENTS.md Commands for managing Jurassic Tube SSH tunnels, which create public HTTPS tunnels to your local WordPress instance. Use `npm run tube:setup` for initial configuration, `npm run tube:start` to activate a tunnel, and `npm run tube:stop` to deactivate. ```bash npm run tube:setup npm run tube:start npm run tube:stop npm run tube:status ``` -------------------------------- ### Initialize Local Configuration Source: https://github.com/automattic/woocommerce-payments/blob/develop/tests/qit/LOCAL_DEVELOPMENT.md Copy the default environment configuration file to a local version. ```bash cp tests/qit/config/default.env tests/qit/config/local.env ``` -------------------------------- ### Start Docker Environment and Development Workflow Source: https://github.com/automattic/woocommerce-payments/blob/develop/AGENTS.md Launch the Dockerized development environment and initiate the watch mode for continuous integration of frontend and backend changes. ```bash npm run up npm run dev ``` -------------------------------- ### Create Terminal Intent Error Response Example Source: https://github.com/automattic/woocommerce-payments/blob/develop/docs/rest-api/source/includes/wp-api-v3/order.md Example JSON response for an intent creation error. ```json { "code": "wcpay_intent_creation_error", "message": "Intent creation failed with the following message: ", "data": { "status": 500 } } ``` -------------------------------- ### Serve Built API Docs Locally Source: https://github.com/automattic/woocommerce-payments/blob/develop/docs/rest-api/README.md Serve the built HTML documentation locally using npx serve. Access it at localhost:3000. ```bash npx serve build ``` -------------------------------- ### Capture Authorization Uncapturable Response Example Source: https://github.com/automattic/woocommerce-payments/blob/develop/docs/rest-api/source/includes/wp-api-v3/order.md Example JSON response when an authorization cannot be captured due to its status or other conditions. ```json { "code": "wcpay_payment_uncapturable", "message": "The payment cannot be captured", "data": { "status": 409 } } ``` -------------------------------- ### Combine Container Startup with Watch Mode Source: https://github.com/automattic/woocommerce-payments/blob/develop/docker/README.md Starts the Docker environment and enables watch mode for JavaScript assets simultaneously, streamlining the development workflow. ```bash npm run dev ``` -------------------------------- ### Capture Terminal Payment Success Response Example Source: https://github.com/automattic/woocommerce-payments/blob/develop/docs/rest-api/source/includes/wp-api-v3/order.md Example JSON response when a terminal payment is successfully captured. ```json { "status": "succeeded", "id": "pi_ZZZZZZZZZZZZZZZZAAAAAAAA" } ``` -------------------------------- ### WooPay Create and Confirm Setup Intention Source: https://github.com/automattic/woocommerce-payments/blob/develop/includes/core/server/request/class-woopay-create-and-confirm-setup-intention.md Constructs and sends a request to create and confirm a setup intention for WooPay. ```APIDOC ## WooPay_Create_and_Confirm_Setup_Intention ### Description This class is used to construct the request for creating and confirming a setup intention for WooPay. ### Parameters - **customer** (string) - Required - The customer ID. - **is_platform_payment_method** (mixed) - Optional - Sets if the payment method is a platform payment method. - **description** (array) - Optional - Metadata associated with the request. - **payment_method** (string) - Optional - The payment method ID. - **save_in_platform_account** (mixed) - Optional - Sets whether to save in the platform account. - **save_payment_method_to_platform** (mixed) - Optional - Sets whether to save the payment method to the platform. ### Filter - **Name**: wcpay_create_and_confirm_setup_intent_request - **Arguments**: - WCPay\Payment_Information $payment_information - bool $save_in_platform_account - bool $save_payment_method_to_platform ``` -------------------------------- ### Create and Confirm Setup Intention Request Source: https://github.com/automattic/woocommerce-payments/blob/develop/includes/core/server/request/class-woopay-create-and-confirm-setup-intention.md Instantiate and configure the `WooPay_Create_and_Confirm_Setup_Intention` request class. Use setters to define customer, payment method, and save preferences. Assign hooks and arguments before sending the request. ```php $request = WooPay_Create_and_Confirm_Setup_Intention::create(); $request->set_customer( $customer_id ); $request->set_is_platform_payment_method( $is ); $request->set_metadata( $metadata ); $request->set_payment_method( $payment_method_id ); $request->set_save_in_platform_account( $save ); $request->set_save_payment_method_to_platform( $save ); $request->assign_hook( 'wcpay_create_and_confirm_setup_intent_request' ); $request->set_hook_args( $payment_information, $save_in_platform_account, $save_payment_method_to_platform ); $request->send(); ``` -------------------------------- ### Capture Terminal Payment Server Error Response Example Source: https://github.com/automattic/woocommerce-payments/blob/develop/docs/rest-api/source/includes/wp-api-v3/order.md Example JSON response for a server error during terminal payment capture. ```json { "code": "wcpay_server_error", "message": "Unexpected server error", "data": { "status": 500 } } ``` -------------------------------- ### Configure Local Environment Variables Source: https://github.com/automattic/woocommerce-payments/blob/develop/tests/qit/LOCAL_DEVELOPMENT.md Add QIT CLI credentials and Jetpack tokens to the local configuration file. ```bash # QIT CLI Credentials QIT_USER=your_qit_username QIT_PASSWORD=your_qit_application_password # Jetpack Tokens E2E_JP_SITE_ID=your_site_id E2E_JP_BLOG_TOKEN=your_blog_token E2E_JP_USER_TOKEN=your_user_token ``` -------------------------------- ### Get Payouts Summary Source: https://github.com/automattic/woocommerce-payments/blob/develop/docs/rest-api/source/includes/wp-api-v3/payouts.md Fetches a summary of payouts matching the query, useful for getting totals without retrieving the full list. ```shell curl -X GET https://example.com/wp-json/wc/v3/payments/deposits/summary \ -u consumer_key:consumer_secret ``` ```json { "count": 42, "store_currencies": [ "chf", "eur", "gbp", "nok", "sek", "usd", "dkk" ], "total": 5744395, "currency": "eur" } ``` -------------------------------- ### Create_Setup_Intention Request Source: https://github.com/automattic/woocommerce-payments/blob/develop/includes/core/server/request/class-create-setup-intention.md Details for constructing and sending a request to create a setup intention. ```APIDOC ## Create_Setup_Intention ### Description The `Create_Setup_Intention` class is used to construct the request for creating a setup intention in the WooCommerce Payments system. ### Parameters - **customer** (string) - Required - The customer ID associated with the setup intention. - **payment_method_types** (array) - Required - The list of payment method types to be used. ### Filter - **Name**: `wcpay_create_setup_intent_request` ### Request Example ```php $request = Create_Setup_Intention::create(); $request->set_customer( $customer_id ); $request->set_payment_method_types( $payment_methods ); $request->send(); ``` ``` -------------------------------- ### Authorization API Error Response Example Source: https://github.com/automattic/woocommerce-payments/blob/develop/docs/rest-api/source/includes/wp-api-v3/authorization.md Example JSON response for a bad request, indicating invalid query parameters such as sorting direction. ```json { "code": "wcpay_bad_request", "message": "Error: Invalid sorting direction: ", "data": null } ``` -------------------------------- ### Record a Terms of Service agreement Source: https://github.com/automattic/woocommerce-payments/blob/develop/includes/core/server/request/class-add-account-tos-agreement.md Initializes the request, sets the required source and user name, and sends the request to the server. ```php $request = Add_Account_Tos_Agreement::create(); $request->set_source( 'settings-popup' ); $request->set_user_name( 'current_username' ); $request->send(); ``` -------------------------------- ### GET /deposits Source: https://github.com/automattic/woocommerce-payments/blob/develop/includes/core/server/request/class-get-request.md The Get_Request class is used to construct basic HTTP GET requests. It allows for optional ID parameters to specify a resource. ```APIDOC ## GET /deposits ### Description Constructs a GET request for deposits, optionally with a specific ID. ### Method GET ### Endpoint /deposits ### Parameters #### Query Parameters - **id** (string) - Optional - The ID of the deposit resource. ### Request Example ```php $request = Request::get( ('deposits', $id ); $request->assign_hook( 'wcpay_get_deposit_request' ); $request->send(); ``` ### Response #### Success Response (200) - **data** (object) - The requested deposit data. #### Response Example ```json { "data": { "id": "123", "amount": "100.00", "status": "completed" } } ``` ``` -------------------------------- ### Basic Request Creation and Usage Source: https://github.com/automattic/woocommerce-payments/blob/develop/includes/core/server/CONTRIBUTING.md Demonstrates the standard way to create and use a request object, such as `Create_And_Confirm_Intention`, by instantiating it, setting hook arguments, and sending the request. ```php $request = Create_And_Confirm_Intention::create(); $request->set_hook_args( $payment_information ); // Call all necessary setters... $intent = $request->send(); ``` -------------------------------- ### Construct and send a List_Deposits request Source: https://github.com/automattic/woocommerce-payments/blob/develop/includes/core/server/request/class-list-deposits.md Initializes a new deposit listing request, applies optional filters and pagination settings, and executes the request. ```php $request = List_Deposits::create(); $request->set_match( $match ); $request->set_page( $page ); $request->set_page_size( $page_size ); $request->set_sort_by( $sort ); $request->set_sort_direction( $direction ); $request->set_status_is( $status_is ); $request->set_status_is_not( $status_is_not ); $request->set_store_currency_is( $store_currency_is ); $request->send(); ``` -------------------------------- ### Get Account Login Data Source: https://github.com/automattic/woocommerce-payments/blob/develop/includes/core/server/request/class-get-account-login-data.md Constructs a request to get a one-time dashboard login URL. The test_mode flag is sent only when the site is in sandbox mode. ```APIDOC ## POST /automattic/woocommerce-payments/Get_Account_Login_Data ### Description This endpoint is used to construct the request for getting a one-time dashboard login URL. The `test_mode` flag is sent only when the site is in sandbox mode. ### Method POST ### Endpoint /automattic/woocommerce-payments/Get_Account_Login_Data ### Parameters #### Request Body - **redirect_url** (string) - Required - The URL to redirect to after login. ### Request Example ```json { "redirect_url": "http://example.org/wp-admin/admin.php?page=wc-admin&path=/payments/overview" } ``` ### Response #### Success Response (200) - **login_url** (string) - The one-time login URL. - **test_mode** (boolean) - Indicates if the request was made in test mode. #### Response Example ```json { "login_url": "https://example.com/wp-login.php?action=woocommerce-payments-login&token=abcdef12345", "test_mode": false } ``` ``` -------------------------------- ### Build REST API Docs Locally Source: https://github.com/automattic/woocommerce-payments/blob/develop/docs/rest-api/README.md Use this script to build the documentation locally. Requires Docker and Node.js. ```bash cd docs/rest-api ./build.sh ```