ScandiPWA
Create Magento AppCreate ScandiPWA AppUser ManualGitHub
  • Why Scandi
  • πŸš€Quick-start Guide
  • πŸ—ΊοΈRoadmap
  • Introduction to the Stack
    • CMA, CSA, and ScandiPWA
    • Challenges
  • Setting up Scandi
    • Storefront Mode Setup
      • Proxying requests to server
    • Magento Mode Setup
    • Existing Magento 2 setup
    • Magento Commerce Cloud setup
    • Updating to new releases
      • Storefront mode upgrade
      • Magento mode upgrade
      • CMA upgrade
      • CSA upgrade
      • Custom ScandiPWA composer dependency update
      • Local ScandiPWA Composer Package Setup
    • Docker Setup [deprecated]
      • Legacy Docker setup
      • Migrating to CMA & CSA
  • Developing with Scandi
    • Override Mechanism
      • Overriding JavaScript
        • Overriding classes
        • Overriding non-classes
      • Overriding Styles
      • Overriding the HTML / PHP
      • Parent Themes
    • Extensions
      • Creating an extension
      • Installing an extension
      • Migrating from 3.x to 4.x
      • Publishing an extension
      • Extension Terminology
    • Working With Magento
      • Magento troubleshooting
      • Working with Magento modules
      • Working with GraphQL
      • GraphQL Security
      • Working with "granular cache"
    • Developer Tools
      • Debugging in VSCode
      • ScandiPWA CLI
      • Configuring ESLint
      • CSA Commands
    • Deploying Your App
      • Build & Deploy Android app
      • Build & Deploy iOS app
  • Structure
    • Directory Structure
    • Building Blocks
      • Components
        • Styling Components
      • Routes
      • Redux Stores
      • GraphQL Queries
      • Global Styles
      • The Util Directory
      • Type Checking
    • Application assets
    • Code Style
      • JavaScript Code Style
      • SCSS Code Style
  • Tutorials
    • Customizing Your Theme
      • Styling
        • Customizing the Global Styles
        • Adding a New Font
        • Overriding a Components Styles
        • Extending a Component's Styles
      • Customizing JavaScript
        • Customizing the Footer Copyright
        • Adding a New Page
        • Adding a Section in My Account
        • Adding a Tab on the Product Page
        • Creating a New Redux Store
    • Payment Method Integration
      • Setting Up for Development
      • Redirecting to the Payment Provider
      • Handling the Customer's Return
    • Creating a Custom Widget
      • Scandi CMS System Overview
      • Creating a Magento Widget
      • Implementing the Rendering
    • Video Tutorials
      • #1 Setting up and talking theory
      • #2 Templating in React
      • #3 Overriding a file
      • #4 Styling the application
      • #5 Patterns of ScandiPWA
    • Dark Mode Extension
    • Deploying Native Apps
    • Product 3D Model Extension
      • Part 1: Magento 3D Model Uploads
      • Part 2: GraphQL API
      • Part 3: Scandi Frontend
    • Social Share, Full Extension Development
      • STEP-1 and 2 Creating Magento 2 Module
      • STEP-3 Backend Configurations Settings
      • STEP-4 Simple GraphQl and Resolver
      • STEP-5 Creating Extension, Base Redux Store
      • STEP-6 Extension plugins
      • STEP-7 GraphQL types, Helpers
      • STEP-8 Query Field and FieldList
      • STEP-9 render Plugins and MSTP Plugin, Component creation
      • STEP-10 SocialShare Component Development
      • STEP-11 SocialShare for CategoryPage
      • TASK-1 Changing LinkedIn to Twitter
      • STEP-12 Comments for Admin Users
      • STEP-13 Final, bugfixes
    • Accessing Magento 2 Controllers
      • STEP-1 Creating Magento 2 Module
      • STEP-2 - Create Magento 2 Frontend Route and Basic Controller
      • STEP-3 Accessing Magento 2 Controller, Bypassing ScandiPWA frontend
      • STEP-4 Creating ScandiPWA Extension with additional dependencies
      • STEP-5 Creating Plugin and Axios request
  • About
    • Support
    • Release notes
    • Technical Information
    • Data Analytics
    • Contributing
      • Installation from Fork
      • Repository structure
      • Code contribution process
      • Submitting an Issue
      • Publishing ScandiPWA
Powered by GitBook
On this page
  • Creating a New App
  • Setting up the Payment Extension
  • Sigh... Webhooks
  • Using ngrok

Was this helpful?

  1. Tutorials
  2. Payment Method Integration

Setting Up for Development

Before you can start working on the Scandi integration, you need to set up a local environment

Creating a New App

First, make sure you have a working Magento app with Scandi installed. The easiest way to get this setup is by using create-magento-app with create-scandipwa-app!

Next, since we want to create a reusable extension that can be installed on multiple projects, we can initialize it with a single command. After checking that you have the scandipwa CLI utility installed, navigate to your theme's root directory and enter this command:

(don't forget to replace your-payment-provider with the actual payment provider name!)

scandipwa extension create your-payment-provider-scandi

This will automatically create a new extension, including some boilerplate configuration to get you started. It will also install the extension into your app.

Setting up the Payment Extension

In most cases, you'll also want to install the Magento payment integration extension. While it might not provide out-of-the-box support for working with Scandi, it will already include most of the payment logic that you need for the integration.

Next, you'll need to configure the extension. The configuration will vary across providers, but you'll most likely have to log in to your account on the payment provider's website to copy some credentials into your Magento configuration – check the extension's documentation for more details!

In our example, Mollie needs us to enter a few authentication secrets to connect the extension to the Mollie account. We also need to enable the different payment methods supported by Mollie.

Be sure to also enable test mode in the extension. This will allow you to ensure your extension is working correctly without needing to make real payments.

It might be a good idea to get an idea of how the Magento extension works before starting work on your Scandi integration. You could simply switch the theme to Luma and complete a

Sigh... Webhooks

Many payment workflows involve webhooks. Webhooks allow a third-party server (in this case the payment provider) to notify your Magento app when something of interest has happened – for example, when a payment has been completed or canceled.

Crucially, since the payment providers' servers need to be able to notify your app, the URL needs to be accessible to them. This means that you can't simply keep your app on localhost, because then your computer is the only one that can access the website. And of course, the payment provider isn't running on your computer, so they can't access your app.

Fortunately, there is a workaround! You can tunnel traffic from a publicly accessible address to your locally-running app. ngrok is a tool that allows you to do it for free.

Using ngrok

./ngrok http 80 --region eu

Note: the --region parameter is optional, but your requests might be faster if you specify a region that is close to where you are.

Now, your local app will be available to anyone that knows the ngrok URL – which will be displayed after running the above command. And "anyone" includes the payment service provider, so webhooks will work!

PreviousPayment Method IntegrationNextRedirecting to the Payment Provider

Last updated 3 years ago

Was this helpful?

First, , and install the ngrok tool. Configure ngrok as specified in the instructions on their website. Then, you should be able to create a tunnel from a public .ngrok.io URL to your localhost. The easiest way is to create a HTTP tunnel:

Don't forget to update the Magento base_url to the new ngrok URL. Otherwise, you'll keep getting redirected to your address.

create a ngrok account
localhost