Receipt Page

Display a receipt for an SDK transaction.

This code section sets up the Receipt page when using SDK giving forms.

Method

This function accepts a CreateTransactionResult object as its argument. From that data, it will render the receipt page.

This function is self-contained except for a local object theData, which stores form data in a redundant object.

theData.truncatedCardData is created at the end of the Recaptcha Callback function: theData.truncatedCardData = "****" + $('#cardData-cardNumber').val().slice(12,16);

function renderReceiptElements(dataIn) {

     //Accepts CreateTransactionResult object as argument.

     //Get date
     var date = new Date();
     var ddmmyyyy = [
         String(date.getMonth() + 1),
         String(date.getDate()),
         date.getFullYear()
     ];

     var dateText = ddmmyyyy[0] + '/' + ddmmyyyy[1] + '/' + ddmmyyyy[2];

     //Donor name
     $('#receipt-name-text').text("" + dataIn._raw_response.donor.contact.firstname + " " + dataIn._raw_response.donor.contact.lastname);

     //Receipt date
     $('#receipt-date-text').text("" + dateText);

     //Amount
     $('#receipt-gift-text').text("$" + dataIn._raw_response.transaction.total_value);

     //Recurring
     $('#receipt-frequency-text').text("" + dataIn._raw_response.form_data.frequency);

     //Truncated card
     $('#receipt-card-text').text("" + theData.truncatedCardData);

     //Set initial form to invisible
    $('#transaction-data').addClass('form-complete');
     $('#transaction-data').css('display', 'none');

     //Set receipt to visible
     $('.receipt-container').addClass('receipt-active');

     //For some reason there must be explicit css here
    $('.receipt-container').css('display', 'block');
    $('.receipt-container').css('opacity', '1');
}