11const fs = require ( 'fs' ) ;
22const util = require ( 'util' ) ;
33const express = require ( 'express' ) ;
4- const request = require ( 'request' ) ;
4+ const request = require ( 'request-promise-native ' ) ;
55const store = require ( '../store' ) ;
66const router = express . Router ( ) ;
77
@@ -41,6 +41,7 @@ const titles = {
4141 socket : ':' + settings . socket ,
4242 title : titles [ page ] ,
4343 stripePublishKey : settings . stripePublishKey ,
44+ googleCaptchaKey : settings . googleCaptchaKey ,
4445 stats : store . get ( 'stats' ) [ '30' ] . total ,
4546 latestVersion : settings . latestVersion
4647 } ) ;
@@ -50,22 +51,22 @@ const titles = {
5051 } ) ;
5152
5253 router . post ( '/donate' , async ( req , res , next ) => {
53- let data ;
54+ let data , captchaBody ;
5455 try {
5556 data = JSON . parse ( req . body . data ) ;
56- let body = await request . post ( {
57+ captchaBody = await request . post ( {
5758 url :'https://www.google.com/recaptcha/api/siteverify' ,
5859 form : {
59- secret : settings . googleCaptchaKey ,
60+ secret : settings . googleCaptchaSecretKey ,
6061 response : data . recaptcha
6162 }
6263 } ) ;
63- body = JSON . parse ( body ) ;
64+ captchaBody = JSON . parse ( captchaBody ) ;
65+ if ( process . env . spec === "true" ) captchaBody = { success : true } ;
6466 } catch ( e ) {
65- if ( process . env . spec === "true" ) body = { success : true } ;
66- else return res . sendStatus ( 400 ) ;
67+ if ( process . env . spec === "true" ) throw e ;
6768 }
68- if ( body . success === true ) {
69+ if ( captchaBody . success === true ) {
6970 data = JSON . parse ( req . body . data ) ;
7071 stripe . charges . create ( {
7172 amount : data . token . price ,
0 commit comments