Integrate the Virtual Cards SDK
Integrate the Virtual Cards SDK into your application
Prerequisites
Get Started
Integrate the JS SDK
To use the Virtual Cards SDK in a Web or Node.js project, you must add @sudoplatform/sudo-virtual-cards
as a dependency to your project.
yarn add '@sudoplatform/sudo-virtual-cards'
# or
npm install --save '@sudoplatform/sudo-virtual-cards'
To instantiate and initialize a client in your application, add the following:
import { DefaultApiClientManager } from '@sudoplatform/sudo-api-client'
import { DefaultConfigurationManager } from '@sudoplatform/sudo-common'
import { DefaultSudoVirtualCardsClient } from '@sudoplatform/sudo-virtual-cards'
import { DefaultSudoProfilesClient } from '@sudoplatform/sudo-profiles'
import { DefaultSudoUserClient } from '@sudoplatform/sudo-user'
const sdkConfigJSON = /* ... refer to Users documentation ... */
DefaultConfigurationManager.getInstance().setConfig(sdkConfigJSON)
const userClient = new DefaultSudoUserClient(/* refer to Users documentation */)
const profilesClient = new DefaultSudoProfilesClient(/* refer to Sudos documentation */)
const apiClientManager = DefaultApiClientManager.getInstance().setAuthClient(userClient)
const virtualCardsClient = new DefaultSudoVirtualCardsClient(
apiClientManager,
userClient,
profilesClient
)
Integrate the iOS SDK
To use the Virtual Cards SDK in an iOS app, you need to install the SudoVirtualCards package via Swift Package Manager
Open your project settings in XCode, and go to the Package Dependencies
tab. Click on the +
sign to add a dependency.
Enter the repository URL https://github.com/sudoplatform/sudo-virtual-cards-ios
in the top right search box and select the sudo-virtual-cards-ios
repository.
Select the required version and Add Package
.
Sudo Platform SDKs conform to semantic versioning so in most cases you will leave the Dependency Rule as Up to Next Major Version
to receive regular updates without introducing any breaking changes.
This will resolve the local package dependency and install the latest version of the Virtual Cards SDK.
To instantiate a client in your application, add the following:
import SudoVirtualCards
import SudoProfiles
import SudoUser
let userClient = // ... see "Users" docs
let profilesClient = // ... see "Sudos" docs
do {
let virtualCardsClient = DefaultSudoVirtualCardsClient(
keyNamespace: keyNamespace,
userClient: userClient,
profilesClient: profilesClient
)
} catch {
// Handle initialization error. An error might be thrown due to invalid
// or missing confiugration file.
}s
You only need one client instance for a given user per device. Instantiating multiple clients with the same configuration and using them at the same time may cause unexpected runtime errors to occur.
See it in action. Be sure to take a look at the open source iOS sample app on Github that our team published as a reference for integrating the Virtual Cards SDK into your app as quickly and seamlessly as possible.
Integrate the Android SDK
The Android SDK is open source and compatible with Android 6 (API level 23) and above.
Add this line to the dependencies section of the app module build.gradle
and synchronize your project with Android Studio.
dependencies {
implementation 'com.sudoplatform:sudovirtualcards:$latest_version'
// For Stripe funding source. https://github.com/stripe/stripe-android
implementation 'com.stripe:stripe-android:20.5.0'
// For Checkout funding source. https://github.com/checkout/frames-android
implementation 'com.github.checkout:frames-android:3.1.2'
}
To instantiate a client in your application, add the following
val userClient = // ... see "Users" docs
val profilesClient = // ... see "Sudos" docs
val virtualCardsClient = SudoVirtualCardsClient.builder()
.setContext(appContext)
.setSudoUserClient(userClient)
.setSudoProfilesClient(profilesClient)
.build()
You only need one client instance for a given user per device. Instantiating multiple clients with the same configuration and using them at the same time may cause unexpected runtime errors to occur.
See it in action. Be sure to take a look at the open source Android sample app on Github that our team published as a reference for integrating the Virtual Cards SDK into your app as quickly and seamlessly as possible.
Last updated