Skip to content

Commit 7780e62

Browse files
authored
Merge pull request #170 from just1and0/master
update main branch
2 parents faa68fc + 43e69e0 commit 7780e62

File tree

10 files changed

+82
-39
lines changed

10 files changed

+82
-39
lines changed

.DS_Store

4 KB
Binary file not shown.

.all-contributorsrc

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,41 @@
152152
"contributions": [
153153
"doc"
154154
]
155+
},
156+
{
157+
"login": "erasmuswill",
158+
"name": "Wilhelm Erasmus",
159+
"avatar_url": "https://avatars.githubusercontent.com/u/15966713?v=4",
160+
"profile": "https://erasmuswill.dev",
161+
"contributions": [
162+
"code"
163+
]
164+
},
165+
{
166+
"login": "opmat",
167+
"name": "Matiluko Opeyemi Emmanuel",
168+
"avatar_url": "https://avatars.githubusercontent.com/u/2133903?v=4",
169+
"profile": "https://github.com/opmat",
170+
"contributions": [
171+
"code"
172+
]
173+
},
174+
{
175+
"login": "mureyvenom",
176+
"name": "Oluwamurewa Alao",
177+
"avatar_url": "https://avatars.githubusercontent.com/u/47125673?v=4",
178+
"profile": "https://mureyfolio.com.ng/",
179+
"contributions": [
180+
"code"
181+
]
155182
}
156183
],
157184
"contributorsPerLine": 7,
158185
"projectName": "React-Native-Paystack-WebView",
159186
"projectOwner": "just1and0",
160187
"repoType": "github",
161188
"repoHost": "https://github.com",
162-
"skipCi": true
189+
"skipCi": true,
190+
"commitType": "docs",
191+
"commitConvention": "angular"
163192
}

README.md

Lines changed: 28 additions & 22 deletions
Large diffs are not rendered by default.

lib/paystack.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import * as React from 'react';
22
import { PayStackProps } from './types';
3-
declare const _default: React.ForwardRefExoticComponent<Pick<PayStackProps, "paystackKey" | "billingEmail" | "phone" | "lastName" | "firstName" | "amount" | "currency" | "channels" | "refNumber" | "billingName" | "handleWebViewMessage" | "onCancel" | "autoStart" | "onSuccess" | "activityIndicatorColor"> & React.RefAttributes<React.ReactNode>>;
3+
declare const _default: React.ForwardRefExoticComponent<Pick<PayStackProps, "paystackKey" | "billingEmail" | "phone" | "lastName" | "firstName" | "amount" | "currency" | "channels" | "refNumber" | "billingName" | "subaccount" | "handleWebViewMessage" | "onCancel" | "autoStart" | "onSuccess" | "activityIndicatorColor"> & React.RefAttributes<React.ReactNode>>;
44
export default _default;

lib/paystack.js

Lines changed: 8 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/paystack.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/types/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export interface PayStackProps {
1919
channels?: PaymentChannels[];
2020
refNumber?: string;
2121
billingName?: string;
22+
subaccount?: string;
2223
handleWebViewMessage?: (string: string) => void;
2324
onCancel: (Response: Response) => void;
2425
onSuccess: (SuccessResponse: SuccessResponse) => void;

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"name": "react-native-paystack-webview",
3-
"version": "4.0.3",
3+
"version": "4.1.4",
44
"description": "This package allows you to accept payment in your react native project using paystack ",
55
"homepage": "https://github.com/just1and0/React-Native-Paystack-WebView#readme",
66
"main": "lib/index.js",
7-
"types": "lib/index.ts",
7+
"types": "lib/index.d.ts",
88
"author": "Oluwatobi Shokunbi <[email protected]>",
99
"license": "MIT",
1010
"files": [

src/paystack.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const Paystack: React.ForwardRefRenderFunction<React.ReactNode, PayStackProps> =
1919
channels = ['card'],
2020
refNumber,
2121
billingName,
22+
subaccount,
2223
handleWebViewMessage,
2324
onCancel,
2425
autoStart = false,
@@ -51,6 +52,8 @@ const Paystack: React.ForwardRefRenderFunction<React.ReactNode, PayStackProps> =
5152
};
5253

5354
const refNumberString = refNumber ? `ref: '${refNumber}',` : ''; // should only send ref number if present, else if blank, paystack will auto-generate one
55+
56+
const subAccountString = subaccount ? `subaccount: '${subaccount}',` : ''; // should only send subaccount with the correct subaccoount_code if you want to enable split payment on transaction
5457

5558
const Paystackcontent = `
5659
<!DOCTYPE html>
@@ -62,11 +65,12 @@ const Paystack: React.ForwardRefRenderFunction<React.ReactNode, PayStackProps> =
6265
<title>Paystack</title>
6366
</head>
6467
<body onload="payWithPaystack()" style="background-color:#fff;height:100vh">
65-
<script src="https://js.paystack.co/v1/inline.js"></script>
68+
<script src="https://js.paystack.co/v2/inline.js"></script>
6669
<script type="text/javascript">
6770
window.onload = payWithPaystack;
6871
function payWithPaystack(){
69-
var handler = PaystackPop.setup({
72+
var paystack = new PaystackPop();
73+
paystack.newTransaction({
7074
key: '${paystackKey}',
7175
email: '${billingEmail}',
7276
firstname: '${firstName}',
@@ -76,6 +80,7 @@ const Paystack: React.ForwardRefRenderFunction<React.ReactNode, PayStackProps> =
7680
currency: '${currency}',
7781
${getChannels(channels)}
7882
${refNumberString}
83+
${subAccountString}
7984
metadata: {
8085
custom_fields: [
8186
{
@@ -84,16 +89,15 @@ const Paystack: React.ForwardRefRenderFunction<React.ReactNode, PayStackProps> =
8489
value:''
8590
}
8691
]},
87-
callback: function(response){
92+
onSuccess: function(response){
8893
var resp = {event:'successful', transactionRef:response};
8994
window.ReactNativeWebView.postMessage(JSON.stringify(resp))
9095
},
91-
onClose: function(){
96+
onCancel: function(){
9297
var resp = {event:'cancelled'};
9398
window.ReactNativeWebView.postMessage(JSON.stringify(resp))
9499
}
95100
});
96-
handler.openIframe();
97101
}
98102
</script>
99103
</body>

src/types/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export interface PayStackProps {
2222
channels?: PaymentChannels[];
2323
refNumber?: string;
2424
billingName?: string;
25+
subaccount?: string;
2526
handleWebViewMessage?: (string: string) => void;
2627
onCancel: (Response: Response) => void;
2728
onSuccess: (SuccessResponse:SuccessResponse) => void;
@@ -33,4 +34,4 @@ export interface PayStackProps {
3334
export interface PayStackRef {
3435
startTransaction: () => void;
3536
endTransaction: () => void;
36-
}
37+
}

0 commit comments

Comments
 (0)