Skip to content
This repository has been archived by the owner on Jun 25, 2021. It is now read-only.

Commit

Permalink
Merge branch 'master' of github.com:artfulrobot/uk.artfulrobot.civicr…
Browse files Browse the repository at this point in the history
…m.gocardless
  • Loading branch information
Rich Lott / Artful Robot committed Feb 18, 2021
2 parents 83a7970 + 799fc12 commit afba98b
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 28 deletions.
2 changes: 1 addition & 1 deletion ang/gocardless/GoCardlessSettings.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ <h1 crm-page-title>{{ts('GoCardless settings')}}</h1>
<form name="myForm" crm-ui-id-scope>
<div class="messages help">
<p ng-bind-html="ts('Please see <a %1>reference documentation</a> for these settings',
{1: 'href=&quot;https://docs.civicrm.org/gocardless/en/reference/settings/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;'})"></p>
{1: 'href=&quot;https://docs.civicrm.org/gocardless/en/latest/reference/settings/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;'})"></p>
</div>

<div class="crm-block">
Expand Down
15 changes: 12 additions & 3 deletions cli/import-from-gc.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
// What financial type do you want to use?
define('GC_IMPORT_FINANCIAL_TYPE_NAME', 'Donation (regular)');

// What price field do you want to use? Make sure the id exists!
define('GC_IMPORT_PRICE_FIELD_ID', 1);

// You can set a date here, or use NULL
// define('GC_IMPORT_SINCE', '2019-05-01T00:00:00Z');
define('GC_IMPORT_SINCE', NULL);
Expand All @@ -64,6 +67,9 @@ class GCImport
/** @var int financial type. */
public $financialTypeID;

/** @var int Price Field */
public $priceFieldID;

/** @var null|string date. */
public $importSince;

Expand Down Expand Up @@ -124,7 +130,7 @@ class GCImport
* @param String $financialTypeName
* @param null|String $importSince (date)
*/
public function __construct($financialTypeName, $importSince = NULL, $confirmCreateRecur=TRUE, $logDir=NULL) {
public function __construct($financialTypeName, $priceFieldID, $importSince = NULL, $confirmCreateRecur=TRUE, $logDir=NULL) {
civicrm_initialize();

if ($logDir !== NULL) {
Expand All @@ -145,6 +151,8 @@ public function __construct($financialTypeName, $importSince = NULL, $confirmCre
throw new InvalidArgumentException("Failed to find financial type '$financialTypeName'");
}

$this->priceFieldID = $priceFieldID;

$this->confirmCreateRecur = (bool) $confirmCreateRecur;

if ($importSince) {
Expand Down Expand Up @@ -328,7 +336,7 @@ public function getPaymentsToImport($subscription) {
'financial_type_id' => $this->financialTypeID,
'line_total' => $payment->amount / 100,
'unit_price' => $payment->amount / 100,
"price_field_id" => 1,
'price_field_id' => $this->priceFieldID,
'qty' => 1,
]]
]
Expand Down Expand Up @@ -488,7 +496,7 @@ public function createInitialPendingContrib($subscription, $contactID, $contribR
'line_item' => [[
'line_total' => $subscription->amount / 100,
'unit_price' => $subscription->amount / 100,
"price_field_id" => 1,
'price_field_id' => $this->priceFieldID,
'financial_type_id' => $this->financialTypeID,
'qty' => 1,
]]
Expand Down Expand Up @@ -622,6 +630,7 @@ public function saveAffectedSummary() {
try {
$importer = new GCImport(
GC_IMPORT_FINANCIAL_TYPE_NAME,
GC_IMPORT_PRICE_FIELD_ID,
GC_IMPORT_SINCE,
GC_CONFIRM_BEFORE_CREATING_RECUR,
GC_PRIVATE_OUTPUT_DIR
Expand Down
8 changes: 4 additions & 4 deletions docs/tutorial/contribution-page.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Setting up a contribution page is a big topic because there are so many
options, so this tutorial is going to cover the minimal setup required to
start taking regular monthly donations.
start taking regular monthly donations. See the User Guide for more details - [Creating Contribution Pages](https://docs.civicrm.org/user/en/latest/contributions/online-contributions/).

Go to **Contributions » New Contribution Page**.

Expand Down Expand Up @@ -47,7 +47,7 @@ Then click **Save and Done**
If you want to take one-offs, it's not your friend; it won't work and
it will cause a lot of confusion/frustration.

## Make a contribution.
## Make a contribution

You should now be on the list of Contribution Pages. (If not, find it
under **Contributions » Manage Contribution Pages**)
Expand All @@ -65,7 +65,8 @@ Click the **Links** link next to your new contribution page and click

Remember earlier we said GoCardless doesn't do one-offs? Well this is
important here because if a user does not check the "I want to
contribute every month" option then it will simply crash(!).
contribute every month" option then it will simply crash(!). You can
force this option on the [GoCardless Settings](../reference/settings.md#force-recurring) page.

You should now be on GoCardless' website, seeing one of their forms.

Expand Down Expand Up @@ -135,4 +136,3 @@ because we already know.
If you're geeky you might like to [continue the
tutorial](extra-marks.md) which will simulate the payment being
made and updating CiviCRM; and cancelling the subscription.

8 changes: 4 additions & 4 deletions docs/tutorial/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ This extension can be installed from within CiviCRM itself (assuming your
implementation allows that, some do not for security reasons).

!!! info Alternatives
You can install manually or from the git repo (developers) but [see notes](../howto/alternative-installs/)
You can install manually or from the git repo (developers) but [see notes](../howto/alternative-installs.md)

In your CiviCRM site, go to **Administer » System Settings » Extensions**
then visit the **Add New** tab. You can ee the CiviCRM user manual for details: [Installing
then visit the **Add New** tab. You can see the CiviCRM user manual for details: [Installing
extensions](https://docs.civicrm.org/user/en/latest/introduction/extensions/#installing-extensions).

**GoCardless Direct Debit Payment Processor** should be listed there, click the
Expand Down Expand Up @@ -71,6 +71,6 @@ put something in.

Click *Save*. You should now see your payment processor listed.

## Next step: set up your webhooks

## Next step

[Set up your webhooks](webhook.md)
21 changes: 5 additions & 16 deletions docs/tutorial/webhook.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Set up your webhook

!!! note
While we're on this settings page. You will want to tick the Force Recurring checkbox (see [Settings](../reference/settings.md#force-recurring)).

## Figure out your webhook endpoint URL

A "webhook endpoint" is a URL that GoCardless's system will use to tell
A "webhook endpoint" is a URL that GoCardless' system will use to tell
your CRM about payments.

!!! note
Expand All @@ -12,20 +15,6 @@ your CRM about payments.
In CiviCRM, visit **Administer » CiviContribute » GoCardless Settings**.
This page will show you the URLs that you need.

## Fix Contribution Pages problem with non-recurring

While we're on this settings page...

This GoCardless extension cannot handle one-offs; only recurring
contributions are allowed. CiviContribute's pages offer the user
a checkbox asking if they want to make it regular. If they don't check
that, and they're using a GoCardless payment processor, it will crash.

We can fix this by forcing contributions to use recurring payments if
a GoCardless processor is selected, which is what that Force Recurring
checkbox is about. **Check the force recurring checkbox and then click
Save**.

## Set up the webhooks at GoCardless

Login to your GoCardless sandbox account again (it's at
Expand All @@ -51,7 +40,7 @@ You should now see your webhook listed with a green dot and "enabled" in the
Status column.

!!! note
You can't setup a webhook to a private URL. e.g. if you have
You can't set up a webhook to a private URL. e.g. if you have
a development/staging server that's not publicly available, this is not
going to work. GoCardless needs to be able to reach the webhook URL.

Expand Down

0 comments on commit afba98b

Please sign in to comment.