Skip to content

Commit 8235fb9

Browse files
committed
feat : added a customization feel to the paystack component so that a person can input his or her own custom button in the vue-paystack with custom css since it is difficult to overide the default style of the payButton
1 parent a8bee04 commit 8235fb9

File tree

3 files changed

+89
-46
lines changed

3 files changed

+89
-46
lines changed

examples/commonjs/App.vue

Lines changed: 70 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,53 @@
11
<template>
2-
<div class="App">
3-
<p class="App-intro">
4-
<paystack
5-
:amount="amount"
6-
:email="email"
7-
:firstname="firstname"
8-
:lastname="lastname"
9-
:accessCode="accessCode"
10-
:splitCode="splitCode"
11-
:split="split"
12-
:paystackkey="paystackkey"
13-
:reference="genReference"
14-
:callback="callback"
15-
:close="close"
16-
:embed="false"
17-
>
18-
<i>Pay me, My Money</i>
19-
</paystack>
20-
</p>
21-
</div>
2+
<div class="App">
3+
<p class="App-intro">
4+
<paystack
5+
:amount="amount"
6+
:email="email"
7+
:firstname="firstname"
8+
:lastname="lastname"
9+
:accessCode="accessCode"
10+
:splitCode="splitCode"
11+
:split="split"
12+
:paystackkey="paystackkey"
13+
:reference="genReference"
14+
:callback="callback"
15+
:close="close"
16+
:embed="false"
17+
>
18+
<i>Pay me, My Money</i>
19+
</paystack>
20+
<paystack
21+
:amount="amount"
22+
:email="email"
23+
:firstname="firstname"
24+
:lastname="lastname"
25+
:accessCode="accessCode"
26+
:splitCode="splitCode"
27+
:split="split"
28+
:paystackkey="paystackkey"
29+
:reference="genReference"
30+
:callback="callback"
31+
:close="close"
32+
:embed="false"
33+
:custombutton="true"
34+
>
35+
<button
36+
style="
37+
border-radius: 5px;
38+
color: white;
39+
padding: 15px;
40+
background: crimson;
41+
border: 1px solid;
42+
cursor: pointer;
43+
margin: 20px;
44+
"
45+
>
46+
PAY WITH CUSTOM BUTTON
47+
</button>
48+
</paystack>
49+
</p>
50+
</div>
2251
</template>
2352

2453
<script type="text/javascript">
@@ -29,34 +58,34 @@ export default {
2958
},
3059
data(){
3160
return{
32-
paystackkey: "pk_test_xxxxxxxxxxxxxxxxxxxxxxx",
33-
firstname: "Foo",
34-
lastname: "Bar",
35-
email: "foo@bar.com",
36-
amount: 200000,
37-
splitCode: "",
38-
split: {},
39-
channels: ['card']
61+
paystackkey: "pk_test_xxxxxxxxxxxxxxxxxxxxxxx",
62+
firstname: "Foo",
63+
lastname: "Bar",
64+
email: "foo@bar.com",
65+
amount: 200000,
66+
splitCode: "",
67+
split: {},
68+
channels: ['card']
4069
}
4170
},
4271
computed: {
43-
genReference(){
44-
let text = "";
45-
let possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
72+
genReference(){
73+
let text = "";
74+
let possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
4675
47-
for( let i=0; i < 10; i++ )
48-
text += possible.charAt(Math.floor(Math.random() * possible.length));
76+
for( let i=0; i < 10; i++ )
77+
text += possible.charAt(Math.floor(Math.random() * possible.length));
4978
50-
return text;
51-
}
79+
return text;
80+
}
5281
},
5382
methods: {
54-
callback: function(response){
55-
console.log(response)
56-
},
57-
close: function(){
58-
console.log("Payment closed")
59-
}
83+
callback: function(response){
84+
console.log(response)
85+
},
86+
close: function(){
87+
console.log("Payment closed")
88+
}
6089
}
6190
}
6291
</script>

examples/commonjs/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Vue from 'vue'
22
import App from './App.vue'
33
new Vue({
4-
render: h => h(App)
4+
render: h => h(App)
55
}).$mount('#app')

src/paystack.vue

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
<template>
2-
<button
2+
<div
33
v-if="!embed"
4-
class="payButton"
4+
class="payContainer"
55
@click="payWithPaystack"
66
>
7-
<slot>Make Payment</slot>
8-
</button>
7+
<slot v-if="custombutton" />
8+
<button
9+
v-if="!custombutton"
10+
class="payButton"
11+
>
12+
<slot
13+
v-if="!custombutton"
14+
>
15+
Make Payment
16+
</slot>
17+
</button>
18+
</div>
919
<div
1020
v-else
1121
id="paystackEmbedContainer"
@@ -15,6 +25,10 @@
1525
<script type="text/javascript">
1626
export default {
1727
props: {
28+
custombutton: {
29+
type:Boolean,
30+
default : false
31+
},
1832
embed: {
1933
type: Boolean,
2034
default: false

0 commit comments

Comments
 (0)