This guide is designed for web developers and web designers.
How Donorfy web widgets work
A web widget is HTML code that can be embedded into most modern websites to enable online donations to be collected. Donorfy provides two kinds of web widget:
- for single and recurring donations by payment cards (debit/credit cards), using the Stripe payment gateway
- for recurring donations by Direct Debit, using the GoCardless payment gateway
- Stripe - for donations via credit/debit card - do this in Donorfy, Settings, Stripe Connect
- GoCardless - for Direct Debit donations - do this in Donorfy, Settings, GoCardless Connect
- a new donor (we call them constituents), unless it already exists
- a new donation (a Transaction - if a single donation was made)
- a Recurring Payment Instruction (if a recurring donation was set up)
- a Gift Aid Declaration.
It needs a combination of web design and coding skills (HTML, CSS, maybe some PHP) to arrive at a finished solution.
- whether it's Stripe or GoCardless
- and the following settings which affect how the donation is categorised when it reaches Donorfy
- the Product
- the Campaign
- the Payment Method
- the Fund
User interface
The important thing is to use the correct field ids, names, lengths, and the hidden fields. And to call the API correctly. See below for this information.
What happens - Payment Cards via Stripe
When a donor makes a payment card donation and clicks on the Submit button, the following happens within a few seconds:
- The card details are sent directly to Stripe, and Stripe returns to the website a 'token' representing that card (therefore Donorfy never stores the card details)
- the donor information on the form and the token are sent to Donorfy
- Donorfy collects the payment from Stripe using the token provided earlier
- the donor is added (if new) to Donorfy as a new Constituent and the donation is added to the constituent's Timeline as a Transaction.
- If the donor made a recurring donation by card, a Recurring Payment Instruction is added to the constituent's Timeline, and the recurring payments will be subsequently collected by Donorfy.
The process is logged and visible in Financial | Online Donations.
Website compatibility
Any modern website system should be able to accommodate a Donorfy web widget.
Your website needs an SSL certificate - so the page containing the widget needs to be https://yoursite.org/donate (for example).
Your website needs to jquery version 1.9 or later. NOTE: whilst WordPress.Org sites (the majority) do support this, their WordPress.com does not.
The Stripe widget can only use the Live Publishable Key - do not attempt to use the Test Publishable Key from Stripe.
Testing the widget
For Stripe, to do a complete end-to-end test you need to use a real card and submit small test donations, of say £1. You will see the donation in the constituent's Timeline.
For GoCardless you can create a live Direct Debit using real bank account information, see it in the constituent's Timeline and cancel the DD in GoCardless before it gets to claim it.
In both cases, you will see the processing information logged in Financial | Online Donations.
This article has information about troubleshooting common web widget problems
Can I use GoCardless' Sandbox?
No. Donorfy only works with live the GoCardless system.
When testing, as noted in the above Testing the Widget section you will need to create live Direct Debits and then cancel any mandates created whilst testing in the GoCardless dashboard.
Can I connect my GoCardless account to a test Donorfy account?
No. You should not connect one GoCardless account to two Donorfys (your live Donorfy and a test Donorfy account) as this will cause issues with the live submissions and updates from GoCardless to Donorfy. If you want to test using a live GoCardless account then we advise creating a 2nd GoCardless account solely for the purpose of using with your test Donorfy account.
Generating the HTML code to embed in your website
Follow these instructions to create a Stripe (cards) widget, or these instructions for a GoCardless (Direct Debit) widget.
Copy the generated HTML so that you can embed it into a page on your website.
Adding the widget to your website
Create a new page on your website. Paste the HTML that you copied in the previous step into the new page. Ensure that you are pasting it as HTML code, not as content to be displayed on the page (in WordPress for example, make sure you have the Text tab highlighted:
Modifying and styling the widget
You will want to modify the widget so that it is styled nicely into your website. You may also want to default certain values or hide fields. Within reason you can do what you like here to make the widget appear and behave as you wish.
The key things are that you must NOT change are:
- The form tag
- The ids, names and maximum field lengths of the input fields
- The hidden fields at the end of the generated HTML - after the comment 'Do not change these values' - these are used to control the operation of the widget.
Card Number fields do not seem to be working
If you are using the Stripe widgets which are Strong Customer Authentication compliant - see this - the fields where people enter their card number, expiry date and CVC code might not look like you can enter anything into them - as per the example below. If you can see the placeholders in the fields - i.e. 4 sets of 1234 in the card number, MM/YY in the expiry date and CVC then widget is initialising properly, also if you type a random card number in it will be shown in red as it is invalid.
This means your widget is working but you need to make the card number field etc look like the other fields see the next section in this document 'Making the Card Number and associated fields look like the other fields on your page'
Making the Card Number and associated fields look like the other fields on your page
When the card number, expiry date, and CVC fields are added to your page by Stripe they will not have any styling - e.g. background colour, font size etc - associated with them. You may want to add some styling so these fields are consistent with the rest of your page.
You can use the InitialiseForm function to style the controls that Stripe Elements adds to your page - see the example below - also see the Stripe knowledgebase articles for more info.
function InitialiseForm() {
var elementStyles = {
base: {
color: '#32325D',
fontWeight: 500,
fontFamily: 'Source Code Pro, Consolas, Menlo, monospace',
fontSize: '16px',
fontSmoothing: 'antialiased',
'::placeholder': {
color: '#CFD7DF',
},
':-webkit-autofill': {
color: '#e39f48',
},
},
invalid: {
color: '#E25950','::placeholder': {color: '#FFCCA5',},
}
};
var elementClasses = {
focus: 'focused',
empty: 'empty',
invalid: 'invalid',
};
cardNumber.update({style: elementStyles, classes: elementClasses} );
cardExpiry.update({style: elementStyles, classes: elementClasses} );
cardCvc.update({style: elementStyles, classes: elementClasses} );
}
Adding additional fields on the widget
You can prompt for additional information on web widgets to enrich data collection. See these articles:
Comments