Skip to content

Commit

Permalink
fix(medusa-payment-stripe): Fix options typo (#1899)
Browse files Browse the repository at this point in the history
**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>
  • Loading branch information
adrien2p and olivermrbl committed Jul 26, 2022
1 parent aa4bf79 commit e51fdd3
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/tame-dryers-double.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"medusa-payment-stripe": patch
---

Fix options typo in payment intent descriptions
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe("StripeProviderService", () => {
totalsService: TotalsServiceMock,
},
{
api_key: "test",
api_key: "test"
}
)

Expand Down Expand Up @@ -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", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit e51fdd3

Please sign in to comment.