Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/handlerHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ export default {

},

redirectResponse: function(statusCode, location){
const response = {
statusCode,
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Credentials': true,
'Location': location
}
}
return response;
},

missingIdQueryResponse: function (type) {

return this.createResponse(400, {
Expand Down
1 change: 1 addition & 0 deletions services/hello/test/hello.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// tests for hello
// Generated by serverless-mocha-plugin


import mochaPlugin from 'serverless-mocha-plugin';
const expect = mochaPlugin.chai.expect;
const wrapped = mochaPlugin.getWrapper('hello', '/handler.js', 'hello');
Expand Down
28 changes: 27 additions & 1 deletion services/memberships/handler.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import helpers from '../../lib/handlerHelpers';
import db from '../../lib/db';
const { MEMBERSHIPS_TABLE } = require('../../constants/tables');

export const getAll = async(event, ctx, callback) => {

try {
Expand All @@ -25,3 +24,30 @@ export const getAll = async(event, ctx, callback) => {
}

};

export const payment = async(event, ctx, callback) => {
const stripe = require('stripe')('sk_test_51KOxOlBAxwbCreS7JRQtvZCnCgLmn8tjK7WPHDGjpw0s4vfVHLwbcrZZvQLmd5cY7zKRIsfj3pnEDDHTy3G81Tuf00v9ygIBrC');
const session = await stripe.checkout.sessions.create({
payment_method_types: ['card'],
line_items: [
{
price_data: {
currency: 'CAD',
product_data: {
name: 'BizTech Membership',
images: ['https://imgur.com/TRiZYtG.png'],
},
unit_amount: 500,
},
quantity: 1,
},
],
// metadata: event.body,
mode: 'payment',
success_url: `https://app.ubcbiztech.com/signup/success`,
cancel_url: `https://facebook.com`,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should also change cancel_url

});
let response = helpers.createResponse(200, session.url);
callback(null, response);
return null;
}
174 changes: 173 additions & 1 deletion services/memberships/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions services/memberships/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@
"itest": "npm run itest memberships --prefix ../../",
"utest": "npm run utest memberships --prefix ../../",
"test": "npm run utest memberships --prefix ../../ && npm run itest memberships --prefix ../../"
},
"dependencies": {
"stripe": "^8.160.0"
}
}
7 changes: 7 additions & 0 deletions services/memberships/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,11 @@ functions:
name: ${self:service}-authorizer
type: COGNITO_USER_POOLS
arn: arn:aws:cognito-idp:us-west-2:432714361962:userpool/us-west-2_w0R176hhp
membershipsPayment:
handler: handler.payment
events:
- http:
path: memberships/payment
method: post
cors: true