earnshark-sdk
Advanced tools
Comparing version 0.0.6 to 0.0.7
32
index.js
@@ -182,2 +182,34 @@ var http = require('http'), | ||
// Retrieve All Payment Transactions for an Account | ||
exports.getAccountPayments = function(product_id, account_id ,key) { | ||
if (debug) { | ||
return new BbPromise(function(resolve, reject) { | ||
resolve('[ { "Amount":"100", "Created_At":"1474872974062", "Currency":"USD", "Product_ID":1, "PayPal_Transaction":"PAY-11111111111", "Updated_At":"1474872974062", "Account_ID":"local", "PayPal_Payer_ID":"111111", "Subscription_ID":1, "Payment_Processed":true, "Payout_ID":"12345", "Payment_Sent":true, "PayPal_Payment_ID":"PAY-11111111111" } ]') | ||
}); | ||
} else { | ||
var url = baseURL + product_id + '/account/'+account_id+'/transactions?key=' + key; | ||
var headers = { | ||
'User-Agent': 'Super Agent/0.0.1', | ||
'Content-Type': 'application/json' | ||
}, | ||
options = { | ||
url: url, | ||
method: 'GET', | ||
headers: headers | ||
}; | ||
return new BbPromise(function(resolve, reject) { | ||
request(options, function(error, response, body) { | ||
if (error) { | ||
reject(error) | ||
} else { | ||
resolve(response.body) | ||
} | ||
}); | ||
}); | ||
} | ||
}; | ||
// Generate the payment url for license payments | ||
@@ -184,0 +216,0 @@ exports.getPaymentURL = function(product_id, key, account_id, redirect) { |
{ | ||
"name": "earnshark-sdk", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"engines": { | ||
@@ -5,0 +5,0 @@ "node": ">=4.0" |
@@ -27,2 +27,3 @@ # earnshark-sdk-js | ||
* getPaymentURL - Returns the payment portal URL for a subscription(linked to PayPal) | ||
* getAccountPayments - Returns all the payment transactions associated with the account | ||
@@ -38,3 +39,3 @@ | ||
``` | ||
```javascript | ||
var earnsharknpm = require('earnshark-sdk'); | ||
@@ -46,6 +47,6 @@ | ||
var product_id = 'PRODUCT_ID;` // integer | ||
var product_id = 'PRODUCT_ID'; // integer | ||
``` | ||
###To retrieve the account information### | ||
``` | ||
```javascript | ||
earnsharknpm.getAccountInformation(product_id,key,account_id).then(function(data){ | ||
@@ -59,3 +60,3 @@ console.log(data) | ||
###To get the information related to a license### | ||
``` | ||
```javascript | ||
var license_id = 'ID'; // integer | ||
@@ -73,3 +74,3 @@ | ||
###To get all the product licenses### | ||
``` | ||
```javascript | ||
earnsharknpm.getAllLicensesOfProduct(product_id, key).then(function(data) { | ||
@@ -83,3 +84,3 @@ console.log(data) | ||
###To create a new user account### | ||
``` | ||
```javascript | ||
var body = { | ||
@@ -105,2 +106,14 @@ "account":{ | ||
``` | ||
###Generate Payment URL for an Account### | ||
```javascript | ||
earnsharknpm.getPaymentURL(product_id, key, data.account_id, data.redirect) | ||
``` | ||
###To retrieve All Payment Transactions for an Account### | ||
```javascript | ||
earnsharknpm.getAccountPayments(product_id, account_id,key).then(function(data) { | ||
console.log(data) | ||
}, function(err) { | ||
console.log(err) | ||
}); | ||
``` | ||
@@ -107,0 +120,0 @@ |
13522
185
116