forked from pgn420/facebookPlatform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpayment.js
64 lines (57 loc) · 1.5 KB
/
payment.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
function createPayment() {
var paymentContainer = createSection('Payment', 'payment_container');
createButton(paymentContainer, 'Buy Coin', 'buyCoins');
createButton(paymentContainer, 'Buy Gift', 'gift');
createButton(paymentContainer, 'Gift To', 'giftTo');
createButton(paymentContainer, 'New Payer Promotion', 'newPayerPromotion');
}
function verifyPayment(data) {
if (!data) {
alert("There was an error processing your payment. Please try again!");
return;
}
console.log('Verifying payment', data);
if (data.error_code) {
if (data.error_code != 1383010) {
alert("There was an error processing your payment." + data.error_message + " Error code:" + data.error_code);
}
return;
}
}
function buyCoins() {
//var requestID = hash(64);
//console.log("Constructing Request ID: " + requestID);
FB.ui({
method : 'pay',
action : 'purchaseitem',
product : gCoinsObjectURL,
//request_id : requestID,
quantity : 1
}, verifyPayment
);
}
function gift() {
FB.ui({
method: 'gift',
product: gCoinsObjectURL,
message: 'I hope you like my gift!',
}, fbCallback);
}
function giftTo() {
var friend = getSelectedFriend();
console.log('gift to friend ' + friend);
FB.ui({
method: 'gift',
product: gCoinsObjectURL,
message: 'I hope you like my gift!',
to: friend
}, fbCallback);
}
function newPayerPromotion() {
FB.ui({
method: 'fbpromotion',
display: 'popup',
quantity: 1,
product : gCoinsObjectURL,
}, fbCallback);
}