Skip to content

Commit

Permalink
feat(medusa-payment-stripe): Add additional transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
adrien2p committed Aug 8, 2022
1 parent 114cdfc commit 510d84e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ class BancontactProviderService extends AbstractPaymentService {
*/
async createPayment(cart) {
const { customer_id, region_id, email } = cart
const region = await this.regionService_.retrieve(region_id)
const region = await this.regionService_.withTransaction(this.manager_).retrieve(region_id)
const { currency_code } = region

const amount = await this.totalsService_.getTotal(cart)
const amount = await this.totalsService_.withTransaction(this.manager_).getTotal(cart)

const intentRequest = {
amount: Math.round(amount),
Expand All @@ -106,7 +106,7 @@ class BancontactProviderService extends AbstractPaymentService {
}

if (customer_id) {
const customer = await this.customerService_.retrieve(customer_id)
const customer = await this.customerService_.withTransaction(this.manager_).retrieve(customer_id)

if (customer.metadata?.stripe_id) {
intentRequest.customer = customer.metadata.stripe_id
Expand Down
4 changes: 2 additions & 2 deletions packages/medusa-payment-stripe/src/services/stripe-giropay.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class GiropayProviderService extends AbstractPaymentService {
const region = await this.regionService_.retrieve(region_id)
const { currency_code } = region

const amount = await this.totalsService_.getTotal(cart)
const amount = await this.totalsService_.withTransaction(this.manager_).getTotal(cart)

const intentRequest = {
amount: Math.round(amount),
Expand All @@ -104,7 +104,7 @@ class GiropayProviderService extends AbstractPaymentService {
}

if (customer_id) {
const customer = await this.customerService_.retrieve(customer_id)
const customer = await this.customerService_.withTransaction(this.manager_).retrieve(customer_id)

if (customer.metadata?.stripe_id) {
intentRequest.customer = customer.metadata.stripe_id
Expand Down
6 changes: 3 additions & 3 deletions packages/medusa-payment-stripe/src/services/stripe-ideal.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ class StripeProviderService extends AbstractPaymentService {
*/
async createPayment(cart) {
const { customer_id, region_id, email } = cart
const { currency_code } = await this.regionService_.retrieve(region_id)
const { currency_code } = await this.regionService_.withTransaction(this.manager_).retrieve(region_id)

const amount = await this.totalsService_.getTotal(cart)
const amount = await this.totalsService_.withTransaction(this.manager_).getTotal(cart)

const intentRequest = {
description:
Expand All @@ -155,7 +155,7 @@ class StripeProviderService extends AbstractPaymentService {
}

if (customer_id) {
const customer = await this.customerService_.retrieve(customer_id)
const customer = await this.customerService_.withTransaction(this.manager_).retrieve(customer_id)

if (customer.metadata?.stripe_id) {
intentRequest.customer = customer.metadata.stripe_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ class StripeProviderService extends AbstractPaymentService {
*/
async createPayment(cart) {
const { customer_id, region_id, email } = cart
const { currency_code } = await this.regionService_.retrieve(region_id)
const { currency_code } = await this.regionService_.withTransaction(this.manager_).retrieve(region_id)

const amount = await this.totalsService_.getTotal(cart)
const amount = await this.totalsService_.withTransaction(this.manager_).getTotal(cart)

const intentRequest = {
description: cart?.context?.payment_description ?? this.options_?.payment_description,
Expand All @@ -142,7 +142,7 @@ class StripeProviderService extends AbstractPaymentService {
}

if (customer_id) {
const customer = await this.customerService_.retrieve(customer_id)
const customer = await this.customerService_.withTransaction(this.manager_).retrieve(customer_id)

if (customer.metadata?.stripe_id) {
intentRequest.customer = customer.metadata.stripe_id
Expand Down

0 comments on commit 510d84e

Please sign in to comment.