feat(medusa-payment-klarna): Add language variable (#4483)
* Add language variable * Add changeset
This commit is contained in:
1 parent
f20d484b23
commit
5d0e9ac007
3 files changed
+10
-2
No files matched your search
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"medusa-payment-klarna": minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Add language support
|
||||||
@@ -37,6 +37,7 @@ Receive payments on your Medusa commerce application using Klarna.
|
|||||||
KLARNA_TERMS_URL=<YOUR_KLARNA_TERMS_URL>
|
KLARNA_TERMS_URL=<YOUR_KLARNA_TERMS_URL>
|
||||||
KLARNA_CHECKOUT_URL=<YOUR_KLARNA_CHECKOUT_URL>
|
KLARNA_CHECKOUT_URL=<YOUR_KLARNA_CHECKOUT_URL>
|
||||||
KLARNA_CONFIRMATION_URL=<YOUR_KLARNA_CONFIRMATION_URL>
|
KLARNA_CONFIRMATION_URL=<YOUR_KLARNA_CONFIRMATION_URL>
|
||||||
|
KLARNA_LANGUAGE=<YOUR_KLARNA_LANGUAGE>
|
||||||
```
|
```
|
||||||
|
|
||||||
3\. In `medusa-config.js` add the following at the end of the `plugins` array:
|
3\. In `medusa-config.js` add the following at the end of the `plugins` array:
|
||||||
@@ -51,6 +52,7 @@ Receive payments on your Medusa commerce application using Klarna.
|
|||||||
url: process.env.KLARNA_URL,
|
url: process.env.KLARNA_URL,
|
||||||
user: process.env.KLARNA_USER,
|
user: process.env.KLARNA_USER,
|
||||||
password: process.env.KLARNA_PASSWORD,
|
password: process.env.KLARNA_PASSWORD,
|
||||||
|
language: process.env.KLARNA_LANGUAGE,
|
||||||
merchant_urls: {
|
merchant_urls: {
|
||||||
terms: process.env.KLARNA_TERMS_URL,
|
terms: process.env.KLARNA_TERMS_URL,
|
||||||
checkout: process.env.KLARNA_CHECKOUT_URL,
|
checkout: process.env.KLARNA_CHECKOUT_URL,
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ class KlarnaProviderService extends PaymentService {
|
|||||||
this.klarnaOrderManagementUrl_ = "/ordermanagement/v1/orders"
|
this.klarnaOrderManagementUrl_ = "/ordermanagement/v1/orders"
|
||||||
|
|
||||||
this.backendUrl_ = options.backend_url
|
this.backendUrl_ = options.backend_url
|
||||||
|
this.locale_ = options.language ?? 'en-US'
|
||||||
|
|
||||||
/** @private @const {ShippingProfileService} */
|
/** @private @const {ShippingProfileService} */
|
||||||
this.shippingProfileService_ = shippingProfileService
|
this.shippingProfileService_ = shippingProfileService
|
||||||
@@ -101,7 +102,7 @@ class KlarnaProviderService extends PaymentService {
|
|||||||
let order = {
|
let order = {
|
||||||
// Cart id is stored, such that we can use it for hooks
|
// Cart id is stored, such that we can use it for hooks
|
||||||
merchant_data: cart.resource_id ?? cart.id,
|
merchant_data: cart.resource_id ?? cart.id,
|
||||||
locale: "en-US",
|
locale: this.locale_,
|
||||||
}
|
}
|
||||||
|
|
||||||
const { region, gift_card_total, tax_total, total } = cart
|
const { region, gift_card_total, tax_total, total } = cart
|
||||||
@@ -265,7 +266,7 @@ class KlarnaProviderService extends PaymentService {
|
|||||||
const order = {
|
const order = {
|
||||||
// Custom id is stored, such that we can use it for hooks
|
// Custom id is stored, such that we can use it for hooks
|
||||||
merchant_data: resource_id,
|
merchant_data: resource_id,
|
||||||
locale: "en-US",
|
locale: this.locale_,
|
||||||
order_lines: [
|
order_lines: [
|
||||||
{
|
{
|
||||||
name: "Payment Collection",
|
name: "Payment Collection",
|
||||||
|
|||||||
Reference in new issue
Block a user