@vivlab/api-database
Advanced tools
Comparing version 1.0.102 to 1.0.103
@@ -31,3 +31,3 @@ "use strict"; | ||
const paymentIntent = await index_1.stripe.paymentIntents.create({ | ||
amount: getPaymentIntentAmount(carts), | ||
amount: carts.checkout.total, | ||
currency: "eur", | ||
@@ -42,9 +42,6 @@ // payment_method_types, | ||
async function updateStripePaymentIntent({ id, carts, data, stripeAccount }) { | ||
const paymentIntent = await index_1.stripe.paymentIntents.update(id, { amount: getPaymentIntentAmount(carts), ...data }, { stripeAccount }); | ||
const paymentIntent = await index_1.stripe.paymentIntents.update(id, { amount: carts.checkout.total, ...data }, { stripeAccount }); | ||
return transform.stripePaymentIntent(paymentIntent); | ||
} | ||
exports.updateStripePaymentIntent = updateStripePaymentIntent; | ||
function getPaymentIntentAmount(carts) { | ||
return (carts.checkout.total - carts.products.reduce((a, v) => (v.recurring ? a + v.unit_amount : a), 0)); | ||
} | ||
//# sourceMappingURL=payment.js.map |
@@ -10,6 +10,6 @@ "use strict"; | ||
const shipingAddress = invoice.shipping_address; | ||
const address = invoice.billing_address || shipingAddress; | ||
const address = invoice.billing_address?.line1 ? invoice.billing_address : shipingAddress; | ||
const customer = await index_1.stripe.customers.create({ | ||
email: invoice.email, | ||
name: address.name ?? undefined, | ||
name: address.name || undefined, | ||
phone: address.phone ?? undefined, | ||
@@ -43,3 +43,3 @@ payment_method, | ||
}, { stripeAccount }); | ||
await index_1.stripe.subscriptionSchedules.create({ | ||
const subscriptionSchedule = await index_1.stripe.subscriptionSchedules.create({ | ||
customer: customer.id, | ||
@@ -53,4 +53,8 @@ start_date: "now", | ||
}, { stripeAccount }); | ||
const subscription = await index_1.stripe.subscriptions.retrieve(subscriptionSchedule.subscription, { | ||
stripeAccount | ||
}); | ||
await index_1.stripe.invoices.pay(subscription.latest_invoice, { paid_out_of_band: true }, { stripeAccount }); | ||
} | ||
exports.create = create; | ||
//# sourceMappingURL=subscription.js.map |
{ | ||
"name": "@vivlab/api-database", | ||
"version": "1.0.102", | ||
"version": "1.0.103", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
468798
7441