your-project-name/ios/Podfile. Add "Payments" to your Podfile's subspecs. Example:
... target 'your-project-name' do pod 'ExpoKit', :git => "", :subspecs => [ "Core", "CPP", # Add a comma here! "Payments" # Add this line here! ] pod 'React', ...
pod installin
your-project-name/ios. This will add the Payments module files to your project and the corresponding dependencies.
import { DangerZone } from 'expo'; const { Payments } = DangerZone;
payments.initialize({ publishableKey: 'PUBLISHABLE_KEY' // Your Stripe publishable key })
paymentRequestWithApplePayAsyncand
createTokenWithCardAsync) to the Stripe API.
token
tokenIdString - The value of the token. You can store this value on your server and use it to make charges and customers.
createdNumber - When the token was created.
livemodeNumber - Whether or not this token was created in livemode. Will be
1if you used your
Live Publishable Key, and
0if you used your
Test Publishable Key.
cardObject - The credit card details object that were used to create the token.
bankAccountObject - The external (bank) account details object that were used to create the token.
extraObject (iOS only)- An additional information that method can provide.
card
cardIdString - The Stripe ID for the card.
brandString - The card’s brand. Can be one of:
JCB|
American Express|
Visa|
Discover|
Diners Club|
MasterCard|
Unknown.
fundingString (iOS only) - The card’s funding. Can be one of:
debit|
credit|
prepaid|
unknown.
last4String - The last 4 digits of the card.
dynamicLast4String (iOS only) - For cards made with
Apple Pay, this refers to the last 4 digits of the
Device Account Numberfor the tokenized card.
isApplePayCardBool (iOS only) - Whether or not the card originated from Apple Pay.
expMonthNumber - The card’s expiration month. 1-indexed (i.e. 1 == January)
expYearNumber - The card’s expiration year.
countryString - Two-letter ISO code representing the issuing country of the card.
currencyString - This is only applicable when tokenizing debit cards to issue payouts to managed accounts. The card can then be used as a transfer destination for funds in this currency.
nameString - The cardholder’s name.
addressLine1String - The cardholder’s first address line.
addressLine2String - The cardholder’s second address line.
addressCityString - The cardholder’s city.
addressStateString - The cardholder’s state.
addressCountryString - The cardholder’s country.
addressZipString - The cardholder’s zip code.
{ tokenId: 'tok_19GCAQI5NuVQgnjeKNE32K0p', created: 1479236426, livemode: 0, card: { cardId: 'card_19GCAQI5NuVQgnjeRZizG4U3', brand: 'Visa', funding: 'credit', last4: '4242', expMonth: 4, expYear: 2024, country: 'US', name: 'Eugene Grissom', addressLine1: 'Green Street', addressLine2: '3380', addressCity: 'Nashville', addressState: 'Tennessee', addressCountry: 'US', addressZip: '37211', }, }
trueif the device supports making payments; otherwise,
false.
true
Apple Payview to accept payment.
labelString - A short, localized description of the item.
amountString - The summary item’s amount.
requiredBillingAddressFieldsString - A bit field of billing address fields that you need in order to process the transaction. Can be one of:
all|
name|
phone|
requiredShippingAddressFieldsString - A bit field of shipping address fields that you need in order to process the transaction. Can be one of:
all|
name|
phone|
shippingMethodsArray - An array of
shippingMethodobjects that describe the supported shipping methods.
currencyCodeString - The three-letter ISO 4217 currency code.
idString - A unique identifier for the shipping method, used by the app.
labelString - A short, localized description of the shipping method.
detailString - A user-readable description of the shipping method.
amountString - The shipping method’s amount.
requiredBillingAddressFieldsyou should complete the operation by calling
completeApplePayRequestor cancel if an error occurred. This closes Apple Pay. (resolves to undefined, you do not need to store the Promise)
extrafield
shippingMethodObject - Selected
shippingMethodobject.
billingContactObject - The user's billing
contactobject.
shippingContactObject - The user's shipping
contactobject.
nameString - The contact’s name.
phoneNumberString - The contact’s phone number.
streetString - The street name in a postal address.
cityString - The city name in a postal address.
stateString - The state name in a postal address.
countryString - The country name in a postal address.
ISOCountryCodeString - The ISO country code for the country in a postal address.
supplementarySubLocalityString - The contact’s sublocality.
const items = [{ label: 'T-Shirt', amount: '50.00', }, { label: 'Expo, Inc', amount: '50.00', }] const shippingMethods = [{ id: 'fedex', label: 'FedEX', detail: 'Test @ 10', amount: '10.00', }] const options = { requiredBillingAddressFields: 'all', requiredShippingAddressFields: 'all', shippingMethods, } const token = await payments.paymentRequestWithApplePayAsync(items, options) // Client specific code // api.sendTokenToBackend(token) // You should complete the operation by calling payments.completeApplePayRequestAsync() // Or cancel if an error occurred // payments.cancelApplePayRequestAsync()
options
requiredBillingAddressFieldsString - The billing address fields the user must fill out when prompted for their payment details. Can be one of:
full|
zipor not specify to disable.
prefilledInformationObject - You can set this property to pre-fill any information you’ve already collected from your user.
smsAutofillDisabledBool - When entering their payment information, users who have a saved card with Stripe will be prompted to autofill it by entering an SMS code. Set this property to
trueto disable this feature.
themeObject - Can be used to visually style Stripe-provided UI.
prefilledInformation
phoneString - The user’s phone number.
billingAddressObject - The user’s billing address. When set, the add card form will be filled with this address.
billingAddress
nameString - The user’s full name (e.g. "Jane Doe").
line1String - The first line of the user’s street address (e.g. "123 Fake St").
line2String - The apartment, floor number, etc of the user’s street address (e.g. "Apartment 1A").
cityString - The city in which the user resides (e.g. "San Francisco").
stateString - The state in which the user resides (e.g. "CA").
postalCodeString - The postal code in which the user resides (e.g. "90210").
countryString - The ISO country code of the address (e.g. "US").
phoneString - The phone number of the address (e.g. "8885551212").
theme
primaryBackgroundColorString - The primary background color of the theme.
secondaryBackgroundColorString - The secondary background color of this theme.
primaryForegroundColorString - The primary foreground color of this theme. This will be used as the text color for any important labels in a view with this theme (such as the text color for a text field that the user needs to fill out).
secondaryForegroundColorString - The secondary foreground color of this theme. This will be used as the text color for any supplementary labels in a view with this theme (such as the placeholder color for a text field that the user needs to fill out).
accentColorString - The accent color of this theme - it will be used for any buttons and other elements on a view that are important to highlight.
errorColorString - The error color of this theme - it will be used for rendering any error messages or view.
const options = { smsAutofillDisabled: true, requiredBillingAddressFields: 'full', prefilledInformation: { billingAddress: { name: 'Gunilla Haugeh', line1: 'Canary Place', line2: '3', city: 'Macon', state: 'Georgia', country: 'US', postalCode: '31217', }, }, } const token = await Payments.paymentRequestWithCardFormAsync(options) // Client specific code // api.sendTokenToBackend(token)
numberString (Required) - The card’s number.
expMonthNumber (Required) - The card’s expiration month.
expYearNumber (Required) - The card’s expiration year.
cvcString - The card’s security code, found on the back.
nameString - The cardholder’s name.
addressLine1String - The first line of the billing address.
addressLine2String - The second line of the billing address.
addressCityString - City of the billing address.
addressStateString - State of the billing address.
addressZipString - Zip code of the billing address.
addressCountryString - Country for the billing address.
brandString (Android only) - Brand of this card. Can be one of:
JCB|
American Express|
Visa|
Discover|
Diners Club|
MasterCard|
Unknown.
last4String (Android only) - last 4 digits of the card.
fingerprintString (Android only) - The card fingerprint.
fundingString (Android only) - The funding type of the card. Can be one of:
debit|
credit|
prepaid|
unknown.
countryString (Android only) - ISO country code of the card itself.
currencyString - Three-letter ISO currency code representing the currency paid out to the bank account. This is only applicable when tokenizing debit cards to issue payouts to managed accounts. You should not set it otherwise. The card can then be used as a transfer destination for funds in this currency.
const params = { // mandatory number: '4242424242424242', expMonth: 11, expYear: 17, cvc: '223', // optional name: 'Test User', currency: 'usd', addressLine1: '123 Test Street', addressLine2: 'Apt. 5', addressCity: 'Test City', addressState: 'Test State', addressCountry: 'Test Country', addressZip: '55555', } const token = await stripe.createTokenWithCardAsync(params) // Client specific code // api.sendTokenToBackend(token)
payments.initialize({ publishableKey: 'PUBLISHABLE_KEY', // Your Stripe publishable key merchantId: 'MERCHANT_ID' // Your Apple Pay merchant ID })