Skip to content

Commit

Permalink
Port colemanw#420 - Remove doTransferCheckout
Browse files Browse the repository at this point in the history
  • Loading branch information
jitendrapurohit committed Sep 6, 2021
1 parent 28ae8fc commit 7688b2c
Showing 1 changed file with 21 additions and 29 deletions.
50 changes: 21 additions & 29 deletions includes/wf_crm_webform_postprocess.inc
Expand Up @@ -1983,41 +1983,33 @@ class wf_crm_webform_postprocess extends wf_crm_webform_base {
$params['webform_redirect_cancel'] = $this->getIpnRedirectUrl('cancel');
$params['webform_redirect_success'] = $this->getIpnRedirectUrl('success');

if (method_exists($paymentProcessor, 'doTransferCheckout')) {
//Paypal Express checkout
if(wf_crm_aval($_POST, 'credit_card_number') == 'express'){
try {
$params['button'] = 'express';
$params['component'] = 'contribute';
$result = $paymentProcessor->doPreApproval($params);
if (empty($result)) {
// This could happen, for example, when paypal looks at the button value & decides it is not paypal express.
return;
}
}
catch (\Civi\Payment\Exception\PaymentProcessorException $e) {
drupal_set_message(ts('Payment approval failed with message :') . $e->getMessage(),'error');
CRM_Utils_System::redirect($this->getIpnRedirectUrl('cancel'));
}
$preApprovalParams = $paymentProcessor->getPreApprovalDetails($result['pre_approval_parameters']);
$params = array_merge($params, $preApprovalParams);
if (!empty($result['redirect_url'])) {
CRM_Utils_System::redirect($result['redirect_url']);
}
}
// doTransferCheckout is deprecated but some processors might still implement it.
// Somewhere around 4.6 it was replaced by doPayment as the method of choice,
// but to be safe still call it if it exists for now.
$paymentProcessor->doTransferCheckout($params, 'contribute');
}
else {
//Paypal Express checkout
if (wf_crm_aval($_POST, 'credit_card_number') == 'express') {
try {
$paymentProcessor->doPayment($params);
$params['button'] = 'express';
$params['component'] = 'contribute';
$result = $paymentProcessor->doPreApproval($params);
if (empty($result)) {
// This could happen, for example, when paypal looks at the button value & decides it is not paypal express.
return;
}
}
catch (\Civi\Payment\Exception\PaymentProcessorException $e) {
drupal_set_message(ts('Payment approval failed with message: ') . $e->getMessage(),'error');
CRM_Utils_System::redirect($this->getIpnRedirectUrl('cancel'));
}
$preApprovalParams = $paymentProcessor->getPreApprovalDetails($result['pre_approval_parameters']);
$params = array_merge($params, $preApprovalParams);
if (!empty($result['redirect_url'])) {
CRM_Utils_System::redirect($result['redirect_url']);
}
}
try {
$paymentProcessor->doPayment($params);
}
catch (\Civi\Payment\Exception\PaymentProcessorException $e) {
drupal_set_message(ts('Payment approval failed with message: ') . $e->getMessage(),'error');
CRM_Utils_System::redirect($this->getIpnRedirectUrl('cancel'));
}

}
Expand Down

0 comments on commit 7688b2c

Please sign in to comment.