Related
Is it possible to make partial refund using Authorize.Net? E.g. I have a transaction by 300$. First time I need to make a refund 100$ on this transaction. And second time to make a refund 50$.
What kind of transaction status will be after that?
first request:
...
"refId": "123456",
"transactionRequest": {
"transactionType": "refundTransaction",
"amount": "100.00",}
"refTransId": "1234567890"
}
...
second request:
...
"refId": "123456",
"transactionRequest": {
"transactionType": "refundTransaction",
"amount": "50.00",}
"refTransId": "1234567890"
}
...
Yes, you can make multiple refunds against one transaction as long as you do not go over the original transaction amount.
Below I made a $50 payment and then following up with a $20 and $10 refund. Both were successful.
Here is my original AUTH_CAPTURE request:
{
"createTransactionRequest": {
"merchantAuthentication": {
"name": "",
"transactionKey": ""
},
"refId": 38947161,
"transactionRequest": {
"transactionType": "authCaptureTransaction",
"amount": 100,
"payment": {
"creditCard": {
"cardNumber": "4111111111111111",
"expirationDate": "122020",
"cardCode": "999"
}
},
"order": {
"invoiceNumber": "1324567890",
"description": "this is a test transaction"
},
"lineItems": {
"lineItem": [
{
"itemId": "1",
"name": "vase",
"description": "Cannes logo",
"quantity": "18",
"unitPrice": "45.00"
},
{
"itemId": "2",
"name": "desk",
"description": "Big Desk",
"quantity": "10",
"unitPrice": "85.00"
}
]
},
"tax": {
"amount": "4.26",
"name": "level2 tax name",
"description": "level2 tax"
},
"duty": {
"amount": "8.55",
"name": "duty name",
"description": "duty description"
},
"shipping": {
"amount": "4.26",
"name": "level2 tax name",
"description": "level2 tax"
},
"poNumber": "456654",
"customer": {
"id": "18",
"email": "someone#blackhole.tv"
},
"billTo": {
"firstName": "Ellen",
"lastName": "Johnson",
"company": "Souveniropolis",
"address": "14 Main Street",
"city": "Pecan Springs",
"state": "TX",
"zip": "44628",
"country": "USA"
},
"shipTo": {
"firstName": "China",
"lastName": "Bayles",
"company": "Thyme for Tea",
"address": "12 Main Street",
"city": "Pecan Springs",
"state": "TX",
"zip": "44628",
"country": "USA"
},
"customerIP": "192.168.1.1",
"transactionSettings": {
"setting": [
{
"settingName": "allowPartialAuth",
"settingValue": "false"
},
{
"settingName": "duplicateWindow",
"settingValue": "0"
},
{
"settingName": "emailCustomer",
"settingValue": "false"
},
{
"settingName": "recurringBilling",
"settingValue": "false"
},
{
"settingName": "testRequest",
"settingValue": "false"
}
]
},
"userFields": {
"userField": {
"name": "favorite_color",
"value": "blue"
}
}
}
}
}
Here is my original AUTH_CAPTURE response:
{
"transactionResponse": {
"responseCode": "1",
"authCode": "TTJ26B",
"avsResultCode": "Y",
"cvvResultCode": "P",
"cavvResultCode": "2",
"transId": "40032153203",
"refTransID": "",
"transHash": "",
"testRequest": "0",
"accountNumber": "XXXX1111",
"accountType": "Visa",
"messages": [
{
"code": "1",
"description": "This transaction has been approved."
}
],
"userFields": [
{
"name": "favorite_color",
"value": "blue"
}
],
"transHashSha2": "0C9E5A47F93CD5B770A6B4AB24FE0F0D6F3B909066C72A10C4746F48C9886527A18B654736AE8D920D9048A14F2823A0DEC5B5F775A1C48DE9CBCF41C8D28CA3",
"SupplementalDataQualificationIndicator": 0
},
"refId": "38947161",
"messages": {
"resultCode": "Ok",
"message": [
{
"code": "I00001",
"text": "Successful."
}
]
}
}
Here is my first REFUND request (successful):
{
"createTransactionRequest": {
"merchantAuthentication": {
"name": "",
"transactionKey": ""
},
"refId": 30777668,
"transactionRequest": {
"transactionType": "refundTransaction",
"amount": 20,
"payment": {
"creditCard": {
"cardNumber": "4111111111111111",
"expirationDate": "122020"
}
},
"authCode": "40032153203"
}
}
}
Here is my first REFUND response (successful):
{
"transactionResponse": {
"responseCode": "1",
"authCode": "",
"avsResultCode": "P",
"cvvResultCode": "",
"cavvResultCode": "",
"transId": "40032153314",
"refTransID": "",
"transHash": "",
"testRequest": "0",
"accountNumber": "XXXX1111",
"accountType": "Visa",
"messages": [
{
"code": "1",
"description": "This transaction has been approved."
}
],
"transHashSha2": "4CE2D83B56C09494AD5609440E3337A6DEE0F4C74FBC99B218D65F6A121EFFC269F8954AC47C17B3B739E61A860C7B0818A8497D85D314D6E0CD89C9FE71A071",
"SupplementalDataQualificationIndicator": 0
},
"refId": "30777668",
"messages": {
"resultCode": "Ok",
"message": [
{
"code": "I00001",
"text": "Successful."
}
]
}
}
Here is my second REFUND request (successful):
{
"createTransactionRequest": {
"merchantAuthentication": {
"name": "",
"transactionKey": ""
},
"refId": 40597686,
"transactionRequest": {
"transactionType": "refundTransaction",
"amount": 10,
"payment": {
"creditCard": {
"cardNumber": "4111111111111111",
"expirationDate": "122020"
}
},
"authCode": "40032153203"
}
}
}
Here is my second REFUND response (successful):
{
"transactionResponse": {
"responseCode": "1",
"authCode": "",
"avsResultCode": "P",
"cvvResultCode": "",
"cavvResultCode": "",
"transId": "40032153319",
"refTransID": "",
"transHash": "",
"testRequest": "0",
"accountNumber": "XXXX1111",
"accountType": "Visa",
"messages": [
{
"code": "1",
"description": "This transaction has been approved."
}
],
"transHashSha2": "FD146FC0F8F3F31068905EC6C8D252662AA735ACDFAC53B4A8D808060C244C06288700AA8872466C3E240B62130D010CFBDE0473D09B631514A6E2E2CB77804F",
"SupplementalDataQualificationIndicator": 0
},
"refId": "40597686",
"messages": {
"resultCode": "Ok",
"message": [
{
"code": "I00001",
"text": "Successful."
}
]
}
}
I want to add the multiple payment profiles of a single customer in authorize.net. After a long searching I reached a post posted on the community of the authorize.net see link. In this link there a xml formated data in the accepted solution I convert it and send it through the postman then I'm facing the error of
"The element 'createCustomerProfileRequest' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd' has invalid child element '_xmlns' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'."
The json I'm sending is :-
{
"createCustomerProfileRequest": {
"merchantAuthentication": {
"name": "name",
"transactionKey": "transactionKey"
},
"refId": "1361101257555",
"profile": {
"merchantCustomerId": "2CLINC056",
"description": "hiiiiii.",
"email": "",
"paymentProfiles": [
{
"customerType": "individual",
"billTo": {
"firstName": "Joe",
"lastName": "Test",
"company": "CompanyA",
"address": "hello",
"city": "Bangalore",
"state": "Delhi",
"zip": "560078",
"country": "IN",
"phoneNumber": "415-555-1212",
"faxNumber": "415-555-1313"
},
"payment": {
"creditCard": {
"cardNumber": "370000000000002",
"expirationDate": "2029-12"
}
}
},
{
"customerType": "individual",
"billTo": {
"firstName": "Joe",
"lastName": "Test",
"company": "CompanyA",
"address": "vel",
"city": "Chennai",
"state": "AK",
"zip": "560089",
"country": "US",
"phoneNumber": "415-555-1212",
"faxNumber": "415-555-1313"
},
"payment": {
"creditCard": {
"cardNumber": "38000000000006",
"expirationDate": "2029-12"
}
}
}
]
},
"validationMode": "testMode",
"_xmlns": "AnetApi/xml/v1/schema/AnetApiSchema.xsd"
}
}
Developer link
I think your issue is not with the payment profiles but with the JSON itself. You have an invalid element in there and I think it is this line:
"_xmlns": "AnetApi/xml/v1/schema/AnetApiSchema.xsd"
Otherwise your request looks fine as I was able to create multiple payment profiles using similar JSON. The only difference between the two was my JSON didn't have that line.
Request JSON:
{
"createCustomerProfileRequest": {
"merchantAuthentication": {
"name": "xxxxxxxx",
"transactionKey": "xxxxxxxxxxxxxxxx"
},
"profile": {
"merchantCustomerId": "52353345",
"email": "user#example.com",
"paymentProfiles": [
{
"customerType": "individual",
"billTo": {
"firstName": "John",
"lastName": "Smith",
"address": "12345 Main Street",
"city": "Townsville",
"state": "NJ",
"zip": "12345",
"phoneNumber": "800-555-1234"
},
"payment": {
"creditCard": {
"cardNumber": "5555555555554444",
"expirationDate": "2023-08"
}
}
},
{
"customerType": "individual",
"billTo": {
"firstName": "John",
"lastName": "Smithberg",
"address": "42 Main Street",
"city": "Townsville",
"state": "NJ",
"zip": "12345",
"phoneNumber": "800-555-1234"
},
"payment": {
"creditCard": {
"cardNumber": "5105105105105100",
"expirationDate": "2023-09"
}
}
}
],
"shipToList": {
"firstName": "John",
"lastName": "Smith",
"address": "12345 Main Street",
"city": "Townsville",
"state": "NJ",
"zip": "12345",
"phoneNumber": "800-555-1234"
}
},
"validationMode": "liveMode"
}
}
Response JSON:
{
"customerProfileId": "1506322353",
"customerPaymentProfileIdList": [
"1505667207",
"1505667208"
],
"customerShippingAddressIdList": [
"1505655763"
],
"validationDirectResponseList": [
"1,1,1,This transaction has been approved.,A2FD5O,Y,40023515435,none,Test transaction for ValidateCustomerPaymentProfile.,0.00,CC,auth_only,52353345,John,Smith,,12345 Main Street,Townsville,NJ,12345,,800-555-1234,,user#example.com,,,,,,,,,0.00,0.00,0.00,FALSE,none,32573C7D03376A9052AACA73835EDAEF,P,2,,,,,,,,,,,XXXX4444,MasterCard,,,,,,,,,,,,,,,,,",
"1,1,1,This transaction has been approved.,AO13Y1,Y,40023515436,none,Test transaction for ValidateCustomerPaymentProfile.,0.00,CC,auth_only,52353345,John,Smithberg,,42 Main Street,Townsville,NJ,12345,,800-555-1234,,user#example.com,,,,,,,,,0.00,0.00,0.00,FALSE,none,5B937D29D29F261776859B50DC1C3CF6,P,2,,,,,,,,,,,XXXX5100,MasterCard,,,,,,,,,,,,,,,,,"
],
"messages": {
"resultCode": "Ok",
"message": [
{
"code": "I00001",
"text": "Successful."
}
]
}
}
I have a post man request. Which returns a response data as:
[
{
"id": "7ca27c09-2b67-417e-b367-f97d49824a2f",
"tags": [],
"type": "ApplicationProfile",
"userId": "2f2c8684-874d-49ea-bfa4-977069c1e3e2",
"profile": {
"User-Profile": {
"PHI": {
"gender": "Male",
"surgeryDate": {
"value": "2017-06-06"
},
"surgeryType": {
"value": "gastricBand"
},
"heightInches": "72",
"approvalPhase": "2",
"profileImageUrl": "",
"motivationalImageUrl": ""
},
"PII": {
"mail": "c11#c111.com",
"lastName": "",
"firstName": "name1",
"shouldReceiveNotifications": true
}
},
"motivationalGoals": [
{
"goal": "Improving health",
"goalId": "2957"
},
{
"goal": "Relieving pain",
"goalId": "2958"
},
{
"goal": "Feeling better",
"goalId": "2960"
}
]
},
"version": 35,
"createdBy": "2f2c8684-874d-49ea-bfa4-977069c1e3e2",
"lastModifiedBy": "2f2c8684-874d-49ea-bfa4-977069c1e3e2",
"applicationName": "Health Partner",
"createdDateTime": "2017-06-08T16:08:32.497Z",
"lastModifiedDateTime": "2017-06-09T13:23:03.503Z"
},
{
"id": "091b5ebd-b096-436e-a703-f97f0ae77baf",
"tags": [
"Application-Profile"
],
"type": "ApplicationProfile",
"userId": "2f2c8684-874d-49ea-bfa4-977069c1e3e2",
"profile": {
"User-Profile": {
"PHI": {
"gender": "",
"surgeryDate": {
"value": "2017-06-01"
},
"surgeryType": {
"value": ""
},
"heightInches": "72",
"approvalPhase": "2",
"profileImageUrl": "",
"motivationalImageUrl": ""
},
"PII": {
"mail": "c11#c111.com",
"lastName": "Dev",
"firstName": "Kat",
"shouldReceiveNotifications": true
}
},
"motivationalGoals": [
{
"goal": "Improving health",
"goalId": "2957"
},
{
"goal": "Relieving pain",
"goalId": "2958"
},
{
"goal": "Feeling better",
"goalId": "2960"
}
]
},
"version": 41,
"createdBy": "2f2c8684-874d-49ea-bfa4-977069c1e3e2",
"lastModifiedBy": "2f2c8684-874d-49ea-bfa4-977069c1e3e2",
"applicationName": "Health Partner Weightloss",
"createdDateTime": "2017-06-03T16:19:57.811Z",
"lastModifiedDateTime": "2017-06-08T16:07:49.555Z"
}
]
I need to extract the value of the emailid and set as global variable.
here is my code:
var jsonData1 = JSON.parse(responseBody);
postman.setGlobalVariable("jsonData1",jsonData1.profile.User-Profile.PII.mail);
But I am getting error. "User is undefined".
The problem here is that the hyphen / minus sign is interpreted as the subtraction operator.
Consider changing your API and using "userProfile" instead of "User-Profile".
In loopback, how could I remove the PK from the swagger json displayed.
This is the json displayed in my swagger:
{
"user_id": "string",
"order_type": "string",
"date": "2016-04-28",
"payload": {
"id": 0
},
"id": 0
}
image detail- Swagger
how could I remove the "id": 0 ?
This is my order.json :
{
"name": "Order",
"plural": "Orders",
"base": "Model",
"idInjection": true,
"options": {
"validateUpsert": true
},
"properties": {
"user_id": {
"type": "string",
"required": true
},
"order_type": {
"type": "string",
"required": true
},
"date": {
"type": "date",
"required": true
},
"payload": {
"type": "Payload",
"required": true
}
},
"validations": [],
"relations": {},
"acls": [],
"methods": {}
}
This is my order.js:
module.exports = (Order) => {
Order.create = function(body, cb) {
//
}
Order.remoteMethod('create', {
'http': {'path': '/'},
'accepts': [
{'arg': 'body', 'type': 'Order', 'required': true, 'http': { 'source': 'body' } }
]
});
};
Hidden property did the trick
{
"name": "Order",
"plural": "Orders",
"base": "Model",
"idInjection": false,
"options": {
"validateUpsert": true
},
"properties": {
...
},
"validations": [],
"relations": {},
"acls": [],
"methods": {},
"hidden": ["id"]
}
I'm working on an API for a school platform.
I want to migrate and seed the database in a boot script, while I'm still developing.
I can make school instances, group instances, and person instances, but I cannot figure out how to add a relation between the person instances and the group instances (Many to Many)
This is my Person .json file:
{
"name": "Person",
"base": "User",
"strict": true,
"idInjection": true,
"properties": {
"name": {
"type": "string",
"required": true
},
"firstName": {
"type": "string",
"required": true
}
},
"validations": [],
"relations": {
"groups": {
"type": "hasAndBelongsToMany",
"model": "Group"
},
"school": {
"type": "belongsTo",
"model": "School"
}
},
"acls": [],
"methods": []
}
This is my group.json file
{
"name": "Group",
"base": "PersistedModel",
"strict": true,
"idInjection": true,
"properties": {
"name": {
"type": "string",
"required": true
}
},
"validations": [],
"relations": {
"people": {
"type": "hasAndBelongsToMany",
"model": "Person"
},
"school": {
"type": "belongsTo",
"model": "School"
}
},
"acls": [],
"methods": []
}
And this is my boot script:
var async = require('async');
module.exports = function(app) {
var mysqlDs = app.dataSources.mysqlDs;
var boysNames = ["Lucas", "Liam", "Arthur", "Vince", "Noah", "Finn", "Mathis", "Louis", "Adam", "Jules", "Lars", "Seppe", "Stan", "Alexander", "Leon", "Kobe", "Victor", "Matteo", "Milan", "Mats", "Vic", "Wout", "Daan", "Senne", "Ferre", "Tuur", "Nathan", "Elias", "Warre", "Jack", "Felix", "Cas", "Thomas", "Lowie", "Robbe", "Lewis", "Rayan", "Nand", "Sem", "Maxim", "Emiel", "Jasper", "Oscar", "Mauro", "Sam", "Mohamed", "Luca", "Bent", "Ruben", "Simon", "Imran", "Jayden", "Lou", "Viktor", "Bas", "Lenn", "Rune", "Lukas", "Eden", "Emile"];
var girlsNames = ["Emma", "Louise", "Elise", "Ella", "Marie", "Noor", "Lena", "Julie", "Lotte", "Olivia", "Anna", "Elena", "Mila", "Lore", "Fien", "Nina", "Lina", "Nora", "Laura", "Juliette", "Charlotte", "Lisa", "Amber", "Amélie", "Fleur", "Renée", "Lily", "Sara", "Camille", "Hanne", "Luna", "Liv", "Roos", "Helena", "Sarah", "Sofia", "Janne", "Noa", "Jade", "Nore", "Fenna", "Axelle", "Kato", "Alice", "Aya", "Jana", "Lize", "Paulien", "Amelie", "Lucie", "Lara", "Zoë", "Mona", "Manon", "Leonie", "Ines", "Oona", "Laure", "Mira", "Febe"];
var names = ["Jong","Jansen","Vries","Visser","Jans","Bakker","Dijk","Vos","Smit","Berg","Boer","Groot","Janssen","Jacobs","Veen","Bos","Bergman","Hendriks","Dekker","Mulder","Willems","Meijer","Graaf","Leeuwen","Vermeulen","Koster","Peeters","Brouwer","Kok","Peters","Smits","Linden","Vliet","Wit","Beekman","Bosch","Meer","Koning","Beek","Haan","Vermeer","Verhoeven","Bruijn","Jonge","Heuvel","Martens","Dam","Hoek","Pieters","Walle","Bruin","Timmermans","Prins","Wouters","Janssens","Blom","Velde","Loon","Lange","Maas","Mol","Dijkstra","Post","Wal","Maes","Dieleman","Hermans","Jager","Stam","Gerrits","Groen","Roos","Wijk","Kuiper","Broek","Leeuw","Lambert","Kroon","Verdonck","Geerts","Boon","Hoekstra","Schouten","Gastel","Brink","Goossens","Steen","Bleijenberg","Bijl","Dubois","Jonker","Rooij","Driel","Pol","Ruiter","Stevens","Horst","Verbeek","Mertens","Ende","Sanders","Driessen","Huisman","Kooij","Schipper","Waal","Laan","Scholten","Vink","Ven","Postma","Aerts","Santen","Roovers","Verhulst","Verschoor","Ham","Moerman","Rijn","Bax","Franken","Eijk","Martin","Bosman","Meulen","Veenstra","Mostert","Velden","Harms","Wolters","Zanten","Claes","Poot","Ridder","Ginkel","Doorn","Heijden","Oost","Os","Blok","Kramer","Simons","Kuipers","Rovers","Cornelis","Dupont","Valk","Zwart","Gerard","Verweij"]
//first lets recreate all databases
mysqlDs.automigrate(function(){
console.log("tables recreated: let's seed");
async.parallel({
schools: async.apply(createSchools)
// ....
}, function(errFase1, resultsFase1) {
if (errFase1) throw errFase1;
async.parallel({
groups: async.apply(createGroups, resultsFase1.schools),
persons: async.apply(createStudents, resultsFase1.schools),
}, function(errFase2, resultsFase2) {
if (errFase2) throw errFase2;
// ???????????????????????????????????
// ??? HOW TO add a relation between the persons and the groups
// a person must be able to live
// in multiple groups
});
});
});
function createSchools(cb) {
var School = app.models.School;
School.create([
{
"name": "Harvard",
"address": "xxx",
"zip": "0000",
"place": "yyy"
},
{
"name": "Oxford",
"address": "xxx",
"zip": "0000",
"place": "yyy"
}
], cb);
}
function createGroups(schools,cb) {
var Group = app.models.Group;
Group.create([
{ "name": "Class 1", "schoolId": schools[0].id },
{ "name": "Class 2", "schoolId": schools[0].id },
{ "name": "Class 3", "schoolId": schools[0].id },
{ "name": "Class 4", "schoolId": schools[0].id },
{ "name": "Class 5", "schoolId": schools[0].id },
{ "name": "Class 6", "schoolId": schools[0].id },
{ "name": "Class 1", "schoolId": schools[1].id },
{ "name": "Class 2", "schoolId": schools[1].id },
{ "name": "Class 3", "schoolId": schools[1].id },
{ "name": "Class 4", "schoolId": schools[1].id },
{ "name": "Class 5", "schoolId": schools[1].id },
{ "name": "Class 6", "schoolId": schools[1].id },
], cb);
}
function createStudents(schools,cb) {
var Person = app.models.Person;
var students = [];
for (var i = 0; i < 240; i++) {
chooseFrom = (i%2 == 1) ? girlsNames : boysNames ;
students.push({
"name": names[i%names.length],
"firstName": chooseFrom[i%chooseFrom.length],
"username": "student"+i,
"password": "testje",
"email": "student"+i+"#mailinator.com",
"emailVerified": true,
"schoolId": schools[Math.floor(i/120)].id
});
};
Person.create(students, cb);
}
};
To add students to groups, I expected something like this, would do the trick :
Group.findOne(function(err, group){
console.log(group);
group.people().add(students[0].id);
})
I can't find any tutorials on this specific question.
I debugged the bootscript, and inspected the group variable, it's a ModelConstructor. I'm guessing I can get the related people via the people() function, but how can I add a person to a specific group?
Found the correct docs on this one:
http://apidocs.strongloop.com/loopback-datasource-juggler/#relationmixin-hasandbelongstomany
// id needs to be passed not entire instance. even loopbackjs docs needs to be updated
var student = students[0];
Group.findOne(function(err, group){
console.log(group);
group.people.add(student.id); // <--- id and not instance
})