SkyPay SDK for Flutter

Seamless payment integration for Flutter with SkyPay SDK – Simplify and secure payments in your apps effortlessly.

About

SkyPay is a comprehensive payment gateway solution in Nepal by SkyBase Innovations. It simplifies integration, boosts developer productivity, reduces costs, and minimizes technical challenges. With options like Manual Entry, Merchant API, and SkyPay Managed, it streamlines online payments and is especially beneficial for developers. It also supports various payment methods, including Khalti, eliminating the need to integrate with individual banks.

Pre-requisites

  1. Create your FREE MERCHANT ACCOUNT here: Merchant Registration Page
  2. Copy your API Key from your dashboard page

Installation

dependencies:
  skypay_sdk: ^0.0.4

Or from Git:

dependencies:
  skypay_sdk:
    git:
      url: https://github.com/skybaseinnovations/skypay-sdk.git
      ref: main

Provider list, API-backed checkout, polling, and assisted/manual flows.

Initialize

import 'package:skypay_sdk/skypay_sdk.dart';

void main() {
  SkyPay.init('YOUR_API_KEY', debug: true);
  runApp(MyApp());
}

Start payment

final intent = SkyPayIntent(
  amount: 100.0,
  code: 'ORD-12345',
  successUrl: 'https://yourdomain.com/success',
  failureUrl: 'https://yourdomain.com/failure',
);

await SkyPay.instance.startPayment(
  context,
  intent: intent,
  onPaymentCompleted: (payment) {
    print('Payment Successful: ${payment.id}');
  },
  onError: (message) {
    print('Payment Error: $message');
  },
);

V2 features

  • Easy initialization: SkyPay.init(apiKey)
  • Provider list: Fetches available payment providers from the API
  • In-app browser / WebView: Redirects via flutter_inappwebview
  • Status polling: Polls payment status where applicable
  • API, Manual, Assisted modes supported

See the example/ app for a full demo.

Legacy API (Skypay)

The original skypay-sdk hosted checkout URL + embedded WebView flow is still available as Skypay (note spelling) for backward compatibility.

Initialize

@override
void initState() {
  super.initState();
  Skypay.initConfig(
    apiKey: 'YOUR_API_KEY_HERE',
    isProduction: false, // true for production checkout / API hosts
  );
}

Initiate payment

Skypay.initPayment(
  context: context,
  orderId: 'UNIQUE_ORDER_ID',
  amount: 100,
  successUrl: 'https://yourdomain.com/success', // optional; defaults apply
  failureUrl: 'https://yourdomain.com/failure',
  onSuccess: (data) {
    print('Payment Success: $data');
  },
  onFailure: (data) {
    print('Payment Failed: $data');
  },
  onCancel: () {
    print('Payment Cancelled');
  },
);

The legacy flow verifies the transaction with the SkyPay server before calling onSuccess.

Legacy parameters

Parameter Required Description
context yes BuildContext for navigation
amount yes Transaction amount
orderId yes Unique order identifier
onSuccess yes Success callback
onFailure yes Failure callback
onCancel no User closed checkout before completion
successUrl no Override default success redirect (see Constants)
failureUrl no Override default failure redirect

Publishing

  1. Ensure pubspec.yaml, README.md, and CHANGELOG.md are up to date.
  2. Dry run: dart pub publish --dry-run
  3. Publish: dart pub publish

More detail: Dart publishing docs.

Documentation

License

BSD-3-Clause (see LICENSE).

Libraries

skypay_sdk