fix(medusa-payment-stripe): Fix options typo (#1899)

**What**
Fix the options usage across the plugin `this.options_` instead of `this.options`

**Tests**
New unit tests

Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
Adrien de Peretti
2022-07-26 13:34:28 +02:00
committed by GitHub
parent aa4bf795b2
commit e51fdd3304
6 changed files with 32 additions and 5 deletions

View File

@@ -0,0 +1,5 @@
---
"medusa-payment-stripe": patch
---
Fix options typo in payment intent descriptions

View File

@@ -51,7 +51,7 @@ describe("StripeProviderService", () => {
totalsService: TotalsServiceMock,
},
{
api_key: "test",
api_key: "test"
}
)
@@ -79,6 +79,28 @@ describe("StripeProviderService", () => {
description: 'some description',
})
})
it("returns created stripe payment intent for cart with no customer and the options default description", async () => {
const localStripeProviderService = new StripeProviderService({
customerService: CustomerServiceMock,
regionService: RegionServiceMock,
totalsService: TotalsServiceMock,
},
{
api_key: "test",
payment_description: "test options description"
})
carts.frCart.customer_id = ""
carts.frCart.context.payment_description = null
result = await localStripeProviderService.createPayment(carts.frCart)
expect(result).toEqual({
id: "pi_lebron",
customer: "cus_lebron",
amount: 100,
description: "test options description",
})
})
})
describe("retrievePayment", () => {

View File

@@ -90,7 +90,7 @@ class BancontactProviderService extends PaymentService {
const intentRequest = {
amount: Math.round(amount),
description: cart?.context?.payment_description ?? this.options?.payment_description,
description: cart?.context?.payment_description ?? this.options_?.payment_description,
currency: currency_code,
payment_method_types: ["bancontact"],
capture_method: "automatic",

View File

@@ -90,7 +90,7 @@ class GiropayProviderService extends PaymentService {
const intentRequest = {
amount: Math.round(amount),
description: cart?.context?.payment_description ?? this.options?.payment_description,
description: cart?.context?.payment_description ?? this.options_?.payment_description,
currency: currency_code,
payment_method_types: ["giropay"],
capture_method: "automatic",

View File

@@ -90,7 +90,7 @@ class IdealProviderService extends PaymentService {
const intentRequest = {
amount: Math.round(amount),
description: cart?.context?.payment_description ?? this.options?.payment_description,
description: cart?.context?.payment_description ?? this.options_?.payment_description,
currency: currency_code,
payment_method_types: ["ideal"],
capture_method: "automatic",

View File

@@ -125,7 +125,7 @@ class StripeProviderService extends PaymentService {
const amount = await this.totalsService_.getTotal(cart)
const intentRequest = {
description: cart?.context?.payment_description ?? this.options?.payment_description,
description: cart?.context?.payment_description ?? this.options_?.payment_description,
amount: Math.round(amount),
currency: currency_code,
setup_future_usage: "on_session",