-
Notifications
You must be signed in to change notification settings - Fork 63
/
Copy pathpatch-customer-payment-instrument-card.js
84 lines (75 loc) · 2.5 KB
/
patch-customer-payment-instrument-card.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
'use strict';
var cybersourceRestApi = require('cybersource-rest-client');
var path = require('path');
var filePath = path.resolve('Data/Configuration.js');
var configuration = require(filePath);
var createCustomerPaymentInstrument = require('./create-customer-non-default-payment-instrument-card');
function patch_customer_payment_instrument(callback) {
var customerTokenId = 'AB695DA801DD1BB6E05341588E0A3BDC';
try {
var configObject = new configuration();
var apiClient = new cybersourceRestApi.ApiClient();
var requestObj =
new cybersourceRestApi.PostCustomerPaymentInstrumentRequest();
requestObj._default = false;
var card =
new cybersourceRestApi.Tmsv2customersEmbeddedDefaultPaymentInstrumentCard();
card.expirationMonth = '12';
card.expirationYear = '2031';
card.type = '001';
requestObj.card = card;
var billTo =
new cybersourceRestApi.Tmsv2customersEmbeddedDefaultPaymentInstrumentBillTo();
billTo.firstName = 'Chandra';
billTo.lastName = 'Shekhar';
billTo.company = 'CyberSource';
billTo.address1 = '1 Market St';
billTo.locality = 'San Francisco';
billTo.administrativeArea = 'CA';
billTo.postalCode = '94105';
billTo.country = 'US';
billTo.email = '[email protected]';
billTo.phoneNumber = '4158880000';
requestObj.billTo = billTo;
var opts = [];
var instance = new cybersourceRestApi.CustomerPaymentInstrumentApi(
configObject,
apiClient
);
createCustomerPaymentInstrument.create_customer_non_default_payment_instrument_card(
function (error, data) {
if (data) {
var paymentInstrumentTokenId = data['id'];
instance.patchCustomersPaymentInstrument(
customerTokenId,
paymentInstrumentTokenId,
requestObj,
opts,
function (error, data, response) {
if (error) {
console.log('\nError : ' + JSON.stringify(error));
} else if (data) {
console.log('\nData : ' + JSON.stringify(data));
}
console.log('\nResponse : ' + JSON.stringify(response));
console.log(
'\nResponse Code of Patch a Customer Payment Instrument : ' +
JSON.stringify(response['status'])
);
callback(error, data, response);
}
);
}
}
);
} catch (error) {
console.log('\nException on calling the API : ' + error);
}
}
if (require.main === module) {
patch_customer_payment_instrument(function () {
console.log('\nPatchCustomerPaymentInstrument end.');
});
}
module.exports.patch_customer_payment_instrument =
patch_customer_payment_instrument;