{"id":17420035,"url":"https://github.com/bendrucker/stripe-as-promised","last_synced_at":"2025-06-12T03:16:17.885Z","repository":{"id":30183116,"uuid":"33733744","full_name":"bendrucker/stripe-as-promised","owner":"bendrucker","description":"Wrap Stripe.js async methods to return promises","archived":false,"fork":false,"pushed_at":"2020-08-05T21:05:58.000Z","size":18,"stargazers_count":15,"open_issues_count":0,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-10T08:14:06.912Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/bendrucker.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":"2015-04-10T14:47:15.000Z","updated_at":"2022-03-19T15:50:44.000Z","dependencies_parsed_at":"2022-07-08T11:44:13.154Z","dependency_job_id":null,"html_url":"https://github.com/bendrucker/stripe-as-promised","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bendrucker%2Fstripe-as-promised","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bendrucker%2Fstripe-as-promised/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bendrucker%2Fstripe-as-promised/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bendrucker%2Fstripe-as-promised/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bendrucker","download_url":"https://codeload.github.com/bendrucker/stripe-as-promised/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248968914,"owners_count":21191162,"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-10-17T02:39:19.369Z","updated_at":"2025-04-15T00:04:45.881Z","avatar_url":"https://github.com/bendrucker.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# stripe-as-promised [![Build Status](https://travis-ci.org/bendrucker/stripe-as-promised.svg?branch=master)](https://travis-ci.org/bendrucker/stripe-as-promised)\n\n\u003e Wrap [Stripe.js](https://stripe.com/docs/stripe.js)'s asynchronous methods to return promises instead of calling callbacks.\n\n## Installing\n\n```sh\n# npm\n$ npm install stripe-as-promised\n```\n\n## API\n\n#### `stripeAsPromised(Stripe, Promise)` -\u003e `promisifedStripe`\n\n##### Stripe\n\n*Required*  \nType: `function`\n\nThe Stripe.js library\n\n##### Promise\n\n*Required*  \nType: `function`\n\nA Promise constructor\n\nThe returned promisified object promisifes the following methods in addition to exposing utility methods:\n\n* [`card.createToken`](https://stripe.com/docs/stripe.js#card-createToken)\n* [`bankAccount.createToken`](https://stripe.com/docs/stripe.js#bank-account-createToken)\n* [`piiData.createToken`](https://stripe.com/docs/stripe.js?#pii-data-createToken)\n* [`bitcoinReceiver.createReceiver`](https://stripe.com/docs/stripe.js#bitcoinreceiver-createreceiver)\n* [`bitcoinReceiver.pollReceiver`](https://stripe.com/docs/stripe.js#bitcoinreceiver-pollreceiver)\n* `bitcoinReceiver.getReceiver` (undocumented)\n\n\n## Usage\n\n### Example\n\nBelow is an abbreviated version of Stripe's [documented example for creating a token](https://stripe.com/docs/stripe.js#collecting-card-details):\n\n```js\n// card === {number: '42...', ...}\nStripe.card.createToken(card, stripeResponseHandler);\n\nfunction stripeResponseHandler(status, token) {\n  if (token.error) {\n    console.error('Tokenization failed');\n  } else {\n    console.log('Created token', token.id);\n  }\n}\n```\n\nThe same logic with stripe-as-promised would be written as:\n\n```js\nvar stripe = stripeAsPromised(Stripe, Promise);\n\nstripe.card.createToken(card)\n  .then(function (token) {\n    console.log('Created token', token.id);\n  })\n  .catch(function (err) {\n    console.error(err);\n  });\n```\n\n### Bitcoin\n\nFor handling bitcoin transactions, you'll probably want to avoid using the `pollReceiver` method as-is. `cancelReceiverPoll` does not notify the callback passed to `pollReceiver` of the cancellation, so the following code could result in a promise that never resolves:\n\n```js\nstripe.bitcoinReceiver.createReceiver(payment)\n  .then(function (receiver) {\n    return stripe.bitcoinReceiver.pollReceiver(receiver.id);\n  })\n  .then(function (receiver) {\n    console.log('Payment received!');\n  })\n  .catch(function (err) {\n    console.error('Payment error', err);\n  });\n```\n\nIf the receiver is never filled, neither statement is printed. In your application, you'll probably want to implement your own polling implementation that treats cancellations as errors that can be caught and handled downstream.\n\n## License\n\nMIT © [Ben Drucker](http://bendrucker.me)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbendrucker%2Fstripe-as-promised","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbendrucker%2Fstripe-as-promised","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbendrucker%2Fstripe-as-promised/lists"}