[#8] added transaction prefix

This commit is contained in:
B. Endres 2019-11-15 11:13:33 +01:00
commit c9695c1773
6 changed files with 41 additions and 6 deletions

View file

@ -80,15 +80,16 @@ function civicrm_api3_twingle_donation_Cancel($params) {
}
// Retrieve (recurring) contribution.
$default_profile = CRM_Twingle_Profile::getProfile('default');
try {
$contribution = civicrm_api3('Contribution', 'getsingle', array(
'trxn_id' => $params['trx_id'],
'trxn_id' => $default_profile->getTransactionID($params['trx_id']),
));
$contribution_type = 'Contribution';
}
catch (CiviCRM_API3_Exception $exception) {
$contribution = civicrm_api3('ContributionRecur', 'getsingle', array(
'trxn_id' => $params['trx_id'],
'trxn_id' => $default_profile->getTransactionID($params['trx_id']),
));
$contribution_type = 'ContributionRecur';
}

View file

@ -72,8 +72,9 @@ function civicrm_api3_twingle_donation_endrecurring($params) {
);
}
$default_profile = CRM_Twingle_Profile::getProfile('default');
$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
// recurring contributions.

View file

@ -278,10 +278,10 @@ function civicrm_api3_twingle_donation_Submit($params) {
// Do not process an already existing contribution with the given
// transaction ID.
$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(
'trxn_id' => $params['trx_id']
'trxn_id' => $profile->getTransactionID($params['trx_id'])
));
if ($existing_contribution['count'] > 0 || $existing_contribution_recur['count'] > 0) {
throw new CiviCRM_API3_Exception(
@ -511,7 +511,7 @@ function civicrm_api3_twingle_donation_Submit($params) {
$contribution_data = array(
'contact_id' => (isset($organisation_id) ? $organisation_id : $contact_id),
'currency' => $params['currency'],
'trxn_id' => $params['trx_id'],
'trxn_id' => $profile->getTransactionID($params['trx_id']),
'payment_instrument_id' => $params['payment_instrument_id'],
'amount' => $params['amount'] / 100,
'total_amount' => $params['amount'] / 100,