123456789101112131415161718192021222324252627282930313233343536373839 |
- import 'dart:async';
- import 'package:flutter/foundation.dart';
- import 'package:flutter/services.dart';
- class FlutterMercadopago {
- String publicKey;
- String preferenceId;
- FlutterMercadopago({@required this.publicKey, this.preferenceId});
- static const MethodChannel _channel =
- const MethodChannel('flutter_mercadopago');
- static Future<String> get platformVersion async {
- final String version = await _channel.invokeMethod('getPlatformVersion');
- return version;
- }
- FlutterMercadopago setPreferenceId(String preferenceId) {
- this.preferenceId = preferenceId;
- return this;
- }
- Future<dynamic> startForPayment() async {
- if(preferenceId == null)
- throw("Preference ID not found");
- var result = await _channel.invokeMethod("MercadoPagoStartForPayment",
- {
- "publicKey": publicKey ?? null,
- "preferenceId": preferenceId ?? null,
- });
- return result;
- }
- }
|