Skip to content

Commit

Permalink
Feat: Add support for dynamic split
Browse files Browse the repository at this point in the history
  • Loading branch information
damilola-paystack committed Sep 28, 2020
1 parent bf40ef6 commit 6a29144
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ new Vue({
```
[Usage Example via CDN](examples/index.html)

Please checkout [Paystack Documentation](https://developers.paystack.co/docs/paystack-inline) for other available options you can add to the
Please checkout [Paystack Documentation](https://paystack.com/docs/payments/accept-payments#popup) for other available options you can add to the

## Deployment
REMEMBER TO CHANGE THE KEY WHEN DEPLOYING ON A LIVE/PRODUCTION SYSTEM
Expand Down
4 changes: 3 additions & 1 deletion examples/commonjs/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
:lastname="lastname"
:accessCode="accessCode"
:splitCode="splitCode"
:split="split"
:paystackkey="paystackkey"
:reference="genReference"
:callback="callback"
Expand All @@ -32,8 +33,9 @@ export default {
firstname: "Foo",
lastname: "Bar",
email: "[email protected]",
amount: 2000000,
amount: 200000,
splitCode: "",
split: {},
channels: ['card']
}
},
Expand Down
19 changes: 15 additions & 4 deletions src/paystack.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ export default {
type: String,
default: ""
},
split: {
type: Object,
default: function() {
return {};
}
},
splitCode: {
type: String,
default: ""
Expand Down Expand Up @@ -139,6 +145,10 @@ export default {
}
},
isDynamicSplit() {
return this.split.constructor === Object && Object.keys(this.split).length > 0;
},
payWithPaystack() {
this.scriptLoaded &&
this.scriptLoaded.then(() => {
Expand All @@ -161,10 +171,11 @@ export default {
currency: this.currency,
plan: this.plan,
quantity: this.quantity,
subaccount: this.subaccount,
split_code: this.splitCode,
transaction_charge: this.transactionCharge,
bearer: this.bearer
subaccount: this.isDynamicSplit() ? "" : this.subaccount,
split: this.isDynamicSplit() ? this.split : {},
split_code: this.isDynamicSplit() ? "" : this.splitCode,
transaction_charge: this.isDynamicSplit() ? 0 : this.transactionCharge,
bearer: this.isDynamicSplit() ? "" : this.bearer
};
if (this.embed) {
Expand Down

0 comments on commit 6a29144

Please sign in to comment.