capacitor-community / stripe

Stripe Mobile SDK wrapper for Capacitor
MIT License
186 stars 74 forks source link

you must provide a valid key #3

Closed josebyte closed 4 years ago

josebyte commented 4 years ago

I get "you must provide a valid key" error in the setPlubishableKey catch. I'm using "capacitor-stripe": "^0.4.0" and my code: ngOnInit() { this.setPublishKey(); }

async setPublishKey() { await StripePlugin.setPublishableKey('pk_test_XFbXPA2KAKbhaMOllskUKEzx00A3eqpr8y').then((message) => { console.log(message); }).catch((error) => { console.log(error); }); }

What should I do?

ihadeed commented 4 years ago

You need to pass the key in an object:

StripePlugin.setPublishableKey({ key: 'your key here' })
josebyte commented 4 years ago

Thanks! I take it from the usage example:

INITIALIZING THE PLUGIN
import { Plugins } from '@capacitor/core';
const { Stripe } = Plugins;
...
await Stripe.setPublishableKey('pk_test_....');

If you want maybe I can help you with the documentation.