PHP Class WC_Payment_Gateway

Extended by individual payment gateways to handle payments.
Author: WooThemes
Inheritance: extends WC_Settings_API
Datei anzeigen Open project: woocommerce/woocommerce Class Usage Examples

Public Properties

Property Type Description
$availability string Available for all counties or specific.
$chosen boolean Chosen payment method id.
$countries array Countries this gateway is allowed for.
$description string Payment method description for the frontend.
$enabled string yes or no based on whether the method is enabled.
$has_fields boolean True if the gateway shows fields on the checkout.
$icon string Icon for the gateway.
$max_amount integer Maximum transaction amount, zero does not define a maximum.
$method_description string Gateway description.
$method_title string Gateway title.
$new_method_label string Optional label to show for "new payment method" in the payment method/token selection radio selection.
$order_button_text string Set if the place order button should be renamed on selection.
$supports array Supported features such as 'default_credit_card_form', 'refunds'.
$title string Payment method title for the frontend.
$view_transaction_url string Optional URL to view a transaction.

Protected Properties

Property Type Description
$tokens array Contains a users saved tokens for this gateway.

Public Methods

Method Description
admin_options ( ) Output the gateway settings screen.
credit_card_form ( array $args = [], array $fields = [] ) Core credit card form which gateways can used if needed. Deprecated - inheirt WC_Payment_Gateway_CC instead.
get_description ( ) : string Return the gateway's description.
get_icon ( ) : string Return the gateway's icon.
get_method_description ( ) : string Return the description for admin screens.
get_method_title ( ) : string Return the title for admin screens.
get_new_payment_method_option_html ( ) Displays a radio button for entering a new payment method (new CC details) instead of using a saved method.
get_return_url ( WC_Order $order = null ) : string Get the return url (thank you page).
get_saved_payment_method_option_html ( WC_Payment_Token $token ) : string Gets saved payment method HTML from a token.
get_title ( ) : string Return the gateway's title.
get_tokens ( ) : array Returns a users saved tokens for this gateway.
get_transaction_url ( WC_Order $order ) : string Get a link to the transaction on the 3rd party gateway size (if applicable).
has_fields ( ) : boolean Check if the gateway has fields on the checkout.
init_settings ( ) Init settings for gateways.
is_available ( ) : boolean Check if the gateway is available for use.
payment_fields ( ) If There are no payment fields show the description if set.
process_payment ( integer $order_id ) : array Process Payment.
process_refund ( integer $order_id, float $amount = null, string $reason = '' ) : boolean Process refund.
save_payment_method_checkbox ( ) Outputs a checkbox for saving a new payment method to the database.
saved_payment_methods ( ) Grab and display our saved payment methods.
set_current ( ) Set as current gateway.
supports ( string $feature ) : boolean Check if a gateway supports a given feature.
tokenization_script ( ) Enqueues our tokenization script to handle some of the new form options.
validate_fields ( ) : boolean Validate frontend fields.

Protected Methods

Method Description
get_order_total ( ) : float Get the order total in checkout and pay_for_order.

Method Details

admin_options() public method

Output the gateway settings screen.
public admin_options ( )

credit_card_form() public method

Core credit card form which gateways can used if needed. Deprecated - inheirt WC_Payment_Gateway_CC instead.
public credit_card_form ( array $args = [], array $fields = [] )
$args array
$fields array

get_description() public method

Return the gateway's description.
public get_description ( ) : string
return string

get_icon() public method

Return the gateway's icon.
public get_icon ( ) : string
return string

get_method_description() public method

Return the description for admin screens.
public get_method_description ( ) : string
return string

get_method_title() public method

Return the title for admin screens.
public get_method_title ( ) : string
return string

get_new_payment_method_option_html() public method

Only displayed when a gateway supports tokenization.
Since: 2.6.0

get_order_total() protected method

Get the order total in checkout and pay_for_order.
protected get_order_total ( ) : float
return float

get_return_url() public method

Get the return url (thank you page).
public get_return_url ( WC_Order $order = null ) : string
$order WC_Order
return string

get_saved_payment_method_option_html() public method

Gets saved payment method HTML from a token.
Since: 2.6.0
public get_saved_payment_method_option_html ( WC_Payment_Token $token ) : string
$token WC_Payment_Token Payment Token
return string Generated payment method HTML

get_title() public method

Return the gateway's title.
public get_title ( ) : string
return string

get_tokens() public method

Returns a users saved tokens for this gateway.
Since: 2.6.0
public get_tokens ( ) : array
return array

get_transaction_url() public method

Get a link to the transaction on the 3rd party gateway size (if applicable).
public get_transaction_url ( WC_Order $order ) : string
$order WC_Order the order object.
return string transaction URL, or empty string.

has_fields() public method

Check if the gateway has fields on the checkout.
public has_fields ( ) : boolean
return boolean

init_settings() public method

Init settings for gateways.
public init_settings ( )

is_available() public method

Check if the gateway is available for use.
public is_available ( ) : boolean
return boolean

payment_fields() public method

Override this in your gateway if you have some.
public payment_fields ( )

process_payment() public method

Process the payment. Override this in your gateway. When implemented, this should. return the success and redirect in an array. e.g: return array( 'result' => 'success', 'redirect' => $this->get_return_url( $order ) );
public process_payment ( integer $order_id ) : array
$order_id integer
return array

process_refund() public method

If the gateway declares 'refunds' support, this will allow it to refund. a passed in amount.
public process_refund ( integer $order_id, float $amount = null, string $reason = '' ) : boolean
$order_id integer
$amount float
$reason string
return boolean True or false based on success, or a WP_Error object.

save_payment_method_checkbox() public method

Outputs a checkbox for saving a new payment method to the database.
Since: 2.6.0

saved_payment_methods() public method

Grab and display our saved payment methods.
Since: 2.6.0

set_current() public method

Set this as the current gateway.
public set_current ( )

supports() public method

Gateways should override this to declare support (or lack of support) for a feature. For backward compatibility, gateways support 'products' by default, but nothing else.
Since: 1.5.7
public supports ( string $feature ) : boolean
$feature string string The name of a feature to test support for.
return boolean True if the gateway supports the feature, false otherwise.

tokenization_script() public method

Enqueues our tokenization script to handle some of the new form options.
Since: 2.6.0
public tokenization_script ( )

validate_fields() public method

Validate payment fields on the frontend.
public validate_fields ( ) : boolean
return boolean

Property Details

$availability public_oe property

Available for all counties or specific.
public string $availability
return string

$chosen public_oe property

Chosen payment method id.
public bool $chosen
return boolean

$countries public_oe property

Countries this gateway is allowed for.
public array $countries
return array

$description public_oe property

Payment method description for the frontend.
public string $description
return string

$enabled public_oe property

yes or no based on whether the method is enabled.
public string $enabled
return string

$has_fields public_oe property

True if the gateway shows fields on the checkout.
public bool $has_fields
return boolean

$icon public_oe property

Icon for the gateway.
public string $icon
return string

$max_amount public_oe property

Maximum transaction amount, zero does not define a maximum.
public int $max_amount
return integer

$method_description public_oe property

Gateway description.
public string $method_description
return string

$method_title public_oe property

Gateway title.
public string $method_title
return string

$new_method_label public_oe property

Optional label to show for "new payment method" in the payment method/token selection radio selection.
public string $new_method_label
return string

$order_button_text public_oe property

Set if the place order button should be renamed on selection.
public string $order_button_text
return string

$supports public_oe property

Supported features such as 'default_credit_card_form', 'refunds'.
public array $supports
return array

$title public_oe property

Payment method title for the frontend.
public string $title
return string

$tokens protected_oe property

Contains a users saved tokens for this gateway.
protected array $tokens
return array

$view_transaction_url public_oe property

Optional URL to view a transaction.
public string $view_transaction_url
return string