Open PeterPaulez opened 3 years ago
Hello guys!
I have problems with CardFormPaymentRequest
I can show it, and create a paymentIntent, but I have to do it with COPY and PASTE, because I can't write numbers into the boxes.
Other problem is, if I click on cancel button, exceptios is thrown and I can't catch it, no matter where I put the try
import 'package:meta/meta.dart'; import 'package:stripe_app/models/stripeResponse.dart'; import 'package:stripe_payment/stripe_payment.dart'; class StripeService { StripeService._privateConstructor(); static final StripeService _instance = StripeService._privateConstructor(); factory StripeService() => _instance; String _paymentApiURL = 'https://api.stripe.com/v1/payment_intents'; String _secretKey = 'sk_test_'; String _publishableKey = 'pk_test_'; void init() { StripePayment.setOptions( StripeOptions( publishableKey: _publishableKey, androidPayMode: 'test', merchantId: 'test', ), ); } Future pagarTarjetaExistente({ @required String amount, @required String currency, @required CreditCard card, }) async {} Future<StripeResponse> pagarNuevaTarjeta({ @required String amount, @required String currency, }) async { try { final paymentMethod = await StripePayment.paymentRequestWithCardForm( CardFormPaymentRequest()); // TODO: Crear paymentIntent return StripeResponse(ok: true); } catch (e) { return StripeResponse( ok: false, msg: e.toString(), ); } } Future pagarAppleGooglePay({ @required String amount, @required String currency, }) async {} Future _crearPaymentIntent({ @required String amount, @required String currency, }) async {} Future _realizarPago({ @required String amount, @required String currency, @required PaymentMethod paymentMethod, }) async {} }
IconButton( onPressed: () async { final String amount = BlocProvider.of<PagarBloc>(context).state.dineroPagarString; final String currency = BlocProvider.of<PagarBloc>(context).state.moneda; final answer = await this.stripeService.pagarNuevaTarjeta( amount: amount, currency: currency, ); if (answer.ok) { mostrarAlerta( context, 'Tarjeta OK', 'Todo se guardo correctamente en Stripe', ); } else { mostrarAlerta(context, 'Algo salió mal', answer.msg); } }, icon: Icon(Icons.add), )
import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:stripe_app/bloc/pagar/bloc.dart'; import 'package:stripe_app/pages/home.dart'; import 'package:stripe_app/pages/pagoCompleto.dart'; import 'package:stripe_app/services/stripe.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { // Inicializamos StripeService new StripeService()..init(); return MultiBlocProvider( providers: [ BlocProvider(create: (_) => PagarBloc()), ], child: MaterialApp( debugShowCheckedModeBanner: false, title: 'Stripe App', initialRoute: 'home', routes: { 'home': (_) => HomePage(), 'pago_completo': (_) => PagoCompletoPage(), }, theme: ThemeData.light().copyWith( primaryColor: Color(0xff284879), scaffoldBackgroundColor: Color(0xff21212A), ), ), ); } }
seems to happen in iOS simulator. tested in an iPhone and it works
It happens the same in an iPhone.
same issue
Any update on this? Facing same issue.
Hello guys!
I have problems with CardFormPaymentRequest
I can show it, and create a paymentIntent, but I have to do it with COPY and PASTE, because I can't write numbers into the boxes.
Other problem is, if I click on cancel button, exceptios is thrown and I can't catch it, no matter where I put the try