Skip to content

Commit 58054ef

Browse files
committed
Adding nice options for subscriptions and #15
1 parent 0fe0125 commit 58054ef

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

src/paypal-button.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ PAYPAL.apps = PAYPAL.apps || {};
1818
id: "hosted_button_id",
1919
name: "item_name",
2020
number: "item_number",
21-
lang: "lc"
21+
lang: "lc",
22+
recurrence: "p3",
23+
period: "t3"
2224
},
2325
buttonImgs = {
2426
buynow: "//www.paypalobjects.com/{locale}/i/btn/btn_buynow_{size}.gif",
@@ -89,6 +91,12 @@ PAYPAL.apps = PAYPAL.apps || {};
8991
// Subscribe buttons
9092
} else if (type === "subscribe") {
9193
data.add("cmd", "_xclick-subscriptions");
94+
95+
// TODO: "amount cannot be used in prettyParams since it's overloaded
96+
// Find a better way to do this
97+
if (data.items.amount && !data.items.a3) {
98+
data.add("a3", data.items.amount.value);
99+
}
92100
// Buy Now buttons
93101
} else {
94102
data.add("cmd", "_xclick");

test/index.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,10 @@ <h2>Subscribe (Small)</h2>
113113
<script src="../src/paypal-button.js?merchant=6XF3MPZBZV6HU"
114114
data-button="subscribe"
115115
data-name="Subscribe!"
116-
data-amount="1.00"
117116
data-size="small"
118-
data-a3="1.00"
119-
data-p3="1"
120-
data-t3="M"
117+
data-amount="1.00"
118+
data-recurrence="1"
119+
data-period="M"
121120
></script>
122121
</div>
123122

@@ -127,7 +126,8 @@ <h2>Subscribe (Large)</h2>
127126
data-button="subscribe"
128127
data-name="Subscribe!"
129128
data-amount="1.00"
130-
data-size="large"
129+
data-recurrence="1"
130+
data-period="M"
131131
></script>
132132
</div>
133133

0 commit comments

Comments
 (0)