Skip to content

Commit

Permalink
implemented payment cancellation. Clicking on the 'Cancel Payment' on…
Browse files Browse the repository at this point in the history
… the Paystack payment page now closes the Payment webview.
  • Loading branch information
VhiktorBrown committed Sep 23, 2024
1 parent 33701eb commit e58741f
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .flutter-plugins-dependencies
Original file line number Diff line number Diff line change
@@ -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"}
{"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"}
4 changes: 2 additions & 2 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ class _MyHomePageState extends State<MyHomePage> {
PaystackFlutter().pay(
context: context,
secretKey:
'YOUR_PAYSTACK_SECRET_KEY', // Your Paystack secret key.
'YOUR_PAYSTACK_KEY', // Your Paystack secret key.
amount:
60000, // The amount to be charged in the smallest currency unit. If amount is 600, multiply by 100(600*100)
email:
'theelitedevelopers1@gmail.com', // The customer's email address.
callbackUrl:
'https://callback.com', // The URL to which Paystack will redirect the user after the transaction.
showProgressBar:
true, // If true, it shows progress bar to inform user an action is in progress when getting checkout link from Paystack.
false, // If true, it shows progress bar to inform user an action is in progress when getting checkout link from Paystack.
paymentOptions: [
PaymentOption.card,
PaymentOption.bankTransfer,
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ packages:
path: ".."
relative: true
source: path
version: "1.0.1"
version: "1.0.2"
plugin_platform_interface:
dependency: transitive
description:
Expand Down
3 changes: 2 additions & 1 deletion lib/src/models/paystack_request.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ class PaystackRequest {
/// Converts the PaystackRequest object to a JSON map suitable for sending to the Paystack API.
Map<String, dynamic> toJson() {
// Call updateMetadata to ensure the "cancel_action" key-value pair is added
updateMetadata("cancel_action", "https://github.com/VhiktorBrown/paystack_flutter");
updateMetadata(
"cancel_action", "https://github.com/VhiktorBrown/paystack_flutter");

final Map<String, dynamic> baseJson = {
"amount": amount,
Expand Down
3 changes: 2 additions & 1 deletion lib/src/paystack_webview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ class _PaystackWebviewState extends State<PaystackWebview> {
}

//check if Paystack redirects to cancel_url
if(uri.toString() == "https://github.com/VhiktorBrown/paystack_flutter"){
if (uri.toString() ==
"https://github.com/VhiktorBrown/paystack_flutter") {
Navigator.pop(context);
//this means the user cancelled payment.
widget.onCancelled(callback);
Expand Down

0 comments on commit e58741f

Please sign in to comment.