Skip to content

rbedemann/capacitor-sumup-plugin

Repository files navigation


SumUp

@capacitor-community/sumup

Plugin for SumUp Mobile SDK.


Maintainers

Maintainer GitHub Social
Robin Bedemann rbedemann

Installation

Web application

  1. Add plugin to your dependencies

    with yarn

    yarn add @capacitor-community/sumup

    or npm

    npm i -S @capacitor-community/sumup
  2. Import Plugin in your code

    import { Plugins } from '@capacitor/core';
    
    const { SumUp } = Plugins;

Android

  1. Setup SumUp Maven repository

    In app/build.gradle add following lines:

    allprojects {
       repositories {
          maven { url 'https://maven.sumup.com/releases' }
       }
    }
  2. Add Plugin to your app's MainActivity

    In Java:

    public class MainActivity extends BridgeActivity {
      @Override
      public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    
        // Initializes the Bridge
        this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
          // Additional plugins you've installed go here
          // Ex: add(TotallyAwesomePlugin.class);
          add(SumUp.class);
        }});
      }
    }

    Or Kotlin:

    class MainActivity : BridgeActivity() {
        public override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
    
            // Initializes the Bridge
            this.init(savedInstanceState, object : ArrayList<Class<out Plugin?>?>() {
                init {
                    // Additional plugins you've installed go here
                    // Ex: add(TotallyAwesomePlugin.class);
                    add(SumUp::class.java)
                }
            })
        }
    }

Usage

  1. Login

    SumUp.login({
      affiliateKey: "<< YOUR AFFILIATE KEY >>",
    
      // optional: Login Screen will be shown every time, if not provided
      accessToken: "<< ACCESS TOKEN >>",
    })
    .then((loginResponse: SumUpResponse) => {})

    Get your affiliate key here and find out more about how to generate an access token in SumUps official documentation

  2. Initiate a checkoout (Login required)

    SumUp.checkout(
       {
          title: 'Test checkout', 
          total: 100.50, 
          currency: 'EUR',   
          skipSuccessScreen: true,
          additionalInfo: {
            title: 'Booking 1'
          }
       } as CheckoutOptions
    ).then((r: SumUpResponse) => {
     // Checkout completed           
    })
    .catch((r: SumUpResponse) => {   
     // Checkout failed
    })

    Find a detailed description of possible parameters in SumUp's documentation.