Git Product home page Git Product logo

vsf-payment-klarna's Introduction

vsf-payment-klarna for VSF 1.11

Frontend

Installation

  • Copy packages/payment-klarna to src/modules/payment-klarna
  • Update modules/client.ts with the following:
    import { KlarnaCheckout } from './payment-klarna'
    ...
    export const registerModules: VueStorefrontModule[] = [
      ...,
      KlarnaCheckout
    ]
    

Config

See config.json for example config

klarna.create

Endpoint for creating order (vsf-api)

klarna.confirmation

Endpoint for retrieving Klana confirmation snippet (vsf-api)

klarna.validate_order

Endpoint called when order total changes (vsf-api)

klarna.showShippingOptions

If set to true available shipping methods will be sent to Klarna and enable Klarnas shipping method form

klarna.options

https://developers.klarna.com/api/#checkout-api__create-a-new-order__options

Some plugins might use other keys

Checkout

In theme/pages/Checkout.vue

import KCO from 'src/modules/payment-klarna/components/KlarnaCheckout'

export {
  ...,
  components: {
    klarna-checkout: KCO
  }
}

And then just <klarna-checkout /> where you want to render it

Confirmation page

Will be found at www.example.com/confirmation and www.example.com/STORECODE/confirmation

See beforeRegistration.ts for more info

Plugins

If you need to extend this library you most likely don't need to fork it, just create a plugin!

There's a few default plugins already made. See the plugins folder for README and inspiration.

API

Installation

  • Copy packages/payment-klarna-bridge to src/api/extensions/payment-klarna-bridge
  • Add payment-klarna-bridge to registeredExtensions in local.json

Config

See config.json for example config

klarna.merchant_urls

Klarna docs: https://developers.klarna.com/api/#checkout-api__create-a-new-order__merchant_urls

Alongside Klarnas variables ({checkout.order.id}, {checkout.order.url} and/or {checkout.order.uri}) you can also use {{sourceCode}} which will be replaced currentStoreView().storeCode and {{dataSourceCode}} which will be replaced currentStoreView().dataSourceCode (useful if you need a different field for the url).

klarna.auth

Your Klarna auth credentials

"auth": {
  "user": "PK0123_something",
  "pass": "password"
},

klarna.endpoints

"endpoints": {
  "order": "https://api.something.klarna.com", // pick from https://developers.klarna.com/api/#api-urls
  // TODO: Integrate to magento2-vsf-kco module
  "validate_order": "" // will be called when total amount changes
},

https://developers.klarna.com/api/#api-urls

Magento 2

Please use this module: https://github.com/kodbruket/magento2-vsf-kco

Development

Requirements

Protip: On Mac run, install Docker and Brew then run brew install node && brew install yarn && brew install docker-compose

Get started

git clone --recurse-submodules https://github.com/kodbruket/vsf-payment-klarna
cd vsf-payment-klarna
yarn # set up git hooks
docker-compose up
# new tab
make es-restore # seed Magento catalog data

Visit http://localhost:3000

e2e

yarn cypress

Tunnel

ssh -R vsf-payment-klarna:80:localhost:8080 serveo.net

vsf-payment-klarna's People

Contributors

anhuy1989 avatar benjick avatar dependabot[bot] avatar didkan avatar natalia-reyveys avatar phongphanmage avatar sn00k avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vsf-payment-klarna's Issues

Cors blocking

Hi,

I thought this project would be more of a simple module. I followed the instructions, and when klarna did not display on checkout, I extracted all of the respective contents to each respective file and folder on a new vsf project, but encountered cors blocking any requests from the requested resource (Which is klarna in this case) upon checkout.

Has this project been tested on live production?

An idea is to create preflight guide https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS in your doc. The instructions are just plain commands and not really super instructive on what to do.

Further on the contents in the repo is highly unorganised, making no sense of why the VSF project is linked inside your repo and there's another folder named API containing what I believe is your project containing the klarna API data and config file running on the default vsf port 8080.

Even following your commands will launch a vsf project but will not display any klarna checkout when adding products to shopping cart and checking out.

I recommend to add more detailed information, step by step on how to get klarna checkout working upon checkout with vsf. I would love to help but as of now I have a hard time understanding how to make this properly work upon checkout.

The only result i get upon checkout is "Loading".

storefront_ui docker doesn't start up

I tried including the KlarnaCheckout in my project but I'm stuck at a certain point, so I thought let's give your example a good look.

But when trying to docker-compose up, the storefront_ui container crashes after successfully building. Here's its last words:

...
storefront-ui_1   | <s> [webpack.Progress] 100% 
storefront-ui_1   | 
storefront-ui_1   | Hash: 9f5d9ecbd18cb1aa32f1
storefront-ui_1   | Version: webpack 4.39.0
storefront-ui_1   | Time: 122411ms
storefront-ui_1   | Built at: 08/02/2019 10:41:43 AM
storefront-ui_1   |  46 assets
storefront-ui_1   | Entrypoint app = manifest.9f5d9ecbd18cb1aa32f1.js vendor.9f5d9ecbd18cb1aa32f1.js app.9f5d9ecbd18cb1aa32f1.js
storefront-ui_1   | 
storefront-ui_1   | ERROR in ./src/modules/payment-klarna/hooks/beforeRegistration.ts
storefront-ui_1   | Module not found: Error: Can't resolve '@vue-storefront/core/lib/router-manager' in '/var/www/src/modules/payment-klarna/hooks'
storefront-ui_1   |  @ ./src/modules/payment-klarna/hooks/beforeRegistration.ts 2:0-72 19:4-17 21:4-17
storefront-ui_1   |  @ ./src/modules/payment-klarna/index.ts
storefront-ui_1   |  @ ./src/modules/index.ts
storefront-ui_1   |  @ ./core/modules-entry.ts
storefront-ui_1   |  @ ./core/app.ts
storefront-ui_1   |  @ ./core/client-entry.ts
storefront-ui_1   |  @ multi babel-polyfill ./core/client-entry.ts
storefront-ui_1   | 
storefront-ui_1   | ERROR in /var/www/src/modules/payment-klarna/hooks/beforeRegistration.ts
storefront-ui_1   | [tsl] ERROR in /var/www/src/modules/payment-klarna/hooks/beforeRegistration.ts(2,31)
storefront-ui_1   |       TS2307: Cannot find module '@vue-storefront/core/lib/router-manager'.
storefront-ui_1   | 
storefront-ui_1   | ERROR in /var/www/src/modules/payment-klarna/store/getters.ts
storefront-ui_1   | [tsl] ERROR in /var/www/src/modules/payment-klarna/store/getters.ts(12,37)
storefront-ui_1   |       TS2345: Argument of type '{ name: string; fullPath: any; params: { parentSku: any; slug: any; childSku: any; }; }' is not assignable to parameter of type 'string | Route'.
storefront-ui_1   |   Type '{ name: string; fullPath: any; params: { parentSku: any; slug: any; childSku: any; }; }' is missing the following properties from type 'Route': path, hash, query, matched
storefront-ui_1   | Child html-webpack-plugin for "index.amp.html":
storefront-ui_1   |      1 asset
storefront-ui_1   |     Entrypoint undefined = index.amp.html
storefront-ui_1   | Child html-webpack-plugin for "index.basic.html":
storefront-ui_1   |      1 asset
storefront-ui_1   |     Entrypoint undefined = index.basic.html
storefront-ui_1   | Child html-webpack-plugin for "index.html":
storefront-ui_1   |      1 asset
storefront-ui_1   |     Entrypoint undefined = index.html
storefront-ui_1   | Child html-webpack-plugin for "index.minimal.html":
storefront-ui_1   |      1 asset
storefront-ui_1   |     Entrypoint undefined = index.minimal.html
storefront-ui_1   | error Command failed with exit code 2.
storefront-ui_1   | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
vsf-payment-klarna_storefront-ui_1 exited with code 1

Any ideas?

PS: Some env info:

  • tried master@ea1bd082791e9ec6970b3a6fc9cd8977210f04fb
  • docker-compose version 1.22.0, build f46880fe
  • Docker version 18.06.1-ce, build e68fc7a
  • OS: Debian GNU/Linux 8.7 (jessie)

module for klarna payments

Greetings
klarna checkout is not working for production mode
is there a module for vsf which works with klarna payment?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.