Improve docblock comments in WC_Gateway_Paypal classes

* Added comments to `get_icon` method
* Added missing param tags to various methods.
* Renamed integer to int
* Renamed boolean to bool
This commit is contained in:
Fredrik Forsmo 2016-01-05 20:19:12 +01:00
parent e4c45c0c47
commit 9ae4f4e7ab
5 changed files with 25 additions and 7 deletions

View File

@ -20,7 +20,7 @@ if ( ! defined( 'ABSPATH' ) ) {
*/
class WC_Gateway_Paypal extends WC_Payment_Gateway {
/** @var boolean Whether or not logging is enabled */
/** @var bool Whether or not logging is enabled */
public static $log_enabled = false;
/** @var WC_Logger Logger instance */
@ -84,7 +84,7 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
}
/**
* get_icon function.
* Get gateway icon.
* @return string
*/
public function get_icon() {
@ -257,7 +257,7 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
* @param int $order_id
* @param float $amount
* @param string $reason
* @return boolean True or false based on success, or a WP_Error object
* @return bool True or false based on success, or a WP_Error object
*/
public function process_refund( $order_id, $amount = null, $reason = '' ) {
$order = wc_get_order( $order_id );

View File

@ -16,6 +16,9 @@ class WC_Gateway_Paypal_IPN_Handler extends WC_Gateway_Paypal_Response {
/**
* Constructor.
*
* @param bool $sandbox
* @param string $receiver_email
*/
public function __construct( $sandbox = false, $receiver_email = '' ) {
add_action( 'woocommerce_api_wc_gateway_paypal', array( $this, 'check_response' ) );
@ -135,6 +138,7 @@ class WC_Gateway_Paypal_IPN_Handler extends WC_Gateway_Paypal_Response {
/**
* Check payment amount from IPN matches the order.
* @param WC_Order $order
* @param int $amount
*/
protected function validate_amount( $order, $amount ) {
if ( number_format( $order->get_total(), 2, '.', '' ) != number_format( $amount, 2, '.', '' ) ) {
@ -150,6 +154,7 @@ class WC_Gateway_Paypal_IPN_Handler extends WC_Gateway_Paypal_Response {
* Check receiver email from PayPal. If the receiver email in the IPN is different than what is stored in.
* WooCommerce -> Settings -> Checkout -> PayPal, it will log an error about it.
* @param WC_Order $order
* @param string $receiver_email
*/
protected function validate_receiver_email( $order, $receiver_email ) {
if ( strcasecmp( trim( $receiver_email ), trim( $this->receiver_email ) ) != 0 ) {
@ -164,6 +169,7 @@ class WC_Gateway_Paypal_IPN_Handler extends WC_Gateway_Paypal_Response {
/**
* Handle a completed payment.
* @param WC_Order $order
* @param array $posted
*/
protected function payment_status_completed( $order, $posted ) {
if ( $order->has_status( 'completed' ) ) {
@ -193,6 +199,7 @@ class WC_Gateway_Paypal_IPN_Handler extends WC_Gateway_Paypal_Response {
/**
* Handle a pending payment.
* @param WC_Order $order
* @param array $posted
*/
protected function payment_status_pending( $order, $posted ) {
$this->payment_status_completed( $order, $posted );
@ -201,6 +208,7 @@ class WC_Gateway_Paypal_IPN_Handler extends WC_Gateway_Paypal_Response {
/**
* Handle a failed payment.
* @param WC_Order $order
* @param array $posted
*/
protected function payment_status_failed( $order, $posted ) {
$order->update_status( 'failed', sprintf( __( 'Payment %s via IPN.', 'woocommerce' ), wc_clean( $posted['payment_status'] ) ) );
@ -209,6 +217,7 @@ class WC_Gateway_Paypal_IPN_Handler extends WC_Gateway_Paypal_Response {
/**
* Handle a denied payment.
* @param WC_Order $order
* @param array $posted
*/
protected function payment_status_denied( $order, $posted ) {
$this->payment_status_failed( $order, $posted );
@ -217,6 +226,7 @@ class WC_Gateway_Paypal_IPN_Handler extends WC_Gateway_Paypal_Response {
/**
* Handle an expired payment.
* @param WC_Order $order
* @param array $posted
*/
protected function payment_status_expired( $order, $posted ) {
$this->payment_status_failed( $order, $posted );
@ -225,6 +235,7 @@ class WC_Gateway_Paypal_IPN_Handler extends WC_Gateway_Paypal_Response {
/**
* Handle a voided payment.
* @param WC_Order $order
* @param array $posted
*/
protected function payment_status_voided( $order, $posted ) {
$this->payment_status_failed( $order, $posted );
@ -233,6 +244,7 @@ class WC_Gateway_Paypal_IPN_Handler extends WC_Gateway_Paypal_Response {
/**
* Handle a refunded order.
* @param WC_Order $order
* @param array $posted
*/
protected function payment_status_refunded( $order, $posted ) {
// Only handle full refunds, not partial.
@ -251,6 +263,7 @@ class WC_Gateway_Paypal_IPN_Handler extends WC_Gateway_Paypal_Response {
/**
* Handle a reveral.
* @param WC_Order $order
* @param array $posted
*/
protected function payment_status_reversed( $order, $posted ) {
$order->update_status( 'on-hold', sprintf( __( 'Payment %s via IPN.', 'woocommerce' ), wc_clean( $posted['payment_status'] ) ) );
@ -264,6 +277,7 @@ class WC_Gateway_Paypal_IPN_Handler extends WC_Gateway_Paypal_Response {
/**
* Handle a cancelled reveral.
* @param WC_Order $order
* @param array $posted
*/
protected function payment_status_canceled_reversal( $order, $posted ) {
$this->send_ipn_email_notification(
@ -275,6 +289,7 @@ class WC_Gateway_Paypal_IPN_Handler extends WC_Gateway_Paypal_Response {
/**
* Save important data from the IPN to the order.
* @param WC_Order $order
* @param array $posted
*/
protected function save_paypal_meta_data( $order, $posted ) {
if ( ! empty( $posted['payer_email'] ) ) {

View File

@ -16,6 +16,9 @@ class WC_Gateway_Paypal_PDT_Handler extends WC_Gateway_Paypal_Response {
/**
* Constructor.
*
* @param bool $sandbox
* @param string $identity_token
*/
public function __construct( $sandbox = false, $identity_token = '' ) {
add_action( 'woocommerce_thankyou_paypal', array( $this, 'check_response' ) );

View File

@ -49,7 +49,7 @@ class WC_Gateway_Paypal_Refund {
* @param WC_Order $order
* @param float $amount
* @param string $reason
* @param boolean $sandbox
* @param bool $sandbox
* @return array|wp_error The parsed response from paypal, or a WP_Error object
*/
public static function refund_order( $order, $amount = null, $reason = '', $sandbox = false ) {

View File

@ -39,7 +39,7 @@ class WC_Gateway_Paypal_Request {
/**
* Get the PayPal request URL for an order.
* @param WC_Order $order
* @param boolean $sandbox
* @param bool $sandbox
* @return string
*/
public function get_request_url( $order, $sandbox = false ) {
@ -276,8 +276,8 @@ class WC_Gateway_Paypal_Request {
/**
* Add PayPal Line Item.
* @param string $item_name
* @param integer $quantity
* @param integer $amount
* @param int $quantity
* @param int $amount
* @param string $item_number
* @return bool successfully added or not
*/