@@ -97,56 +97,20 @@ You can then create a `Charge` object with the access code and card details. The
9797 expiryMonth: expiryMonth,
9898 expiryYear: expiryYear,
9999 );
100-
101- // Using Cascade notation (similar to Java's builder pattern)
102- // return PaymentCard(
103- // number: cardNumber,
104- // cvc: cvv,
105- // expiryMonth: expiryMonth,
106- // expiryYear: expiryYear)
107- // ..name = 'Segun Chukwuma Adamu'
108- // ..country = 'Nigeria'
109- // ..addressLine1 = 'Ikeja, Lagos'
110- // ..addressPostalCode = '100001';
111-
112- // Using optional parameters
113- // return PaymentCard(
114- // number: cardNumber,
115- // cvc: cvv,
116- // expiryMonth: expiryMonth,
117- // expiryYear: expiryYear,
118- // name: 'Ismail Adebola Emeka',
119- // addressCountry: 'Nigeria',
120- // addressLine1: '90, Nnebisi Road, Asaba, Deleta State');
121100 }
122101
123- _chargeCard(String accessCode) {
102+ _chargeCard(String accessCode) async {
124103 var charge = Charge()
125104 ..accessCode = accessCode
126105 ..card = _getCardFromUI();
127106
128- PaystackPlugin.chargeCard(context,
129- charge: charge,
130- beforeValidate: (transaction) => handleBeforeValidate(transaction),
131- onSuccess: (transaction) => handleOnSuccess(transaction),
132- onError: (error, transaction) => handleOnError(error, transaction));
133- }
134-
135- handleBeforeValidate(Transaction transaction) {
136- // This is called only before requesting OTP
137- // Save reference so you may send to server if error occurs with OTP
138- }
139-
140- handleOnError(Object e, Transaction transaction) {
141- // If an access code has expired, simply ask your server for a new one
142- // and restart the charge instead of displaying error
143- }
144-
145-
146- handleOnSuccess(Transaction transaction) {
147- // This is called only after transaction is successful
107+ final response = await PaystackPlugin.chargeCard(context, charge: charge);
108+ // Use the response
148109 }
149110```
111+ The transaction is successful if ` response.status ` is true. Please, see the documentation
112+ of [ CheckoutResponse] ( https://pub.dev/documentation/flutter_paystack/latest/flutter_paystack/CheckoutResponse-class.html )
113+ for more information.
150114
151115
152116
0 commit comments