commerce_paypal_wps.module in Commerce PayPal 7.2
Same filename and directory in other branches
Implements PayPal Website Payments Standard in Drupal Commerce checkout.
File
modules/wps/commerce_paypal_wps.moduleView source
<?php
/**
* @file
* Implements PayPal Website Payments Standard in Drupal Commerce checkout.
*/
/**
* Implements hook_commerce_payment_method_info().
*/
function commerce_paypal_wps_commerce_payment_method_info() {
$payment_methods = array();
$payment_methods['paypal_wps'] = array(
'base' => 'commerce_paypal_wps',
'title' => t('PayPal WPS'),
'short_title' => t('PayPal'),
'description' => t('PayPal Website Payments Standard'),
'terminal' => FALSE,
'offsite' => TRUE,
'offsite_autoredirect' => TRUE,
// Because the order form generation code does not have access to a payment
// method info array, we set the bn directly there instead of making use of
// this buttonsource variable. It's here for consistency with other payment
// methods in this package.
'buttonsource' => 'CommerceGuys_Cart_PPS',
);
return $payment_methods;
}
/**
* Returns the default settings for the PayPal WPS payment method.
*/
function commerce_paypal_wps_default_settings() {
$default_currency = commerce_default_currency();
return array(
'business' => '',
'currency_code' => in_array($default_currency, array_keys(commerce_paypal_currencies('paypal_wps'))) ? $default_currency : 'USD',
'allow_supported_currencies' => FALSE,
'language' => 'US',
'server' => 'sandbox',
'payment_action' => 'sale',
'ipn_logging' => 'notification',
'receiver_emails' => '',
'ipn_create_billing_profile' => FALSE,
'show_payment_instructions' => FALSE,
);
}
/**
* Payment method callback: settings form.
*/
function commerce_paypal_wps_settings_form($settings = array()) {
$form = array();
// Merge default settings into the stored settings array.
$settings = (array) $settings + commerce_paypal_wps_default_settings();
$form['business'] = array(
'#type' => 'textfield',
'#title' => t('PayPal e-mail address'),
'#description' => t('The primary e-mail address of the PayPal account you want to use to receive payments.'),
'#default_value' => $settings['business'],
'#required' => TRUE,
);
$form['currency_code'] = array(
'#type' => 'select',
'#title' => t('Default currency'),
'#description' => t('Transactions in other currencies will be converted to this currency, so multi-currency sites must be configured to use appropriate conversion rates.'),
'#options' => commerce_paypal_currencies('paypal_wps'),
'#default_value' => $settings['currency_code'],
);
$form['allow_supported_currencies'] = array(
'#type' => 'checkbox',
'#title' => t('Allow transactions to use any currency in the options list above.'),
'#description' => t('Transactions in unsupported currencies will still be converted into the default currency.'),
'#default_value' => $settings['allow_supported_currencies'],
);
$form['language'] = array(
'#type' => 'select',
'#title' => t('PayPal login page language / locale'),
'#options' => commerce_paypal_wps_languages(),
'#default_value' => $settings['language'],
);
$form['server'] = array(
'#type' => 'radios',
'#title' => t('PayPal server'),
'#options' => array(
'sandbox' => 'Sandbox - use for testing, requires a PayPal Sandbox account',
'live' => 'Live - use for processing real transactions',
),
'#default_value' => $settings['server'],
);
$form['payment_action'] = array(
'#type' => 'radios',
'#title' => t('Payment action'),
'#options' => array(
'sale' => t('Sale - authorize and capture the funds at the time the payment is processed'),
'authorization' => t('Authorization - reserve funds on the card to be captured later through your PayPal account'),
),
'#default_value' => $settings['payment_action'],
);
$form['ipn_logging'] = array(
'#type' => 'radios',
'#title' => t('IPN logging'),
'#options' => array(
'notification' => t('Log notifications during IPN validation and processing.'),
'full_ipn' => t('Log notifications with the full IPN during validation and processing (used for debugging).'),
),
'#default_value' => $settings['ipn_logging'],
);
$form['receiver_emails'] = array(
'#type' => 'textfield',
'#title' => t('PayPal receiver e-mail addresses'),
'#description' => t('Enter the primary e-mail address for your PayPal account if different from the one entered above or a comma separated list of all valid e-mail addresses on the account.') . '<br />' . t('IPNs that originate from payments made to a PayPal account whose e-mail address is not in this list will not be processed.'),
'#default_value' => $settings['receiver_emails'],
);
$form['ipn_create_billing_profile'] = array(
'#type' => 'checkbox',
'#title' => t('Create a billing profile based on name and country data in the IPN for any order that does not have one yet.'),
'#description' => t('This is most useful for sites that do not collect billing information locally but still want to have customer names on orders.'),
'#default_value' => $settings['ipn_create_billing_profile'],
);
$form['show_payment_instructions'] = array(
'#type' => 'checkbox',
'#title' => t('Show a message on the checkout form when PayPal WPS is selected telling the customer to "Continue with checkout to complete payment via PayPal."'),
'#default_value' => $settings['show_payment_instructions'],
);
return $form;
}
/**
* Payment method callback: adds a message to the submission form if enabled in
* the payment method settings.
*/
function commerce_paypal_wps_submit_form($payment_method, $pane_values, $checkout_pane, $order) {
$form = array();
if (!empty($payment_method['settings']['show_payment_instructions'])) {
$form['paypal_wps_information'] = array(
'#markup' => '<span class="commerce-paypal-wps-info">' . t('(Continue with checkout to complete payment via PayPal.)') . '</span>',
);
}
return $form;
}
/**
* Implements hook_form_FORM_ID_alter().
*/
function commerce_paypal_wps_form_commerce_checkout_form_alter(&$form, &$form_state) {
// If this checkout form contains the payment method radios...
if (!empty($form['commerce_payment']['payment_method']['#options'])) {
// Loop over its options array looking for a PayPal WPS option.
foreach ($form['commerce_payment']['payment_method']['#options'] as $key => &$value) {
list($method_id, $rule_name) = explode('|', $key);
// If we find PayPal WPS...
if ($method_id == 'paypal_wps') {
// Prepare the replacement radio button text with icons.
$icons = commerce_paypal_icons();
$value = t('!logo PayPal - pay securely without sharing your financial information', array(
'!logo' => $icons['paypal'],
));
$value .= '<div class="commerce-paypal-icons"><span class="label">' . t('Includes:') . '</span>' . implode(' ', $icons) . '</div>';
// Add the CSS.
$form['commerce_payment']['payment_method']['#attached']['css'][] = drupal_get_path('module', 'commerce_paypal_wps') . '/theme/commerce_paypal_wps.theme.css';
break;
}
}
}
}
/**
* Payment method callback: redirect form, a wrapper around the module's general
* use function for building a WPS form.
*/
function commerce_paypal_wps_redirect_form($form, &$form_state, $order, $payment_method) {
// Return an error if the enabling action's settings haven't been configured.
if (empty($payment_method['settings']['business'])) {
drupal_set_message(t('PayPal WPS is not configured for use. No PayPal e-mail address has been specified.'), 'error');
return array();
}
$settings = array(
// Return to the previous page when payment is canceled
'cancel_return' => url('checkout/' . $order->order_id . '/payment/back/' . $order->data['payment_redirect_key'], array(
'absolute' => TRUE,
)),
// Return to the payment redirect page for processing successful payments
'return' => url('checkout/' . $order->order_id . '/payment/return/' . $order->data['payment_redirect_key'], array(
'absolute' => TRUE,
)),
// Specify the current payment method instance ID in the notify_url
'payment_method' => $payment_method['instance_id'],
// Include the application indicator
'bn' => $payment_method['buttonsource'],
);
return commerce_paypal_wps_order_form($form, $form_state, $order, $payment_method['settings'] + $settings);
}
/**
* Payment method callback: redirect form return validation.
*/
function commerce_paypal_wps_redirect_form_validate($order, $payment_method) {
if (!empty($payment_method['settings']['ipn_logging']) && $payment_method['settings']['ipn_logging'] == 'full_ipn') {
watchdog('commerce_paypal_wps', 'Customer returned from PayPal with the following POST data:!ipn_data', array(
'!ipn_data' => '<pre>' . check_plain(print_r($_POST, TRUE)) . '</pre>',
), WATCHDOG_NOTICE);
}
// This may be an unnecessary step, but if for some reason the user does end
// up returning at the success URL with a Failed payment, go back.
if (!empty($_POST['payment_status']) && $_POST['payment_status'] == 'Failed') {
return FALSE;
}
}
/**
* Payment method callback: validate an IPN based on receiver e-mail address,
* price, and other parameters as possible.
*/
function commerce_paypal_wps_paypal_ipn_validate($order, $payment_method, $ipn) {
// Prepare a trimmed list of receiver e-mail addresses.
if (!empty($payment_method['settings']['receiver_emails'])) {
$receiver_emails = explode(',', $payment_method['settings']['receiver_emails']);
}
else {
$receiver_emails = array();
}
// Add the business e-mail address to the list of addresses.
$receiver_emails[] = $payment_method['settings']['business'];
foreach ($receiver_emails as $key => &$email) {
$email = trim(strtolower($email));
}
// Return FALSE if the receiver e-mail does not match one specified by the
// payment method instance.
if (!in_array(trim(strtolower($ipn['receiver_email'])), $receiver_emails)) {
commerce_payment_redirect_pane_previous_page($order);
watchdog('commerce_paypal_wps', 'IPN rejected: invalid receiver e-mail specified (@receiver_email); must match the primary e-mail address on the PayPal account.', array(
'@receiver_email' => $ipn['receiver_email'],
), WATCHDOG_NOTICE);
return FALSE;
}
// Prepare the IPN data for inclusion in the watchdog message if enabled.
$ipn_data = '';
if (!empty($payment_method['settings']['ipn_logging']) && $payment_method['settings']['ipn_logging'] == 'full_ipn') {
$ipn_data = '<pre>' . check_plain(print_r($ipn, TRUE)) . '</pre>';
}
// Log a message including the PayPal transaction ID if available.
if (!empty($ipn['txn_id'])) {
watchdog('commerce_paypal_wps', 'IPN validated for Order @order_number with ID @txn_id.!ipn_data', array(
'@order_number' => $order->order_number,
'@txn_id' => $ipn['txn_id'],
'!ipn_data' => $ipn_data,
), WATCHDOG_NOTICE);
}
else {
watchdog('commerce_paypal_wps', 'IPN validated for Order @order_number.!ipn_data', array(
'@order_number' => $order->order_number,
'!ipn_data' => $ipn_data,
), WATCHDOG_NOTICE);
}
}
/**
* Payment method callback: process an IPN once it's been validated.
*/
function commerce_paypal_wps_paypal_ipn_process($order, $payment_method, &$ipn) {
// Do not perform any processing on WPS transactions here that do not have
// transaction IDs, indicating they are non-payment IPNs such as those used
// for subscription signup requests.
if (empty($ipn['txn_id'])) {
return FALSE;
}
// Exit when we don't get a payment status we recognize.
if (!in_array($ipn['payment_status'], array(
'Failed',
'Voided',
'Pending',
'Completed',
'Refunded',
))) {
commerce_payment_redirect_pane_previous_page($order);
return FALSE;
}
// If this is a prior authorization capture IPN for which we've already
// created a transaction...
if (in_array($ipn['payment_status'], array(
'Voided',
'Completed',
)) && !empty($ipn['auth_id']) && ($auth_ipn = commerce_paypal_ipn_load($ipn['auth_id']))) {
// Load the prior IPN's transaction and update that with the capture values.
$transaction = commerce_payment_transaction_load($auth_ipn['transaction_id']);
}
else {
// Create a new payment transaction for the order.
$transaction = commerce_payment_transaction_new('paypal_wps', $order->order_id);
$transaction->instance_id = $payment_method['instance_id'];
}
$wrapper = entity_metadata_wrapper('commerce_order', $order);
$order_currency_code = $wrapper->commerce_order_total->currency_code
->value();
$amount = commerce_currency_decimal_to_amount($ipn['mc_gross'], $ipn['mc_currency']);
$transaction->amount = commerce_currency_convert($amount, $ipn['mc_currency'], $order_currency_code);
$transaction->currency_code = $order_currency_code;
$transaction->remote_id = $ipn['txn_id'];
$transaction->payload[REQUEST_TIME . '-ipn'] = $ipn;
// Set the transaction's statuses based on the IPN's payment_status.
$transaction->remote_status = $ipn['payment_status'];
// If we didn't get an approval response code...
switch ($ipn['payment_status']) {
case 'Failed':
$transaction->status = COMMERCE_PAYMENT_STATUS_FAILURE;
$transaction->message = t("The payment has failed. This happens only if the payment was made from your customer’s bank account.");
break;
case 'Voided':
$transaction->status = COMMERCE_PAYMENT_STATUS_FAILURE;
$transaction->message = t('The authorization was voided.');
break;
case 'Pending':
$transaction->status = COMMERCE_PAYMENT_STATUS_PENDING;
$transaction->message = commerce_paypal_ipn_pending_reason($ipn['pending_reason']);
break;
case 'Completed':
$transaction->status = COMMERCE_PAYMENT_STATUS_SUCCESS;
$transaction->message = t('The payment has completed.');
break;
case 'Refunded':
$transaction->status = COMMERCE_PAYMENT_STATUS_SUCCESS;
$transaction->message = t('Refund for transaction @txn_id', array(
'@txn_id' => $ipn['parent_txn_id'],
));
break;
}
// Save the transaction information.
commerce_payment_transaction_save($transaction);
$ipn['transaction_id'] = $transaction->transaction_id;
// Create a billing profile based on the IPN if enabled.
if (!empty($payment_method['settings']['ipn_create_billing_profile']) && isset($order->commerce_customer_billing)) {
$order_wrapper = entity_metadata_wrapper('commerce_order', $order);
// If this order does not have a billing profile yet...
if ($order_wrapper->commerce_customer_billing
->value() === NULL) {
// Ensure we have the required data in the IPN.
if (empty($ipn['residence_country']) || empty($ipn['first_name']) || empty($ipn['last_name'])) {
$data = array_intersect_key($ipn, drupal_map_assoc(array(
'residence_country',
'first_name',
'last_name',
)));
watchdog('commerce_paypal_wps', 'A billing profile for Order @order_number could not be created due to insufficient data in the IPN:!data', array(
'@order_number' => $order->order_number,
'!data' => '<pre>' . check_plain(print_r($data, TRUE)) . '</pre>',
), WATCHDOG_WARNING);
}
else {
// Create the new profile now.
$profile = commerce_customer_profile_new('billing', $order->uid);
// Prepare an addressfield array to set to the customer profile.
$field = field_info_field('commerce_customer_address');
$instance = field_info_instance('commerce_customer_profile', 'commerce_customer_address', 'billing');
$address = addressfield_default_values($field, $instance);
// Add the address value.
$profile_wrapper = entity_metadata_wrapper('commerce_customer_profile', $profile);
$profile_wrapper->commerce_customer_address = array_merge($address, array(
'country' => $ipn['residence_country'],
'name_line' => $ipn['first_name'] . ' ' . $ipn['last_name'],
'first_name' => $ipn['first_name'],
'last_name' => $ipn['last_name'],
));
// Save the profile, reference it from the order, and save the order.
$profile_wrapper
->save();
$order_wrapper->commerce_customer_billing = $profile_wrapper;
$order_wrapper
->save();
watchdog('commerce_paypal_wps', 'Billing profile created for Order @order_number containing the first and last names and residence country of the customer based on IPN data.', array(
'@order_number' => $order->order_number,
));
}
}
}
commerce_payment_redirect_pane_next_page($order);
watchdog('commerce_paypal_wps', 'IPN processed for Order @order_number with ID @txn_id.', array(
'@txn_id' => $ipn['txn_id'],
'@order_number' => $order->order_number,
), WATCHDOG_INFO);
}
/**
* Builds a Website Payments Standard form from an order object.
*
* @param $order
* The fully loaded order being paid for.
* @param $settings
* An array of settings used to build out the form, including:
* - server: which server to use, either sandbox or live
* - business: the PayPal e-mail address the payment submits to
* - cancel_return: the URL PayPal should send the user to on cancellation
* - return: the URL PayPal should send the user to on successful payment
* - currency_code: the PayPal currency code to use for this payment if the
* total for the order is in a non-PayPal supported currency
* - language: the PayPal language code to use on the payment form
* - payment_action: the PayPal payment action to use: sale, authorization,
* or order
* - payment_method: optionally a payment method instance ID to include in the
* IPN notify_url
*
* @return
* A renderable form array.
*/
function commerce_paypal_wps_order_form($form, &$form_state, $order, $settings) {
$wrapper = entity_metadata_wrapper('commerce_order', $order);
// Determine the currency code to use to actually process the transaction,
// which will either be the default currency code or the currency code of the
// order if it's supported by PayPal if that option is enabled.
$currency_code = $settings['currency_code'];
$order_currency_code = $wrapper->commerce_order_total->currency_code
->value();
if (!empty($settings['allow_supported_currencies']) && in_array($order_currency_code, array_keys(commerce_paypal_currencies('paypal_wps')))) {
$currency_code = $order_currency_code;
}
$amount = $wrapper->commerce_order_total->amount
->value();
// Ensure a default value for the payment_method setting.
$settings += array(
'payment_method' => '',
);
$line_item_types = array();
if (function_exists('commerce_product_line_item_types')) {
$line_item_types = commerce_product_line_item_types();
}
// Build the data array that will be translated into hidden form values.
$data = array(
// Specify the checkout experience to present to the user.
'cmd' => '_cart',
// Signify we're passing in a shopping cart from our system.
'upload' => 1,
// The store's PayPal e-mail address
'business' => $settings['business'],
// The path PayPal should send the IPN to
'notify_url' => commerce_paypal_ipn_url($settings['payment_method']),
// The application generating the API request
'bn' => 'CommerceGuys_Cart_PPS',
// Set the correct character set
'charset' => 'utf-8',
// Do not display a comments prompt at PayPal
'no_note' => 1,
// Do not display a shipping address prompt at PayPal
'no_shipping' => 1,
// Return to the review page when payment is canceled
'cancel_return' => $settings['cancel_return'],
// Return to the payment redirect page for processing successful payments
'return' => $settings['return'],
// Return to this site with payment data in the POST
'rm' => 2,
// The type of payment action PayPal should take with this order
'paymentaction' => $settings['payment_action'],
// Set the currency and language codes
'currency_code' => $currency_code,
'lc' => $settings['language'],
// Use the timestamp to generate a unique invoice number
'invoice' => commerce_paypal_ipn_invoice($order),
// Provide a default email for non-PayPal users.
'email' => substr($order->mail, 0, 127),
// Define a single item in the cart representing the whole order.
'amount_1' => commerce_paypal_price_amount(commerce_currency_convert($amount, $order_currency_code, $currency_code), $currency_code),
'item_name_1' => t('Order @order_number at @store', array(
'@order_number' => $order->order_number,
'@store' => variable_get('site_name', url('<front>', array(
'absolute' => TRUE,
))),
)),
'on0_1' => t('Product count'),
'os0_1' => commerce_line_items_quantity($wrapper->commerce_line_items, $line_item_types),
);
// If a billing address is available, pass it to PayPal to populate
// field values for non-PayPal users paying with their card.
if (!empty($wrapper->commerce_customer_billing->commerce_customer_address)) {
// Assign billing address fields to hidden form values.
$billing_address = $wrapper->commerce_customer_billing->commerce_customer_address
->value();
$data['address1'] = substr($billing_address['thoroughfare'], 0, 100);
$data['address2'] = substr($billing_address['premise'], 0, 100);
$data['city'] = substr($billing_address['locality'], 0, 40);
$data['state'] = $billing_address['administrative_area'];
$data['zip'] = substr($billing_address['postal_code'], 0, 32);
$data['country'] = $billing_address['country'];
$data['first_name'] = drupal_substr($billing_address['first_name'], 0, 32);
$data['last_name'] = drupal_substr($billing_address['last_name'], 0, 32);
}
// Allow modules to alter parameters of the API request.
drupal_alter('commerce_paypal_wps_order_form_data', $data, $order);
$form['#action'] = commerce_paypal_wps_server_url($settings['server']);
foreach ($data as $name => $value) {
if (isset($value)) {
$form[$name] = array(
'#type' => 'hidden',
'#value' => $value,
);
}
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Proceed to PayPal'),
);
return $form;
}
/**
* Returns the URL to the specified PayPal WPS server.
*
* @param $server
* Either sandbox or live indicating which server to get the URL for.
*
* @return
* The URL to use to submit requests to the PayPal WPS server.
*/
function commerce_paypal_wps_server_url($server) {
switch ($server) {
case 'sandbox':
return 'https://www.sandbox.paypal.com/cgi-bin/webscr';
case 'live':
return 'https://www.paypal.com/cgi-bin/webscr';
}
}
/**
* Returns an array of all possible language codes.
*/
function commerce_paypal_wps_languages() {
return array(
t('By country') => array(
'AL' => t('Albania'),
'DZ' => t('Algeria'),
'AD' => t('Andorra'),
'AO' => t('Angola'),
'AI' => t('Anguilla'),
'AG' => t('Antigua and Barbuda'),
'AR' => t('Argentina'),
'AM' => t('Armenia'),
'AW' => t('Aruba'),
'AU' => t('Australia'),
'AT' => t('Austria'),
'AZ' => t('Azerbaijan Republic'),
'BS' => t('Bahamas'),
'BH' => t('Bahrain'),
'BB' => t('Barbados'),
'BY' => t('Belarus'),
'BE' => t('Belgium'),
'BZ' => t('Belize'),
'BJ' => t('Benin'),
'BM' => t('Bermuda'),
'BT' => t('Bhutan'),
'BO' => t('Bolivia'),
'BA' => t('Bosnia and Herzegovina'),
'BW' => t('Botswana'),
'BR' => t('Brazil'),
'BN' => t('Brunei'),
'BG' => t('Bulgaria'),
'BF' => t('Burkina Faso'),
'BI' => t('Burundi'),
'KH' => t('Cambodia'),
'CM' => t('Cameroon'),
'CA' => t('Canada'),
'CV' => t('Cape Verde'),
'KY' => t('Cayman Islands'),
'TD' => t('Chad'),
'CL' => t('Chile'),
'C2' => t('China'),
'CO' => t('Colombia'),
'KM' => t('Comoros'),
'CK' => t('Cook Islands'),
'CR' => t('Costa Rica'),
'CI' => t('Cote D\'Ivoire'),
'HR' => t('Croatia'),
'CY' => t('Cyprus'),
'CZ' => t('Czech Republic'),
'CD' => t('Democratic Republic of the Congo'),
'DK' => t('Denmark'),
'DJ' => t('Djibouti'),
'DM' => t('Dominica'),
'DO' => t('Dominican Republic'),
'EC' => t('Ecuador'),
'EG' => t('Egypt'),
'SV' => t('El Salvador'),
'ER' => t('Eritrea'),
'EE' => t('Estonia'),
'ET' => t('Ethiopia'),
'FK' => t('Falkland Islands'),
'FO' => t('Faroe Islands'),
'FJ' => t('Fiji'),
'FI' => t('Finland'),
'FR' => t('France'),
'GF' => t('French Guiana'),
'PF' => t('French Polynesia'),
'GA' => t('Gabon Republic'),
'GM' => t('Gambia'),
'GE' => t('Georgia'),
'DE' => t('Germany'),
'GI' => t('Gibraltar'),
'GR' => t('Greece'),
'GL' => t('Greenland'),
'GD' => t('Grenada'),
'GP' => t('Guadeloupe'),
'GT' => t('Guatemala'),
'GN' => t('Guinea'),
'GW' => t('Guinea Bissau'),
'GY' => t('Guyana'),
'HN' => t('Honduras'),
'HK' => t('Hong Kong'),
'HU' => t('Hungary'),
'IS' => t('Iceland'),
'IN' => t('India'),
'ID' => t('Indonesia'),
'IE' => t('Ireland'),
'IL' => t('Israel'),
'IT' => t('Italy'),
'JM' => t('Jamaica'),
'JP' => t('Japan'),
'JO' => t('Jordan'),
'KZ' => t('Kazakhstan'),
'KE' => t('Kenya'),
'KI' => t('Kiribati'),
'KW' => t('Kuwait'),
'KG' => t('Kyrgyzstan'),
'LA' => t('Laos'),
'LV' => t('Latvia'),
'LS' => t('Lesotho'),
'LI' => t('Liechtenstein'),
'LT' => t('Lithuania'),
'LU' => t('Luxembourg'),
'MK' => t('Macedonia'),
'MG' => t('Madagascar'),
'MW' => t('Malawi'),
'MY' => t('Malaysia'),
'MV' => t('Maldives'),
'ML' => t('Mali'),
'MT' => t('Malta'),
'MH' => t('Marshall Islands'),
'MQ' => t('Martinique'),
'MR' => t('Mauritania'),
'MU' => t('Mauritius'),
'YT' => t('Mayotte'),
'MX' => t('Mexico'),
'FM' => t('Micronesia'),
'MD' => t('Moldova'),
'MC' => t('Monaco'),
'MN' => t('Mongolia'),
'ME' => t('Montenegro'),
'MS' => t('Montserrat'),
'MA' => t('Morocco'),
'MZ' => t('Mozambique'),
'NA' => t('Namibia'),
'NR' => t('Nauru'),
'NP' => t('Nepal'),
'NL' => t('Netherlands'),
'AN' => t('Netherlands Antilles'),
'NC' => t('New Caledonia'),
'NZ' => t('New Zealand'),
'NI' => t('Nicaragua'),
'NE' => t('Niger'),
'NG' => t('Nigeria'),
'NU' => t('Niue'),
'NF' => t('Norfolk Island'),
'NO' => t('Norway'),
'OM' => t('Oman'),
'PW' => t('Palau'),
'PA' => t('Panama'),
'PG' => t('Papua New Guinea'),
'PY' => t('Paraguay'),
'PE' => t('Peru'),
'PH' => t('Philippines'),
'PN' => t('Pitcairn Islands'),
'PL' => t('Poland'),
'PT' => t('Portugal'),
'QA' => t('Qatar'),
'CG' => t('Republic of the Congo'),
'RE' => t('Reunion'),
'RO' => t('Romania'),
'RU' => t('Russia'),
'RW' => t('Rwanda'),
'KN' => t('Saint Kitts and Nevis Anguilla'),
'PM' => t('Saint Pierre and Miquelon'),
'VC' => t('Saint Vincent and Grenadines'),
'WS' => t('Samoa'),
'SM' => t('San Marino'),
'ST' => t('São Tomé and Príncipe'),
'SA' => t('Saudi Arabia'),
'SN' => t('Senegal'),
'RS' => t('Serbia'),
'SC' => t('Seychelles'),
'SL' => t('Sierra Leone'),
'SG' => t('Singapore'),
'SK' => t('Slovakia'),
'SI' => t('Slovenia'),
'SB' => t('Solomon Islands'),
'SO' => t('Somalia'),
'ZA' => t('South Africa'),
'KR' => t('South Korea'),
'ES' => t('Spain'),
'LK' => t('Sri Lanka'),
'SH' => t('St. Helena'),
'LC' => t('St. Lucia'),
'SR' => t('Suriname'),
'SJ' => t('Svalbard and Jan Mayen Islands'),
'SZ' => t('Swaziland'),
'SE' => t('Sweden'),
'CH' => t('Switzerland'),
'TW' => t('Taiwan'),
'TJ' => t('Tajikistan'),
'TZ' => t('Tanzania'),
'TH' => t('Thailand'),
'TG' => t('Togo'),
'TO' => t('Tonga'),
'TT' => t('Trinidad and Tobago'),
'TN' => t('Tunisia'),
'TR' => t('Turkey'),
'TM' => t('Turkmenistan'),
'TC' => t('Turks and Caicos Islands'),
'TV' => t('Tuvalu'),
'UG' => t('Uganda'),
'UA' => t('Ukraine'),
'AE' => t('United Arab Emirates'),
'GB' => t('United Kingdom'),
'US' => t('United States'),
'UY' => t('Uruguay'),
'VU' => t('Vanuatu'),
'VA' => t('Vatican City State'),
'VE' => t('Venezuela'),
'VN' => t('Vietnam'),
'VG' => t('Virgin Islands (British)'),
'WF' => t('Wallis and Futuna Islands'),
'YE' => t('Yemen'),
'ZM' => t('Zambia'),
'ZW' => t('Zimbabwe'),
),
t('By language') => array(
'da_DK' => t('Danish (for Denmark only)'),
'fr_CA' => t('French (for Canada only)'),
'he_IL' => t('Hebrew (for all)'),
'id_ID' => t('Indonesian (for Indonesia only)'),
'jp_JP' => t('Japanese (for Japan only)'),
'no_NO' => t('Norwegian (for Norway only)'),
'pt_BR' => t('Brazilian Portuguese (for Portugal and Brazil only)'),
'ru_RU' => t('Russian (for Lithuania, Latvia, and Ukraine only)'),
'sv_SE' => t('Swedish (for Sweden only)'),
'th_TH' => t('Thai (for Thailand only)'),
'tr_TR' => t('Turkish (for Turkey only)'),
'zh_CN' => t('Simplified Chinese (for China only)'),
'zh_HK' => t('Traditional Chinese (for Hong Kong only)'),
'zh_TW' => t('Traditional Chinese (for Taiwan only)'),
),
);
}
Functions
Name | Description |
---|---|
commerce_paypal_wps_commerce_payment_method_info | Implements hook_commerce_payment_method_info(). |
commerce_paypal_wps_default_settings | Returns the default settings for the PayPal WPS payment method. |
commerce_paypal_wps_form_commerce_checkout_form_alter | Implements hook_form_FORM_ID_alter(). |
commerce_paypal_wps_languages | Returns an array of all possible language codes. |
commerce_paypal_wps_order_form | Builds a Website Payments Standard form from an order object. |
commerce_paypal_wps_paypal_ipn_process | Payment method callback: process an IPN once it's been validated. |
commerce_paypal_wps_paypal_ipn_validate | Payment method callback: validate an IPN based on receiver e-mail address, price, and other parameters as possible. |
commerce_paypal_wps_redirect_form | Payment method callback: redirect form, a wrapper around the module's general use function for building a WPS form. |
commerce_paypal_wps_redirect_form_validate | Payment method callback: redirect form return validation. |
commerce_paypal_wps_server_url | Returns the URL to the specified PayPal WPS server. |
commerce_paypal_wps_settings_form | Payment method callback: settings form. |
commerce_paypal_wps_submit_form | Payment method callback: adds a message to the submission form if enabled in the payment method settings. |