Skip to content

Commit

Permalink
Merge pull request #487 from commercelayer/feat/support-affirm-and-kl…
Browse files Browse the repository at this point in the history
…arna-on-stripe

Add support affirm and klarna on stripe
  • Loading branch information
malessani authored Nov 14, 2024
2 parents bb3714e + fcebe23 commit df8b369
Show file tree
Hide file tree
Showing 11 changed files with 1,225 additions and 703 deletions.
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ orbs:
jobs:
test: # this can be any name you choose
docker:
- image: mcr.microsoft.com/playwright:v1.47.2-focal
- image: mcr.microsoft.com/playwright:v1.48.2-focal
resource_class: medium+
parallelism: 10

Expand Down Expand Up @@ -59,7 +59,7 @@ jobs:

build:
docker:
- image: cimg/node:18.17.0
- image: cimg/node:20.18.0
resource_class: medium
environment:
FOLDER: checkout
Expand All @@ -86,7 +86,7 @@ jobs:

build-on-pci-bucket:
docker:
- image: cimg/node:18.17.0
- image: cimg/node:20.18.0
resource_class: medium
environment:
FOLDER: checkout
Expand Down
9 changes: 8 additions & 1 deletion components/composite/Checkout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const Checkout: React.FC<Props> = ({
let checkoutComSession = ""
let redirectResult = ""
let redirectStatus = ""
let paymentIntentClientSecret = ""

if (query.PayerID) {
paypalPayerId = query.PayerID as string
Expand All @@ -82,11 +83,16 @@ const Checkout: React.FC<Props> = ({
redirectStatus = query.redirect_status as string
}

if (query.payment_intent_client_secret) {
paymentIntentClientSecret = query.payment_intent_client_secret as string
}

const checkoutAlreadyStarted =
!!paypalPayerId ||
!!redirectResult ||
!!checkoutComSession ||
!!redirectStatus
!!redirectStatus ||
!!paymentIntentClientSecret

const { activeStep, lastActivableStep, setActiveStep, steps } =
useActiveStep()
Expand Down Expand Up @@ -207,6 +213,7 @@ const Checkout: React.FC<Props> = ({
},
stripe: {
redirectStatus,
paymentIntentClientSecret,
},
}}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ export const CheckoutCustomerAddresses: React.FC<Props> = ({
{hasCustomerAddresses && (
<>
<Transition
as="div"
show={!showBillingAddressForm}
{...addressesTransition}
>
Expand All @@ -183,6 +184,7 @@ export const CheckoutCustomerAddresses: React.FC<Props> = ({
</>
<div className="top-0 mt-4">
<Transition
as="div"
show={showBillingAddressForm}
beforeEnter={() => setMountBillingAddressForm(true)}
afterLeave={() => setMountBillingAddressForm(false)}
Expand Down Expand Up @@ -236,6 +238,7 @@ export const CheckoutCustomerAddresses: React.FC<Props> = ({
>
<Transition
show={!showShippingAddressForm}
as="div"
{...addressesTransition}
>
<GridContainer className="mb-4">
Expand Down Expand Up @@ -263,6 +266,7 @@ export const CheckoutCustomerAddresses: React.FC<Props> = ({
</div>
<div className="mt-4">
<Transition
as="div"
show={showShippingAddressForm}
beforeEnter={() => setMountShippingAddressForm(true)}
beforeLeave={() => setMountShippingAddressForm(false)}
Expand Down
16 changes: 8 additions & 8 deletions components/data/AppProvider/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,9 @@ export function calculateSettings(
...(isShipmentRequired
? calculateSelectedShipments(prepareShipments(order.shipments))
: {
hasShippingMethod: true,
shipments: [],
}),
hasShippingMethod: true,
shipments: [],
}),
...checkPaymentMethod(order),
returnUrl: order.return_url,
cartUrl: order.cart_url,
Expand All @@ -370,7 +370,7 @@ export function checkPaymentMethod(order: Order) {
let hasPaymentMethod = Boolean(
// @ts-expect-error no type for payment_method
paymentSource?.payment_method?.lenght > 0 ||
paymentSource?.payment_response?.source
paymentSource?.payment_response?.source
)
const paymentRequired = isPaymentRequired(order)
if (!hasPaymentMethod && !paymentRequired) {
Expand Down Expand Up @@ -408,10 +408,10 @@ export function calculateSelectedShipments(
const shipmentsSelected = shipments?.map((shipment) => {
return shipment.shipmentId === payload?.shipmentId
? {
...shipment,
shippingMethodId: payload.shippingMethod.id,
shippingMethodName: payload.shippingMethod.name,
}
...shipment,
shippingMethodId: payload.shippingMethod.id,
shippingMethodName: payload.shippingMethod.name,
}
: shipment
})
const hasShippingMethod = hasShippingMethodSet(shipmentsSelected)
Expand Down
1 change: 0 additions & 1 deletion next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ let nextConfig = {
output: process.env.NODE_ENV === "production" ? "export" : "standalone",
distDir: "out/dist",
poweredByHeader: false,
swcMinify: false,
webpack: (config) => {
return config
},
Expand Down
56 changes: 28 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,43 +72,43 @@
"commercelayer"
],
"dependencies": {
"@commercelayer/js-auth": "^6.6.0",
"@commercelayer/organization-config": "^1.4.9",
"@commercelayer/react-components": "4.15.11",
"@commercelayer/sdk": "6.13.0",
"@faker-js/faker": "^9.0.3",
"@headlessui/react": "^1.7.19",
"@next/bundle-analyzer": "^14.2.14",
"@next/eslint-plugin-next": "^14.2.14",
"@playwright/test": "1.47.2",
"@commercelayer/js-auth": "^6.7.0",
"@commercelayer/organization-config": "^1.4.11",
"@commercelayer/react-components": "4.16.0",
"@commercelayer/sdk": "^6.25.0",
"@faker-js/faker": "^9.2.0",
"@headlessui/react": "^2.2.0",
"@next/bundle-analyzer": "^15.0.3",
"@next/eslint-plugin-next": "^15.0.3",
"@playwright/test": "1.48.2",
"@tailwindcss/forms": "^0.5.9",
"@types/async-retry": "1.4.8",
"@types/node": "^22.7.4",
"@types/react": "^18.3.11",
"@types/react-gtm-module": "^2.0.3",
"@types/node": "^22.9.0",
"@types/react": "^18.3.12",
"@types/react-gtm-module": "^2.0.4",
"@types/styled-components": "^5.1.34",
"async-retry": "^1.3.3",
"autoprefixer": "^10.4.20",
"babel-plugin-macros": "^3.1.0",
"babel-plugin-styled-components": "^2.1.4",
"classnames": "^2.5.1",
"cron-parser": "^4.9.0",
"cronstrue": "^2.50.0",
"cronstrue": "^2.51.0",
"dotenv": "^16.4.5",
"i18next": "^23.15.1",
"next": "^14.2.14",
"i18next": "^23.16.5",
"next": "^15.0.3",
"next-build-id": "^3.0.0",
"next-i18next": "^15.3.1",
"postcss": "^8.4.47",
"postcss": "^8.4.49",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-gtm-module": "^2.0.11",
"react-i18next": "^15.0.2",
"react-router-dom": "^6.26.2",
"react-i18next": "^15.1.1",
"react-router-dom": "^6.28.0",
"styled-components": "^6.1.13",
"tailwindcss": "^3.4.13",
"tailwindcss": "^3.4.14",
"twin.macro": "^3.4.1",
"typescript": "^5.6.2"
"typescript": "^5.6.3"
},
"devDependencies": {
"@semantic-release/changelog": "^6.0.3",
Expand All @@ -120,21 +120,21 @@
"@typescript-eslint/eslint-plugin": "^7.18.0",
"@typescript-eslint/parser": "^7.18.0",
"eslint": "^8.57.0",
"eslint-config-next": "^14.2.14",
"eslint-config-next": "^15.0.3",
"eslint-config-prettier": "^9.1.0",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-n": "^17.10.3",
"eslint-plugin-n": "^17.13.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-promise": "^6.4.0",
"eslint-plugin-react": "^7.37.1",
"eslint-plugin-react": "^7.37.2",
"eslint-plugin-tailwind": "^0.2.1",
"npm-check-updates": "^17.1.3",
"npm-check-updates": "^17.1.11",
"prettier": "^3.3.3",
"semantic-release": "^24.1.2",
"serve": "^14.2.3",
"stylelint": "^16.9.0",
"semantic-release": "^24.2.0",
"serve": "^14.2.4",
"stylelint": "^16.10.0",
"stylelint-config-standard": "^36.0.1"
},
"resolutions": {
Expand All @@ -156,4 +156,4 @@
"path-to-regexp@>=2.0.0 <3.3.0": "=3.3.0"
}
}
}
}
Loading

0 comments on commit df8b369

Please sign in to comment.