{"id":18542762,"url":"https://github.com/coinbase/coinbase-commerce-php","last_synced_at":"2025-05-16T16:09:26.876Z","repository":{"id":33079211,"uuid":"137251173","full_name":"coinbase/coinbase-commerce-php","owner":"coinbase","description":"Coinbase Commerce PHP","archived":false,"fork":false,"pushed_at":"2023-11-30T10:01:33.000Z","size":57,"stargazers_count":143,"open_issues_count":26,"forks_count":156,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-05-14T08:43:51.280Z","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/coinbase.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2018-06-13T17:49:54.000Z","updated_at":"2025-05-01T12:20:51.000Z","dependencies_parsed_at":"2024-06-18T14:08:34.525Z","dependency_job_id":null,"html_url":"https://github.com/coinbase/coinbase-commerce-php","commit_stats":{"total_commits":16,"total_committers":11,"mean_commits":"1.4545454545454546","dds":0.6875,"last_synced_commit":"c258b69d5bb6d4dd45fdc68fee3b60c4a75247d2"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coinbase%2Fcoinbase-commerce-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coinbase%2Fcoinbase-commerce-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coinbase%2Fcoinbase-commerce-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coinbase%2Fcoinbase-commerce-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coinbase","download_url":"https://codeload.github.com/coinbase/coinbase-commerce-php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254564127,"owners_count":22092122,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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-06T20:10:25.771Z","updated_at":"2025-05-16T16:09:26.845Z","avatar_url":"https://github.com/coinbase.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![CircleCI](https://circleci.com/gh/coinbase/coinbase-commerce-php/tree/master.svg?style=svg)](https://circleci.com/gh/coinbase/coinbase-commerce-php/tree/master)\n# Coinbase Commerce\n**Note: This repository is not actively maintained.**\n\nThe official PHP library for the [Coinbase Commerce API](https://commerce.coinbase.com/docs/).\n\n# Table of contents\n\n\u003c!--ts--\u003e\n   * [PHP Versions](#php-version)\n   * [Documentation](#documentation)\n   * [Installation](#installation)\n   * [Usage](#usage)\n      * [Checkouts](#checkouts)\n      * [Charges](#charges)\n      * [Events](#events)\n      * [Webhooks](#webhooks)\n      * [Warnings](#warnings)\n   * [Testing and Contributing](#testing-and-contributing)\n\u003c!--te--\u003e\n\n## PHP versions\nPHP  version 5.4 and above are supported.\n\n## Documentation\nFor more details visit [Coinbase API docs](https://commerce.coinbase.com/docs/api/).\n\nTo start using this library register an account on [Coinbase Commerce](https://commerce.coinbase.com/signup).\nYou will find your ``API_KEY`` from User Settings.\n\nNext initialize a ``Client`` for interacting with the API. The only required parameter to initialize a client is ``apiKey``, however, you can also pass in ``baseUrl``, ``apiVersion``  and ``timeout``.\nParameters can be also be set post-initialization:\n``` php\nuse CoinbaseCommerce\\ApiClient;\n\n//Make sure you don't store your API Key in your source code!\n$apiClientObj = ApiClient::init(\u003cAPI_KEY\u003e);\n$apiClientObj-\u003esetTimeout(3);\n```\n\n### Disable SSL Check\n``` php\n$apiClientObj-\u003everifySsl(false);\n```\n\nThe API resource class provides the following static methods: ``list, all, create, retrieve, updateById, deleteById``.  Additionally, the API resource class also provides the following instance methods: ``save, delete, insert, update``.\n\nEach API method returns an ``ApiResource`` which represents the JSON response from the API.\nWhen the response data is parsed into objects, the appropriate ``ApiResource`` subclass will automatically be used.\n\nClient supports the handling of common API errors and warnings.\nAll errors that occur during any interaction with the API will be raised as exceptions.\n\n\n| Error                        | Status Code |\n|------------------------------|-------------|\n| APIException                 |      *      |   \n| InvalidRequestException      |     400     |   \n| ParamRequiredException       |     400     |  \n| ValidationException          |     400     |  \n| AuthenticationException      |     401     |  \n| ResourceNotFoundException    |     404     |\n| RateLimitExceededException   |     429     |\n| InternalServerException      |     500     |\n| ServiceUnavailableException  |     503     |\n\n## Installation\n\nInstall with ``composer``:\n``` sh\ncomposer require coinbase/coinbase-commerce\n```\n## Usage\n``` php\nuse CoinbaseCommerce\\ApiClient;\n\n//Make sure you don't store your API Key in your source code!\nApiClient::init('API_KEY');\n```\n## Checkouts \n[Checkouts API docs](https://commerce.coinbase.com/docs/api/#checkouts)\nMore examples on how to use checkouts can be found in the [`examples/Resources/CheckoutExample.php`](examples/Resources/CheckoutExample.php) file\n\n### Load checkout resource class\n``` php\nuse CoinbaseCommerce\\Resources\\Checkout;\n```\n### Retrieve\n``` php\n$checkoutObj = Checkout::retrieve(\u003ccheckout_id\u003e);\n```\n### Create\n``` php\n$checkoutData = [\n    'name' =\u003e 'The Sovereign Individual',\n    'description' =\u003e 'Mastering the Transition to the Information Age',\n    'pricing_type' =\u003e 'fixed_price',\n    'local_price' =\u003e [\n        'amount' =\u003e '100.00',\n        'currency' =\u003e 'USD'\n    ],\n    'requested_info' =\u003e ['name', 'email']\n];\n$newCheckoutObj = Checkout::create($checkoutData);\n\n// or\n\n$newCheckoutObj = new Checkout();\n\n$newCheckoutObj-\u003ename = 'The Sovereign Individual';\n$newCheckoutObj-\u003edescription = 'Mastering the Transition to the Information Age';\n$newCheckoutObj-\u003epricing_type = 'fixed_price';\n$newCheckoutObj-\u003elocal_price = [\n    'amount' =\u003e '100.00',\n    'currency' =\u003e 'USD'\n];\ncheckoutObj-\u003erequested_info = ['name', 'email'];\n\ncheckoutObj-\u003esave();\n```\n### Update\n``` php\n$checkoutObj = new Checkout();\n\n$checkoutObj-\u003eid = \u003ccheckout_id\u003e;\n$checkoutObj-\u003ename = 'new name';\n\n$checkoutObj-\u003esave();\n// or\n$newParams = [\n    'name' =\u003e 'New name'\n];\n\nCheckout::updateById(\u003ccheckout_id\u003e, $newParams});\n```\n### Delete\n``` php\n$checkoutObj = new Checkout();\n\n$checkoutObj-\u003eid = \u003ccheckout_id\u003e;\n$checkoutObj-\u003edelete();\n\n// or\n\nCheckout::deleteById(\u003ccheckout_id\u003e);\n```\n### List\nList method returns ApiResourceList object.  \n\n``` php\n$params = [\n    'limit' =\u003e 2,\n    'order' =\u003e 'desc'\n];\n\n$list = Checkout::getList($params);\n\nforeach($list as $checkout) {\n    var_dump($checkout);\n}\n\n// Get number of items in list\n$count = $list-\u003ecount();\n\n// or\n$count = count($list);\n\n// Get number of all checkouts\n$countAll = $list-\u003ecountAll();\n\n// Get pagination\n$pagination = $list-\u003egetPagination();\n\n// To load next page with previous setted params(in this case limit, order)\nif ($list-\u003ehasNext()) {\n    $list-\u003eloadNext();\n    \n    foreach($list as $checkout) {\n        var_dump($checkout);\n    }\n}\n\n```\n### Get all checkouts\n``` php\n$params = [\n    'order' =\u003e 'desc'  \n];\n\n$allCheckouts = Checkout::getAll($params);\n\n```\n## Charges\n[Charges API docs](https://commerce.coinbase.com/docs/api/#charges)\nMore examples on how to use charges can be found in the [`examples/Resources/ChargeExample.php`](examples/Resources/ChargeExample.php) file\n\n### Load charge resource class\n``` php\nuse CoinbaseCommerce\\Resources\\Charge;\n```\n### Retrieve\n``` php\n$chargeObj = Charge::retrieve(\u003ccharge_id\u003e);\n```\n### Create\n``` php\n$chargeData = [\n    'name' =\u003e 'The Sovereign Individual',\n    'description' =\u003e 'Mastering the Transition to the Information Age',\n    'local_price' =\u003e [\n        'amount' =\u003e '100.00',\n        'currency' =\u003e 'USD'\n    ],\n    'pricing_type' =\u003e 'fixed_price'\n];\nCharge::create($chargeData);\n\n// or\n$chargeObj = new Charge();\n\n$chargeObj-\u003ename = 'The Sovereign Individual';\n$chargeObj-\u003edescription = 'Mastering the Transition to the Information Age';\n$chargeObj-\u003elocal_price = [\n    'amount' =\u003e '100.00',\n    'currency' =\u003e 'USD'\n];\n$chargeObj-\u003epricing_type = 'fixed_price';\n$chargeObj-\u003esave();\n```\n### List\n``` php\n$list = Charge::getList();\n\nforeach($list as $charge) {\n    var_dump($list);\n}\n\n$pagination = $list-\u003egetPagination();\n```\n### Get all charges\n``` php\n$allCharges = Charge::getAll();\n```\n\n### Resolve a charge\nResolve a charge that has been previously marked as unresolved. \n```\n$chargeObj = Charge::retrieve(\u003ccharge_id\u003e);\n\nif ($chargeObj) {\n    $chargeObj-\u003eresolve();\n}\n```\n\n### Cancel a charge\nCancels a charge that has been previously created. \nNote: Only new charges can be successfully canceled. Once payment is detected, charge can no longer be canceled.\n\n```\n$chargeObj = Charge::retrieve(\u003ccharge_id\u003e);\n\nif ($chargeObj) {\n    $chargeObj-\u003ecancel();\n}\n```\n\n## Events\n[Events API Docs](https://commerce.coinbase.com/docs/api/#events)\nMore examples on how to use events can be found in the [`examples/Resources/EventExample.php`](examples/Resources/EventExample.php) file\n\n### Load event resource class\n``` php\nuse CoinbaseCommerce\\Resources\\Event;\n```\n### Retrieve\n``` php\n$eventObj = Event::retrieve(\u003cevent_id\u003e);\n```\n### List\n``` php\n$listEvent = Event::getList();\n\nforeach($listEvent as $event) {\n    var_dump($event);\n}\n\n$pagination = $listEvent-\u003egetPagination();\n```\n### Get all events\n``` php\n$allEvents = Event::getAll();\n```\n\n## Warnings\nIt's prudent to be conscious of warnings. The library will log all warnings to a standard PSR-3 logger if one is configured.\n``` php\nuse CoinbaseCommerce\\ApiClient;\n\n//Make sure you don't store your API Key in your source code!\n$apiClientObj = ApiClient::init(\u003cAPI_KEY\u003e);\n$apiClientObj-\u003esetLogger($logger);\n```\n\n## Webhooks\nCoinbase Commerce signs the webhook events it sends to your endpoint, allowing you to validate and verify that they weren't sent by someone else.\nYou can find a simple example of how to use this with Express in the [`examples/Webhook`](examples/Webhook) folder\n### Verify Signature header\n``` php\nuse CoinbaseCommerce\\Webhook;\n\ntry {\n    Webhook::verifySignature($signature, $body, $sharedSecret);\n    echo 'Successfully verified';\n} catch (\\Exception $exception) {\n    echo $exception-\u003egetMessage();\n    echo 'Failed';\n}\n```\n\n### Testing and Contributing\nAny and all contributions are welcome! The process is simple: fork this repo, make your changes, run the test suite, and submit a pull request. To run the tests, clone the repository and run the following commands:\n\n``` sh\ncomposer install\ncomposer test\n```\n\nLicense\n----\n\nApache-2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoinbase%2Fcoinbase-commerce-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoinbase%2Fcoinbase-commerce-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoinbase%2Fcoinbase-commerce-php/lists"}