registers payment/fulfillment providers with correct names

This commit is contained in:
Sebastian Rindom
2020-05-28 20:17:13 +02:00
parent 9b51cf857c
commit 98a72ca7b4
5 changed files with 35 additions and 18 deletions
@@ -32,10 +32,6 @@ export default app => {
)
// Shipping Options
route.post(
"/:id/shipping-options",
middlewares.wrap(require("./create-shipping-options").default)
)
route.post(
"/:id/shipping-methods",
middlewares.wrap(require("./add-shipping-method").default)
+7 -5
View File
@@ -148,12 +148,14 @@ function registerServices(pluginDetails, container) {
cradle => new loaded(cradle, pluginDetails.options)
),
})
} else {
const name = formatRegistrationName(fn)
container.register({
[name]: asFunction(cradle => new loaded(cradle, pluginDetails.options)),
})
}
// Always register the service with a nice name, if we need to import it
// from somewhere
const name = formatRegistrationName(fn)
container.register({
[name]: asFunction(cradle => new loaded(cradle, pluginDetails.options)),
})
})
}
+17 -2
View File
@@ -692,7 +692,15 @@ class CartService extends BaseService {
if (!region.payment_providers.includes(pSession.provider_id)) {
return null
}
return this.paymentProviderService_.updateSession(pSession, cart)
const data = await this.paymentProviderService_.updateSession(
pSession,
cart
)
return {
provider_id: pSession.provider_id,
data,
}
})
)
}
@@ -708,13 +716,20 @@ class CartService extends BaseService {
return null
}
return this.paymentProviderService_.createSession(pId, cart)
const data = await this.paymentProviderService_.createSession(pId, cart)
return {
provider_id: pId,
data,
}
})
)
// Filter null sessions
newSessions = newSessions.filter(s => !!s)
console.log(sessions)
console.log(newSessions)
// Update the payment sessions with the concatenated array of updated and
// newly created payment sessions
return this.cartModel_
@@ -335,8 +335,9 @@ class ShippingProfileService extends BaseService {
async fetchCartOptions(cart) {
const products = this.getProductsInCart_(cart)
const profiles = await this.list({ products: { $in: products } })
const optionIds = profiles.reduce((acc, next) =>
acc.concat(next.shipping_options)
const optionIds = profiles.reduce(
(acc, next) => acc.concat(next.shipping_options),
[]
)
const options = await Promise.all(