function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Kumar Vikash 9Kumar Vikash 9 

Emailing payment schedules to the donor after setting up of a recurring payment

I am planning to add a button on the Opportunity Page to email the payments and its status as an attachment to the Primary Contact. I want to include -
1. The payment scheduled date, and
2. Corresponding payment amount (even though it would be the same) 
3. Payment Status (even though it would be unpaid)

I like the solution from SDocs, but want to create it in-house.
For generating the pdf, I am using the below code - 
 

<apex:page controller="vik_ThisOpportunityController" renderAs="pdf">
    <apex:form >
    	<h1 style="font-family: sans-serif; font-size:20px;">
            Payments Details for the Opportunities
        </h1>
        <p style="font-family: sans-serif; font-size:16px;">
            For your recurring donation, please find below the details on payments
        </p>
        <table style="width: 100%;">
            <tr style="font-size: 0.8em; font-family: sans-serif; ">
                    <th style="padding: 8px;
                               text-align: left; border-bottom: 1px solid #ddd;">Scheduled Date</th>
                    <th style="padding: 8px;
                               text-align: left; border-bottom: 1px solid #ddd;">Payment Amount</th>
                    <th style="padding: 8px;
                               text-align: left; border-bottom: 1px solid #ddd;">Payment Status</th>
            </tr>
            <apex:repeat value="{! payments }" var="pay">
            	<tr style="font-family: sans-serif; font-size: 0.8em;">
                	<td style="padding: 8px; text-align: left; 
                               border-bottom: 1px solid #ddd;">{!pay.npe01__Scheduled_Date__c}</td>
                    <td style="padding: 8px; text-align: left; 
                               border-bottom: 1px solid #ddd;">{!pay.npe01__Payment_Amount__c}</td>
                    <td style="padding: 8px; text-align: left; 
                               border-bottom: 1px solid #ddd;">{!pay.Payment_Status__c}</td>
                </tr>
            </apex:repeat>
        </table>
    </apex:form>
</apex:page>
Corresponding controller - 
public class vik_ThisOpportunityController {
    
    private final List<npe01__opppayment__c> payments;
    
    public vik_ThisOpportunityController() {
        List<npe01__opppayment__c> payments = [SELECT npe01__Scheduled_Date__c, npe01__Payment_Amount__c, Payment_Status__c 
                                               FROM npe01__opppayment__c 
                                               WHERE npe01__Opportunity__r.Id='006f400000CdtQjAAJ'];
    }
    
    public List<npe01__opppayment__c> getPayments() {
        return payments;
    }
}
Please find below the result from the Query Editor, which I want to replicate in the pdf - 
Query result with separate payments and their status

Right, now I am just trying to develop a table for a static Opportunity ID and later plan to make it dynamic, so that I can add a button in the Opportunity page, which picks up the Opportunity ID, and emails the related payments. My problem is that, even with the static content, I am not getting any output-
Current output pdf with no rows
I have a feeling that I might even not need a custom controller for this as Payment is intrinsic to the npsp Salesforce, but still it would be really appreciated if you could help me troubleshoot this.

Thanks!