omise_dart 0.3.0 copy "omise_dart: ^0.3.0" to clipboard
omise_dart: ^0.3.0 copied to clipboard

A Dart SDK that serves as an API wrapper for the Omise API.

example/omise_dart_example.dart

import 'package:omise_dart/omise_dart.dart';

Future<void> main() async {
  // Initialize the Omise API with your public and secret keys
  final omiseApi = OmiseApi(
    publicKey: "your_public_key_here", // Replace with your actual public key
    secretKey: "your_secret_key_here", // Replace with your actual secret key
    enableDebug: false, // Enables debug logging
  );

  // Create a token using card details
  final createTokenRequest = CreateTokenRequest(
    name: "Name",
    number: "4242424242424242", // Example test card number
    expirationMonth: "09", // Card expiry month
    expirationYear: "27", // Card expiry year
  );

  // Call the Omise API to create a token
  final token = await omiseApi.tokens.create(createTokenRequest);

  print('Token created: ${token.id}');

  // Retrieve token information using the token ID
  final retrievedToken = await omiseApi.tokens.get(token.id);

  print('Token retrieved: ${retrievedToken.id}');

  // Create a source
  final createSourceRequest = CreateSourceRequest(
      name: "Name",
      amount: 2000,
      currency: Currency.thb,
      type: PaymentMethodName.promptpay);

  // Call the Omise API to create a source
  final source = await omiseApi.sources.create(createSourceRequest);

  print('Source created: ${source.id}');

  // Retrieve token information using the token ID
  final retrievedSource = await omiseApi.sources.get(source.id);

  print('Source retrieved: ${retrievedSource.id}');

  // Fetch capability information from the Omise API
  final capability = await omiseApi.capability.get();

  print('Capability retrieved: ${capability.country}');
}
0
likes
140
points
65
downloads

Publisher

verified publisheropn.ooo

Weekly Downloads

A Dart SDK that serves as an API wrapper for the Omise API.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

http

More

Packages that depend on omise_dart