File tree Expand file tree Collapse file tree
src/components/stripe-button Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11{
22 "name" : " crwn-clothing" ,
33 "version" : " 0.1.0" ,
4+ "proxy" : " http://localhost:5000" ,
45 "private" : true ,
56 "dependencies" : {
7+ "axios" : " 0.18.0" ,
68 "firebase" : " 6.0.2" ,
79 "node-sass" : " 4.12.0" ,
810 "react" : " ^16.8.6" ,
Original file line number Diff line number Diff line change 11import React from 'react' ;
22import StripeCheckout from 'react-stripe-checkout' ;
3+ import axios from 'axios' ;
34
45const StripeCheckoutButton = ( { price } ) => {
56 const priceForStripe = price * 100 ;
6- const publishableKey = 'pk_test_CXkmJ4cc7Ap4BZJDGLDH8R3A00fs1ubI6N ' ;
7+ const publishableKey = 'pk_test_WBqax2FWVzS9QlpJScO07iuL ' ;
78
89 const onToken = token => {
910 console . log ( token ) ;
10- alert ( 'Payment Successful' ) ;
11+ axios ( {
12+ url : '/payment' ,
13+ method : 'post' ,
14+ data : {
15+ amount : priceForStripe ,
16+ token : token
17+ }
18+ } )
19+ . then ( response => {
20+ console . log ( response ) ;
21+ } )
22+ . catch ( error => {
23+ console . log ( 'Payment Error: ' , error ) ;
24+ alert (
25+ 'There was an issue with your payment! Please make sure to use the provided credit card data'
26+ ) ;
27+ } ) ;
1128 } ;
1229
1330 return (
Original file line number Diff line number Diff line change @@ -2067,6 +2067,14 @@ aws4@^1.8.0:
20672067 resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.8.0.tgz#f0e003d9ca9e7f59c7a508945d7b2ef9a04a542f"
20682068 integrity sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==
20692069
2070+ axios@0.18.0 :
2071+ version "0.18.0"
2072+ resolved "https://registry.yarnpkg.com/axios/-/axios-0.18.0.tgz#32d53e4851efdc0a11993b6cd000789d70c05102"
2073+ integrity sha1-MtU+SFHv3AoRmTts0AB4nXDAUQI=
2074+ dependencies :
2075+ follow-redirects "^1.3.0"
2076+ is-buffer "^1.1.5"
2077+
20702078axobject-query@^2.0.2 :
20712079 version "2.0.2"
20722080 resolved "https://registry.yarnpkg.com/axobject-query/-/axobject-query-2.0.2.tgz#ea187abe5b9002b377f925d8bf7d1c561adf38f9"
@@ -4371,7 +4379,7 @@ flush-write-stream@^1.0.0:
43714379 inherits "^2.0.3"
43724380 readable-stream "^2.3.6"
43734381
4374- follow-redirects@^1.0.0 :
4382+ follow-redirects@^1.0.0, follow-redirects@^1.3.0 :
43754383 version "1.7.0"
43764384 resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.7.0.tgz#489ebc198dc0e7f64167bd23b03c4c19b5784c76"
43774385 integrity sha512-m/pZQy4Gj287eNy94nivy5wchN3Kp+Q5WgUPNy5lJSZ3sgkVKSYV/ZChMAQVIgx1SqfZ2zBZtPA2YlXIWxxJOQ==
You can’t perform that action at this time.
0 commit comments