View source
<?php
class PayPalPaymentPPSPaymentMethodController extends PaymentMethodController implements PayPalPaymentIPNPaymentMethodControllerInterface {
const CAPTURE_AUTOMATIC = 0;
const CAPTURE_MANUAL = 1;
const SERVER_URL = 'https://www.paypal.com/cgi-bin/webscr';
const SANDBOX_SERVER_URL = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
public $controller_data_defaults = array(
'email_address' => '',
'server' => self::SERVER_URL,
'capture' => self::CAPTURE_AUTOMATIC,
);
public $payment_method_configuration_form_elements_callback = 'paypal_payment_pps_payment_method_configuration_form_elements';
public function __construct() {
$currency_codes = array(
'AUD',
'BRL',
'CAD',
'CHF',
'CZK',
'DKK',
'EUR',
'GBP',
'HKD',
'HUF',
'ILS',
'JPY',
'MXN',
'MYR',
'NOK',
'NZD',
'PHP',
'PLN',
'SEK',
'SGD',
'THB',
'TRY',
'TWD',
'USD',
);
$this->currencies = array_fill_keys($currency_codes, array());
$this->title = 'PayPal Payments Standard';
}
public function validate(Payment $payment, PaymentMethod $payment_method, $strict) {
}
public function execute(Payment $payment) {
entity_save('payment', $payment);
$_SESSION['paypal_payment_pps_pid'] = $payment->pid;
$url = 'paypal_payment_pps/redirect/' . $payment->pid;
if (!empty($payment->contextObj)) {
$payment->contextObj
->redirect($url);
}
else {
drupal_goto($url);
}
}
public static function PayPalValidateIPNVariables(Payment $payment, array $ipn_variables) {
return strtolower($ipn_variables['business']) == strtolower($payment->method->controller_data['email_address']);
}
public static function PayPalProcessIPN(Payment $payment, array $ipn_variables) {
}
}