sagepay 0.0.7+21 copy "sagepay: ^0.0.7+21" to clipboard
sagepay: ^0.0.7+21 copied to clipboard

Flutter plugin for SagePay services. It supports the android and iOS platforms and it is easy to use. It's used for making payment as a Sagecloud merchant.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:sagepay/sagepay.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'SagePay Example',
      theme: ThemeData(
        primarySwatch: Colors.red,
      ),
      home: const MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key});

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("SagePay Example"),
      ),
      body: Center(
          child: SizedBox(
        child: ElevatedButton(
          onPressed: () => gotoPaymentGateway(),
          child: const Text('Go to SagePay Checkout'),
        ),
      )),
    );
  }

  gotoPaymentGateway() async {
    final sagePay = SagePay(
      context: context,
      amount: 100,
      reference: "{{randomly generated string}}",
      callbackUrl: "{{call back url}}",
      token: "{{Secret Key}}",
      business:
          Business(name: "{{business name}}", email: "{{business email}}"),
    );

    PaymentResponse? response = await sagePay.chargeTransaction();

    if (response != null) {
      if (response.success!) {
        //handle success response
      } else {
        //Handle not successful
      }
    } else {
      //User cancelled checkout
    }
  }
}
2
likes
120
points
25
downloads

Publisher

unverified uploader

Weekly Downloads

Flutter plugin for SagePay services. It supports the android and iOS platforms and it is easy to use. It's used for making payment as a Sagecloud merchant.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

dio, flutter, flutter_inappwebview, google_fonts

More

Packages that depend on sagepay