Skip to content

Commit

Permalink
Payline refactoring.
Browse files Browse the repository at this point in the history
  • Loading branch information
cybersonic committed Apr 21, 2016
1 parent 61433e3 commit 451eaa9
Show file tree
Hide file tree
Showing 4 changed files with 263 additions and 153 deletions.
45 changes: 2 additions & 43 deletions api/gateway/paylinedata/PaylineRequest.cfc
Expand Up @@ -81,51 +81,10 @@ component
if(!isNull(customer)){
var customer = customer.getMemento();


for(var k in customer){

if(k EQ "address" && !isNull(customer[k])){
var address = customer[k];
//Should be elevated out to the customer themselves no?
addKey(ret, "first_name", address.getFirstName());
addKey(ret, "last_name", address.getLastName());
addKey(ret, "company", address.getcompany());
addKey(ret, "address1", address.getaddress());
addKey(ret, "address2", address.getAddress2());
addKey(ret, "city", address.getCity());
addKey(ret, "state", address.getState());
addKey(ret, "zip", address.getZip());
addKey(ret, "country", address.getcountry());
addKey(ret, "phone", address.getphoneNumber());
addKey(ret, "fax", address.getphoneNumber());
addKey(ret, "email", address.getEmail());
}
else if(k EQ "shippingaddress" && !isNull(customer[k])){
var address = customer[k];
addKey(ret, "shipping_firstname", address.getFirstName());
addKey(ret, "shipping_lastname", address.getLastName());
addKey(ret, "shipping_company", address.getcompany());
addKey(ret, "shipping_address1", address.getaddress());
addKey(ret, "shipping_address2", address.getAddress2());
addKey(ret, "shipping_city", address.getCity());
addKey(ret, "shipping_state", address.getState());
addKey(ret, "shipping_zip", address.getZip());
addKey(ret, "shipping_country", address.getcountry());
addKey(ret, "shipping_phone", address.getphoneNumber());
addKey(ret, "shipping_fax", address.getphoneNumber());
addKey(ret, "shipping_email", address.getEmail());
if(!isNull(customer[k])){
addKey(ret, k, customer[k]);
}



//Dont add fields we don't have
else if(!isNull(customer[k])){
addKey(ret, k, customer[k]);
}




}
}

Expand Down
65 changes: 20 additions & 45 deletions api/gateway/paylinedata/PaylineResponse.cfc
Expand Up @@ -76,10 +76,11 @@ component
var parsedResult = getResult();

if(isXML(getResult())){
//We have to process this differently

//We have to process this differently
parseXMLResponse(getResult());
setParsedResult(parsedResult);



}
else {
Expand Down Expand Up @@ -158,62 +159,36 @@ component
setResponse(1);
setMessage("Returned customer from customer_vault");

var custData = {
'customerVaultId': custXML.customer_vault_id.XMLText,
"taxId": custXML.customertaxid.XMLText,
"shippingCarrier": custXML.shipping_carrier.XMLText,
"trackingNumber": custXML.tracking_number.XMLText,
"shippingDate": custXML.shipping_date.XMLText,
"shipping": custXML.shipping.XMLText,
"ccHash": custXML.cc_hash.XMLText,
"ccbin": custXML.cc_bin.XMLText,
"processorId": custXML.processor_id.XMLText,
}

setCustomerVaultId( custXML.customer_vault_id.XMLText);


var inputStruct = {};
for(var field in custXML.XMLChildren){

inputStruct[field.xmlName] = field.XMLText;


}


custData.address = new address({
"firstName":custXML.first_name.XMLText,
"lastName":custXML.last_name.XMLText,
"company":custXML.company.XMLText,
"address":custXML.address_1.XMLText,
"address2":custXML.address_2.XMLText,
"city":custXML.city.XMLText,
"state":custXML.state.XMLText,
"zip":custXML.postal_code.XMLText,
"country":custXML.country.XMLText,
"phoneNumber":custXML.phone.XMLText,
"email":custXML.email.XMLText,
"faxNumber":custXML.fax.XMLText,
"cellPhoneNumber":custXML.cell_phone.XMLText,
"website":custXML.website.XMLText,
});
custData.shippingAddress = new address({
"firstName":custXML.shipping_first_name.XMLText,
"lastName":custXML.shipping_last_name.XMLText,
"address":custXML.shipping_address_1.XMLText,
"address2":custXML.shipping_address_2.XMLText,
"city":custXML.shipping_city.XMLText,
"state":custXML.shipping_state.XMLText,
"zip":custXML.shipping_postal_code.XMLText,
"country":custXML.shipping_country.XMLText,
"email":custXML.shipping_email.XMLText,
});


var card = getService().createCreditCard();
card.setAccount(custXML.cc_number.XMLText);
card.setMonth(Left(custXML.cc_exp.XMLText, 2));
card.setYear(Right(custXML.cc_exp.XMLText, 2));
card.setIssueNumber(custXML.cc_issue_number.XMLText);

custData.card = card;
card.setStartMonth(Left(custXML.cc_start_date.XMLText, 2));
card.setStartYear(Right(custXML.cc_start_date.XMLText, 2));


inputStruct.card = card;


var customer = new customer(custData);
var customer = new customer().populate(inputStruct);

setCustomer(customer);
return;
return this;
}

//get the root
Expand Down

0 comments on commit 451eaa9

Please sign in to comment.