Skip to content

Commit 1b92b35

Browse files
committed
Send customer details to Stripe
1 parent c2fcfdc commit 1b92b35

File tree

3 files changed

+29
-19
lines changed

3 files changed

+29
-19
lines changed

public/js/app.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20457,40 +20457,41 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
2045720457

2045820458
var checkout = /*#__PURE__*/function () {
2045920459
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
20460-
var _yield$localState$str, paymentMethod, error, kunde;
20460+
var _store$getCustomerDet, firstName, lastName, address, zipcode, city, state, email, _yield$localState$str, paymentMethod, error, kunde;
2046120461

2046220462
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
2046320463
while (1) {
2046420464
switch (_context2.prev = _context2.next) {
2046520465
case 0:
20466-
_context2.next = 2;
20466+
_store$getCustomerDet = store.getCustomerDetails, firstName = _store$getCustomerDet.firstName, lastName = _store$getCustomerDet.lastName, address = _store$getCustomerDet.address, zipcode = _store$getCustomerDet.zipcode, city = _store$getCustomerDet.city, state = _store$getCustomerDet.state, email = _store$getCustomerDet.email;
20467+
_context2.next = 3;
2046720468
return localState.stripe.createPaymentMethod("card", localState.cardElement, {
2046820469
billing_details: {
20469-
name: "Test test",
20470-
email: "test@test.no",
20470+
name: "".concat(firstName, " ").concat(lastName),
20471+
email: email,
2047120472
address: {
20472-
line1: "Test",
20473-
city: "City",
20474-
state: "State",
20475-
postal_code: "1234"
20473+
line1: address,
20474+
city: city,
20475+
state: state,
20476+
postal_code: zipcode
2047620477
}
2047720478
}
2047820479
});
2047920480

20480-
case 2:
20481+
case 3:
2048120482
_yield$localState$str = _context2.sent;
2048220483
paymentMethod = _yield$localState$str.paymentMethod;
2048320484
error = _yield$localState$str.error;
2048420485

2048520486
if (!(error || !paymentMethod.id)) {
20486-
_context2.next = 8;
20487+
_context2.next = 9;
2048720488
break;
2048820489
}
2048920490

2049020491
localState.orderError = "Error";
2049120492
return _context2.abrupt("return");
2049220493

20493-
case 8:
20494+
case 9:
2049420495
kunde = _objectSpread(_objectSpread({}, store.getCustomerDetails), {}, {
2049520496
cart: JSON.stringify(store.getCartContent),
2049620497
amount: 5000,
@@ -20511,7 +20512,7 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
2051120512
localState.orderError = true;
2051220513
});
2051320514

20514-
case 10:
20515+
case 11:
2051520516
case "end":
2051620517
return _context2.stop();
2051720518
}

resources/js/components/Checkout/OrderCheckout.vue

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,28 @@ onMounted(async () => {
8282
});
8383
8484
const checkout = async () => {
85+
const {
86+
firstName,
87+
lastName,
88+
address,
89+
zipcode,
90+
city,
91+
state,
92+
email,
93+
} = store.getCustomerDetails;
94+
8595
const { paymentMethod, error } = await localState.stripe.createPaymentMethod(
8696
"card",
8797
localState.cardElement,
8898
{
8999
billing_details: {
90-
name: "Test test",
91-
email: "test@test.no",
100+
name: `${firstName} ${lastName}`,
101+
email: email,
92102
address: {
93-
line1: "Test",
94-
city: "City",
95-
state: "State",
96-
postal_code: "1234",
103+
line1: address,
104+
city: city,
105+
state: state,
106+
postal_code: zipcode,
97107
},
98108
},
99109
}

resources/js/store/useCart.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ export const useCart = defineStore("shopState", {
6464
getOrderDetails() {
6565
return this.order;
6666
},
67-
6867
getCartContent() {
6968
return this.cart;
7069
},

0 commit comments

Comments
 (0)