Skip to content

Commit 8459d5e

Browse files
committed
Match the names as used in the API Reference
1 parent 5a1d867 commit 8459d5e

File tree

5 files changed

+81
-81
lines changed

5 files changed

+81
-81
lines changed

RecurringBilling/get-list-of-subscription.js

Lines changed: 0 additions & 77 deletions
This file was deleted.
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
'use strict';
2+
3+
var ApiContracts = require('authorizenet').APIContracts;
4+
var ApiControllers = require('authorizenet').APIControllers;
5+
var utils = require('../utils.js');
6+
var constants = require('../constants.js');
7+
8+
function getListOfSubscription(callback) {
9+
var merchantAuthenticationType = new ApiContracts.MerchantAuthenticationType();
10+
merchantAuthenticationType.setName(constants.apiLoginKey);
11+
merchantAuthenticationType.setTransactionKey(constants.transactionKey);
12+
13+
var refId = utils.getRandomInt();
14+
15+
var sorting = new ApiContracts.ARBGetSubscriptionListSorting();
16+
sorting.setOrderDescending(true);
17+
sorting.setOrderBy(ApiContracts.ARBGetSubscriptionListOrderFieldEnum.CREATETIMESTAMPUTC);
18+
19+
var paging = new ApiContracts.Paging();
20+
paging.setOffset(1);
21+
paging.setLimit(100);
22+
23+
var listRequest = new ApiContracts.ARBGetSubscriptionListRequest();
24+
25+
listRequest.setMerchantAuthentication(merchantAuthenticationType);
26+
27+
listRequest.setRefId(refId);
28+
listRequest.setSearchType(ApiContracts.ARBGetSubscriptionListSearchTypeEnum.SUBSCRIPTIONACTIVE);
29+
listRequest.setSorting(sorting);
30+
listRequest.setPaging(paging);
31+
32+
console.log(JSON.stringify(listRequest.getJSON(), null, 2));
33+
34+
var ctrl = new ApiControllers.ARBGetSubscriptionListController(listRequest.getJSON());
35+
36+
ctrl.execute(function(){
37+
var apiResponse = ctrl.getResponse();
38+
39+
var response = new ApiContracts.ARBGetSubscriptionListResponse(apiResponse);
40+
41+
console.log(JSON.stringify(response, null, 2));
42+
43+
if(response != null){
44+
if(response.getMessages().getResultCode() == ApiContracts.MessageTypeEnum.OK){
45+
console.log('Total Results: ' + response.getTotalNumInResultSet());
46+
console.log('List of Subscription IDs: ');
47+
var subscriptions = response.getSubscriptionDetails().getSubscriptionDetail();
48+
for (var i=0;i<subscriptions.length;i++)
49+
{
50+
console.log(subscriptions[i].getId());
51+
}
52+
console.log('Message Code: ' + response.getMessages().getMessage()[0].getCode());
53+
console.log('Message Text: ' + response.getMessages().getMessage()[0].getText());
54+
}
55+
else{
56+
console.log('Result Code: ' + response.getMessages().getResultCode());
57+
console.log('Error Code: ' + response.getMessages().getMessage()[0].getCode());
58+
console.log('Error message: ' + response.getMessages().getMessage()[0].getText());
59+
}
60+
}
61+
else{
62+
console.log('Null Response.');
63+
}
64+
65+
66+
67+
callback(response);
68+
});
69+
}
70+
71+
if (require.main === module) {
72+
getListOfSubscription(function(){
73+
console.log('getListOfSubscriptions call complete.');
74+
});
75+
}
76+
77+
module.exports.getListOfSubscriptions = getListOfSubscriptions;

RecurringBilling/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module.exports = {
44
cancelSubscription: require('./cancel-subscription.js').cancelSubscription,
55
createSubscriptionFromCustomerProfile: require('./create-subscription-from-customer-profile.js').createSubscriptionFromCustomerProfile,
66
createSubscription: require('./create-subscription.js').createSubscription,
7-
getListOfSubscription: require('./get-list-of-subscription.js').getListOfSubscription,
7+
getListOfSubscriptions: require('./get-list-of-subscriptions.js').getListOfSubscriptions,
88
getSubscriptionStatus: require('./get-subscription-status.js').getSubscriptionStatus,
99
getSubscription: require('./get-subscription.js').getSubscription,
1010
updateSubscription: require('./update-subscription.js').updateSubscription

list_of_sample_codes.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ chargeTokenizedCreditCard,1
1313
cancelSubscription,1
1414
createSubscriptionFromCustomerProfile,1
1515
createSubscription,1
16-
getListOfSubscription,1
16+
getListOfSubscriptions,1
1717
getSubscriptionStatus,1
1818
getSubscription,1
1919
updateSubscription,1

test-runner.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ class TestRunner {
104104
RecurringBillingModule.createSubscription(validateFunctionCallback);
105105
}
106106

107-
getListOfSubscription(validateFunctionCallback){
108-
RecurringBillingModule.getListOfSubscription(validateFunctionCallback);
107+
getListOfSubscriptions(validateFunctionCallback){
108+
RecurringBillingModule.getListOfSubscriptions(validateFunctionCallback);
109109
}
110110

111111
getSubscriptionStatus(validateFunctionCallback){

0 commit comments

Comments
 (0)