Skip to content
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

Port #420 - Remove doTransferCheckout #610

Merged
merged 1 commit into from
Sep 6, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
50 changes: 21 additions & 29 deletions includes/wf_crm_webform_postprocess.inc
Original file line number Diff line number Diff line change
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