Skip to content

Commit 5a1d867

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

File tree

5 files changed

+86
-91
lines changed

5 files changed

+86
-91
lines changed

PayPalExpressCheckout/authorization-and-capture-continue.js

Lines changed: 0 additions & 87 deletions
This file was deleted.
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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 authorizationAndCaptureContinued(transactionId, callback) {
9+
var merchantAuthenticationType = new ApiContracts.MerchantAuthenticationType();
10+
merchantAuthenticationType.setName(constants.apiLoginKey);
11+
merchantAuthenticationType.setTransactionKey(constants.transactionKey);
12+
13+
var payPalType = new ApiContracts.PayPalType();
14+
payPalType.setCancelUrl('http://www.merchanteCommerceSite.com/Success/TC25262');
15+
payPalType.setSuccessUrl('http://www.merchanteCommerceSite.com/Success/TC25262');
16+
payPalType.setPayerID('B2LA5T27DMX7G');
17+
18+
var paymentType = new ApiContracts.PaymentType();
19+
paymentType.setPayPal(payPalType);
20+
21+
var txnRequest = new ApiContracts.TransactionRequestType();
22+
txnRequest.setTransactionType(ApiContracts.TransactionTypeEnum.AUTHCAPTURECONTINUETRANSACTION);
23+
txnRequest.setPayment(paymentType);
24+
txnRequest.setAmount(utils.getRandomAmount());
25+
txnRequest.setRefTransId(transactionId);
26+
27+
var createRequest = new ApiContracts.CreateTransactionRequest();
28+
createRequest.setMerchantAuthentication(merchantAuthenticationType);
29+
createRequest.setTransactionRequest(txnRequest);
30+
31+
console.log(JSON.stringify(createRequest.getJSON(), null, 2));
32+
33+
var ctrl = new ApiControllers.CreateTransactionController(createRequest.getJSON());
34+
35+
ctrl.execute(function () {
36+
37+
var apiResponse = ctrl.getResponse();
38+
39+
var response = new ApiContracts.CreateTransactionResponse(apiResponse);
40+
41+
console.log(JSON.stringify(response, null, 2));
42+
43+
if (response !== null) {
44+
if (response.getMessages().getResultCode() === ApiContracts.MessageTypeEnum.OK) {
45+
if (response.getTransactionResponse().getMessages() !== null) {
46+
console.log('Successfully created transaction with Transaction ID: ' + response.getTransactionResponse().getTransId());
47+
console.log('Payer Id: ' + response.getTransactionResponse().getSecureAcceptance().getPayerID());
48+
console.log('Response Code: ' + response.getTransactionResponse().getResponseCode());
49+
console.log('Message Code: ' + response.getTransactionResponse().getMessages().getMessage()[0].getCode());
50+
console.log('Description: ' + response.getTransactionResponse().getMessages().getMessage()[0].getDescription());
51+
} else {
52+
console.log('Failed Transaction.');
53+
if (response.getTransactionResponse().getErrors() !== null) {
54+
console.log('Error Code: ' + response.getTransactionResponse().getErrors().getError()[0].getErrorCode());
55+
console.log('Error message: ' + response.getTransactionResponse().getErrors().getError()[0].getErrorText());
56+
}
57+
}
58+
} else {
59+
console.log('Failed Transaction. ');
60+
if (response.getTransactionResponse() !== null && response.getTransactionResponse().getErrors() !== null) {
61+
console.log('Error Code: ' + response.getTransactionResponse().getErrors().getError()[0].getErrorCode());
62+
console.log('Error message: ' + response.getTransactionResponse().getErrors().getError()[0].getErrorText());
63+
} else {
64+
console.log('Error Code: ' + response.getMessages().getMessage()[0].getCode());
65+
console.log('Error message: ' + response.getMessages().getMessage()[0].getText());
66+
}
67+
}
68+
} else {
69+
console.log('Null Response.');
70+
}
71+
72+
callback(response);
73+
});
74+
}
75+
76+
if (require.main === module) {
77+
authorizationAndCaptureContinued('2260016287', function () {
78+
console.log('authorizationAndCaptureContinued call complete.');
79+
});
80+
}
81+
82+
module.exports.authorizationAndCaptureContinued = authorizationAndCaptureContinued;

PayPalExpressCheckout/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
module.exports = {
4-
authorizationAndCaptureContinue: require('./authorization-and-capture-continue.js').authorizationAndCaptureContinue,
4+
authorizationAndCaptureContinued: require('./authorization-and-capture-continued.js').authorizationAndCaptureContinued,
55
authorizationAndCapture: require('./authorization-and-capture.js').authorizationAndCapture,
66
authorizationOnlyContinued: require('./authorization-only-continued.js').authorizationOnlyContinued,
77
authorizationOnly: require('./authorization-only.js').authorizationOnly,

list_of_sample_codes.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ getTransactionListForCustomer,1
2525
getUnsettledTransactionList,1
2626
createVisaCheckoutTransaction,0
2727
decryptVisaCheckoutData,1
28-
authorizationAndCaptureContinue,1
28+
authorizationAndCaptureContinued,1
2929
authorizationAndCapture,1
3030
authorizationOnlyContinued,1
3131
authorizationOnly,1

test-runner.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,9 @@ class TestRunner {
175175
});
176176
}
177177

178-
authorizationAndCaptureContinue(validateFunctionCallback){
178+
authorizationAndCaptureContinued(validateFunctionCallback){
179179
PayPalExpressCheckoutModule.authorizationAndCapture(function(response){
180-
PayPalExpressCheckoutModule.authorizationAndCaptureContinue(response.getTransactionResponse().getTransId(), validateFunctionCallback);
180+
PayPalExpressCheckoutModule.authorizationAndCaptureContinued(response.getTransactionResponse().getTransId(), validateFunctionCallback);
181181
});
182182
}
183183

0 commit comments

Comments
 (0)