+--------------------------------------------------------------------+
*/
+use Civi\Payment\Exception\PaymentProcessorException;
+
/**
*
* @package CRM
* @return bool
*/
protected function supportsPreApproval() {
- if ($this->_processorName == ts('PayPal Express')) {
+ if ($this->_processorName == ts('PayPal Express') || $this->_processorName == ts('PayPal Pro')) {
return TRUE;
}
return FALSE;
* @return array
*/
public function getPreApprovalDetails($storedDetails) {
- return $this->getExpressCheckoutDetails($storedDetails['token']);
+ return empty($storedDetails['token']) ? array() : $this->getExpressCheckoutDetails($storedDetails['token']);
}
/**
* @throws \Civi\Payment\Exception\PaymentProcessorException
*/
public function doPayment(&$params, $component = 'contribute') {
- if ($this->_paymentProcessor['payment_processor_type'] != 'PayPal_Express') {
+ if ($this->_paymentProcessor['payment_processor_type'] != 'PayPal_Express'
+ && (!empty($params['credit_card_number']) && empty($params['token']))
+ ) {
return parent::doPayment($params, $component);
}
$this->_component = $component;
$result = $this->invokeAPI($args);
return array(
'fee_amount' => $result['feeamt'],
+ 'net_amount' => $params['gross_amount'] - $result['feeamt'],
);
}
$error[] = ts('Password is not set in the Administer » System Settings » Payment Processors.');
}
}
- if (!$this->_paymentProcessor['user_name']) {
+ if (empty($this->_paymentProcessor['user_name'])) {
$error[] = ts('User Name is not set in the Administer » System Settings » Payment Processors.');
}
* - redirect_url (if set the browser will be redirected to this.
*/
public function doPreApproval(&$params) {
+ if (!isset($params['button']) || !stristr($params['button'], 'express')) {
+ return array();
+ }
$this->_component = $params['component'];
$token = $this->setExpressCheckOut($params);
return array(