Skip to content

Commit

Permalink
build dist version
Browse files Browse the repository at this point in the history
  • Loading branch information
lukman-paystack committed Feb 22, 2024
1 parent c049f8f commit 17a8a67
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 9 deletions.
31 changes: 25 additions & 6 deletions dist/doc/guides/checkout-webview/handling-redirect.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,23 @@ Widget build(BuildContext context) {
initialUrl: 'https://checkout.paystack.com/7zu1ot06d0qn9h6',
javascriptMode: JavascriptMode.unrestricted,
userAgent: 'Flutter;Webview',
navigationDelegate: (navigation){
//Listen for callback URL
if(navigation.url == "https://hello.pstk.xyz/callback"){
navigationDelegate: (navigation) {
//Listen for callback URL
if (navigation.url == "https://hello.pstk.xyz/callback") {
verifyTransaction(reference);
Navigator.of(context).pop(); //close webview
}
if (navigation.url == "https://your-cancel-url.com") {
//handle webview removal
Navigator.of(context).pop(); //close webview
//Run the cancel payment function if you have one
}
return NavigationDecision.navigate;
},
),
);
}`
}
`

const js = `import React from 'react';
import { WebView } from 'react-native-webview';
Expand All @@ -25,6 +31,7 @@ export default function App() {
const authorization_url = 'https://checkout.paystack.com/luKuasMan';
const callback_url = 'https://yourcallback.com';
const cancel_url = "https://your-cancel-url.com";
onNavigationStateChange = state => {
Expand All @@ -37,6 +44,12 @@ export default function App() {
const redirectTo = 'window.location = "' + callback_url + '"';
this.webview.injectJavaScript(redirectTo);
}
if (url === cancel_url) {
// handle webview removal
// You can either unmount the component, or
// Use a navigator to pop off the view
// Run the cancel payment function if you have one
}
};
return (
Expand All @@ -46,15 +59,16 @@ export default function App() {
onNavigationStateChange={ this.onNavigationStateChange }
/>
);
}
`
}`

const kt = `class MainActivity : AppCompatActivity() {
private val authorizationUrl: String
get() = "https://checkout.paystack.com/ok62i2sdld514e4"
private val callbackUrl: String
get() = "https://yourcallback.com"
private val cancelUrl: String
get() = "https://your-cancel-url.com"
override fun onCreate(savedInstanceState: Bundle?) {
// ...
Expand All @@ -76,6 +90,11 @@ const kt = `class MainActivity : AppCompatActivity() {
if (url?.host == callbackUrl) {
return true
}
if (url?.host == cancelUrl) {
// handle webview removal
// Run the cancel payment function if you have one
return true
}
return super.shouldOverrideUrlLoading(view, request)
}
Expand Down
13 changes: 10 additions & 3 deletions dist/doc/payments/accept-payment/redirect-backend.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
const sh = `curl https://api.paystack.co/transaction/initialize
-H "Authorization: Bearer YOUR_SECRET_KEY"
-H "Content-Type: application/json"
-d '{ "email": "[email protected]", "amount": "20000" }'
-d '{ "email": "[email protected]", "amount": "20000",
"callback_url":"https://hello.pstk.xyz/callback",
"metadata":{"cancel_action": "https://your-cancel-url.com"}
}'
-X POST`

const js = `const https = require('https')
const params = JSON.stringify({
"email": "[email protected]",
"amount": "20000"
"amount": "20000",
"callback_url":"https://hello.pstk.xyz/callback",
"metadata":{"cancel_action": "https://your-cancel-url.com"}
})
const options = {
Expand Down Expand Up @@ -44,7 +49,9 @@ const php = `<?php
$fields = [
'email' => "[email protected]",
'amount' => "20000"
'amount' => "20000",
'callback_url' => "https://hello.pstk.xyz/callback",
'metadata' => ["cancel_action" => "https://your-cancel-url.com"]
];
$fields_string = http_build_query($fields);
Expand Down

0 comments on commit 17a8a67

Please sign in to comment.