Jump to content

Fundraising/SmashPig

From Wikitech

Standalone Installation

This is where all the IPN listeners live as well as some maintenance scrips.

Live endpoint: https://payments-listener.wikimedia.org/adyen

CiviCRM Extension

We have written an extension in CiviCRM to use the SmashPig library to charge recurring payments. It currently supports credit cards via Ingenico and Adyen, and iDEAL and Apple Pay via Adyen.

The SmashPig extension has a settings menu in the Civi UI:

Administer -> System Settings -> SmashPig Settings

Here you can switch the extension to either use queues or directly insert the donation. In production we always want to use queues so that the charge job doesn't conflict with the donation queue consumer for table access, and so that any special data munging we apply in the queue consumer is applied consistently.

The extension defines a CiviCRM PaymentProcessor implementation (limited to only charging recurring installments) and a job that can be run via the CiviCRM.

Running the recurring job with 1 donation

drush @wmff -vv cvapi job.process_smashpig_recurring batch_size=1

Running with a specific recurring_id

drush @wmff -vv cvapi job.process_smashpig_recurring contribution_recur_id=12345

Runing through run job (if on prod, always use this instead of above two since we do not want deadlock), this will call the process control script and create a log file

run-job -j recurring_smashpig_charge --slow-start

Maintenance Scripts

You can run the SmashPig maintenance scripts from any server with SmashPig installed. Often the CiviCRM server is the most convenient since it's central and can see everything. Some of these are run on a schedule by process-control. All take a --config-node argument which specifies the payment processor config to load (perhaps it should be renamed).

ConsumePendingQueue

(Run on schedule)

CreateIpnMessagesFromPendingDb

(only for testing, may be obsolete)

DeleteExpiredPendingMessages

(Run on schedule)

DumpConfig

Print the merged config tree. Handy if you're not sure what's been overridden

php DumpConfig.php --config-node=adyen

EmptyQueueToDump

Script to empty out a queue backing store into a file. Objects are not kept in the queue after dumping.

InitializeSequence

Reset a sequence generator to a specific number, like the redis counter we use for ContributionTrackingId

PopulateQueueFromDump

Counterpart of EmptyQueueToDump.

php Maintenance/PopulateQueueFromDump.php --queue=recurring-modify queueMessage.json

QueueJobRunner

(Run on schedule) Runs jobs like those we send to jobs-adyen, jobs-paypal, etc

QueuePeek

Display the first message in the queue in print_r format

php Maintenance/QueuePeek.php donations

RequeueDelayedMessages

(Run on schedule)

TestFailMail

Logs stuff at every level up to alert to trigger a failmail.