[#8] added twingle ID prefix
This commit is contained in:
parent
33c81951fc
commit
d9a44f07e7
7 changed files with 42 additions and 7 deletions
|
@ -145,6 +145,21 @@ class CRM_Twingle_Profile {
|
||||||
$this->data[$attribute_name] = $value;
|
$this->data[$attribute_name] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the CiviCRM transaction ID (to be used in contributions and recurring contributions)
|
||||||
|
*
|
||||||
|
* @param $twingle_id string Twingle ID
|
||||||
|
* @return string CiviCRM transaction ID
|
||||||
|
*/
|
||||||
|
public function getTransactionID($twingle_id) {
|
||||||
|
$prefix = CRM_Core_BAO_Setting::getItem('de.systopia.twingle', 'twingle_prefix');
|
||||||
|
if (empty($prefix)) {
|
||||||
|
return $twingle_id;
|
||||||
|
} else {
|
||||||
|
return $prefix . $twingle_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verifies whether the profile is valid (i.e. consistent and not colliding
|
* Verifies whether the profile is valid (i.e. consistent and not colliding
|
||||||
* with other profiles).
|
* with other profiles).
|
||||||
|
|
|
@ -80,15 +80,16 @@ function civicrm_api3_twingle_donation_Cancel($params) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve (recurring) contribution.
|
// Retrieve (recurring) contribution.
|
||||||
|
$default_profile = CRM_Twingle_Profile::getProfile('default');
|
||||||
try {
|
try {
|
||||||
$contribution = civicrm_api3('Contribution', 'getsingle', array(
|
$contribution = civicrm_api3('Contribution', 'getsingle', array(
|
||||||
'trxn_id' => $params['trx_id'],
|
'trxn_id' => $default_profile->getTransactionID($params['trx_id']),
|
||||||
));
|
));
|
||||||
$contribution_type = 'Contribution';
|
$contribution_type = 'Contribution';
|
||||||
}
|
}
|
||||||
catch (CiviCRM_API3_Exception $exception) {
|
catch (CiviCRM_API3_Exception $exception) {
|
||||||
$contribution = civicrm_api3('ContributionRecur', 'getsingle', array(
|
$contribution = civicrm_api3('ContributionRecur', 'getsingle', array(
|
||||||
'trxn_id' => $params['trx_id'],
|
'trxn_id' => $default_profile->getTransactionID($params['trx_id']),
|
||||||
));
|
));
|
||||||
$contribution_type = 'ContributionRecur';
|
$contribution_type = 'ContributionRecur';
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,8 +72,9 @@ function civicrm_api3_twingle_donation_endrecurring($params) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$default_profile = CRM_Twingle_Profile::getProfile('default');
|
||||||
$contribution = civicrm_api3('ContributionRecur', 'getsingle', array(
|
$contribution = civicrm_api3('ContributionRecur', 'getsingle', array(
|
||||||
'trxn_id' => $params['trx_id'],
|
'trxn_id' => $default_profile->getTransactionID($params['trx_id']),
|
||||||
));
|
));
|
||||||
// End SEPA mandate (which ends the associated recurring contribution) or
|
// End SEPA mandate (which ends the associated recurring contribution) or
|
||||||
// recurring contributions.
|
// recurring contributions.
|
||||||
|
|
|
@ -278,10 +278,10 @@ function civicrm_api3_twingle_donation_Submit($params) {
|
||||||
// Do not process an already existing contribution with the given
|
// Do not process an already existing contribution with the given
|
||||||
// transaction ID.
|
// transaction ID.
|
||||||
$existing_contribution = civicrm_api3('Contribution', 'get', array(
|
$existing_contribution = civicrm_api3('Contribution', 'get', array(
|
||||||
'trxn_id' => $params['trx_id']
|
'trxn_id' => $profile->getTransactionID($params['trx_id'])
|
||||||
));
|
));
|
||||||
$existing_contribution_recur = civicrm_api3('ContributionRecur', 'get', array(
|
$existing_contribution_recur = civicrm_api3('ContributionRecur', 'get', array(
|
||||||
'trxn_id' => $params['trx_id']
|
'trxn_id' => $profile->getTransactionID($params['trx_id'])
|
||||||
));
|
));
|
||||||
if ($existing_contribution['count'] > 0 || $existing_contribution_recur['count'] > 0) {
|
if ($existing_contribution['count'] > 0 || $existing_contribution_recur['count'] > 0) {
|
||||||
throw new CiviCRM_API3_Exception(
|
throw new CiviCRM_API3_Exception(
|
||||||
|
@ -511,7 +511,7 @@ function civicrm_api3_twingle_donation_Submit($params) {
|
||||||
$contribution_data = array(
|
$contribution_data = array(
|
||||||
'contact_id' => (isset($organisation_id) ? $organisation_id : $contact_id),
|
'contact_id' => (isset($organisation_id) ? $organisation_id : $contact_id),
|
||||||
'currency' => $params['currency'],
|
'currency' => $params['currency'],
|
||||||
'trxn_id' => $params['trx_id'],
|
'trxn_id' => $profile->getTransactionID($params['trx_id']),
|
||||||
'payment_instrument_id' => $params['payment_instrument_id'],
|
'payment_instrument_id' => $params['payment_instrument_id'],
|
||||||
'amount' => $params['amount'] / 100,
|
'amount' => $params['amount'] / 100,
|
||||||
'total_amount' => $params['amount'] / 100,
|
'total_amount' => $params['amount'] / 100,
|
||||||
|
|
|
@ -31,4 +31,18 @@ return array(
|
||||||
'is_contact' => 0,
|
'is_contact' => 0,
|
||||||
'description' => 'Whether to provide CiviSEPA functionality for manual debit payment method. This requires the CiviSEPA (org.project60.sepa) extension be installed.',
|
'description' => 'Whether to provide CiviSEPA functionality for manual debit payment method. This requires the CiviSEPA (org.project60.sepa) extension be installed.',
|
||||||
),
|
),
|
||||||
|
'twingle_prefix' => array(
|
||||||
|
'group_name' => 'de.systopia.twingle',
|
||||||
|
'group' => 'de.systopia.twingle',
|
||||||
|
'name' => 'twingle_prefix',
|
||||||
|
'type' => CRM_Utils_Type::T_STRING,
|
||||||
|
'quick_form_type' => 'Element',
|
||||||
|
'html_type' => 'text',
|
||||||
|
'title' => 'Twingle ID Prefix',
|
||||||
|
'default' => '',
|
||||||
|
'add' => '4.6',
|
||||||
|
'is_domain' => 1,
|
||||||
|
'is_contact' => 0,
|
||||||
|
'description' => 'You can use this setting to add a prefix to the Twingle transaction ID, in order to avoid collisions with other transaction ids.',
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -15,3 +15,7 @@
|
||||||
{htxt id='id-twingle_use_sepa'}
|
{htxt id='id-twingle_use_sepa'}
|
||||||
{ts domain="de.systopia.twingle" 1="<a href=\"https://github.com/project60/org.project60.sepa\" target=\"_blank\">CiviSEPA (<kbd>org.project60.sepa</kbd>) extension</a>"}When the %1 is enabled and one of its payment instruments is assigned to a Twingle payment method (practically the <em>debit_manual</em> payment method), submitting a Twingle donation through the API will create a SEPA mandate with the given data.{/ts}
|
{ts domain="de.systopia.twingle" 1="<a href=\"https://github.com/project60/org.project60.sepa\" target=\"_blank\">CiviSEPA (<kbd>org.project60.sepa</kbd>) extension</a>"}When the %1 is enabled and one of its payment instruments is assigned to a Twingle payment method (practically the <em>debit_manual</em> payment method), submitting a Twingle donation through the API will create a SEPA mandate with the given data.{/ts}
|
||||||
{/htxt}
|
{/htxt}
|
||||||
|
|
||||||
|
{htxt id='id-twingle_prefix'}
|
||||||
|
{ts domain="de.systopia.twingle"}You can use this setting to add a prefix to the Twingle transaction ID, in order to avoid collisions with other transaction ids.{/ts}
|
||||||
|
{/htxt}
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
<table class="form-layout-compressed">
|
<table class="form-layout-compressed">
|
||||||
{foreach from=$elementNames item=elementName}
|
{foreach from=$elementNames item=elementName}
|
||||||
<tr class="crm-twingle-form-block-{$form.$elementName.name}">
|
<tr class="crm-twingle-form-block-{$form.$elementName.name}">
|
||||||
<td class="label">{$form.$elementName.label} <a onclick='CRM.help("{$form.$elementName.label}", {literal}{"id":"id-{/literal}{$form.$elementName.name}{literal}","file":"CRM\/Twingle\/Form\/Settings"}{/literal}); return false;' href="#" title="{ts domain="de.systopia.twingle"}Help{/ts}" class="helpicon"></a></td>
|
<td class="label">{$form.$elementName.label} <a onclick='CRM.help("{$form.$elementName.label}", {literal}{"id":"id-{/literal}{$fo/rm.$elementName.name}{literal}","file":"CRM\/Twingle\/Form\/Settings"}{/literal}); return false;' href="#" title="{ts domain="de.systopia.twingle"}Help{/ts}" class="helpicon"></a></td>
|
||||||
<td>
|
<td>
|
||||||
{$form.$elementName.html}
|
{$form.$elementName.html}
|
||||||
<br />
|
<br />
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue