Skip to content

spookynova/sucrose

Repository files navigation

Sucrose

A Bridge Payment Gateway for Xendit and any other payment gateway.

GitHub Repo Size Pub Version GitHub top language Codacy grade

Available Payment Gateway

  • Xendit (WIP)
  • Midtrans (WIP)

Installation

flutter pub add sucrose

Getting Started

Init Xendit

import 'package:sucrose/sucrose.dart';
    
final sucrose = Sucrose.initXendit(xenditApiKey:"YOUR_API_KEY");

Init Midtrans

import 'package:sucrose/sucrose.dart';
    
final sucrose = Sucrose.initMidtrans(
    midtransApiKey: "YOUR_API_KEY",
    environment: MidtransEnvironment.SANDBOX,
    debug: true,
);

Get Started with Xendit

Create Invoice

  final response = await sucrose.xendit.createInvoice(
    request: XenditInvoiceRequest(
      externalId: "ref 13123213",
      amount: 10000,
      description: "your description goes here",
      payerEmail: "hello@mail.com",
      items: [
        XenditInvoiceItem(
          name: "item 1",
          price: 10000,
          quantity: 1,
          category: "meow",
          url: "https://google.com",
        ),
      ],
    ),
  );

Get Started with Midtrans

Create Snap Transaction

    final response = await sucrose.midtrans.createSnapTransaction(
      request: MidtransSnapTransactionRequest(
        transactionDetails: MidtransTransactionDetail(
          orderId: "Inv-${DateTime.now().millisecondsSinceEpoch}",
          grossAmount: 12500,
        ),
        itemDetails: [
          MidtransItemDetail(
            id: "021930129031",
            name: "Steam Wallet IDR 12K",
            price: 12500,
            quantity: 1,
          ),
        ],
        customerDetails: MidtransCustomerDetails(
          email: "test@mail.com",
          firstName: "Test",
          lastName: "Test",
          phone: "08123456789",
          shippingAddress: MidtransShippingAddress(
            address: "Jalan Teknologi Indonesia",
            city: "Jakarta",
            countryCode: "IDN",
            firstName: "Test",
            lastName: "Test",
            phone: "08123456789",
            postalCode: "12345",
          ),
          billingAddress: MidtransBillingAddress(
            address: "Jalan Teknologi Indonesia",
            city: "Jakarta",
            countryCode: "IDN",
            firstName: "Test",
            lastName: "Test",
            phone: "08123456789",
            postalCode: "12345",
          ),
        ),
      ),
    );

Feedback

If you have any feedback, please reach out to us at evnx32@gmail.com