Skip to content

Commit 17a8a67

Browse files
build dist version
1 parent c049f8f commit 17a8a67

File tree

2 files changed

+35
-9
lines changed

2 files changed

+35
-9
lines changed

dist/doc/guides/checkout-webview/handling-redirect.js

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,23 @@ Widget build(BuildContext context) {
55
initialUrl: 'https://checkout.paystack.com/7zu1ot06d0qn9h6',
66
javascriptMode: JavascriptMode.unrestricted,
77
userAgent: 'Flutter;Webview',
8-
navigationDelegate: (navigation){
9-
//Listen for callback URL
10-
if(navigation.url == "https://hello.pstk.xyz/callback"){
8+
navigationDelegate: (navigation) {
9+
//Listen for callback URL
10+
if (navigation.url == "https://hello.pstk.xyz/callback") {
1111
verifyTransaction(reference);
1212
Navigator.of(context).pop(); //close webview
1313
}
14+
if (navigation.url == "https://your-cancel-url.com") {
15+
//handle webview removal
16+
Navigator.of(context).pop(); //close webview
17+
//Run the cancel payment function if you have one
18+
}
1419
return NavigationDecision.navigate;
1520
},
1621
),
1722
);
18-
}`
23+
}
24+
`
1925

2026
const js = `import React from 'react';
2127
import { WebView } from 'react-native-webview';
@@ -25,6 +31,7 @@ export default function App() {
2531
2632
const authorization_url = 'https://checkout.paystack.com/luKuasMan';
2733
const callback_url = 'https://yourcallback.com';
34+
const cancel_url = "https://your-cancel-url.com";
2835
2936
onNavigationStateChange = state => {
3037
@@ -37,6 +44,12 @@ export default function App() {
3744
const redirectTo = 'window.location = "' + callback_url + '"';
3845
this.webview.injectJavaScript(redirectTo);
3946
}
47+
if (url === cancel_url) {
48+
// handle webview removal
49+
// You can either unmount the component, or
50+
// Use a navigator to pop off the view
51+
// Run the cancel payment function if you have one
52+
}
4053
};
4154
4255
return (
@@ -46,15 +59,16 @@ export default function App() {
4659
onNavigationStateChange={ this.onNavigationStateChange }
4760
/>
4861
);
49-
}
50-
`
62+
}`
5163

5264
const kt = `class MainActivity : AppCompatActivity() {
5365
5466
private val authorizationUrl: String
5567
get() = "https://checkout.paystack.com/ok62i2sdld514e4"
5668
private val callbackUrl: String
5769
get() = "https://yourcallback.com"
70+
private val cancelUrl: String
71+
get() = "https://your-cancel-url.com"
5872
5973
override fun onCreate(savedInstanceState: Bundle?) {
6074
// ...
@@ -76,6 +90,11 @@ const kt = `class MainActivity : AppCompatActivity() {
7690
if (url?.host == callbackUrl) {
7791
return true
7892
}
93+
if (url?.host == cancelUrl) {
94+
// handle webview removal
95+
// Run the cancel payment function if you have one
96+
return true
97+
}
7998
8099
return super.shouldOverrideUrlLoading(view, request)
81100
}

dist/doc/payments/accept-payment/redirect-backend.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
const sh = `curl https://api.paystack.co/transaction/initialize
22
-H "Authorization: Bearer YOUR_SECRET_KEY"
33
-H "Content-Type: application/json"
4-
-d '{ "email": "[email protected]", "amount": "20000" }'
4+
-d '{ "email": "[email protected]", "amount": "20000",
5+
"callback_url":"https://hello.pstk.xyz/callback",
6+
"metadata":{"cancel_action": "https://your-cancel-url.com"}
7+
}'
58
-X POST`
69

710
const js = `const https = require('https')
811
912
const params = JSON.stringify({
1013
"email": "[email protected]",
11-
"amount": "20000"
14+
"amount": "20000",
15+
"callback_url":"https://hello.pstk.xyz/callback",
16+
"metadata":{"cancel_action": "https://your-cancel-url.com"}
1217
})
1318
1419
const options = {
@@ -44,7 +49,9 @@ const php = `<?php
4449
4550
$fields = [
4651
'email' => "[email protected]",
47-
'amount' => "20000"
52+
'amount' => "20000",
53+
'callback_url' => "https://hello.pstk.xyz/callback",
54+
'metadata' => ["cancel_action" => "https://your-cancel-url.com"]
4855
];
4956
5057
$fields_string = http_build_query($fields);

0 commit comments

Comments
 (0)