1.0.6 • Published 4 years ago

@hptest/hptest-new-test v1.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

react-native-chargebee

React Native wrapper for rendering a Chargebee hosted checkout page within a WebView component.

Installation

yarn add @chargebee/react-native-chargebee

Dependencies

To successfully use this package, you need react native webview with version >= 8.1.1

yarn add "react-native-webview"

Usage

The package comes with type definition which you can use to see the list of allowed props.

For site, use the Chargebee site name. For example, if the Chargebee domain is 'honey-comics.chargebee.com', then the site name is honey-comics. For planName, use the Chargebee plan ID. For example, if the plan name is 'Annual Comic Subscription', the plan ID might be something like annual-comic-subs.

import { CheckoutCart } from "@chargebee/react-native-chargebee";

// ...

<CheckoutCart
  success={(hostedPageId: string) => successfulPurchase(hostedPageId)}
  step={(stepName: string) => handleStep(stepName)}
  site={site}
  planName={planName}
  couponIds={couponIds}
  addons={addons}
  customer={customer}
  subscription={subscription}
  billingAddress={billingAddress}
/>

Example

The base repository includes a sample application that shows the props accepted by the component.

The example app showcases the various options that can be passed.

To install the base dependencies, run yarn bootstrap in the root directory:

yarn bootstrap

To start the packager:

yarn example start

To run the example app on Android:

yarn example android

To run the example app on iOS:

yarn example ios

Properties

The properties that can be passed to the CheckoutCart component are:

PropRequiredTypeDescription
siteYesStringName of the chargebee hosted site
planNameYesStringName of the plan user is purchasing
addonsNoAddon[]Parameters for addons. Multiple addons can be passed. Fields are listed below
couponIdsNoString[]Identifier of the coupon as a List. Coupon Codes can also be passed
customerNoCustomerDetails about the customer that needs to be prefilled in checkout. Fields are listed below
subscriptionNoSubscriptionDetails about the subscription. Fields listed below
billingAddressNoAddressBilling address of the customer. Fields listed below
shippingAddressNoAddressShipping address of the customer. Fields listed below

Addon

PropRequiredTypeDescription
idYesstringIdentifier of the addon
quantityNointeger default=1, min=1Addon quantity. Applicable only for the quantity based addons

Customer

PropRequiredTypeDescription
emailNostring max chars=70Email of the customer. Configured email notifications will be sent to this email.
firstNameNostring max chars=150First name of the customer. If not provided it will be got from contact information entered in the hosted page .
lastNameNostring max chars=150Last name of the customer. If not provided it will be got from contact information entered in the hosted page .
companyNostring max chars=250Company name of the customer.
localeNoString max chars=50Determines which region-specific language Chargebee uses to communicate with the customer. In the absence of the locale attribute, Chargebee will use your site's default language for customer communication.
phoneNoString max chars=50Phone number of the customer.
vat_numberNoString max chars=20VAT/ Tax registration number of the customer. Learn more.

Subscription

PropRequiredTypeDescription
planQuantityNointeger default=1, min=1Plan quantity for this subscription.
startDateNointeger timestamp(UTC) in secondsAllows you to specify a future date or a past date on which the subscription starts.Past dates can be entered in case the subscription has already started. Any past date entered must be within the current billing cycle/plan term. The subscription will start immediately if this parameter is not passed.

Address

PropRequiredTypeDescription
firstNameNoString max chars=150First name.
lastNameNoString max chars=150Last name.
emailNoString max chars=70Email.
companyNoString max chars=250Company name.
phoneNoString max chars=50Phone number.
line1NoString max chars=150Address line 1.
line2NoString max chars=150Address line 2.
line3NoString max chars=150Address line 3.
cityNoString max chars=50City.
stateCodeNoString max chars=50The ISO 3166-2 state/province code without the country prefix. Currently supported for USA, Canada and India. For instance, for Arizona ( USA), set the stateCode as AZ (not US-AZ). or, for Tamil Nadu (India), set the stateCode as TN (not IN-TN). or, for British Columbia (Canada), set the stateCode as BC (not CA-BC). Note: If the 'stateCode' is specified, the 'state' attribute should not be provided as Chargebee will set the value automatically (for US, Canada, India).
stateNoString max chars=50The state/province name. Use this to pass the state/province information for cases where 'stateCode' is not supported or cannot be passed.
zipNoString max chars=20Zip or Postal code.
countryNoString max chars=502-letter ISO 3166 alpha-2 country code.

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

Chargebee is available under the MIT license. See the LICENSE file for more info.

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago