Skip to content

Instantly share code, notes, and snippets.

@mfifth
Created September 19, 2017 23:29
Show Gist options
  • Save mfifth/0aaa7f13c023e9452e54d9a0882bdaaa to your computer and use it in GitHub Desktop.
Save mfifth/0aaa7f13c023e9452e54d9a0882bdaaa to your computer and use it in GitHub Desktop.
async function save_account(ctx) {
const {files, fields} = await asyncBusboy(ctx.req);
var email = fields.email;
var first_name = fields.firstName;
var last_name = fields.lastName;
var address = fields.address;
var addressTwo = fields.addressTwo;
var city = fields.addressCity;
var state = fields.addressState;
var zip = fields.addressZip;
var card_num = fields.creditCardNumber;
var card_month_exp = fields.creditCardExpMonth;
var card_year_exp = fields.creditCardExpYear;
var card_cvv = fields.creditCardCvv;
const res = await client.query('INSERT INTO customers (email, first_name, last_name, address, address_2, city, state, zip) VALUES ($1, $2, $3, $4, $5, $6, $7)', [email, first_name, last_name, address, addressTwo, city, state, zip])
billing_data = {
email: data.email,
first_name: data.firstName,
last_name: data.lastName,
address: data.address,
address_2: data.addressTwo,
city: data.addressCity,
state: data.addressState,
zip: data.addressZip,
card_num: data.creditCardNumber,
card_month_exp: data.creditCardExpMonth,
card_year_exp: data.creditCardExpYear,
card_cvv: data.creditCardCvv
};
send_to_braintree(billing_data);
return res.rows;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment