{"id":20614950,"url":"https://github.com/borsaco/coinbasebundle","last_synced_at":"2025-10-26T08:18:12.127Z","repository":{"id":55351402,"uuid":"214151586","full_name":"borsaco/CoinbaseBundle","owner":"borsaco","description":"Coinbase Commerce Bundle for Symfony","archived":false,"fork":false,"pushed_at":"2021-01-28T19:57:57.000Z","size":51,"stargazers_count":2,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T17:57:29.411Z","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":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/borsaco.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}},"created_at":"2019-10-10T10:18:03.000Z","updated_at":"2024-12-03T14:50:56.000Z","dependencies_parsed_at":"2022-08-14T22:01:17.424Z","dependency_job_id":null,"html_url":"https://github.com/borsaco/CoinbaseBundle","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borsaco%2FCoinbaseBundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borsaco%2FCoinbaseBundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borsaco%2FCoinbaseBundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borsaco%2FCoinbaseBundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/borsaco","download_url":"https://codeload.github.com/borsaco/CoinbaseBundle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249029660,"owners_count":21201110,"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-16T11:13:58.363Z","updated_at":"2025-10-26T08:18:07.078Z","avatar_url":"https://github.com/borsaco.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CoinbaseBundle\nCoinbase Commerce Bundle for Symfony\n\n## API Reference\n\nFor more information about Coinbase Commerce API, look at:\n \n\u003e https://commerce.coinbase.com/docs/\n\n## Getting Started\n\nAssuming you already have your own **symfony** project, please follow the below instructions along with configuration installation and test codes.\nThis bundle makes it very easy to develop high level of Coinbase Commerce applications. \n\n## Prerequisites\n\nCreate **_coinbase.yaml_** file under folder **_[symfonyproject]/config/packages/_**  \n\n##### coinbase.yaml\n\n```\ncoinbase_commerce:\n  api:\n    key: 3f8944d4*********************\n    version: \"2018-03-22\"\n  webhook:\n    secret: 3e859e4b************************\n```\n\n\n\n## Installing\n\nedit your composer with the bundle library and version\n\n```\ncomposer require borsaco/coinbase-bundle\n```\n\n## Development\n\nYou can get the handler inside your Controller and call the functions\n\n### Create new Charge\nLet's create a new charge along with $3.6 donation. The input can be json array, json string or Charge object\n\n#### CALL WITH JSON ARRAY\n```\n   use Borsaco\\CoinbaseBundle\\Handler\\CoinbaseHandler;\n\n   /**\n    * @Route(\"/acceptcrypto/\", name=\"acceptcrypto\")\n    */\n    public function acceptDonation(CoinbaseHandler $coinbaseHandler){\n        $amount = 3.6;//$3.6 dollars\n        $json =  [\n           \"name\" =\u003e \"Cancer Donation Box\",\n           \"description\" =\u003e \"Donate to Children\",\n           \"local_price\" =\u003e array(\"amount\" =\u003e $amount, \"currency\" =\u003e \"USD\"),\n           \"pricing_type\" =\u003e \"fixed_price\",\n           \"metadata\" =\u003e array(\"id\" =\u003e \"1234\", \"firstname\" =\u003e \"John\", \"lastname\" =\u003e \"Doe\", \"email\" =\u003e \"jdoe@example.com\")\n        ];\n        \n        $charge = $coinbaseHandler-\u003ecreateNewCharge($json);//get the charge object\n\n        $this-\u003eredirect($charge-\u003egetHostedUrl());//it will redirect you to the coinbase crypto box to be paid in 15 minutes\n    }\n```\n\n#### CALL WITH JSON STRING\n```\n   /**\n    * @Route(\"/acceptcrypto/\", name=\"acceptcrypto\")\n    */\n    public function acceptDonation(CoinbaseHandler $coinbaseHandler){\n        \n        $json_string = \"{\\\"name\\\":\\\"Cancer Donation Form\\\",\\\"description\\\":\\\"Donation to Children\\\",\\\"pricing_type\\\":\\\"fixed_price\\\",\\\"local_price\\\":{\\\"amount\\\":\\\"2.7\\\",\\\"currency\\\":\\\"USD\\\"},\\\"meta_data\\\":{\\\"id\\\":\\\"12345\\\",\\\"firstname\\\":\\\"Victor\\\",\\\"lastname\\\":\\\"Doe\\\",\\\"email\\\":\\\"vdoe@example.com\\\"}}\";\n        \n        /**\n        * @var Charge $charge\n        */\n        $charge = $coinbaseHandler-\u003ecreateNewCharge($json_string);//get the charge object\n\n        $this-\u003eredirect($charge-\u003egetHostedUrl());//it will redirect you to the coinbase crypto box to be paid in 15 minutes\n    }\n```\n\n#### CALL WITH CHARGE OBJECT\n```\n   /**\n    * @Route(\"/acceptcrypto/\", name=\"acceptcrypto\")\n    */\n    public function acceptDonation(CoinbaseHandler $coinbaseHandler){\n        \n        /**\n        * @var Charge $charge\n        */\n        $charge = new Charge();\n        $charge-\u003esetName(\"Cancer Donation Form\");\n        $charge-\u003esetDescription(\"Donation to Children\");\n        $charge-\u003esetPricingType(\"fixed_price\");\n       \n        $localPrice = new Money();\n        $localPrice-\u003esetAmount(2.6);\n        $localPrice-\u003esetCurrency(\"USD\");\n        $charge-\u003esetLocalPrice($localPrice);\n       \n       \n        //Whatever object fields you wanna put\n        $metadata = new Metadata();\n        $metadata-\u003eid = \"1234\";\n        $metadata-\u003efirstname = \"Melisa\";\n        $metadata-\u003elastname = \"Doe\";\n        $metadata-\u003eemail = \"mdoe@example.com\";\n        $charge-\u003esetMetadata($metadata);\n        \n        /**\n        * @var Charge $charge\n        */\n        $charge = $coinbaseHandler-\u003ecreateNewCharge($charge);//get the charge object\n\n        $this-\u003eredirect($charge-\u003egetHostedUrl());//it will redirect you to the coinbase crypto box to be paid in 15 minutes\n    }\n```\n\n## Show a Charge\n```\n$code = \"2G3GM4X9\";\n/**\n* get a single charge\n* @var Charge $charge\n*/\n$charge = $coinbaseHandler-\u003eshowCharge($code);\n$hosted_url = $charge-\u003egetHostedUrl();\n```\n\n## List Charges\n```\n/**\n* list charges\n* @var Charges $charges\n*/\n$charges = $this-\u003e_coinbaseHandler-\u003elistCharges();\n\n//iterate through the charges\nforeach ($charges-\u003egetData() as $charge){\n    print_r($charge);\n}\n```\n\n## Charge Object\n\nCharge is one of your main object model that is re-usable once it is retrieved. It includes all other object models;\n\u003e Addresses, Timeline, Pricing, Money etc..\n\nIt includes the raw json string as well in case you need to look up the fields manually. \n```\n$charge-\u003egetRawJson()\n```\n\nHere is an example of a returned Charge object that is already expired. No action taken in 15 minutes\n\n```\nApp\\Coinbase\\Commerce\\Model\\Charge Object\n(\n    [code:protected] =\u003e GR9M6MYK\n    [name:protected] =\u003e Cancer Donation Box\n    [description:protected] =\u003e Donate to Children\n    [hosted_url:protected] =\u003e https://commerce.coinbase.com/charges/GR9M6MYK\n    [created_at:protected] =\u003e 2018-06-18T22:21:38Z\n    [expires_at:protected] =\u003e 2018-06-18T22:36:38Z\n    [confirmed_at:protected] =\u003e \n    [pricing_type:protected] =\u003e fixed_price\n    [addresses:protected] =\u003e App\\Coinbase\\Commerce\\Model\\Addresses Object\n        (\n            [ethereum:protected] =\u003e 0xa5027c04f257f8f9c4a2f1f10***************\n            [bitcoin:protected] =\u003e 1PTGB2jGD8ohqdtPPFa***************\n            [bitcoincash:protected] =\u003e qqz8q26722wq22ep9fsxy0vu4sz***************\n            [litecoin:protected] =\u003e LKF2ETmPtqkqYG1s1f1***************\n        )\n\n    [metadata:protected] =\u003e App\\Coinbase\\Commerce\\Model\\Metadata Object\n        (\n            [id] =\u003e 1234\n            [firstname] =\u003e John\n            [lastname] =\u003e Doe\n            [email] =\u003e jdoe@example.com\n        )\n\n    [timeline:protected] =\u003e Array\n        (\n            [0] =\u003e App\\Coinbase\\Commerce\\Model\\Timeline Object\n                (\n                    [status:protected] =\u003e NEW\n                    [time:protected] =\u003e 2018-06-18T22:21:38Z\n                    [payment:protected] =\u003e \n                )\n\n            [1] =\u003e App\\Coinbase\\Commerce\\Model\\Timeline Object\n                (\n                    [status:protected] =\u003e EXPIRED\n                    [time:protected] =\u003e 2018-06-18T22:36:46Z\n                    [payment:protected] =\u003e \n                )\n\n        )\n\n    [pricing:protected] =\u003e App\\Coinbase\\Commerce\\Model\\Pricing Object\n        (\n            [local:protected] =\u003e App\\Coinbase\\Commerce\\Model\\Money Object\n                (\n                    [amount:protected] =\u003e 1.00\n                    [currency:protected] =\u003e USD\n                )\n\n            [ethereum:protected] =\u003e App\\Coinbase\\Commerce\\Model\\Money Object\n                (\n                    [amount:protected] =\u003e 0.001935000\n                    [currency:protected] =\u003e ETH\n                )\n\n            [bitcoin:protected] =\u003e App\\Coinbase\\Commerce\\Model\\Money Object\n                (\n                    [amount:protected] =\u003e 0.00014900\n                    [currency:protected] =\u003e BTC\n                )\n\n            [bitcoincash:protected] =\u003e App\\Coinbase\\Commerce\\Model\\Money Object\n                (\n                    [amount:protected] =\u003e 0.00112791\n                    [currency:protected] =\u003e BCH\n                )\n\n            [litecoin:protected] =\u003e App\\Coinbase\\Commerce\\Model\\Money Object\n                (\n                    [amount:protected] =\u003e 0.01010867\n                    [currency:protected] =\u003e LTC\n                )\n\n        )\n\n    [payments:protected] =\u003e Array\n        (\n        )\n\n    [json:protected] =\u003e Array\n        (\n            [data] =\u003e Array\n                (\n                    [addresses] =\u003e Array\n                        (\n                            [ethereum] =\u003e 0xa5027c04f257f8f9c4a2f1f10***************\n                            [bitcoin] =\u003e 1PTGB2jGD8ohqdtPPFa***************\n                            [bitcoincash] =\u003e qqz8q26722wq22ep9fsxy0vu4sz***************\n                            [litecoin] =\u003e LKF2ETmPtqkqYG1s1f1***************\n                        )\n\n                    [code] =\u003e GR9M6MYK\n                    [created_at] =\u003e 2018-06-18T22:21:38Z\n                    [description] =\u003e Donate to Children\n                    [expires_at] =\u003e 2018-06-18T22:36:38Z\n                    [hosted_url] =\u003e https://commerce.coinbase.com/charges/GR9M6MYK\n                    [metadata] =\u003e Array\n                        (\n                            [id] =\u003e 1234\n                            [firstname] =\u003e John\n                            [lastname] =\u003e Doe\n                            [email] =\u003e jdoe@example.com\n                        )\n\n                    [name] =\u003e Cancer Donation Box\n                    [payments] =\u003e Array\n                        (\n                        )\n\n                    [pricing] =\u003e Array\n                        (\n                            [local] =\u003e Array\n                                (\n                                    [amount] =\u003e 1.00\n                                    [currency] =\u003e USD\n                                )\n\n                            [ethereum] =\u003e Array\n                                (\n                                    [amount] =\u003e 0.001935000\n                                    [currency] =\u003e ETH\n                                )\n\n                            [bitcoin] =\u003e Array\n                                (\n                                    [amount] =\u003e 0.00014900\n                                    [currency] =\u003e BTC\n                                )\n\n                            [bitcoincash] =\u003e Array\n                                (\n                                    [amount] =\u003e 0.00112791\n                                    [currency] =\u003e BCH\n                                )\n\n                            [litecoin] =\u003e Array\n                                (\n                                    [amount] =\u003e 0.01010867\n                                    [currency] =\u003e LTC\n                                )\n\n                        )\n\n                    [pricing_type] =\u003e fixed_price\n                    [timeline] =\u003e Array\n                        (\n                            [0] =\u003e Array\n                                (\n                                    [status] =\u003e NEW\n                                    [time] =\u003e 2018-06-18T22:21:38Z\n                                )\n\n                            [1] =\u003e Array\n                                (\n                                    [status] =\u003e EXPIRED\n                                    [time] =\u003e 2018-06-18T22:36:46Z\n                                )\n\n                        )\n\n                )\n\n        )\n\n)\n\n```\n\n### Webhook\nTo retrieve a Webhook object from a json string, use the method below, just so simple!\n\n```\n/** @var Webhook $webhook */\n$webhook = $this-\u003e_coinbaseHandler-\u003eparseWebhook($jsonString);\n```\n\nWhen Coinbase calls your webhook endpoint, follow the below example inside your controller\n\n```\n    /**\n    * @Route(\"/webhooks/\", name=\"webhooks\")\n    * @throws \\Exception\n    */\n    public function webHook(Request $request, CoinbaseHandler $coinbaseHandler){\n\n        if ($request-\u003egetMethod() != 'POST') {\n            return new Response( 'Only post requests accepted!',  400);\n        }\n\n        $jsonString = $request-\u003egetContent();//get the json string from the request\n\n        // This header contains the SHA256 HMAC signature of the raw request payload\n        $cc_signagure = isset($_SERVER[\"HTTP_X_CC_WEBHOOK_SIGNATURE\"]) ? $_SERVER[\"HTTP_X_CC_WEBHOOK_SIGNATURE\"] : '';\n        if(!$coinbaseHandler-\u003evalidateWebhookSignature($cc_signagure, $request)){\n                throw new \\Exception(\"Request could not be validated\");\n        }\n        \n        /** @var Webhook $webhook */\n        $webhook = $coinbaseHandler-\u003eparseWebhook($jsonString);\n        //You have your webhook object. Do Something... save webhook data to database or email people or anything useful\n\n        if($webhook-\u003egetEvent()-\u003egetType() == Event::TYPE_CHARGE_CREATED){\n            //Do Something\n        }\n\n        return new Response('',Response::HTTP_OK, array('Content-Type' =\u003e 'text/html'));//make sure you respond with status 200 (OK) at the end\n    }\n\n```\n\n### Webhook Object\nHere is an example of Webhook Object\n```\nApp\\Coinbase\\Commerce\\Model\\Webhook Object\n(\n    [id:protected] =\u003e 1\n    [scheduled_for:protected] =\u003e 2017-01-31T20:50:02Z\n    [event:protected] =\u003e App\\Coinbase\\Commerce\\Model\\Event Object\n        (\n            [id:protected] =\u003e 24934862-d980-46cb-9402-43c81b0cdba6\n            [type:protected] =\u003e charge:created\n            [api_version:protected] =\u003e 2018-03-22\n            [created_at:protected] =\u003e 2017-01-31T20:49:02Z\n            [data:protected] =\u003e App\\Coinbase\\Commerce\\Model\\Charge Object\n                (\n                    [code:protected] =\u003e 66BEOV2A\n                    [name:protected] =\u003e The Sovereign Individual\n                    [description:protected] =\u003e Mastering the Transition to the Information Age\n                    [local_price:protected] =\u003e \n                    [hosted_url:protected] =\u003e https://commerce.coinbase.com/charges/66BEOV2A\n                    [created_at:protected] =\u003e 2017-01-31T20:49:02Z\n                    [expires_at:protected] =\u003e 2017-01-31T21:04:02Z\n                    [confirmed_at:protected] =\u003e \n                    [pricing_type:protected] =\u003e no_price\n                    [addresses:protected] =\u003e App\\Coinbase\\Commerce\\Model\\Addresses Object\n                        (\n                            [ethereum:protected] =\u003e 0x419f91df39951fd4e8acc8f1874b01c0c78ceba6\n                            [bitcoin:protected] =\u003e mymZkiXhQNd6VWWG7VGSVdDX9bKmviti3U\n                            [bitcoincash:protected] =\u003e \n                            [litecoin:protected] =\u003e \n                        )\n\n                    [metadata:protected] =\u003e App\\Coinbase\\Commerce\\Model\\Metadata Object\n                        (\n                        )\n\n                    [timeline:protected] =\u003e Array\n                        (\n                            [0] =\u003e App\\Coinbase\\Commerce\\Model\\Timeline Object\n                                (\n                                    [status:protected] =\u003e NEW\n                                    [time:protected] =\u003e 2017-01-31T20:49:02Z\n                                    [payment:protected] =\u003e \n                                )\n\n                        )\n\n                    [pricing:protected] =\u003e \n                    [payments:protected] =\u003e Array\n                        (\n                        )\n\n                    [raw_json:protected] =\u003e Array\n                        (\n                            [code] =\u003e 66BEOV2A\n                            [name] =\u003e The Sovereign Individual\n                            [description] =\u003e Mastering the Transition to the Information Age\n                            [hosted_url] =\u003e https://commerce.coinbase.com/charges/66BEOV2A\n                            [created_at] =\u003e 2017-01-31T20:49:02Z\n                            [expires_at] =\u003e 2017-01-31T21:04:02Z\n                            [timeline] =\u003e Array\n                                (\n                                    [0] =\u003e Array\n                                        (\n                                            [time] =\u003e 2017-01-31T20:49:02Z\n                                            [status] =\u003e NEW\n                                        )\n\n                                )\n\n                            [metadata] =\u003e Array\n                                (\n                                )\n\n                            [pricing_type] =\u003e no_price\n                            [payments] =\u003e Array\n                                (\n                                )\n\n                            [addresses] =\u003e Array\n                                (\n                                    [bitcoin] =\u003e mymZkiXhQNd6VWWG7VGSVdDX9bKmviti3U\n                                    [ethereum] =\u003e 0x419f91df39951fd4e8acc8f1874b01c0c78ceba6\n                                )\n\n                        )\n\n                )\n\n        )\n\n)\n```\n\n# Note\nThis is a repaired copy of https://github.com/mehmetsen80/cbcommercesymfonybundle\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fborsaco%2Fcoinbasebundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fborsaco%2Fcoinbasebundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fborsaco%2Fcoinbasebundle/lists"}