main function
dynamic
main()
Implementation
main()async{
final repo = CartRepository(paynowCartItems: <PaynowCartItem, int>{});
final cart = CartCubit(
cartRepository: repo
);
final bloc = PaynowBloc(
config: PaynowConfig(
integrationId: PAYNOW_INTEGRATION_ID,
integrationKey: PAYNOW_INTEGRATION_KEY,
authEmail: 'ignertic@icloud.com',
reference: 'Some Test',
),
cartRepository: repo,
);
bloc.stream.listen((state) {
if (state is PaynowFailedState){
print(state.message);
}else if (state is PaynowPendingState){
print(state.response.redirectUrl);
}else if(state is PaynowLoadingState){
print('Processing...');
}
});
final item = PaynowCartItem(amount: 3,title: 'sf');
cart.addToCart(item, quantity: 5);
bloc.startPayment(PaynowPaymentInfo(
paymentMethod: PaynowPaymentMethod.web,
returnUrl: 'google.com',
resultUrl: 'google.com/res',
));
}