React Native Stripe binding for iOS/Android platforms
before 5.0.0:
// somewhere in the app start section
stripe.init({
merchantId: '<MERCHANT_ID>',
publishableKey: '<PUB_KEY>',
androidPayMode: 'test',
})
stripe.paymentRequestWithAndroidPay(paymentOptions)
after 5.0.0:
// same as above except used method name
stripe.setOptions({
merchantId: '<MERCHANT_ID>',
publishableKey: '<PUB_KEY>',
androidPayMode: 'test',
})
stripe.paymentRequestWithAndroidPay(paymentOptions)
// somewhere in the app start section
// make sure you've set androidPayMode before using androidPay related methods i.e.
// stripe.deviceSupportsAndroidPay()
// stripe.paymentRequestWithAndroidPay()
// or runtime exception will be thrown
stripe.setOptions({
androidPayMode: 'test',
})
// somewhere else later i.e. near store cart code
stripe.setOptions({
publishableKey: '<PUB_KEY>',
})
// make sure you've set *all* needed options before, both androidPayMode and publishableKey
// or exception will be thrown
stripe.paymentRequestWithAndroidPay(paymentOptions)
before 5.0.0:
// you couldn't before set billing_address_required, shipping_address_required options
// to require user filling that data. shipping_address_required was true by default
// and such data was missing in the method response (useless user input)
stripe.paymentRequestWithAndroidPay(paymentOptions)
after 5.0.0:
// explicitly set required input from user by
// setting billing_address_required, shipping_address_required props,
// omitted values are false by default
const addressRequirements = {
billing_address_required: false,
shipping_address_required: true,
}
stripe.paymentRequestWithAndroidPay({
paymentOptions,
...addressRequirements,
})
shippingContact
, billingContact
appear are in results of paymentRequestWithAndroidPay()
setOptions()
performs multi-step initialization and used instead of init()
. Options publishableKey
, androidPayMode
are settable at runtime. If method requires presence of options that are unset, runtime exception will be thrown. Special case: androidPayMode
re-init is forbidden and leads to runtime exception.StripeModule
StripeModule
Activity NPE