{"id":20290608,"url":"https://github.com/gocardless/gocardless-pro-php","last_synced_at":"2026-02-24T18:01:08.381Z","repository":{"id":29597749,"uuid":"33137790","full_name":"gocardless/gocardless-pro-php","owner":"gocardless","description":"GoCardless Pro PHP Client","archived":false,"fork":false,"pushed_at":"2026-02-18T14:46:33.000Z","size":3285,"stargazers_count":102,"open_issues_count":17,"forks_count":40,"subscribers_count":88,"default_branch":"master","last_synced_at":"2026-02-18T18:32:59.568Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gocardless.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2015-03-30T17:35:58.000Z","updated_at":"2026-02-18T14:49:31.000Z","dependencies_parsed_at":"2023-12-21T14:14:37.575Z","dependency_job_id":"5d9ccc08-2ab0-4809-ab2a-74e1103a6b1c","html_url":"https://github.com/gocardless/gocardless-pro-php","commit_stats":{"total_commits":696,"total_committers":17,"mean_commits":40.94117647058823,"dds":"0.47413793103448276","last_synced_commit":"d843a4a94cbe20ab5c0533eb805c48a87600abdf"},"previous_names":[],"tags_count":95,"template":false,"template_full_name":null,"purl":"pkg:github/gocardless/gocardless-pro-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gocardless%2Fgocardless-pro-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gocardless%2Fgocardless-pro-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gocardless%2Fgocardless-pro-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gocardless%2Fgocardless-pro-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gocardless","download_url":"https://codeload.github.com/gocardless/gocardless-pro-php/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gocardless%2Fgocardless-pro-php/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29793659,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-24T16:37:37.581Z","status":"ssl_error","status_checked_at":"2026-02-24T16:37:37.074Z","response_time":75,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T15:08:27.190Z","updated_at":"2026-02-24T18:01:08.323Z","avatar_url":"https://github.com/gocardless.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GoCardless Pro PHP client library\n\nA PHP client for interacting with the GoCardless Pro API.\n\n[![PHP version](https://badge.fury.io/ph/gocardless%2Fgocardless-pro.svg)](https://badge.fury.io/ph/gocardless%2Fgocardless-pro)\n[![CircleCI](https://circleci.com/gh/gocardless/gocardless-pro-php.svg?style=shield)](https://circleci.com/gh/gocardless/gocardless-pro-php)\n\n\n- [\"Getting started\" guide](https://developer.gocardless.com/getting-started/api/introduction/?lang=php)\nwith copy and paste PHP code samples\n- [API Reference](https://developer.gocardless.com/api-reference)\n- [Composer Package](https://packagist.org/packages/gocardless/gocardless-pro)\n- [Changelog](https://github.com/gocardless/gocardless-pro-php/releases)\n\n### Installation\n\nThe recommended way to install `gocardless-pro` is using\n[Composer](https://getcomposer.org/).\n\n```bash\n# Install Composer\ncurl -sS https://getcomposer.org/installer | php\n```\n\nNext, run the Composer command to install the latest stable version of `gocardless-pro`.\n```bash\nphp composer.phar require gocardless/gocardless-pro\n```\n\nAfter installing, you need to require Composer's autoloader:\n```php\nrequire 'vendor/autoload.php';\n```\n\n### Initialising A Client\n\nCreate a `GoCardlessPro\\Client` instance, providing your access token and the environment\nyou want to use. We strongly advise storing your access token as an environment variable,\nrather than directly in your code. You can easily load the environment variables from a\n`.env` file by using something like [phpdotenv](https://github.com/vlucas/phpdotenv),\nthough keep it out of version control!\n\n```php\n$access_token = getenv('GC_ACCESS_TOKEN');\n$client = new \\GoCardlessPro\\Client([\n  'access_token' =\u003e $access_token,\n  'environment'  =\u003e \\GoCardlessPro\\Environment::SANDBOX\n]);\n```\n\nYou can create an `access_token` from the \"Developers\" tab in your GoCardless dashboard.\n\nThe environment can either be `\\GoCardlessPro\\Environment::SANDBOX` or\n`\\GoCardlessPro\\Environment::LIVE`, depending on whether you want to\nuse the sandbox or live API.\n\nFor full documentation, see our [API docs](https://developer.gocardless.com/api-reference).\n\n### GET requests\n\nYou can make a request to get a list of resources using the `list` method.\n\n```php\n$client-\u003ecustomers()-\u003elist();\n```\n\n*Note: This README will use customers throughout but each of the resources in the API is\navailable in this library.*\n\nIf you need to pass any options, the last (or only, in the absence of URL params)\nargument to `list()` is an array of URL parameters:\n\n```php\n$customers = $client-\u003ecustomers()-\u003elist(['params' =\u003e ['limit' =\u003e 400]]);\n```\n\nA call to `list()` returns an instance of `ListResponse`. You can use its `records`\nattribute to iterate through the results.\n\n```php\necho count($customers-\u003erecords);\nforeach ($customers-\u003erecords as $resource) {\n  echo $resource-\u003egiven_name;\n}\n```\n\nIn the case where a URL parameter is needed, the method signature will contain the\nrequired arguments:\n\n```php\n$customer = $client-\u003ecustomers()-\u003eget($customer_id);\necho $customer-\u003egiven_name;\n```\n\nAs with list, the last argument can be an options array, with any URL parameters given:\n\n```php\n$client-\u003ecustomers()-\u003eget($customer_id, ['params' =\u003e ['some_flag' =\u003e true]]);\n```\n\nBoth individual resource and ListResponse instances have an `api_response` attribute,\nwhich lets you access the following properties of the request:\n\n- `status`\n- `headers`\n- `body`\n\n```php\n$api_response = $client-\u003ecustomers()-\u003eget($customer_id)-\u003eapi_response;\necho $api_response-\u003estatus_code;\n```\n\n### POST/PUT Requests\n\nFor POST and PUT requests, you need to provide a body for your request by passing it in\nas the first argument.\n\n```php\n$client-\u003ecustomers()-\u003ecreate([\n  'params' =\u003e ['given_name' =\u003e 'Pete', 'family_name' =\u003e 'Hamilton']\n]);\n```\n\nAs with GET requests, if any parameters are required, these come first:\n\n```php\n$client-\u003ecustomers()-\u003eupdate($customer_id, [\n  'params' =\u003e ['family_name' =\u003e 'Smith']\n]);\n```\n\nThe GoCardless API includes [idempotency keys](https://developer.gocardless.com/api-reference/#making-requests-idempotency-keys).\nThe library will automatically inject these into your request when you create a resource,\npreventing it from getting duplicated if something goes wrong with the API (e.g.\nnetworking issues or a timeout).\n\nYou can also specify your own idempotency key - you\ncould, for example, use IDs of records in your database, protecting yourself not only\nfrom network or API issues, but also mistakes on your side which could lead to\ndouble-creation:\n\n```php\n$client-\u003ecustomers()-\u003ecreate([\n  'params' =\u003e  ['given_name' =\u003e 'Pete', 'family_name' =\u003e 'Hamilton']\n  'headers' =\u003e ['Idempotency-Key' =\u003e 'ABC123']\n]);\n```\n\nIf the library hits an idempotency key conflict (that is, you try to create a resource\nwith an idempotency key you've already used), it will automatically load and return the\nalready-existing resource.\n\n### Handling Failures\n\nWhen the API returns an error, the library will return a corresponding subclass of\n`ApiException`, one of:\n\n- `InvalidApiUsageException`\n- `InvalidStateException`\n- `ValidationFailedException`\n\nThese types of error are covered in the\n[API documentation](https://developer.gocardless.com/pro/#overview-errors).\n\nIf the error is an HTTP transport layer error (e.g. timeouts or issues within\nGoCardless's infrastructure), requests will automatically be retried by the library up to\n3 times, with a 500ms delay between attempts, before a `ApiConnectionException` is\nraised.\n\nIf the library can't parse the response from GoCardless, it will throw a\n`MalformedResponseException`.\n\n```php\ntry {\n  $client-\u003ecustomer()-\u003ecreate([\n    'params' =\u003e ['invalid_name' =\u003e 'Pete']\n  ]);\n} catch (\\GoCardlessPro\\Core\\Exception\\ApiException $e) {\n  // Api request failed / record couldn't be created.\n} catch (\\GoCardlessPro\\Core\\Exception\\MalformedResponseException $e) {\n  // Unexpected non-JSON response.\n} catch (\\GoCardlessPro\\Core\\Exception\\ApiConnectionException $e) {\n  // Network error.\n}\n```\n\nProperties of the exception can be accessed with the following methods:\n- `$e-\u003egetType();`\n- `$e-\u003egetCode();`\n- `$e-\u003egetErrors();`\n- `$e-\u003egetDocumentationUrl();`\n- `$e-\u003egetMessage();`\n- `$e-\u003egetRequestId();`\n- `$e-\u003egetApiResponse();`\n\n### Handling webhooks\n\nGoCardless supports webhooks, allowing you to receive real-time notifications when things happen in your account, so you can take automatic actions in response, for example:\n\n* When a customer cancels their mandate with the bank, suspend their club membership\n* When a payment fails due to lack of funds, mark their invoice as unpaid\n* When a customer's subscription generates a new payment, log it in their \"past payments\" list\n\nThe client allows you to validate that a webhook you receive is genuinely from GoCardless, and to parse it into `GoCardlessPro\\Resources\\Event` objects which are easy to work with:\n\n```php\n\u003c?php\n// When you create a webhook endpoint, you can specify a secret. When GoCardless sends\n// you a webhook, it will sign the body using that secret. Since only you and GoCardless\n// know the secret, you can check the signature and ensure that the webhook is truly\n// from GoCardless.\n//\n// We recommend storing your webhook endpoint secret in an environment variable\n// for security, but you could include it as a string directly in your code\n$webhook_endpoint_secret = getenv('GOCARDLESS_WEBHOOK_ENDPOINT_SECRET');\n\n$request_body = file_get_contents('php://input');\n\n$headers = getallheaders();\n$signature_header = $headers['Webhook-Signature'];\n\ntry {\n     $events = GoCardlessPro\\Webhook::parse($request_body, $signature_header, $webhook_endpoint_secret);\n\n     foreach ($events as $event) {\n         // You can access each event in the webhook.\n         echo $event-\u003eid;\n     }\n\n     header('HTTP/1.1 200 OK');\n} catch (GoCardlessPro\\Core\\Exception\\InvalidSignatureException) {\n     // The webhook doesn't appear to be genuinely from GoCardless, as the signature\n     // included in the `Webhook-Signature` header doesn't match the one computed with\n     // your webhook endpoint secret and the body.\n     header('HTTP/1.1 498 Invalid Token');\n}\n```\n\nFor more details on working with webhooks, see our [\"Getting started\" guide](https://developer.gocardless.com/getting-started/api/introduction/?lang=php).\n\n## Supporting PHP \u003e= 8.1\n\nThis client library only supports PHP \u003e= 8.1 Earlier releases of PHP are now considered\n[end of life](http://php.net/supported-versions.php) and may be exposed to security\nvulnerabilities.\n\n## Contributing\n\nThis client is auto-generated from Crank, a toolchain that we hope to soon open source.\nIssues should for now be reported on this repository.\n\n**Please do not modify the source code yourself, your changes will be overridden!**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgocardless%2Fgocardless-pro-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgocardless%2Fgocardless-pro-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgocardless%2Fgocardless-pro-php/lists"}