Skip to content

Commit e58741f

Browse files
committed
implemented payment cancellation. Clicking on the 'Cancel Payment' on the Paystack payment page now closes the Payment webview.
1 parent 33701eb commit e58741f

File tree

5 files changed

+8
-6
lines changed

5 files changed

+8
-6
lines changed

.flutter-plugins-dependencies

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"webview_flutter_wkwebview","path":"/Users/user/.pub-cache/hosted/pub.dev/webview_flutter_wkwebview-3.14.0/","native_build":true,"dependencies":[]}],"android":[{"name":"webview_flutter_android","path":"/Users/user/.pub-cache/hosted/pub.dev/webview_flutter_android-3.16.3/","native_build":true,"dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"webview_flutter","dependencies":["webview_flutter_android","webview_flutter_wkwebview"]},{"name":"webview_flutter_android","dependencies":[]},{"name":"webview_flutter_wkwebview","dependencies":[]}],"date_created":"2024-09-23 01:23:01.343186","version":"3.21.0-1.0.pre.6"}
1+
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"webview_flutter_wkwebview","path":"/Users/user/.pub-cache/hosted/pub.dev/webview_flutter_wkwebview-3.14.0/","native_build":true,"dependencies":[]}],"android":[{"name":"webview_flutter_android","path":"/Users/user/.pub-cache/hosted/pub.dev/webview_flutter_android-3.16.3/","native_build":true,"dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"webview_flutter","dependencies":["webview_flutter_android","webview_flutter_wkwebview"]},{"name":"webview_flutter_android","dependencies":[]},{"name":"webview_flutter_wkwebview","dependencies":[]}],"date_created":"2024-09-23 02:02:03.084629","version":"3.21.0-1.0.pre.6"}

example/lib/main.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ class _MyHomePageState extends State<MyHomePage> {
4242
PaystackFlutter().pay(
4343
context: context,
4444
secretKey:
45-
'YOUR_PAYSTACK_SECRET_KEY', // Your Paystack secret key.
45+
'YOUR_PAYSTACK_KEY', // Your Paystack secret key.
4646
amount:
4747
60000, // The amount to be charged in the smallest currency unit. If amount is 600, multiply by 100(600*100)
4848
email:
4949
'[email protected]', // The customer's email address.
5050
callbackUrl:
5151
'https://callback.com', // The URL to which Paystack will redirect the user after the transaction.
5252
showProgressBar:
53-
true, // If true, it shows progress bar to inform user an action is in progress when getting checkout link from Paystack.
53+
false, // If true, it shows progress bar to inform user an action is in progress when getting checkout link from Paystack.
5454
paymentOptions: [
5555
PaymentOption.card,
5656
PaymentOption.bankTransfer,

example/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ packages:
169169
path: ".."
170170
relative: true
171171
source: path
172-
version: "1.0.1"
172+
version: "1.0.2"
173173
plugin_platform_interface:
174174
dependency: transitive
175175
description:

lib/src/models/paystack_request.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ class PaystackRequest {
101101
/// Converts the PaystackRequest object to a JSON map suitable for sending to the Paystack API.
102102
Map<String, dynamic> toJson() {
103103
// Call updateMetadata to ensure the "cancel_action" key-value pair is added
104-
updateMetadata("cancel_action", "https://github.com/VhiktorBrown/paystack_flutter");
104+
updateMetadata(
105+
"cancel_action", "https://github.com/VhiktorBrown/paystack_flutter");
105106

106107
final Map<String, dynamic> baseJson = {
107108
"amount": amount,

lib/src/paystack_webview.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@ class _PaystackWebviewState extends State<PaystackWebview> {
192192
}
193193

194194
//check if Paystack redirects to cancel_url
195-
if(uri.toString() == "https://github.com/VhiktorBrown/paystack_flutter"){
195+
if (uri.toString() ==
196+
"https://github.com/VhiktorBrown/paystack_flutter") {
196197
Navigator.pop(context);
197198
//this means the user cancelled payment.
198199
widget.onCancelled(callback);

0 commit comments

Comments
 (0)