fxendit 0.0.3 copy "fxendit: ^0.0.3" to clipboard
fxendit: ^0.0.3 copied to clipboard

PlatformAndroid

The easy way to use Xendit Software Development Kit (SDK) in Flutter.

FXendit #

Using Xendit in Flutter.

Getting Started #

Add dependency to your project.

$ flutter pub add fxendit
copied to clipboard

Usage #

Get your public key.

Set minSdkVersion in your gradle to 21. Then add related permissions and activities to AndroidManifest.

<manifest...>
  ...

  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
  <uses-permission android:name="android.permission.INTERNET"/>
  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
  <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

  <application...>
    ...

    <activity
      android:name="com.xendit.example.CreateTokenActivity"
      android:theme="@style/NormalTheme"/>

    <activity
      android:name="com.xendit.example.AuthenticationActivity"
      android:theme="@style/NormalTheme"/>

    <activity
      android:name="com.xendit.example.ValidationUtilActivity"
      android:theme="@style/NormalTheme"/>

    <activity android:name="com.xendit.XenditActivity"/>
    ...
  </application>
</manifest>
copied to clipboard

Initialize Xendit:

import 'package:fxendit/fxendit.dart';
copied to clipboard
Xendit xendit = Xendit('your_xendit_public_key');
copied to clipboard

Create a Single Use Token.

XCard card = XCard(
  creditCardNumber: '4111111111111111',
  creditCardCVN: '123',
  expirationMonth: '09',
  expirationYear: '2021',
);

TokenResult result = await xendit.createSingleUseToken(
  card,
  amount: 75000,
  shouldAuthenticate: true,
  onBehalfOf: '',
);

if (result.isSuccess) {
  tokenId = result.token!.id;
  print('Token ID: ${result.token!.id}');
} else {
  print('SingleUseToken Error: ${result.errorCode} - ${result.errorMessage}');
}
copied to clipboard

Create a Multiple Use Token.

XCard card = XCard(
  creditCardNumber: '4111111111111111',
  creditCardCVN: '123',
  expirationMonth: '09',
  expirationYear: '2021',
);

TokenResult result = await xendit.createMultipleUseToken(card);

if (result.isSuccess) {
  tokenId = result.token!.id;
  print('Token ID: ${result.token!.id}');
} else {
  print('MultipleUseToken Error: ${result.errorCode} - ${result.errorMessage}');
}
copied to clipboard

Create a 3DS Authentication.

AuthenticationResult result = await xendit.createAuthentication(tokenId, amount: 50000);

if (result.isSuccess) {
  print('Authentication ID: ${result.authentication!.id}');
} else {
  print('Authentication Error: ${result.errorCode} - ${result.errorMessage}');
}
copied to clipboard

Check if a credit card number is valid.

String cardNumber = '4111111111111111';

bool isValid = CardValidator.isCardNumberValid(cardNumber);
copied to clipboard

Check if credit card expiration month and year is valid.

String expirationMonth = '09';
String expirationYear = '2021';

bool isValid = CardValidator.isExpiryValid(expirationMonth, expirationYear);
copied to clipboard

Check if a card CVN is valid.

String cardCVN = '123';

bool isValid = CardValidator.isCvnValid(cardCVN);
copied to clipboard

Get card type based on card number.

String cardNumber = '4111111111111111';

CardType cardType = CardValidator.getCardType(cardNumber);
print('${cardType.cardName} - ${cardType.cardKey}');
copied to clipboard

Check if the card CVN length is valid for its type.

String cardNumber = '4111111111111111';
String cardCVN = '123';

bool isValid = CardValidator.isCvnValidForCardType(cardCVN, cardNumber);
copied to clipboard

Example #

Learn more from example project here.

11
likes
140
points
35
downloads

Publisher

unverified uploader

Weekly Downloads

2024.09.14 - 2025.03.29

The easy way to use Xendit Software Development Kit (SDK) in Flutter.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

flutter, intl

More

Packages that depend on fxendit