Title: Implementation on ReactJS · Issue #26 · AuthorizeNet/sample-code-node · GitHub
Open Graph Title: Implementation on ReactJS · Issue #26 · AuthorizeNet/sample-code-node
X Title: Implementation on ReactJS · Issue #26 · AuthorizeNet/sample-code-node
Description: How can I use AcceptJS on the client side? I am using ReactJS on the front end and Serverless, NodeJS on the backend. It is a bit confusing to implement AcceptJS. Previously when I have used stripe , it was pretty much straight forward. ...
Open Graph Description: How can I use AcceptJS on the client side? I am using ReactJS on the front end and Serverless, NodeJS on the backend. It is a bit confusing to implement AcceptJS. Previously when I have used stripe...
X Description: How can I use AcceptJS on the client side? I am using ReactJS on the front end and Serverless, NodeJS on the backend. It is a bit confusing to implement AcceptJS. Previously when I have used stripe...
Opengraph URL: https://github.com/AuthorizeNet/sample-code-node/issues/26
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Implementation on ReactJS","articleBody":"How can I use AcceptJS on the client side? I am using ReactJS on the front end and Serverless, NodeJS on the backend. It is a bit confusing to implement AcceptJS. Previously when I have used _stripe_ , it was pretty much straight forward. \r\n\r\n```import React from 'react';\r\nimport StripeCheckout from 'react-stripe-checkout';\r\n\r\nimport config from '../config';\r\n\r\nclass PayButton extends React.Component {\r\n constructor(props) {\r\n super(props);\r\n this.onToken = this.onToken.bind(this);\r\n }\r\n\r\n async onToken(token) { // On a successful tokenization request,\r\n const res = await fetch(config.stripe.apiUrl, { // POST to our backend server with the token and charge details\r\n method: 'POST',\r\n body: JSON.stringify({\r\n token,\r\n charge: {\r\n amount: this.props.amount,\r\n currency: config.stripe.currency,\r\n },\r\n }),\r\n });\r\n const data = await res.json();\r\n console.log('onToken');\r\n console.log(data);\r\n }\r\n\r\n render() {\r\n return (\r\n \u003cStripeCheckout\r\n name=\"Serverless Stripe Store Inc.\"\r\n token={this.onToken}\r\n amount={this.props.amount}\r\n currency={config.stripe.currency}\r\n stripeKey={config.stripe.apiKey} // Stripe publishable API Key\r\n allowRememberMe={false}\r\n /\u003e\r\n );\r\n }\r\n}```\r\n\r\nIn the backend though, it is\r\n```const stripe = require('stripe')(process.env.STRIPE_SECRET_KEY);\r\n\r\nmodule.exports.handler = (event, context, callback) =\u003e {\r\n const requestBody = JSON.parse(event.body);\r\n const token = requestBody.token.id;\r\n const amount = requestBody.charge.amount;\r\n const currency = requestBody.charge.currency;\r\n\r\n return stripe.charges.create({ // Create Stripe charge with token\r\n amount,\r\n currency,\r\n description: 'Serverless Stripe Test charge',\r\n source: token,\r\n })\r\n .then((charge) =\u003e { // Success response\r\n const response = {\r\n statusCode: 200,\r\n headers: {\r\n 'Access-Control-Allow-Origin': '*',\r\n },\r\n body: JSON.stringify({\r\n message: `Charge processed succesfully!`,\r\n charge,\r\n }),\r\n };\r\n callback(null, response);\r\n })\r\n .catch((err) =\u003e { // Error response\r\n const response = {\r\n statusCode: 500,\r\n headers: {\r\n 'Access-Control-Allow-Origin': '*',\r\n },\r\n body: JSON.stringify({\r\n error: err.message,\r\n }),\r\n };\r\n callback(null, response);\r\n })\r\n};```\r\n\r\nIs there an equivalent method to implement this?","author":{"url":"https://github.com/vamshi9","@type":"Person","name":"vamshi9"},"datePublished":"2019-06-20T10:42:34.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/26/sample-code-node/issues/26"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:9831358d-f299-0d6f-a57f-f45fbbed3685 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C27E:D449A:89C21A:B32F5C:696AF084 |
| html-safe-nonce | 1c19ef91f84baeb3f8ece5eafbc0fa37309fbef61d5b18678316e312f432a6b0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMjdFOkQ0NDlBOjg5QzIxQTpCMzJGNUM6Njk2QUYwODQiLCJ2aXNpdG9yX2lkIjoiNzgzNzAxNjc0MjE5NjYwNTA2MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | aea8b72dbf7dff459ea52121ad1eef26c7da19bf6306b335c12d5918a65c8198 |
| hovercard-subject-tag | issue:458580633 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/AuthorizeNet/sample-code-node/26/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f0306da3189c75efd6f6b110c6bdd82022901f30a064e3fdbf06e70664e9174d/AuthorizeNet/sample-code-node/issues/26 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f0306da3189c75efd6f6b110c6bdd82022901f30a064e3fdbf06e70664e9174d/AuthorizeNet/sample-code-node/issues/26 |
| og:image:alt | How can I use AcceptJS on the client side? I am using ReactJS on the front end and Serverless, NodeJS on the backend. It is a bit confusing to implement AcceptJS. Previously when I have used stripe... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | vamshi9 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| turbo-cache-control | no-preview |
| go-import | github.com/AuthorizeNet/sample-code-node git https://github.com/AuthorizeNet/sample-code-node.git |
| octolytics-dimension-user_id | 6014037 |
| octolytics-dimension-user_login | AuthorizeNet |
| octolytics-dimension-repository_id | 58068712 |
| octolytics-dimension-repository_nwo | AuthorizeNet/sample-code-node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 58068712 |
| octolytics-dimension-repository_network_root_nwo | AuthorizeNet/sample-code-node |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 82560a55c6b2054555076f46e683151ee28a19bc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width