Skip to content

Commit a93f4ae

Browse files
authored
feat(RNPSW): : add plan and invoice_limit props for pre-defined plan subscription (#181)
* feat(RNPSW): add plan prop add plan prop to provide option for creating subscription to predefined plan on paystack. This is in response to [issue #162](#162) * fix(RNPSW): add `invoice_limit` prop add `invoice_limit` prop, this is the number of times to charge customer during subscription to plan * fix(RNPSW): correct the planCodeString prop name
1 parent 6804e84 commit a93f4ae

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ function Pay(){
121121
| `billingEmail(required by paystack)` | Billers email | default: `nill` |
122122
| `billingMobile` | Billers mobile | default: `nill` |
123123
| `billingName` | Billers Name | default: `nill` |
124+
| `plan` | Specify plan code generated from the Paystack Dashboard or API to create a subscription to a predefined plan by the transaction. The plan code is a unique code given to every plan, it is used to identify a particular plan. Here's an example of usage: `plan: "PLANCODE"`. The `PLANCODE` comes in the format `PLN_xxxxxxxxxx` *NOTE*: _This would invalidate/override the value provided in `amount`_ | default: `nill` |
125+
| `invoice_limit` | Specify the number of times to charge customer during subscription to plan (integer). Works together with the `plan` prop | default: `nill` |
124126
| `subaccount` | Specify subaccount code generated from the Paystack Dashboard or API to enable Split Payment on the transaction. Here's an example of usage: `subaccount: "SUB_ACCOUNTCODE"` | default: `nill` |
125127
| `split_code` | Specify _split_code_ generated from the Paystack Dashboard under _Transaction Splits menu_ or API to enable Multi-Split Payment on the transaction. According to Paystack's documentation available [here](https://paystack.com/docs/payments/multi-split-payments/), Multi-split enables merchants to split the settlement for a transaction across their payout account, and one or more subaccounts. Here's an example of usage: `split_code: "SPL_xxxxxxx"` | default: `nill` |
126128
| `split` | Specify _split_ object to enable Dynamic Multi-Split Payment on the transaction. According to Paystack's documentation available [here](https://paystack.com/docs/payments/multi-split-payments/#dynamic-splits), Sometimes, you can't determine a split configuration until later in the purchase flow. With dynamic splits, you can create splits on the fly. The Structure is defined [in the Dynamic Multi-Split Structure below](#dynamic-multi-split-payment-object-structure) | default: `nill` |

development/paystack.tsx

+9
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ const Paystack: React.ForwardRefRenderFunction<React.ReactNode, PayStackProps> =
1919
channels = ['card'],
2020
refNumber,
2121
billingName,
22+
plan,
23+
invoice_limit,
2224
subaccount,
2325
split_code,
2426
split,
@@ -70,6 +72,11 @@ const Paystack: React.ForwardRefRenderFunction<React.ReactNode, PayStackProps> =
7072
const dynamicSplitString = dynamicSplitObjectIsValid(split) ? `split: ` + JSON.stringify(split) + `,` : ''; // should only send split for dynamic multi-account split with the correct split object as defined
7173
//Sometimes, you can't determine a split configuration until later in the purchase flow. With dynamic splits, you can create splits on the fly. This can be achieved by passing a split object
7274

75+
const planCodeString = plan ? `plan: '${plan}',` : ''; // should only send plan with the predefined plan_code as generated on paystack dashboard if present, else if blank, it will be ignored.
76+
// Please note that when plan is provided, the amount prop will be ignored
77+
78+
const invoiceLimitString = invoice_limit? `invoice_limit: ${invoice_limit},` : ''; // should only send invoice limit as integer when plan subscription is specified
79+
7380
const Paystackcontent = `
7481
<!DOCTYPE html>
7582
<html lang="en">
@@ -95,6 +102,8 @@ const Paystack: React.ForwardRefRenderFunction<React.ReactNode, PayStackProps> =
95102
currency: '${currency}',
96103
${getChannels(channels)}
97104
${refNumberString}
105+
${planCodeString}
106+
${invoiceLimitString}
98107
${subAccountString}
99108
${splitCodeString}
100109
${dynamicSplitString}

development/types/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ export interface PayStackProps {
3939
channels?: PaymentChannels[];
4040
refNumber?: string;
4141
billingName?: string;
42+
plan?: string;
43+
invoice_limit?: number;
4244
subaccount?: string;
4345
split_code?: string;
4446
split?: DynamicMultiSplitProps;

0 commit comments

Comments
 (0)