{"id":20872709,"url":"https://github.com/fdom92/stencil-payment","last_synced_at":"2025-05-12T13:33:55.050Z","repository":{"id":57370739,"uuid":"102823575","full_name":"Fdom92/stencil-payment","owner":"Fdom92","description":"Payment request API implementation in Stenciljs","archived":false,"fork":false,"pushed_at":"2018-08-25T17:45:06.000Z","size":4941,"stargazers_count":29,"open_issues_count":0,"forks_count":9,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-19T03:35:35.516Z","etag":null,"topics":["component","payment","stencil","stenciljs","typescript","web"],"latest_commit_sha":null,"homepage":null,"language":"HTML","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/Fdom92.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":"2017-09-08T05:59:50.000Z","updated_at":"2022-07-24T16:20:16.000Z","dependencies_parsed_at":"2022-09-18T10:41:19.339Z","dependency_job_id":null,"html_url":"https://github.com/Fdom92/stencil-payment","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fdom92%2Fstencil-payment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fdom92%2Fstencil-payment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fdom92%2Fstencil-payment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fdom92%2Fstencil-payment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Fdom92","download_url":"https://codeload.github.com/Fdom92/stencil-payment/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253748386,"owners_count":21957915,"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":["component","payment","stencil","stenciljs","typescript","web"],"created_at":"2024-11-18T06:20:17.912Z","updated_at":"2025-05-12T13:33:54.370Z","avatar_url":"https://github.com/Fdom92.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Built With Stencil](https://img.shields.io/badge/-Built%20With%20Stencil-16161d.svg?logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDE5LjIuMSwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPgo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkxheWVyXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IgoJIHZpZXdCb3g9IjAgMCA1MTIgNTEyIiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCA1MTIgNTEyOyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI%2BCjxzdHlsZSB0eXBlPSJ0ZXh0L2NzcyI%2BCgkuc3Qwe2ZpbGw6I0ZGRkZGRjt9Cjwvc3R5bGU%2BCjxwYXRoIGNsYXNzPSJzdDAiIGQ9Ik00MjQuNywzNzMuOWMwLDM3LjYtNTUuMSw2OC42LTkyLjcsNjguNkgxODAuNGMtMzcuOSwwLTkyLjctMzAuNy05Mi43LTY4LjZ2LTMuNmgzMzYuOVYzNzMuOXoiLz4KPHBhdGggY2xhc3M9InN0MCIgZD0iTTQyNC43LDI5Mi4xSDE4MC40Yy0zNy42LDAtOTIuNy0zMS05Mi43LTY4LjZ2LTMuNkgzMzJjMzcuNiwwLDkyLjcsMzEsOTIuNyw2OC42VjI5Mi4xeiIvPgo8cGF0aCBjbGFzcz0ic3QwIiBkPSJNNDI0LjcsMTQxLjdIODcuN3YtMy42YzAtMzcuNiw1NC44LTY4LjYsOTIuNy02OC42SDMzMmMzNy45LDAsOTIuNywzMC43LDkyLjcsNjguNlYxNDEuN3oiLz4KPC9zdmc%2BCg%3D%3D\u0026colorA=16161d\u0026style=flat-square)\n\n# wc-payment\n\nwc-payment is a web component built with [Stencil](https://stenciljs.com/) that allows you to use the [Payment Request API](https://developers.google.com/web/fundamentals/discovery-and-monetization/payment-request/).\n\n![Demo](./docs/video.gif)\n\n## Getting Started\n\nTo try this component:\n\n```bash\ngit clone git@github.com:Fdom92/stencil-payment.git\ncd my-app\ngit remote rm origin\n```\n\nand run:\n\n```bash\nnpm install\nnpm start\n```\n\n## Using this component\n\n### Script tag\n\n- Put `\u003cscript src='https://unpkg.com/stencil-payment@latest/dist/payment.js'\u003e\u003c/script\u003e` in the head of your index.html\n- Then you can use the element like this:\n```html\n\u003cwc-payment\u003e\n    Pay\n\u003c/wc-payment\u003e\n```\n\n### Node Modules\n- Run `npm install stencil-payment --save`\n- Put a script tag similar to this `\u003cscript src='node_modules/stencil-payment/dist/payment.js\u003e\u003c/script\u003e` in the head of your index.html\n- Then you can use the element like this:\n```html\n\u003cwc-payment\u003e\n    Pay\n\u003c/wc-payment\u003e\n```\n\n### In a stencil-starter app\n- Run `npm install stencil-payment --save`\n- Add `{ name: 'stencil-payment' }` to your [collections](https://github.com/ionic-team/stencil-starter/blob/master/stencil.config.js#L5)\n- Then you can use the element like this:\n```html\n\u003cwc-payment\u003e\n    Pay\n\u003c/wc-payment\u003e\n```\n\n## Parameters\n\n### methodData\n\nYou need to pass the list of payment methods:\n\n```js\nvar methodData = [\n  {\n    supportedMethods: [\"visa\", \"mastercard\"]\n  }\n]\n```\n\nAt the moment payment api only accept this cards:\n\n- amex\n- diners\n- discover\n- jcb\n- maestro\n- mastercard\n- unionpay\n- visa\n\n### details\n\nYou need to pass the details of the transaction, an object with displayItems and the total object with the final value:\n\n```js\nvar details = {\n  displayItems: [\n    {\n      label: \"Original donation amount\",\n      amount: { currency: \"USD\", value : \"65.00\" }, // US$65.00\n    },\n    {\n      label: \"Friends and family discount\",\n      amount: { currency: \"USD\", value : \"-10.00\" }, // -US$10.00\n      pending: true // The price is not determined yet\n    }\n  ],\n  total:  {\n    label: \"Total\",\n    amount: { currency: \"USD\", value : \"55.00\" }, // US$55.00\n  }\n}\n```\n\n### options\n\nYou can also get the email address, phone number or name of a user when configuring the options object:\n\n```js\n  var options = {\n    requestShipping: true,\n    requestPayerEmail: true,\n    requestPayerPhone: true,\n    requestPayerName: true\n  };\n```\n\n## Events\n\n### paymentFailed\n\nYou can listen to this event to know when the payment was unsucessfull:\n\n```js\nelement = document.querySelector('wc-payment');\nelement.addEventListener(\"paymentFailed\", () =\u003e {});\n```\n\n### paymentSucceeded\n\nYou can listen to this event to know when the payment was sucessfull:\n\n```js\nelement = document.querySelector('wc-payment');\nelement.addEventListener(\"paymentSucceeded\", () =\u003e {});\n```\n\n## Methods\n\n### show\n\nYou can show the payment request anytime with the `show` method like this:\n\n```js\nelement = document.querySelector('wc-payment');\nelement.show();\n```\n\nThis way you can bind this function to your own pay button or wherever you want.\n\n### abort\n\nYou can abort the transaction with the `abort` method anytime due to some error.\n\n```js\nelement = document.querySelector('wc-payment');\nelement.abort();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffdom92%2Fstencil-payment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffdom92%2Fstencil-payment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffdom92%2Fstencil-payment/lists"}