Skip to content

Manage Recurring Contributions #256

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 24 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
1a0ef0f
Pass recurring contributions data to omnipay
bastienho Oct 13, 2023
dd3286d
Adds hook for data customization for Systempay
bastienho Oct 13, 2023
d2c79b6
Merge branch 'master' into recurring-contributions
bastienho Oct 17, 2023
858204f
Bump hounddd/omnipay-systempay to v3.0.3
bastienho Oct 17, 2023
99416ff
Next payment should occur after 1 interval
bastienho Oct 20, 2023
7ecbfb3
Manage DAILY frequency
bastienho Oct 20, 2023
d3217e3
Alter page_action in subscription context
bastienho Oct 20, 2023
1f1439c
Implement order_id in omnipay-systempay
bastienho Oct 23, 2023
9b5b096
Fake version
bastienho Oct 23, 2023
b5eb797
Fix path of Metadata
bastienho Oct 23, 2023
ae94911
Merge branch 'recurring-contributions' into update-from-3.21
bastienho Oct 25, 2023
9ab87fb
Merge pull request #2 from agencenous/update-from-3.21
bastienho Oct 25, 2023
0741811
Cleanup repo
bastienho Oct 25, 2023
587266c
pre-update omnipay-systempay deps
bastienho Oct 25, 2023
bfcc6d3
Check if contributionrecur is set
bastienho Oct 26, 2023
c008872
Allows custom data merging
bastienho Nov 3, 2023
86bb46b
Merge branch 'recurring-contributions' into v3.22-conflicts-resolution
bastienho Dec 5, 2023
83cca0c
Merge pull request #3 from agencenous/v3.22-conflicts-resolution
bastienho Jan 4, 2024
b6a74cc
Merge branch 'recurring-contributions' into master
bastienho Jan 9, 2024
42c71d8
Merge pull request #4 from agencenous/master
bastienho Jan 9, 2024
1e41844
Composer upgrade
bastienho Jan 9, 2024
501f32f
Add missing myclabs/deep-copy
bastienho Jan 9, 2024
8014cb7
Composer with no-dev
bastienho Jan 9, 2024
a072218
cleanup repo
bastienho Jan 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CRM/Core/Payment/OmnipayMultiProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,21 @@ protected function getCreditCardOptions(array $params): array {
'cardReference' => $params['token'] ?? NULL,
'transactionReference' => $params['token'] ?? NULL,
'cardTransactionType' => $params['cardTransactionType'] ?? NULL,
'token' => null
];

// CiviCRM data related to recurring contributions
// We store it in the `token` attribute
// as suggested in https://omnipay.thephpleague.com/api/recurring-billing/
if(isset($params['is_recur'])){
$creditCardOptions['token'] = [
'isRecur' => $params['is_recur'] ?? FALSE,
'frequencyInterval' => $params['frequency_interval'] ?? NULL,
'frequencyUnit' => $params['frequency_unit'] ?? NULL,
'contributionRecurID' => $params['contributionRecurID'] ?? NULL,
];
}

if (!empty($params['action'])) {
$creditCardOptions['action'] = 'Purchase';
}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"razorpay/omnipay-razorpay": "^3.0@dev",
"clue/stream-filter": "^1.4.1",
"cloudcogsio/omnipay-firstatlanticcommerce-gateway" : "^1.0.2",
"hounddd/omnipay-systempay": "dev-master",
"hounddd/omnipay-systempay": "^3.0.3",
"ext-json": "*"
},
"replace": {
Expand Down
69 changes: 34 additions & 35 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
<url desc="Licensing">http://civicrm.org/licensing</url>
</urls>
<releaseDate>2024-01-01</releaseDate>
<version>3.23</version>
<develStage>stable</develStage>
<version>3.23.patched</version>
<develStage>dev</develStage>
<compatibility>
<ver>5.69</ver>
</compatibility>
Expand Down
45 changes: 45 additions & 0 deletions omnipaymultiprocessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,48 @@ function omnipaymultiprocessor_civicrm_preProcess($formName, $form) {
}

}

function omnipaymultiprocessor_civicrm_alterPaymentProcessorParams($instance, $params, &$creditCardOptions){
if($instance instanceof CRM_Core_Payment_OmnipayMultiProcessor ) {
$payment_processor_id = $params['payment_processor_id'];

$payment_processor_types = civicrm_api4('PaymentProcessor', 'get', [
'select' => [
'payment_processor_type_id.name',
],
'where' => [
['id', '=', $payment_processor_id],
],
'limit' => 1,
'checkPermissions' => false,
]);
$payment_processor_type_name = $payment_processor_types->first()['payment_processor_type_id.name'];

// Custom data tranformation for recurring contributions in SystemPay
if($payment_processor_type_name === 'omnipay_SystemPay' && isset($creditCardOptions['token']) && $creditCardOptions['token']){
$rawTokenData = $creditCardOptions['token'];
if(empty($rawTokenData['contributionRecurID'])){
return;
}
$creditCardOptions['token'] = [];
$creditCardOptions['token']['vads_page_action'] = 'REGISTER_PAY_SUBSCRIBE';
$creditCardOptions['token']['vads_sub_amount'] = $creditCardOptions['amount']*100;
$creditCardOptions['token']['vads_sub_currency'] = $creditCardOptions['currency'];
$creditCardOptions['token']['vads_subscription'] = $rawTokenData['contributionRecurID'];

// Next payment should occur after 1 interval
$creditCardOptions['token']['vads_sub_effect_date'] = date('Ymd', strtotime('+'.$rawTokenData['frequencyInterval'].' '.$rawTokenData['frequencyUnit']));

// Manage frequency
$creditCardOptions['token']['vads_sub_desc'] = 'RRULE:FREQ='.(strtoupper($rawTokenData['frequencyUnit']=='day'?'dai':$rawTokenData['frequencyUnit']).'LY').';INTERVAL='.$rawTokenData['frequencyInterval'];

// TODO: implement this option
// $creditCardOptions['token']['vads_sub_init_amount'] = null;
// $creditCardOptions['token']['vads_sub_init_amount_number'] = null;

if(isset($rawTokenData['token'])){
$creditCardOptions['token'] = array_merge($creditCardOptions['token'], $rawTokenData['token']);
}
}
}
}
17 changes: 15 additions & 2 deletions vendor/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,21 @@
// autoload.php @generated by Composer

if (PHP_VERSION_ID < 50600) {
echo 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
exit(1);
if (!headers_sent()) {
header('HTTP/1.1 500 Internal Server Error');
}
$err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
if (!ini_get('display_errors')) {
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
fwrite(STDERR, $err);
} elseif (!headers_sent()) {
echo $err;
}
}
trigger_error(
$err,
E_USER_ERROR
);
}

require_once __DIR__ . '/composer/autoload_real.php';
Expand Down
Loading