Skip to main content

daravel_payments 1.19.0 copy "daravel_payments: ^1.19.0" to clipboard
daravel_payments: ^1.19.0 copied to clipboard

Payments for Daravel through Midtrans, Xendit and Stripe. Verified webhooks applied exactly once, amounts checked, events after commit, and a fake for tests.

example/main.dart

import 'package:daravel/daravel.dart';
import 'package:daravel_payments/daravel_payments.dart';

/// `POST /api/checkout` starts a Midtrans Snap payment (MIDTRANS_SERVER_KEY
/// in .env); Midtrans then notifies `POST /payments/webhook/midtrans`, and
/// a verified, first-time `paid` reaches the PaymentPaid listener.
Application createApp() =>
    Application.configure(basePath: '.')
        .withPayments()
        .withMigrations(const [CreatePaymentTables()])
        .withEvents(
          (events) => events.listen<PaymentPaid>(
            (PaymentPaid paid) =>
                Log.info('Paid', {'order': paid.payment.orderId}),
          ),
        )
        .withRouting(
          api: (router) => router.post('/checkout', (Request request) async {
            final checkout = await Payment.checkout(
              PaymentRequest(
                orderId: 'ORDER-${DateTime.now().millisecondsSinceEpoch}',
                amount: 150000,
                items: const [PaymentItem(name: 'Assessment', price: 150000)],
              ),
            );
            return checkout.toJson();
          }),
        )
        .create();

Future<void> main() async => Application.serveWith(createApp);
0
likes
0
points
1k
downloads

Documentation

Documentation

Publisher

verified publisherframework.daravel.dev

Weekly Downloads

Payments for Daravel through Midtrans, Xendit and Stripe. Verified webhooks applied exactly once, amounts checked, events after commit, and a fake for tests.

Homepage
Repository (GitHub)
View/report issues

Topics

#payments #midtrans #xendit #stripe #server

Funding

Consider supporting this project:

github.com

License

unknown (license)

Dependencies

crypto, daravel, dartisan_cli

More

Packages that depend on daravel_payments