{"id":25872821,"url":"https://github.com/jacobbennett/stripetesttoken","last_synced_at":"2025-04-05T05:05:45.001Z","repository":{"id":14588912,"uuid":"76759985","full_name":"JacobBennett/StripeTestToken","owner":"JacobBennett","description":"Use this to quickly generate Stripe test tokens for successful or exceptional responses from Stripe.","archived":false,"fork":false,"pushed_at":"2023-10-25T19:22:24.000Z","size":231,"stargazers_count":148,"open_issues_count":2,"forks_count":17,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-05T00:43:55.115Z","etag":null,"topics":["php","stripe"],"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/JacobBennett.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":"2016-12-18T03:12:24.000Z","updated_at":"2024-07-16T18:05:49.000Z","dependencies_parsed_at":"2022-08-07T08:00:23.753Z","dependency_job_id":null,"html_url":"https://github.com/JacobBennett/StripeTestToken","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JacobBennett%2FStripeTestToken","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JacobBennett%2FStripeTestToken/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JacobBennett%2FStripeTestToken/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JacobBennett%2FStripeTestToken/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JacobBennett","download_url":"https://codeload.github.com/JacobBennett/StripeTestToken/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247289426,"owners_count":20914464,"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":["php","stripe"],"created_at":"2025-03-02T08:28:48.269Z","updated_at":"2025-04-05T05:05:44.986Z","avatar_url":"https://github.com/JacobBennett.png","language":"PHP","readme":"![](https://raw.githubusercontent.com/JacobBennett/StripeTestToken/master/stripetesttoken-01.jpg)\n\n# Stripe Test Tokens\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/jacobbennett/stripe-test-token.svg?maxAge=2592000?style=flat-square)](https://packagist.org/packages/jacobbennett/stripe-test-token)\n[![Travis](https://img.shields.io/travis/JacobBennett/StripeTestToken.svg?maxAge=2592000?style=flat-square)](https://travis-ci.org/JacobBennett/StripeTestToken)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)\n\nUse this to quickly create Stripe test tokens for successful and exceptional responses from Stripe.\n\n## Install\n```bash\ncomposer require jacobbennett/stripe-test-token\n```\n\n## Usage\n```php\n\u003c?php\n\nuse JacobBennett\\StripeTestToken;\nuse Stripe\\Charge;\n\nStripeTestToken::setApiKey('your_stripe_secret_test_key');\n\n// Fake a Successful Charge\n\nCharge::create([\n        'amount' =\u003e 500,\n        'currency' =\u003e 'usd',\n        'source' =\u003e StripeTestToken::validVisa(),\n]);\n\n\n// Fake a Failing Charge\n\ntry {\n\n        Charge::create([\n                'amount' =\u003e 500,\n                'currency' =\u003e 'usd',\n                'source' =\u003e StripeTestToken::cvcFail(),\n        ]);\n\n} catch (\\Stripe\\Error\\Card $e) {\n        // handle errors\n}\n\n```\n\n## Docs \n\n\u003e Find full descriptions at original [Stripe Docs Reference](https://stripe.com/docs/testing#cards)\n\n### Using Methods\n\nTo use any of the methods below, call the listed method as a static on the `StripeTestToken` class. If you only want to return the corresponding card number, such as with Selenium or Laravel Dusk, you can call the same method on the `StripeCardNumber` class.\n\n```php\n\u003c?php \n\n\\JacobBennett\\StripeCardNumber::validVisa(); // Returns the valid Visa card number 4012888888881881\n\\JacobBennett\\StripeTestToken::validVisa(); // Attempts to generate a token against the Stripe API for a valid Visa card\n```\n\n### Test card numbers\nGenuine card information cannot be used in test mode. Instead, use any of the following test card methods to create a successful payment token:\n\n| Method |\n| --- |\n| validVisa |\n| validVisaDebit |\n| validMastercard |\n| validMastercardDebit |\n| validMastercardPrepaid |\n| validAmex |\n| validDiscover |\n| validDinersClub |\n| validJCB |\n\n### Testing for specific responses and errors\n\nThe following methods can be used to create tokens that produce specific responses—useful for testing different scenarios and error codes. Verification checks only run when the required information is provided (e.g., for `cvc_check` to fail, a CVC code must be provided).\n\n| Method | Description |\n| --- | --- |\n| successDirectToBalance | Charge succeeds and funds will be added directly to your available balance (bypassing your pending balance). |\n| addressZipFail | The `address_line1_check` and `address_zip_check` verifications fail. If your account is [blocking payments that fail ZIP code validation](https://stripe.com/docs/radar/rules#traditional-bank-checks), the charge is declined. |\n| addressFail | Charge succeeds but the `address_line1_check` verification fails. |\n| zipFail | The `address_zip_check` verification fails. If your account is [blocking payments that fail ZIP code validation](https://stripe.com/docs/radar/rules#traditional-bank-checks), the charge is declined. |\n| addressZipUnavailable | Charge succeeds but the `address_zip_check` and `address_line1_check` verifications are both unavailable. |\n| cvcFail | If a CVC number is provided, the `cvc_check` fails. If your account is [blocking payments that fail CVC code validation](https://stripe.com/docs/radar/rules#traditional-bank-checks), the charge is declined. |\n| customerChargeFail | Attaching this card to a [Customer](https://stripe.com/docs/api#customer_object) object succeeds, but attempts to charge the customer fail. |\n| successWithReview | Charge succeeds with a `risk_level` of elevated and [placed into review](https://stripe.com/docs/radar/review). |\n| declineCard | Charge is declined with a `card_declined` code. |\n| declineFraudulentCard | Charge is declined with a `card_declined` code and a `fraudulent` reason. |\n| declineIncorrectCvc | Charge is declined with an `incorrect_cvc` code. |\n| declineExpiredCard | Charge is declined with an `expired_card` code. |\n| declineProcessingError | Charge is declined with a `processing_error` code. |\n| declineIncorrectNumber | Charge is declined with an `incorrect_number` code as the card number fails the [Luhn check](https://en.wikipedia.org/wiki/Luhn_algorithm). |\n\n## Testing\n\nIn order to run the full test suite, you must have `STRIPE_KEY` set in your environment, as the test will hit the Stripe API in order to generate a test token.\n\n```\n$ STRIPE_KEY=sk_test_YourTestKeyHere phpunit tests/\n```\n\n## License\n\nThis project is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacobbennett%2Fstripetesttoken","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjacobbennett%2Fstripetesttoken","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacobbennett%2Fstripetesttoken/lists"}