{"id":22341826,"url":"https://github.com/code-corps/ember-stripe-service","last_synced_at":"2025-07-30T01:32:18.160Z","repository":{"id":26397639,"uuid":"29847345","full_name":"code-corps/ember-stripe-service","owner":"code-corps","description":"An ember-cli addon which injects Stripe as an Ember service","archived":false,"fork":false,"pushed_at":"2019-02-08T15:48:22.000Z","size":407,"stargazers_count":91,"open_issues_count":5,"forks_count":33,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-06-17T02:03:26.945Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/code-corps.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-01-26T06:03:40.000Z","updated_at":"2024-09-02T16:19:25.000Z","dependencies_parsed_at":"2022-09-04T07:41:22.257Z","dependency_job_id":null,"html_url":"https://github.com/code-corps/ember-stripe-service","commit_stats":null,"previous_names":["buritica/ember-stripe-service"],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/code-corps/ember-stripe-service","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-corps%2Fember-stripe-service","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-corps%2Fember-stripe-service/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-corps%2Fember-stripe-service/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-corps%2Fember-stripe-service/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/code-corps","download_url":"https://codeload.github.com/code-corps/ember-stripe-service/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-corps%2Fember-stripe-service/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266768249,"owners_count":23981350,"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","status":"online","status_checked_at":"2025-07-23T02:00:09.312Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-12-04T08:08:19.706Z","updated_at":"2025-07-30T01:32:17.856Z","avatar_url":"https://github.com/code-corps.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ember-stripe-service\n[![Build Status](https://travis-ci.org/code-corps/ember-stripe-service.svg?branch=master)](https://travis-ci.org/code-corps/ember-stripe-service) [![npm version](https://badge.fury.io/js/ember-stripe-service.svg)](https://badge.fury.io/js/ember-stripe-service) [![Ember Observer Score](https://emberobserver.com/badges/ember-stripe-service.svg)](https://emberobserver.com/addons/ember-stripe-service) [![Inline docs](http://inch-ci.org/github/code-corps/ember-stripe-service.svg?branch=master\u0026style=shields)](http://inch-ci.org/github/code-corps/ember-stripe-service) [![Discord](https://img.shields.io/discord/480462759797063690.svg?logo=discord)](https://discord.gg/zT3asNS)\n\n`ember-stripe-service` is an easy way to add Stripe.js library to your ember-cli project without having to deal with manually setting the script tag. We will keep this addon on Stripe v2.  Stripe v2 passes an object to create a token.  Stripe v3 requires that first argument to be a Stripe Element.  Stripe v3 is supported in [`ember-stripe-elements`](https://github.com/code-corps/ember-stripe-elements).  As such, this addon should only be used to create tokens and I would imagine most of you will use `ember-stripe-elements`.\n\n## Features\n- sets stripe.js script in index.html (test, app)\n- initializes stripe with publishable key\n- injects service in controllers which provides promisified method for `Stripe.card.createToken`\n- provides debugging logs for easy troubleshooting\n- client side validations for card number, expiration dates, card type and CVC\n- lazy load stripe.js\n\n## Installation\n\n* `npm install --save ember-stripe-service`\n* `ember server`\n* set `stripe.publishableKey` in `config/environment.js`\n* Visit your app at http://localhost:4200, you should now see the stripe.js script has been included\n* `Stripe` global is now available in your app\n\n## Configuration\n\n### Stripe Publishable Key\nIn order to use Stripe you must set your [publishable key](https://dashboard.stripe.com/account/apikeys) in `config/environment.js`.\n\n````javascript\nENV.stripe = {\n  publishableKey: 'pk_thisIsATestKey',\n  debug: false, // turn on debugging\n  lazyLoad: false, // lazy load stripe\n  mock: false // mock out stripe.js, good for offline testing\n};\n````\n\n## Lazy loading\n\nIf `lazyLoad` is set to turn Stripe.js will not be loaded until you call the `load()` function on the service. It's best to call this function in a route's beforeModel hook.\n\n```js\n// subscription page route\n\nimport Ember from 'ember';\n\nexport default Ember.Route.extend({\n  stripe: Ember.inject.service('stripe'),\n\n  beforeModel() {\n    return this.get('stripe').load();\n  }\n});\n```\n\n## Creating Stripe Tokens for Cards\n\n`ember-stripe-service` provides a promisified version of\n`Stripe.card.createToken` which makes it easier to interact with its returns\nwithin your Ember controllers.\n\nThe method makes `createToken` operate under Ember run's loop making it easier\nto create integration tests that operate with Stripe's test mode.\n\nTo use it inside of a controller action or method you would:\n\n````javascript\n\nexport default Ember.Controller.extend({\n  stripe: Ember.inject.service(),\n  myCreditCardProcessingMethod: function() {\n\n    var customer = this.get('customer');\n\n    // obtain access to the injected service\n    var stripe = this.get('stripe');\n\n    // if for example you had the cc set in your controller\n    var card = this.get('creditCard');\n\n    return stripe.card.createToken(card).then(function(response) {\n      // you get access to your newly created token here\n      customer.set('stripeToken', response.id);\n      return customer.save();\n    })\n    .then(function() {\n      // do more stuff here\n    })\n    .catch(function(response) {\n      // if there was an error retrieving the token you could get it here\n\n      if (response.error.type === 'card_error') {\n        // show the error in the form or something\n      }\n    });\n  }\n})\n````\n## Creating Stripe Tokens for Bank Accounts\n\nThe interface is similar for bank account tokens:\n\n````javascript\n\n    // obtain access to the injected service\n    var stripe = this.get('stripe');\n\n    // if for example you had the cc set in your controller\n    var bankAccount = {\n      country: 'US',\n      routingNumber: '1235678',\n      accountNumber: '23875292349'\n    }\n\n    return stripe.bankAccount.createToken(bankAccount).then(function(response) {\n      // you get access to your newly created token here\n      customer.set('bankAccountStripeToken', response.id);\n      return customer.save();\n    })\n    .catch(response) {\n      // if there was an error retrieving the token you could get it here\n\n      if (response.error.type === 'invalid_request_error') {\n        // show an error in the form\n      }\n    }\n  }\n})\n````\n\n## Creating Stripe Tokens for PII Data\n\nThe interface is similar yet again for PII data tokens:\n\n````javascript\n\n    // obtain access to the injected service\n    var stripe = this.get('stripe');\n\n    var piiData = {\n      personalIdNumber: '123456789'\n    }\n\n    return stripe.piiData.createToken(piiData).then(function(response) {\n      // you get access to your newly created token here\n      customer.set('personalIdNumberStripeToken', response.id);\n      return customer.save();\n    })\n    .catch(response) {\n      // if there was an error retrieving the token you could get it here\n\n      if (response.error.type === 'invalid_request_error') {\n        // show an error in the form\n      }\n    }\n  }\n})\n````\n\n## Debugging\nBy setting `LOG_STRIPE_SERVICE` to true in your application configuration you can enable some debugging messages from the service\n\n````javascript\nvar ENV = {\n  // some vars...\n  stripe: {\n    debug: true\n  }\n  // more config ...\n}\n````\n\n## Client-side Validations\nStripe has a few client-side validation helpers. See more information\n[here](https://stripe.com/docs/stripe.js?#card-validation-helpers)\n\n* `validateCardNumber` - Checks that the number is formatted correctly and passes the Luhn check.\n* `validateExpiry` - Checks whether or not the expiration date represents an actual month in the future.\n* `validateCVC` - Checks whether or not the supplied number could be a valid verification code.\n* `cardType` - Returns the type of the card as a string. The possible types are \"Visa\", \"MasterCard\", \"American\n  Express\", \"Discover\", \"Diners Club\", and \"JCB\". If a card isn't recognized, the return value is \"Unknown\".\n\n## Running Tests\n\n* `ember test`\n* `ember test --server`\n\nIn order to run integration tests which use real Stripe tokens, the environment variable `STRIPE_PUBLISHABLE_KEY` must be set to use a real Stripe Publishable Key (either test or live).\n\n* `export STRIPE_PUBLISHABLE_KEY=\"pk_thisIsAKey\" ember test`\n\nThis repo comes with a `envrc.example` file, which uses the [direnv](http://direnv.net/) tool to manage directory-local environment variables. To use direnv to set the `STRIPE_PUBLISHABLE_KEY` environment variable, install and enable `direnv`, make a copy of `envrc.example` and name it `.envrc`, and add your key to that file. Note that `.envrc` is ignored by git, and thus will not ever be checked into this repository.\n\nYou can also use any other tool you'd like to manage setting your environment variable.\n\nYou can get the test key used to run this repo's integration tests by looking at the output from the latest Travis build.\n\nFor more information on using ember-cli, visit [http://www.ember-cli.com/](http://www.ember-cli.com/).\n\n## Upcoming Features\n- We're thinking of giving access other methods of Stripe, but we're not sure so if you find one useful please make an issue\n- Provide an option to inject mocked Stripe library inspired by ember-cli-custom-form but with deeper mocking and set by config flag not environment so integration tests can still be run with real service if wanted\n- PRs welcome and encouraged, and if you're not sure how to implement something we could try to work together\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcode-corps%2Fember-stripe-service","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcode-corps%2Fember-stripe-service","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcode-corps%2Fember-stripe-service/lists"}