{"id":16725805,"url":"https://github.com/klev-o/crypto-pay-api","last_synced_at":"2026-01-24T12:10:03.315Z","repository":{"id":57007395,"uuid":"456463339","full_name":"klev-o/crypto-pay-api","owner":"klev-o","description":"Simple and convenient object-oriented implementation Crypto Pay API with php version ^7.4 support. Based on the Official Crypto Pay Api","archived":false,"fork":false,"pushed_at":"2024-08-30T10:23:01.000Z","size":172,"stargazers_count":18,"open_issues_count":4,"forks_count":12,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-20T01:21:04.502Z","etag":null,"topics":["api","crypto-pay-api","cryptopay","php","telegram","tg","webhooks"],"latest_commit_sha":null,"homepage":"","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/klev-o.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":"2022-02-07T10:44:36.000Z","updated_at":"2025-07-19T04:32:42.000Z","dependencies_parsed_at":"2024-10-27T11:51:39.504Z","dependency_job_id":"68085100-2e94-42bc-b6aa-a4c4c5f3aced","html_url":"https://github.com/klev-o/crypto-pay-api","commit_stats":{"total_commits":11,"total_committers":1,"mean_commits":11.0,"dds":0.0,"last_synced_commit":"87d2f6665075175ac66b1a505e3a2c2aa2a271c1"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/klev-o/crypto-pay-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klev-o%2Fcrypto-pay-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klev-o%2Fcrypto-pay-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klev-o%2Fcrypto-pay-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klev-o%2Fcrypto-pay-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/klev-o","download_url":"https://codeload.github.com/klev-o/crypto-pay-api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klev-o%2Fcrypto-pay-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28727391,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-24T10:24:43.181Z","status":"ssl_error","status_checked_at":"2026-01-24T10:24:36.112Z","response_time":89,"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":["api","crypto-pay-api","cryptopay","php","telegram","tg","webhooks"],"created_at":"2024-10-12T22:51:05.290Z","updated_at":"2026-01-24T12:10:03.290Z","avatar_url":"https://github.com/klev-o.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg alt=\"CryptoPayApi\" src=\"images/crypto.jpg\"/\u003e\n\n# klev-o/crypto-pay-api\n\nSimple and convenient implementation Crypto Pay API with php version ^7.4 support. Based on the [Official Crypto Pay Api](https://help.crypt.bot/crypto-pay-api)\n\n[![License](https://img.shields.io/github/license/klev-o/crypto-pay-api)](https://github.com/klev-o/crypto-pay-api/blob/main/LICENSE)\n![Packagist Downloads](https://img.shields.io/packagist/dt/klev-o/crypto-pay-api)\n![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/klev-o/crypto-pay-api?include_prereleases)\n![Scrutinizer code quality (GitHub/Bitbucket)](https://img.shields.io/scrutinizer/quality/g/klev-o/crypto-pay-api)\n![GitHub last commit](https://img.shields.io/github/last-commit/klev-o/crypto-pay-api)\n\n## 📖 Intro\n\nFully object-oriented and simple code. All available types and methods are described using classes with documentation of all fields.  For each class, the url to the documentation is indicated, where you can study the nuances, etc.\n\n## 🛠 Installation\n\nRun this command in your command line:\n```php\ncomposer require klev-o/crypto-pay-api\n```\n\n## 🔌Usage\n\n### Common\n\nFirst, you need to create an object of the CryptoPay class, passing the API key of your application to the constructor:\n\n\n```php\n\u003c?php\n\nrequire_once '../vendor/autoload.php';\n\n$api = new \\Klev\\CryptoPayApi\\CryptoPay('YOUR_APP_TOKEN');\n```\n\n\u003e To create an app and get an api token, open [@CryptoBot](http://t.me/CryptoBot?start=pay) or [@CryptoTestnetBot](http://t.me/CryptoTestnetBot?start=pay) (for testnet), send /pay command, then go to ‘Create App’.\n\nYou can pass the second parameter $isTestnet to the CryproPay constructor to make all requests go through the testnet. This is useful for any experiments)\n\n```php\n\u003c?php\n\nrequire_once '../vendor/autoload.php';\n\n//the second parameter true - activates the testnet\n$api = new \\Klev\\CryptoPayApi\\CryptoPay('YOUR_APP_TOKEN', true);\n```\nThen you can call all possible methods. To check that everything is working correctly, you can call the `$api-\u003egetMe()` method, which will return basic information about your application.\n\n```php\n\u003c?php\n\nrequire_once '../vendor/autoload.php';\n\n$api = new \\Klev\\CryptoPayApi\\CryptoPay('YOUR_APP_TOKEN');\n\n$result = $api-\u003egetMe();\n\nprint_r($result)\n```\n\nIf everything works well, then you will see something like this\n\n```php\n//Display if everything is working well\nArray\n(\n    [app_id] =\u003e 12345 //your id will be different\n    [name] =\u003e Some App //your name will be different\n    [payment_processing_bot_username] =\u003e CryptoBot\n)\n```\n\n\nFor more complex methods, value objects are used, for example, this is how you can create invoices:\n\n```php\n\u003c?php\n\nuse Klev\\CryptoPayApi\\Methods\\CreateInvoice;\nuse Klev\\CryptoPayApi\\CryptoPay;\nuse Klev\\CryptoPayApi\\Enums\\PaidBtnName;\n\nrequire_once '../vendor/autoload.php';\n\n$api = new CryptoPay('YOUR_APP_TOKEN');\n\n$data = new CreateInvoice('TON', '0.53');\n$data-\u003eallow_anonymous = false;\n$data-\u003epaid_btn_name = PaidBtnName::OPEN_CHANNEL;\n\n$createdInvoice = $api-\u003ecreateInvoice($data)\n```\n\nAs you can see above, required parameters are passed through the constructor, while optional parameters can be set directly. Also, for values that expect \"one of\", special enums are created, located at the namespace `Klev\\CryptoPayApi\\Enums`.\n\nBy the same principle, objects are created for the methods `getInvoice()` and `Transfer()`\n\n***\n\nMore detailed examples can be found in the [demo directory](https://github.com/klev-o/crypto-pay-api/tree/main/demo)\n\nAll available methods can be viewed at the `$api` object, or refer to the [official documentation](https://telegra.ph/Crypto-Pay-API-11-25)\n\n### Webhooks\n\nUsing a webhook, you can receive updates for your application\n\n\u003e Please note that the interceptor must first be activated in your application. This can be done in the following way: open [@CryptoBot](http://t.me/CryptoBot?start=pay) or [@CryptoTestnetBot](http://t.me/CryptoTestnetBot?start=pay) (for testnet), send /pay command, then go to ‘My Apps’, choose your app, open ‘Webhooks’ and click ‘Enable Webhooks’. Read more [here](https://telegra.ph/Crypto-Pay-API-11-25#Webhooks)\n\nTo receive updates, you need to use the `$api-\u003egetWebhookUpdates()` method and subscribe to listen for the necessary events. There is currently only one event (or update type) available - invoice_paid. It also has an enum - `PaidType::INVOICE_PAID`:\n\n```php\n\u003c?php\n\nuse Klev\\CryptoPayApi\\Methods\\CreateInvoice;\nuse Klev\\CryptoPayApi\\CryptoPay;\nuse Klev\\CryptoPayApi\\Enums\\PaidType;\nuse Monolog\\Handler\\StreamHandler;\nuse Monolog\\Logger;\n\nrequire_once '../vendor/autoload.php';\n\n//The logger does not have to be created, it is used only for an example\n$log = new Logger('App');\n$log-\u003epushHandler(new StreamHandler('../var/logs/app.log'));\n\n$api = new CryptoPay('YOUR_APP_TOKEN');\n$api-\u003esetEnableEvents(true);\n\n//subscribe to an event\n$api-\u003eon(PaidType::INVOICE_PAID, static function(Update $update) use ($log) {\n    //do something with the data\n    $log-\u003einfo('webhook data: ', (array)$update);\n});\n\n$api-\u003egetWebhookUpdates();\n```\n\nYou can register multiple handlers for the same event.\n\n\u003e You can also just get the result from the `$api-\u003egetWebhookUpdates()` method without subscribing to events\n\n\u003e By default, events are disabled. To enable them, you need to use the method `$api-\u003esetEnableEvents(true);`\n\n## 📟Advanced\n\nAlso, as an event handler, you can use anything that corresponds to the callable type. Let's take an example:\n\n\u003e Let's say we have installed `composer require php-di/php-di`, although you can use any other psr-compatible\n\n```php\n\u003c?php\n\nuse Klev\\CryptoPayApi\\CryptoPay;\nuse Klev\\CryptoPayApi\\Enums\\PaidType;\nuse Monolog\\Handler\\StreamHandler;\nuse Monolog\\Logger;\nuse Psr\\Log\\LoggerInterface;\n\nrequire_once '../vendor/autoload.php';\n\n$api = new CryptoPay('YOUR_APP_TOKEN');\n\n//Use Container builder\n$builder = new DI\\ContainerBuilder();\n\n$builder-\u003eaddDefinitions([\n    //specify the rules on how to create an object\n    LoggerInterface::class =\u003e function(\\DI\\Container $c) {\n        $log = new Logger('App');\n        $log-\u003epushHandler(new StreamHandler('../var/logs/app.log'));\n        return $log;\n    },\n    //specify the rules on how to create an object\n    InvoicePaidListener::class =\u003e function(\\DI\\Container $c) {\n        return new InvoicePaidListener($c-\u003eget(LoggerInterface::class));\n    }\n]);\n$container = $builder-\u003ebuild();\n\n//Instead of using an anonymous function, we can now use a custom class, into which,\n//if necessary, we can pull everything we need (working with the database, sending by mail, etc.)\nclass InvoicePaidListener\n{\n    private Logger $log;\n    \n    public function __construct(Logger $log)\n    {\n        $this-\u003elog = $log;\n    }\n    public function __invoke(Update $update)\n    {\n        $this-\u003elog-\u003einfo('payload', (array)$update);\n    }\n\n}\n\n//Now the event subscription looks more concise\n$api-\u003eon(PaidType::INVOICE_PAID, $container-\u003eget(InvoicePaidListener::class));\n\n$api-\u003egetWebhookUpdates();\n```\n\nYou can use your dependency injection container to pipe all the necessary functionality from your code into handlers\n\n## 🎁Dontations\n\nSupport the project if you like it. Funds will go towards food.\n\n| Network                     | Currency          | Wallet                                                                                                                             |\n|-----------------------------|-------------------|------------------------------------------------------------------------------------------------------------------------------------|\n| Bitcoin                     | `BTC`             | `1M1qhSE6sN34a4d7ZtCh6y17Vf3LtdoW62`\u003cbr/\u003eor\u003cbr/\u003e`14cvXywCMucKMhFYDCbmQ1ZHhayDgbD65R`                                               |\n| The Open Network            | `TON`             | `EQAYZK8rWrS9Fhojdc486BpplDmTSLHum440f-L2--SA2Oid` \u003cbr/\u003e or\u003cbr/\u003e `ton://transfer/UQBVsumSIvsq4PfeFMhxSV9m_zPB31cHJX4X2lAVh9BUJXm3` |\n| Binance Smart Chain – BEP20 | `BNB, BUSD, USDT` | `0x674B09Ab418bb41C075847bde004bb7F492c2121`                                                                                       |\n\n## 🧨Troubleshooting\n\nPlease, if you find any errors or not exactly - report this [problem page](https://github.com/klev-o/crypto-pay-api/issues)\n\n## And finally...\nHappy botting 🤖","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fklev-o%2Fcrypto-pay-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fklev-o%2Fcrypto-pay-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fklev-o%2Fcrypto-pay-api/lists"}