In this article we are going to demonstrate, how you can leverage RaiseNow and https://qr-rechnung.net to dynamically generate a TwintQr/SwissQr payment slip based on opportunities or recurring donations in Salesforce.
Here is an example:
Donors will be able to use this payment slip to pay either with Twint or via their online-banking application. Twint payments will be automatically matched in Salesforce.
If you use the RaiseNow reconciliation for processing payments from your bank, these payments will be automatically matched as well, on processing the camt file provided by your bank.
Disclaimers:
- https://qr-rechnung.net is not a service provided by RaiseNow. It is an independent project and free for use. Please read carefully through the terms of use and the FAQs. We really appreciate this project and are happy we can use it in this show case. However, RaiseNow cannot provide any support regrding https://qr-rechnung.net.
- This article is written as a proof-of-concept and has not (yet) been tested in the wild. It is likely that edge cases hidden in your data are not covered. Please do your own testing. We appreciate your feedback and suggestions for improvements.
To generate the qr payment slip in Salesforce we will use:
- Salesforce flow to provide some date
- RaiseNow to generate the payment reference
- qr-rechnung.net to generate dynamic PDF links for the qr payment slip
The basic concept is very simple:
When a RaiseNow payment reference is generated, either identify the related opportunity and update fields on that opportunity or identify the related recurring donation and update fields on that recurring donation.
The complete flow looks like this:
Formulas and Variables
The flow will emply a number of variables and formulas. The essentials happen in this part.
Formulas:
calculateAddressIsComplete
IF($Record.RaiseNow__Contact__r.FirstName == "", false, IF ($Record.RaiseNow__Contact__r.LastName="",false, IF($Record.RaiseNow__Contact__r.MailingStreet=="",false,IF($Record.RaiseNow__Contact__r.MailingPostalCode=="",false,IF($Record.RaiseNow__Contact__r.MailingCity=="",false,true)))))
-> If we have a complete address we will use that within the payment slip. Else we will set an empty address.
calculateAmount
If({!isRecurringDonation}==true,{!$Record.RaiseNow__Subscription__r.RaiseNow__NPSP_Recurring_Donation__r.npe03__Amount__c},{!$Record.RaiseNow__Opportunity__r.Amount})
-> If our main object is a recurring donation, get the amount from there. If it is an opportunity, get the amount from the opportunity.
getAddresseeString
IF({!addressIsComplete} == true,HTMLENCODE({!$Record.RaiseNow__Contact__r.FirstName}+" "+{!$Record.RaiseNow__Contact__r.LastName}+","+{!$Record.RaiseNow__Contact__r.MailingStreet}+",,"+{!$Record.RaiseNow__Contact__r.MailingPostalCode}+","+{!$Record.RaiseNow__Contact__r.MailingCity}+","+"CH"),",,,,,")
-> If we have a complete address, we need to HTML encode that address in order to pass it as a query string to https://qr-rechnung.net later.
getAverageDonationAmount
IF({!$Record.RaiseNow__Contact__r.npo02__AverageAmount__c}==0,"50",TEXT({!$Record.RaiseNow__Contact__r.npo02__AverageAmount__c}))
-> If we do not have an opportunity or a recurring donation to base our choice upon, the contacts average donation amount seems like a good choice. This is somewhat arbitrary.
getRecipientLanguage
IF({!$Record.RaiseNow__Contact__r.RaiseNow__Language__c}=="","de",{!$Record.RaiseNow__Contact__r.RaiseNow__Language__c})
-> We need to define the language in which the payment slip will be rendered. This formula defaults to german and retrieves the language from the RaiseNow field. Adapt to whatever suits your needs.
htmlEncodeOrganisationAddress
HTMLENCODE({!organisationAddress})
-> We also need to HTML encode the organisation address for use with https://qr-rechnung.net later.
Variables:
addressIsComplete
{!calculateAddressIsComplete}
-> It is handy to use this in other formulas.
htmlEncodedTwintString
<replace-me-with-the-html-encoded-twint-string-for-your-organisation>
-> HTMLENCODE provided by Salesforce does not properly convert some of the characters in the twint string as needed for this scenarios. One easy way to do this is to download the qr code from hub and use the image to generate the string needed directly on https://qr-rechnung.net.
See this short video on how to do that.
<replace with your QR IBAN>
{!$GlobalConstant.False}
organisationAddress
Futurogoal,Hardturmstrasse,101,8005,Zürich,CH
-> Obvoiusly replace with your proper address. Note, the number of elements seperated by "," is very important.
Build the SwissQR Formula:
"https://qr-rechnung.net/#/b,"+{!getRecipientLanguage}+",SPC,0200,1,"+{!IBAN}+",S,"+{!htmlEncodeOrganisationAddress}+",,,,,,,,"+TEXT({!calculateAmount})+","+"CHF"+",S,"+{!getAddresseeString}+",QRR,"+{!$Record.RaiseNow__Payment_Reference__c}+",,EPD,,"+{!htmlEncodedTwintString}+"?op=viewpdf"
Build the flow
Decision element
Check if the generated payment reference targets a recurring donation:
Check if the generated payment refernence targets a direct marketing campaign:
-> The check for the null value for the opportunity is important here to catch some edge cases such as repeated use of a reference number or direct payment refernence generation on the opportunity.
Updating records
Depending on the above decision we simply update custom fields on the respective records
Recurring Donation:
Payment refeference
Opportunity
Using it
There are many potential applications. Here is an example of an email template for this purpose. Behind the link in the sceencast is simply this formula.
{{{Opportunity.SwissQR__c}}}
Comments
0 comments
Please sign in to leave a comment.