flutter_kwikpaisa_pg_sdk 1.1.0 copy "flutter_kwikpaisa_pg_sdk: ^1.1.0" to clipboard
flutter_kwikpaisa_pg_sdk: ^1.1.0 copied to clipboard

A Flutter plugin for integrating the KwikPaisa NEO Bank payment gateway.

markdown Copy code

Flutter KwikPaisa PG SDK #

A Flutter plugin for integrating the KwikPaisa NEO Bank payment gateway.

Installation #

Add this to your package's pubspec.yaml file:

dependencies:
  flutter_kwikpaisa_pg_sdk: ^1.1.0
Then, run the following command to install the new dependency:

bash
Copy code
flutter pub get
Configuration
Before using the plugin, you need to configure your KwikPaisa API keys. Follow these steps:

Create a configuration file: Create a new file named kwikpaisa_configure.dart in your lib folder.

Add the following code to kwikpaisa_configure.dart:

dart
Copy code
class KwikPaisaConfig {
  static const String baseUrl = 'https://uat.api.kwikpaisa.com';
  static const String contentType = 'application/json';
  static const String clientId = '<Your Client ID>'; // Replace with your API Client ID
  static const String clientSecret = '<Your Client Secret>'; // Replace with your API Client Secret
  static const String orderSource = 'rest-api'; // This can be adjusted based on your source
}
Make sure to replace <Your Client ID> and <Your Client Secret> with your actual KwikPaisa API credentials.

Usage
Step 1: Import the SDK
In your Flutter application, import the KwikPaisa PG SDK and the configuration file:

dart
Copy code
import 'package:flutter_kwikpaisa_pg_sdk/flutter_kwikpaisa_pg_sdk.dart';
import 'kwikpaisa_configure.dart';
Step 2: Create an Order
You can create a new order using the KwikPaisaPaymentGateway class. Here’s how you can do it:

dart
Copy code
void createOrder() async {
  final paymentGateway = KwikPaisaPaymentGateway();

  Map<String, dynamic> orderData = {
    'customer_name': 'John Doe',
    'customer_email': 'john.doe@example.com',
    'customer_phone': '1234567890',
    'customer_address_line1': '123 Main St',
    'customer_address_city': 'Your City',
    'customer_address_state': 'Your State',
    'customer_address_country': 'Your Country',
    'customer_address_postal_code': '110011',
    'order_amount': '100.00',
    'order_currency': 'INR',
    'order_note': 'Payment for services',
    'service_type': 'service', // Adjust this based on your service type
    'return_url': 'yourapp://kwikpaisaReturn', // Set your return URL scheme
  };

  try {
    Map<String, dynamic> response = await paymentGateway.createOrder(orderData);
    if (response['code'] == '200' && response['status'] == 'success') {
      String paymentLink = response['return_data']['payment_link'];
      // Open the payment link in a WebView or external browser
      // Implement WebView or URL launcher to open the link
    } else {
      print('Order creation failed: ${response['message']}');
    }
  } catch (e) {
    print('Error: $e');
  }
}
Step 3: Handle Payment Completion
After the payment is completed, the user will be redirected to the return URL you specified. You can create another screen to handle the return and fetch the order status:

dart
Copy code
void handlePaymentReturn(String orderId) async {
  final paymentGateway = KwikPaisaPaymentGateway();

  Map<String, dynamic> statusData = {
    'order_id': orderId,
  };

  try {
    Map<String, dynamic> response = await paymentGateway.checkOrderStatus(statusData);
    // Handle the response based on the order status
    if (response['status'] == 'paid') {
      print('Payment successful for order: $orderId');
    } else {
      print('Payment not completed for order: $orderId');
    }
  } catch (e) {
    print('Error: $e');
  }
}
Testing
You can test the plugin by running the Flutter application and initiating a payment. Make sure to replace the API credentials and use valid order data.

Contribution
Contributions are welcome! Please feel free to submit issues and pull requests.

License
This project is licensed under the MIT License. See the LICENSE file for more information.
0
likes
0
points
40
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin for integrating the KwikPaisa NEO Bank payment gateway.

Homepage

License

unknown (license)

Dependencies

crypto, flutter, http, plugin_platform_interface, webview_flutter

More

Packages that depend on flutter_kwikpaisa_pg_sdk

Packages that implement flutter_kwikpaisa_pg_sdk