@capacitor-community/sumup
Plugin for SumUp Mobile SDK.
Maintainer | GitHub | Social |
---|---|---|
Robin Bedemann | rbedemann |
-
Add plugin to your dependencies
with yarn
yarn add @capacitor-community/sumup
or npm
npm i -S @capacitor-community/sumup
-
Import Plugin in your code
import { Plugins } from '@capacitor/core'; const { SumUp } = Plugins;
-
Setup SumUp Maven repository
In
app/build.gradle
add following lines:allprojects { repositories { maven { url 'https://maven.sumup.com/releases' } } }
-
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) } }) } }
-
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
-
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.