Manage Funding Sources

Provides the essentials for a user to link their real payment methods with a virtual card.

Funding sources supply the means for a user to link a real funding source with a virtual card. A user can supply their credit or debit card as a method to fund a transaction performed on the virtual card.

Creating a Funding Source

A funding source is created by invoking a series of steps from the retrieval of funding source configuration to setup and completion of the creation process.

circle-info

Before creating a funding source, the identity of your user must first be verified via Secure Id Verification.

To begin the process of creating a funding source, call the setupFundingSource method. The funding source providers that your client application supports will inform which provider names you provide to the setupFundingSource method call. The funding source provider supported by the Virtual Cards service is stripe. You must also provide the name of your application to the setupFundingSource method. This name forms part of a shared configuration between your application, the Virtual Cards service, and any third party funding source providers you have a relationship with. Contact usarrow-up-right if you are not certain what application name to use.

Card based Funding Source

circle-exclamation
try {
  const provisionalFundingSource = await virtualCardsClient.setupFundingSource({
    currency: 'USD',
    type: FundingSourceType.CreditCard,
    applicationName: 'yourApplicationName',
    // include only the provider(s) you will support
    supportedProviders: ['stripe'],
  })
} catch (error) {
  // Handle/notify user of errors
}

The call to setupFundingSource will return a ProvisionalFundingSource containing provisioning data required to continue the funding source creation process. To continue, you must use the Stripe API to progress the funding source setup.

Retrieve the provider API key as well as other information pertaining to the funding source provider using the getFundingSourceClientConfiguration method:

try {
  const configuration = 
      await virtualCardsClient.getFundingSourceClientConfiguration()
  // [configuration] contains the list of funding source client configuration.
} catch (error) {
  // Handle/notify user of errors
}

Stripe Funding Source Preparation

circle-info

For Stripe React integration, see the documentation at:

https://stripe.com/docs/stripe-js/reactarrow-up-right

For Stripe JavaScript integration, see the documentation at:

https://stripe.com/docs/jsarrow-up-right

To setup a payment intent in Stripe, call StripeClient.confirmSetupIntent(confirmSetupIntentParams: ConfirmSetupIntentParams) and ensure that the ConfirmSetupIntentParams input parameter is populated with card details and billing details that you wish to add as a funding source.

circle-exclamation

Once a Setup Intent has been setup, call completeFundingSource to finish provisioning the FundingSource.

Completing Funding Source Setup with Provider Specific Data

Once the provider-specific data has been obtained, construct a provider specific completion data object and call the completeFundingSource method to finish the process of provisioning a funding source:

The completeFundingSource call accepts an optional updateCardFundingSource parameter (default value is true). This parameter is a flag to indicate whether to automatically update unfunded cards' funding source when a new funding source is created:

Failure during payment processor interaction

If there is any failure returned from the payment processor (Stripe) prior to calling completeFundingSource, then the provisional funding source returned by setupFundingSource method may be re-used for multiple attempts at completeFundingSource.

Examples of failures include the user entering incorrect expiry, billing address or security code information for a card.

Cancelling a Provisional Funding Source

If a user would like to cancel a provisional funding source before it is completed, they can call the cancelProvisionalFundingSource method. This method cancels setting up the funding source at the funding source provider and places the provisional funding source in the failed state.

Cancelling a Funding Source

If a user decides they want to remove a funding source from their account, the ability to provide them with the means to do so is applied with the cancelFundingSource method.

triangle-exclamation

This API call is idempotent, so cancelling an already-cancelled funding source will yield the same result.

When a funding source is cancelled, the record of the funding source will not be deleted, but instead its state will be set to INACTIVE and will no longer be usable for provisioning virtual cards. This is because refunds are always returned to the same original funding source and so clients will need to be able to retain details about cancelled funding in case any such future refunds refer to them.

Any existing virtual cards funded by a cancelled funding source will become unfunded. These can be funded by creating a new funding source and setting the updateCardFundingSource parameter in the completeFundingSource method call to true.

circle-exclamation

Retrieving Funding Sources

Previously created (or cancelled) funding sources can be accessed in two ways: via its identifier (Single Funding Source by Id), or via a list method (List Funding Sources).

A fetch of single or multiple funding sources can be performed remotely or locally by specifying the appropriate CachePolicy as part of the input.

Single Funding Source by Id

To retrieve a single funding source given its unique id, use the getFundingSource method. This method will return the record in an active or inactive state if it exists.

List Funding Sources

The ability to retrieve multiple or all funding sources available to the user is supported. Returned funding sources are sorted based on time of last update, with the default ordering being most recent first. The results can also be filtered and/or paginated and can contain funding sources which may be active whilst others are inactive. To return least recently updated first, provide the sortOrder parameter with a value of ascending.

A call to a list API will return a ListOutput object containing a list of matching items and a nextToken to support pagination. If no results matching the input are found, the result will contain empty items. Note that an empty items list does not necessarily mean that all items have been retrieved. Always check the value of the returned nextToken, there are no more results to retrieve when nextToken is null.

Listing Provisional Funding Sources

Provisional funding sources are created by calls to the setupFundingSource method. The ability to retrieve multiple or all provisional funding sources available to the user is supported. Returned provisional funding sources are sorted based on time of last update, with the default ordering being most recent first. The results can also be filtered and/or paginated. To return least recently updated first, provide the sortOrder parameter with a value of ascending.

A call to a list API will return a ListOutput object containing a list of matching items and a nextToken to support pagination. If no results matching the input are found, the result will contain empty items. Note that an empty items list does not necessarily mean that all items have been retrieved. Always check the value of the returned nextToken, there are no more results to retrieve when nextToken is null.

Subscribing to Funding Source Changes

Consumers of the SDK may choose to subscribe to notifications of changes to Funding Sources from the Sudo Platform rather than polling. This is done via the subscribeToFundingSourceChanges method. Subscribing is done across all Funding Sources associated with the client, not on a per-funding-source basis.

This method accepts a unique subscription identifier and a subscriber object which must implement the fundingSourceChanged(fundingSource: FundingSource): Promise<void> method. This handler should contain application-specific implementation of behavior in the event of a funding source change. The subscription object should also implement the connectionStatusChanged(state: ConnectionState): void method which is invoked in the event of subscription connection state changes between CONNECTED and DISCONNECTED. This handler allows the consumer to detect when the subscription connection has been lost and take appropriate corrective action.

If the subscribeToFundingSourceChanges method is called more than once with the same subscription id, subsequent invocations will replace the earlier subscriptions.

Unsubscribing

Once no longer interested in funding source changes, clients may unsubscribe by calling the unsubscribeFromFundingSourceChanges method, passing the same subscription identifier.

Last updated