/*
inputParams
InvoiceId:InternalId ofthe invoice(INTEGER)
cardId :InternalId of the credit card used(INTEGER)
returnParam
BOOLEAN:true if success Else false
*/
function createPayment(invoiceId,cardId){
try{
var cardIdInt = parseInt(cardId)
var validCard = !isNaN(cardIdInt);
var paymentRecord = record.transform({
fromType: record.Type.INVOICE,
fromId: invoiceId,
toType: record.Type.CUSTOMER_PAYMENT,
isDynamic: true,
});
if(validCard)
{
paymentRecord.setValue({fieldId:"creditcard",value:cardIdInt});
paymentRecord.setValue({fieldId:"autoapply",value:true});
paymentRecord.setValue({fieldId:"payment",value:1});
}
var paymentRecordId = paymentRecord.save();
return true;
} catch (e) {
log.debug("@createPayment", e);
}
return false;
}