{"id":24160506,"url":"https://github.com/simpleweb/saasrunner-client-php","last_synced_at":"2025-06-19T05:06:08.792Z","repository":{"id":14059819,"uuid":"16762848","full_name":"simpleweb/saasrunner-client-php","owner":"simpleweb","description":"PHP client library for the Saas Runner REST API","archived":false,"fork":false,"pushed_at":"2014-09-12T08:13:43.000Z","size":314,"stargazers_count":0,"open_issues_count":2,"forks_count":1,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-03-02T03:41:36.779Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://saasrunner.com/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"algorithm0r/2048-Agent","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/simpleweb.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":"2014-02-12T09:55:51.000Z","updated_at":"2014-09-11T16:25:19.000Z","dependencies_parsed_at":"2022-08-28T22:31:33.868Z","dependency_job_id":null,"html_url":"https://github.com/simpleweb/saasrunner-client-php","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/simpleweb/saasrunner-client-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simpleweb%2Fsaasrunner-client-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simpleweb%2Fsaasrunner-client-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simpleweb%2Fsaasrunner-client-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simpleweb%2Fsaasrunner-client-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simpleweb","download_url":"https://codeload.github.com/simpleweb/saasrunner-client-php/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simpleweb%2Fsaasrunner-client-php/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260690832,"owners_count":23047099,"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":"2025-01-12T16:14:25.146Z","updated_at":"2025-06-19T05:06:03.779Z","avatar_url":"https://github.com/simpleweb.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Saas Runner PHP client library\n\nPHP client library for the Saas Runner REST API\n\n\u003e NB. Requires PHP 5.4+\n\n## Installation\n\nUse [Composer](https://getcomposer.org/) to install `saasrunner-client-php`\n\nAdd `simpleweb/saasrunner-client-php` to your `composer.json` file\n\n```json\n{\n  \"require\": {\n    \"simpleweb/saasrunner\": \"~0.1\",\n  }\n}\n```\n\nand then run\n\n    $ composer install\n\n## Usage\n\nRefer to the [Saas Runner API docs](http://docs.saasrunner.apiary.io/) for more information on the API.\n\nFirst create a client object with your Saas Runner API key\n\n```php\n$client = new SaasRunner\\Client('5201bad4-014a-4eb6-b18c-35b18c6b4249');\n```\n\nAnd then call the relevant resource\n\n#### Subscribers\n\nCreate a new subscriber\n\n```php\n$params = [\n  'subscriber_uid' =\u003e 'SB#013473',\n  'meta' =\u003e [\n    'name' =\u003e 'J Bloggs'\n  ]\n];\n\n$client-\u003esubscribers-\u003ecreate($params);\n```\n\n#### Transactions\n\nCreate a new transaction charge\n\n```php\n$params = [\n  'subscriber_uid' =\u003e 'SB#013473',\n  'transaction_uid' =\u003e 'TX#827473',\n];\n\n$client-\u003etransactions-\u003echarge($params);\n```\n\nCreate a new transaction refund\n\n```php\n$params = [\n  'subscriber_uid' =\u003e 'SB#013473',\n  'transaction_uid' =\u003e 'TX#827474',\n];\n\n$client-\u003etransactions-\u003erefund($params);\n```\n\n#### Events\n\nList all events\n\n```php\n$client-\u003eevents-\u003eindex();\n```\n\nList an individual event\n\n```php\n$client-\u003eevents-\u003eshow(3732);\n```\n\nDelete an event\n\n```php\n$client-\u003eevents-\u003edestroy(3732);\n```\n\n## Error handling\n\nAny response from the Saas Runner API with a `4xx` status code will throw the following exception\n\n```php\nSaasRunner\\Exception\\ResponseError\n```\n\nFor example:\n\n```php\n[1] sr-repl \u003e $client-\u003esubscribers-\u003ecreate();\nPHP Fatal error:  Uncaught exception 'SaasRunner\\Exception\\ResponseError' with message 'Client error response\n[status code] 400\n[reason phrase] Bad Request\n[url] http://api.saasrunner.com/subscribers' in src/SaasRunner/Client.php:88\n```\n\nYou can catch this exception and programatically inspect the response\n\n```php\ntry {\n    $client-\u003esubscribers-\u003ecreate();\n} catch(\\SaasRunner\\Exception\\ResponseError $exception) {\n    echo $ex-\u003egetMessage();\n    // Client error response\n    // [status code] 400\n    // [reason phrase] Bad Request\n    // [url] http://api.saasrunner.com/subscribers\n\n    $response = $ex-\u003egetResponse();\n    echo $response-\u003egetStatusCode();\n    // 400\n}\n```\n\n## Built-in Saas Runner REPL\n\nA REPL for experimenting and debugging is provided, powered by [boris](https://github.com/d11wtq/boris).\n\nTo start it, run the following command (replacing `API_KEY` with your API key)\n\n    $ bin/sr-repl API_KEY\n    [1] sr-repl \u003e $client;\n    // object(SaasRunner\\Client)(\n    //   'client' =\u003e object(Guzzle\\Http\\Client)(\n    //\n    //   ),\n    //   'apiKey' =\u003e '5e0130d4-034a-4eb6-b1cc-31b1876ba249',\n    //   ...\n    // )\n\nThe `$client` object is preloaded for you, using the API key you gave.\n\n## Running the tests\n\n    $ bin/phpspec run\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimpleweb%2Fsaasrunner-client-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimpleweb%2Fsaasrunner-client-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimpleweb%2Fsaasrunner-client-php/lists"}