Skip to content

checkout/checkout-sdk-flutter

Repository files navigation

Checkout SKD for Flutter

⚠️ This SDK is in the Public Beta phase.

A Flutter plugin that wraps the Checkout.com's tokenization API in order to allow the tokenization for card details as well as Apple Pay and Google Pay payloads.

Installation

Add checkout_sdk_flutter to your pubspec.yaml file:

dependencies:
  ...
  checkout_sdk_flutter: <version>

Usage

If our team did not create an account for you already, you can create one here. Once you have an account you should have access to your public API key.

Import the plugin in your code:

import 'package:johnnysdk_flutter/checkout_sdk_flutter.dart';

Initialize the SDK with your public key:

var cko = new Checkout(publicKey: "your_key");

Note that the SDK will automatically determine what environment to use based on the key you provide.

Tokenize a card

final request = CardTokenizationRequest(
    number: "4242424242424242",
    expiryMonth: 11,
    expiryYear: 2029,
    cvv: "100",
    name: "John Smith");
var res = await cko.tokenizeCard(request);

Tokenize an ApplePay payload

final request = ApplePayTokenizationRequest(
tokenData: AppleTokenData(
    version: 'EC_v1',
    data: 'XXXXXX',
    signature: 'XXXXXX',
    header: AppleHeader(
        ephemeralPublicKey: 'XXXXXX',
        publicKeyHash: 'XXXXXX',
        transactionId: 'XXXXXX')),
);

var res = await cko.tokenizeApplePay(request);

Tokenize a GooglePay payload

final request = GooglePayTokenizationRequest(
tokenData: GoogleTokenData(
    signature: 'XXX', protocolVersion: 'XXX', signedMessage: "XXX"),
);

var res = await cko.tokenizeGooglePay(request);

Handle exemptions

try {
  // sdk action
} on UnauthorizedError catch (exception) {
 // handle UnauthorizedError
} on InvalidDataError catch (exception) {
 // handle InvalidDataError
} catch (error) {
 // handle any other exemptions
}