npm i -S capacitor-stripe
import { Plugins } from '@capacitor/core';
const { Stripe } = Plugins;
Stripe.setPublishableKey({ key: 'Your key here' });
This plugin requires @capacitor/android@2.0.0
or higher as it relies on Android X support.
Include the plugin in your app’s MainActivity.java
file:
//
// other imports
// ...
// 1. Import Stripe plugin
import ca.zyra.capacitor.stripe.Stripe;
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>>() {{
//
// other plugins
// ...
// 2. Add Stripe plugin here
add(Stripe.class);
}});
}
}
To enable payments using Google Pay you must add the following <meta-data>
tag to AndroidManifest.xml
inside the
main <application />
tag:
<application
...
<meta-data
android:name="com.google.android.gms.wallet.api.enabled"
android:value="true" />
</application>
There is no need to add any Gradle dependencies as they are already included with this plugin.
Please review the steps outlined here for more details on Going live with Google Pay.
To enable payments using Apple Pay you must follow the first 3 steps in this guide: