Function
Payment gateways functions
On this page
- rpress_process_gateway_select()
- rpress_load_ajax_gateway()
- rpress_no_gateway_error()
- rpress_get_payment_gateways()
- rpress_get_enabled_payment_gateways()
- rpress_is_gateway_active()
- rpress_is_offline_gateway()
- rpress_get_default_gateway()
- rpress_get_gateway_admin_label()
- rpress_get_gateway_checkout_label()
- rpress_get_gateway_supports()
- rpress_gateway_supports_buy_now()
- rpress_shop_supports_buy_now()
- rpress_build_straight_to_gateway_data()
- rpress_send_to_gateway()
- rpress_show_gateways()
- rpress_get_chosen_gateway()
- rpress_record_gateway_error()
- rpress_count_sales_by_gateway()
- rpress_count_sales_by_gateway_with_date_range()
- rpress_get_total_earnings_by_gateway_with_date_range()
- rpress_get_total_tax_by_gateway_with_date_range()
- rpress_cash_on_delivery_payment()
- rpress_manual_payment()
- rpress_register_paypal_gateway_section()
- rpress_register_paypal_gateway_settings()
- rpress_get_paypal_settings_page_url()
- rpress_get_paypal_connect_state_transient_key()
- rpress_get_paypal_connect_mode_transient_key()
- rpress_get_paypal_connect_id_token_transient_key()
- rpress_get_paypal_connect_error_transient_key()
- rpress_set_paypal_connect_error_detail()
- rpress_pop_paypal_connect_error_detail()
- rpress_get_paypal_error_detail_from_wp_error()
- rpress_get_paypal_oauth_api_base_url()
- rpress_get_paypal_oauth_web_base_url()
- rpress_get_paypal_allowed_redirect_hosts()
- rpress_allow_paypal_redirect_hosts()
- rpress_validate_paypal_client_credentials()
- rpress_detect_paypal_credentials_mode()
- rpress_get_paypal_oauth_token_endpoints()
- rpress_extract_paypal_oauth_error()
- rpress_request_paypal_oauth_token()
- rpress_get_paypal_oauth_redirect_url()
- rpress_get_paypal_oauth_scopes()
- rpress_get_paypal_connect_action_url()
- rpress_get_paypal_connect_notice()
- rpress_paypal_connect_callback()
- rpress_handle_paypal_connect_request()
- rpress_handle_paypal_connect_callback()
- rpress_exchange_paypal_oauth_code()
- rpress_extract_paypal_profile_email()
- rpress_extract_paypal_profile_payer_id()
- rpress_extract_paypal_profile_account_type()
- rpress_base64url_decode()
- rpress_get_paypal_account_from_id_token()
- rpress_get_paypal_profile_endpoints()
- rpress_get_paypal_oauth_account()
- rpress_store_connected_paypal_account()
- rpress_get_paypal_merchant_identifier()
- rpress_get_paypal_checkout_currency()
- rpress_process_paypal_purchase()
- rpress_listen_for_paypal_ipn()
- rpress_process_paypal_ipn()
- rpress_process_paypal_web_accept_and_cart()
- rpress_process_paypal_refund()
- rpress_get_paypal_redirect()
- rpress_get_paypal_image_url()
- rpress_paypal_success_page_content()
- rpress_paypal_process_pdt_on_return()
- rpress_paypal_get_payment_transaction_id()
- rpress_paypal_link_transaction_id()
- rpress_paypal_refund_admin_js()
- rpress_maybe_refund_paypal_purchase()
- rpress_refund_paypal_purchase()
- rpress_core_stripe_extension_installed()
- rpress_core_stripe_is_extension_plugin_file()
- rpress_core_stripe_is_available()
- rpress_core_stripe_default_hosted_checkout()
- rpress_core_stripe_remove_cc_form()
- rpress_core_stripe_register_runtime_hooks()
- rpress_core_stripe_register_gateway()
- rpress_core_stripe_register_settings_section()
- rpress_core_stripe_register_gateway_settings()
- rpress_core_stripe_get_secret_key()
- rpress_core_stripe_get_webhook_secret()
- rpress_core_stripe_hosted_checkout_enabled()
- rpress_core_stripe_process_purchase()
- rpress_core_stripe_allowed_redirect_hosts()
- rpress_core_stripe_api_request()
- rpress_core_stripe_get_amount()
- rpress_core_stripe_is_zero_decimal_currency()
- rpress_core_stripe_get_payment_description()
- rpress_core_stripe_process_return()
- rpress_core_stripe_success_page_content()
- rpress_core_stripe_event_listener()
- rpress_core_stripe_verify_webhook_signature()
- rpress_core_stripe_hash_equals()
- rpress_core_stripe_get_payment_id_by_checkout_session()
- rpress_core_stripe_update_payment_from_session()
- rpress_core_stripe_amount_from_minor_units()
- rpress_core_stripe_get_payment_transaction_id()
- rpress_core_stripe_link_transaction_id()
Functions for payment gateways: registering and selecting gateways, and the built-in Cash on Delivery, PayPal Standard and Stripe gateways.
103 functions. Each entry shows the signature, parameters, return value and where it is defined. Functions marked internal are hook callbacks, screen renderers and other plumbing that extensions normally do not call.
rpress_process_gateway_select()#
Redirects to the checkout with the selected payment-mode when the gateway form is submitted.
Hooked to rpress_gateway_select. Fallback for visitors without JavaScript: when $_POST['gateway_submit'] is set, it redirects with wp_safe_redirect() to the current URL with a payment-mode query argument and exits.
rpress_process_gateway_select( $data )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$data | array | Required | Request data passed by the rpress_gateway_select action. Not used by the function. |
Note: Calls exit after redirecting.
Internal. Defined in includes/gateways/actions.php, line 20.
rpress_load_ajax_gateway()#
Handles the AJAX request that loads the payment form of a gateway.
Registered on wp_ajax_rpress_load_gateway and wp_ajax_nopriv_rpress_load_gateway. Verifies the rpress_load_gateway nonce sent as security, then outputs the result of rpress_show_cc_form() when rpress_payment_mode is posted, and exits.
rpress_load_ajax_gateway()
Note: Echoes output and exits. Calls rpress_die() when the nonce check fails.
Internal. Defined in includes/gateways/actions.php, line 32.
rpress_no_gateway_error()#
Sets a checkout error when no payment gateway is enabled and the cart has a total.
Runs on init. If there are no enabled gateways and the cart total is above zero, it removes the credit card form actions and sets the no_gateways error. Otherwise it clears that error.
rpress_no_gateway_error()
Internal. Defined in includes/gateways/actions.php, line 50.
rpress_get_payment_gateways()#
Returns every registered payment gateway, enabled or not.
The built-in gateways are paypal, manual (shown as Test Payment) and cash_on_delivery (shown as Pay by cash). Each entry is an array with admin_label, checkout_label and an optional supports list. Extensions register gateways through the rpress_payment_gateways filter.
rpress_get_payment_gateways()
Returns array: Gateway definitions keyed by gateway ID.
Example
add_filter( 'rpress_payment_gateways', function ( $gateways ) {
$gateways['my_gateway'] = array(
'admin_label' => 'My Gateway',
'checkout_label' => 'My Gateway',
);
return $gateways;
} );
$all = rpress_get_payment_gateways();
Defined in includes/gateways/functions.php, line 20.
rpress_get_enabled_payment_gateways()#
Returns the gateways that are enabled in the RestroPress settings.
Filters rpress_get_payment_gateways() by the gateways option. With $sort set to true the default gateway is moved to the first position. The result passes through the rpress_enabled_payment_gateways filter.
rpress_get_enabled_payment_gateways( $sort = false )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$sort | bool | false | When true, the default gateway is placed first. |
Returns array: Enabled gateway definitions keyed by gateway ID.
Example
$gateways = rpress_get_enabled_payment_gateways( true );
foreach ( $gateways as $id => $gateway ) {
echo esc_html( $gateway['checkout_label'] );
}
Defined in includes/gateways/functions.php, line 53.
rpress_is_gateway_active()#
Checks whether a gateway is enabled.
Returns false for an empty value. The result passes through the rpress_is_gateway_active filter.
rpress_is_gateway_active( $gateway )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$gateway | string | Required | Gateway ID. |
Returns bool: True if the gateway is enabled, false otherwise.
Example
if ( rpress_is_gateway_active( 'cash_on_delivery' ) ) {
// Cash on delivery is available at checkout.
}
Defined in includes/gateways/functions.php, line 80.
rpress_is_offline_gateway()#
Checks whether a gateway is an offline gateway such as cash on delivery or test payment.
The offline list is manual, cash_on_delivery and cod, filterable through rpress_offline_payment_gateways. Any other gateway is treated as an online gateway. The slug is passed through sanitize_key() first.
rpress_is_offline_gateway( $gateway = '' )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$gateway | string | '' | Gateway ID. |
Returns bool: True if the gateway is in the offline list.
Example
if ( rpress_is_offline_gateway( 'cash_on_delivery' ) ) {
// Payment is collected at delivery.
}
Defined in includes/gateways/functions.php, line 95.
rpress_get_default_gateway()#
Returns the default gateway ID from the settings.
Reads the default_gateway option (default paypal). If that gateway is not enabled, the first enabled gateway is used instead. The value passes through the rpress_default_gateway filter.
rpress_get_default_gateway()
Returns string|false: Gateway ID, or false when no gateway is enabled.
Example
$default = rpress_get_default_gateway();
Defined in includes/gateways/functions.php, line 106.
rpress_get_gateway_admin_label()#
Returns the label shown in the admin for a gateway.
Falls back to the gateway ID when the gateway is not registered. For manual, when the id query argument points to a zero-amount order, the label is Test Payment. Filterable through rpress_gateway_admin_label.
rpress_get_gateway_admin_label( $gateway )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$gateway | string | Required | Gateway ID. |
Returns string: Admin label.
Example
echo esc_html( rpress_get_gateway_admin_label( 'paypal' ) );
Defined in includes/gateways/functions.php, line 122.
rpress_get_gateway_checkout_label()#
Returns the label shown to customers at checkout for a gateway.
Falls back to the gateway ID when the gateway is not registered. The manual gateway always returns Test Payment. Filterable through rpress_gateway_checkout_label.
rpress_get_gateway_checkout_label( $gateway )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$gateway | string | Required | Gateway ID. |
Returns string: Checkout label.
Example
echo esc_html( rpress_get_gateway_checkout_label( 'cash_on_delivery' ) );
Defined in includes/gateways/functions.php, line 140.
rpress_get_gateway_supports()#
Returns the feature list a gateway declares.
Looks the gateway up among the enabled gateways only, so a disabled gateway returns an empty array. Filterable through rpress_gateway_supports.
rpress_get_gateway_supports( $gateway )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$gateway | string | Required | Gateway ID. |
Returns array: List of supported features, such as buy_now. Empty when none.
Example
$supports = rpress_get_gateway_supports( 'paypal' );
Defined in includes/gateways/functions.php, line 155.
rpress_gateway_supports_buy_now()#
Checks whether a gateway supports the buy now flow.
True when buy_now is in the gateway's supports list. Filterable through rpress_gateway_supports_buy_now.
rpress_gateway_supports_buy_now( $gateway )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$gateway | string | Required | Gateway ID. |
Returns bool: True if buy now is supported.
Defined in includes/gateways/functions.php, line 167.
rpress_shop_supports_buy_now()#
Checks whether the store can use the buy now flow with its current gateway setup.
Returns true only when taxes are not in use, exactly one gateway is enabled, and that gateway supports buy_now. Filterable through rpress_shop_supports_buy_now.
rpress_shop_supports_buy_now()
Returns bool: True if buy now is available.
Defined in includes/gateways/functions.php, line 178.
rpress_build_straight_to_gateway_data()#
Builds the purchase data array for a single-item, straight-to-gateway purchase.
Uses the menu item's base price, or the price from $options['price_id'] when the item has variable prices. Taxes and discounts are zero, the gateway is paypal and buy_now is true. Calls wp_die() with a 404 response if the price ID does not exist. The result passes through rpress_straight_to_gateway_purchase_data.
rpress_build_straight_to_gateway_data( $fooditem_id = 0, $options = array(), $quantity = 1 )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$fooditem_id | int | 0 | Menu item ID. |
$options | array | array() | Price options. Use the price_id key to select a variable price. |
$quantity | int | 1 | Quantity of the item. |
Returns array: Purchase data in the format used by rpress_send_to_gateway().
Example
$purchase_data = rpress_build_straight_to_gateway_data( 123, array(), 2 );
rpress_send_to_gateway( 'paypal', $purchase_data );
Note: Uses the current user's details when logged in, otherwise empty user info.
Defined in includes/gateways/functions.php, line 201.
rpress_send_to_gateway()#
Sends payment data to a gateway by firing its gateway action.
Adds a gateway_nonce (action rpress-gateway) to the data and fires rpress_gateway_{$gateway}. The gateway's callback is expected to create the order and redirect.
rpress_send_to_gateway( $gateway, $payment_data )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$gateway | string | Required | Gateway ID. Must match the ID the gateway was registered with. |
$payment_data | array | Required | Purchase data to pass to the gateway. |
Example
rpress_send_to_gateway( 'cash_on_delivery', $purchase_data );
Defined in includes/gateways/functions.php, line 286.
rpress_show_gateways()#
Checks whether the gateway selector should be shown at checkout.
True only when more than one gateway is enabled and the cart total is above zero. Filterable through rpress_show_gateways.
rpress_show_gateways()
Returns bool: True if the selector should be shown.
Defined in includes/gateways/functions.php, line 300.
rpress_get_chosen_gateway()#
Returns the gateway selected for the current checkout.
Reads payment-mode from the request, then the payment_mode cookie, and strips unsafe characters. If the value is empty or not an enabled gateway, the default gateway is used. When the cart subtotal is zero or less, manual is returned. Filterable through rpress_chosen_gateway.
rpress_get_chosen_gateway()
Returns string: Gateway ID.
Example
$gateway = rpress_get_chosen_gateway();
Defined in includes/gateways/functions.php, line 320.
rpress_record_gateway_error()#
Records a gateway error in the logs.
A thin wrapper around rpress_record_log() that uses the gateway_error log type.
rpress_record_gateway_error( $title = '', $message = '', $parent = 0 )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$title | string | '' | Log entry title. |
$message | string | '' | Log entry message. |
$parent | int | 0 | Parent ID, usually the order the error relates to. |
Returns int: ID of the new log entry.
Example
rpress_record_gateway_error( 'Gateway Error', 'Request timed out.', $payment_id );
Defined in includes/gateways/functions.php, line 353.
rpress_count_sales_by_gateway()#
Counts the orders placed with a gateway.
Runs a WP_Query over rpress_payment posts matching the _rpress_payment_gateway meta value and the given status.
rpress_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$gateway_id | string | 'paypal' | Gateway ID. |
$status | string | 'publish' | Order post status to count. |
Returns int: Number of matching orders.
Example
$count = rpress_count_sales_by_gateway( 'cash_on_delivery', 'publish' );
Defined in includes/gateways/functions.php, line 365.
rpress_count_sales_by_gateway_with_date_range()#
Counts the orders placed with a gateway, optionally within a date range.
The date filter is applied only when both $start_date and $end_date are provided, and it is inclusive. Dates are passed to WP_Query's date_query as after and before.
rpress_count_sales_by_gateway_with_date_range( $gateway_id = 'paypal', $status = 'publish', $start_date = null, $end_date = null )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$gateway_id | string | 'paypal' | Gateway ID. |
$status | string | 'publish' | Order post status to count. |
$start_date | string | null | Start of the range, for example 2025-01-01. |
$end_date | string | null | End of the range. |
Returns int: Number of matching orders.
Example
$count = rpress_count_sales_by_gateway_with_date_range( 'paypal', 'publish', '2025-01-01', '2025-01-31' );
Defined in includes/gateways/functions.php, line 391.
rpress_get_total_earnings_by_gateway_with_date_range()#
Returns the total of published orders paid through a gateway, optionally within a date range.
Sums _rpress_payment_total for published orders with a total above zero. The date filter on post_date applies only when both dates are given; when they are equal, the end date is extended to 23:59:59.
rpress_get_total_earnings_by_gateway_with_date_range( $gateway_id = 'paypal', $start_date = null, $end_date = null )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$gateway_id | string | 'paypal' | Gateway ID. |
$start_date | string | null | Start of the range. |
$end_date | string | null | End of the range. |
Returns float: Total earnings, 0 when nothing matches.
Example
$total = rpress_get_total_earnings_by_gateway_with_date_range( 'paypal', '2025-01-01', '2025-01-31' );
Defined in includes/gateways/functions.php, line 425.
rpress_get_total_tax_by_gateway_with_date_range()#
Returns the tax collected on published orders paid through a gateway, optionally within a date range.
Sums _rpress_payment_tax for published orders with a tax above zero. The date filter applies only when both dates are given.
rpress_get_total_tax_by_gateway_with_date_range( $gateway_id = 'paypal', $start_date = null, $end_date = null )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$gateway_id | string | 'paypal' | Gateway ID. |
$start_date | string | null | Start of the range. |
$end_date | string | null | End of the range. |
Returns float: Total tax, 0 when nothing matches.
Example
$tax = rpress_get_total_tax_by_gateway_with_date_range( 'paypal', '2025-01-01', '2025-01-31' );
Note: Unlike the earnings function, a range where both dates are the same day ends at midnight of that day, so the day is not fully covered.
Defined in includes/gateways/functions.php, line 464.
rpress_cash_on_delivery_payment()#
Creates an order for the Cash on Delivery gateway and sends the customer to the success page.
Hooked to rpress_gateway_cash_on_delivery. Verifies the gateway nonce (wp_die with 403 on failure), inserts the order, sets its payment status to processing and its order status to pending, empties the cart and redirects. If the order cannot be created it records a gateway error and returns to checkout.
rpress_cash_on_delivery_payment( $purchase_data )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$purchase_data | array | Required | Purchase data, including gateway_nonce. |
Note: Redirects and exits.
Internal. Defined in includes/gateways/functions.php, line 495.
rpress_manual_payment()#
Creates an order for the manual (test) gateway and sends the customer to the success page.
Hooked to rpress_gateway_manual. Verifies the gateway nonce (wp_die with 403 on failure), inserts the order, sets its status to processing, empties the cart and redirects. If the order cannot be created it records a gateway error and returns to checkout.
rpress_manual_payment( $purchase_data )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$purchase_data | array | Required | Purchase data, including gateway_nonce. |
Note: Redirects and exits. Also used for zero-total carts.
Internal. Defined in includes/gateways/manual.php, line 28.
rpress_register_paypal_gateway_section()#
Adds the PayPal Standard subsection to the gateway settings tabs.
Filter callback for rpress_settings_sections_gateways.
rpress_register_paypal_gateway_section($gateway_sections)
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$gateway_sections | array | Required | Current gateway subsections. |
Returns array: Subsections including paypal.
Internal. Defined in includes/gateways/paypal-standard.php, line 30.
rpress_register_paypal_gateway_settings()#
Adds the PayPal Standard settings fields to the gateway settings.
Filter callback for rpress_settings_gateways. Registers the PayPal Connect row, REST client ID and secret, merchant email and related fields under the paypal key.
rpress_register_paypal_gateway_settings($gateway_settings)
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$gateway_settings | array | Required | Current gateway settings. |
Returns array: Gateway settings including the PayPal Standard fields.
Internal. Defined in includes/gateways/paypal-standard.php, line 43.
rpress_get_paypal_settings_page_url()#
Returns the admin URL of the PayPal Standard settings screen.
Defaults to admin.php?page=rpress-settings&tab=gateways§ion=paypal. Extra arguments are merged over the defaults and added to the query string.
rpress_get_paypal_settings_page_url($args = array())
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$args | array | array() | Query arguments to add or override. |
Returns string: Admin URL.
Internal. Defined in includes/gateways/paypal-standard.php, line 103.
rpress_get_paypal_connect_state_transient_key()#
Returns the transient key that stores the PayPal connect state for a user.
rpress_get_paypal_connect_state_transient_key($user_id)
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$user_id | int | Required | User ID. |
Returns string: Transient key rpress_paypal_connect_state_{user_id}.
Internal. Defined in includes/gateways/paypal-standard.php, line 121.
rpress_get_paypal_connect_mode_transient_key()#
Returns the transient key that stores the PayPal connect mode for a user.
rpress_get_paypal_connect_mode_transient_key($user_id)
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$user_id | int | Required | User ID. |
Returns string: Transient key rpress_paypal_connect_mode_{user_id}.
Internal. Defined in includes/gateways/paypal-standard.php, line 133.
rpress_get_paypal_connect_id_token_transient_key()#
Returns the transient key that stores the PayPal connect ID token for a user.
rpress_get_paypal_connect_id_token_transient_key($user_id)
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$user_id | int | Required | User ID. |
Returns string: Transient key rpress_paypal_connect_id_token_{user_id}.
Internal. Defined in includes/gateways/paypal-standard.php, line 145.
rpress_get_paypal_connect_error_transient_key()#
Returns the transient key that stores the PayPal connect error detail for a user.
rpress_get_paypal_connect_error_transient_key($user_id)
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$user_id | int | Required | User ID. |
Returns string: Transient key rpress_paypal_connect_error_{user_id}.
Internal. Defined in includes/gateways/paypal-standard.php, line 157.
rpress_set_paypal_connect_error_detail()#
Stores a PayPal connect error message for the current user for the next admin page load.
Tags are stripped. Empty or non-string messages are ignored. The message is kept in a transient for five minutes.
rpress_set_paypal_connect_error_detail($message)
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$message | string | Required | Error detail message. |
Internal. Defined in includes/gateways/paypal-standard.php, line 169.
rpress_pop_paypal_connect_error_detail()#
Returns and clears the stored PayPal connect error detail for the current user.
rpress_pop_paypal_connect_error_detail()
Returns string: The stored message, or an empty string.
Internal. Defined in includes/gateways/paypal-standard.php, line 189.
rpress_get_paypal_error_detail_from_wp_error()#
Builds a readable PayPal error string from a WP_Error.
Uses paypal_error_description and paypal_error from the error data when present, otherwise the error message. Returns an empty string if the argument is not a WP_Error.
rpress_get_paypal_error_detail_from_wp_error($error)
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$error | WP_Error | Required | Error object. |
Returns string: Readable error detail.
Internal. Defined in includes/gateways/paypal-standard.php, line 209.
rpress_get_paypal_oauth_api_base_url()#
Returns the PayPal REST API base URL for the given mode.
rpress_get_paypal_oauth_api_base_url($mode = '')
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$mode | string | '' | Optional mode override, sandbox or live. Defaults to sandbox in test mode, live otherwise. |
Returns string: https://api-m.sandbox.paypal.com for sandbox, otherwise https://api-m.paypal.com.
Internal. Defined in includes/gateways/paypal-standard.php, line 240.
rpress_get_paypal_oauth_web_base_url()#
Returns the PayPal web base URL for the given mode.
rpress_get_paypal_oauth_web_base_url($mode = '')
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$mode | string | '' | Optional mode override, sandbox or live. Defaults to sandbox in test mode, live otherwise. |
Returns string: https://www.sandbox.paypal.com for sandbox, otherwise https://www.paypal.com.
Internal. Defined in includes/gateways/paypal-standard.php, line 260.
rpress_get_paypal_allowed_redirect_hosts()#
Returns the PayPal hosts allowed for safe redirects.
The list contains the paypal.com, sandbox.paypal.com and ipnpb hosts. Filterable through rpress_paypal_allowed_redirect_hosts.
rpress_get_paypal_allowed_redirect_hosts()
Returns array: Host names.
Internal. Defined in includes/gateways/paypal-standard.php, line 279.
rpress_allow_paypal_redirect_hosts()#
Adds the PayPal hosts to the hosts accepted by wp_safe_redirect().
Filter callback for allowed_redirect_hosts. Merges the hosts from rpress_get_paypal_allowed_redirect_hosts() without duplicates.
rpress_allow_paypal_redirect_hosts($hosts)
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$hosts | array | Required | Allowed redirect hosts. |
Returns array: Hosts including PayPal's.
Internal. Defined in includes/gateways/paypal-standard.php, line 303.
rpress_validate_paypal_client_credentials()#
Checks whether a PayPal REST client ID and secret are valid for an API base URL.
Requests a client-credentials token from v1/oauth2/token and succeeds when an access token comes back.
rpress_validate_paypal_client_credentials($api_base, $client_id, $client_secret)
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$api_base | string | Required | PayPal API base URL. |
$client_id | string | Required | PayPal client ID. |
$client_secret | string | Required | PayPal client secret. |
Returns bool: True if PayPal returned an access token, false on any failure.
Note: Makes a remote HTTP request.
Internal. Defined in includes/gateways/paypal-standard.php, line 333.
rpress_detect_paypal_credentials_mode()#
Detects whether PayPal REST credentials belong to sandbox or live.
Tries sandbox first, then live, using rpress_validate_paypal_client_credentials().
rpress_detect_paypal_credentials_mode($client_id, $client_secret)
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$client_id | string | Required | PayPal client ID. |
$client_secret | string | Required | PayPal client secret. |
Returns string: sandbox, live or unknown.
Note: Makes up to two remote HTTP requests.
Internal. Defined in includes/gateways/paypal-standard.php, line 369.
rpress_get_paypal_oauth_token_endpoints()#
Returns the PayPal token endpoints tried during OAuth code exchange.
rpress_get_paypal_oauth_token_endpoints($api_base)
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$api_base | string | Required | PayPal API base URL. |
Returns array: The openidconnect/tokenservice and oauth2/token URLs.
Internal. Defined in includes/gateways/paypal-standard.php, line 389.
rpress_extract_paypal_oauth_error()#
Extracts the error code and description from a PayPal API response.
Reads error or name for the code, and error_description, message or the first details description for the text. Both values are sanitized.
rpress_extract_paypal_oauth_error($decoded)
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$decoded | mixed | Required | Decoded response body. |
Returns array: Array with paypal_error and paypal_error_description strings, empty when not found.
Internal. Defined in includes/gateways/paypal-standard.php, line 408.
rpress_request_paypal_oauth_token()#
Requests an access token for a PayPal OAuth authorization code from one endpoint.
Posts to the given URL using the redirect URL from rpress_get_paypal_oauth_redirect_url(). Credentials go in a Basic auth header or in the body, depending on $use_basic_auth.
rpress_request_paypal_oauth_token($request_url, $authorization_code, $client_id, $client_secret, $use_basic_auth = true)
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$request_url | string | Required | PayPal token endpoint URL. |
$authorization_code | string | Required | OAuth authorization code. |
$client_id | string | Required | PayPal client ID. |
$client_secret | string | Required | PayPal client secret. |
$use_basic_auth | bool | true | Whether to send the credentials as HTTP Basic auth. |
Returns array: Array with access_token, id_token, response_code, paypal_error and paypal_error_description. access_token is empty on failure.
Note: Makes a remote HTTP request.
Internal. Defined in includes/gateways/paypal-standard.php, line 450.
rpress_get_paypal_oauth_redirect_url()#
Returns the callback URL used by the PayPal OAuth connect flow.
This is the admin-post.php URL. It must be set as the Return URL in the PayPal app.
rpress_get_paypal_oauth_redirect_url()
Returns string: Callback URL.
Internal. Defined in includes/gateways/paypal-standard.php, line 520.
rpress_get_paypal_oauth_scopes()#
Returns the OAuth scopes requested when connecting a PayPal account.
Defaults to openid and email. Filterable through rpress_paypal_oauth_scopes.
rpress_get_paypal_oauth_scopes()
Returns array: Scope names.
Internal. Defined in includes/gateways/paypal-standard.php, line 531.
rpress_get_paypal_connect_action_url()#
Returns the nonce-protected admin-post URL that starts the PayPal connect flow.
The URL triggers the rpress_paypal_connect admin-post action.
rpress_get_paypal_connect_action_url()
Returns string: Connect URL.
Internal. Defined in includes/gateways/paypal-standard.php, line 546.
rpress_get_paypal_connect_notice()#
Returns the CSS class and message for a PayPal connect result notice.
Known keys are success, missing_credentials, access_denied, missing_code, invalid_state, token_failed, profile_failed, save_failed and missing_email_scope.
rpress_get_paypal_connect_notice($notice)
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$notice | string | Required | Notice key. |
Returns array: Array with class and message; both empty for an unknown key.
Internal. Defined in includes/gateways/paypal-standard.php, line 565.
rpress_paypal_connect_callback()#
Renders the PayPal Connect row on the gateway settings screen.
Callback for the paypal_connect settings field type. Shows the last result notice, the connected account, the Connect or Reconnect button and the OAuth Return URL to configure in PayPal.
rpress_paypal_connect_callback($args)
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$args | array | Required | Settings field arguments. desc is printed at the end. |
Note: Echoes output.
Internal. Defined in includes/gateways/paypal-standard.php, line 623.
rpress_handle_paypal_connect_request()#
Starts the PayPal OAuth connect flow from the admin settings.
Hooked to admin_post_rpress_paypal_connect. Requires the manage_shop_settings capability and the rpress_paypal_connect nonce. Detects the credentials mode, stores a state value in a 15 minute transient, and redirects to PayPal's authorize URL. On missing or invalid credentials it redirects back to the settings screen with a notice.
rpress_handle_paypal_connect_request()
Note: Always redirects and exits.
Internal. Defined in includes/gateways/paypal-standard.php, line 710.
rpress_handle_paypal_connect_callback()#
Handles the PayPal OAuth callback and saves the connected account.
Hooked to admin_post and admin_post_rpress_paypal_connect_callback. Returns silently unless error, state or code is in the request. Requires manage_shop_settings, validates the stored state, exchanges the code for a token, fetches the account and stores it, then redirects to the settings screen with a result notice.
rpress_handle_paypal_connect_callback()
Note: Redirects and exits once it proceeds past the initial request check.
Internal. Defined in includes/gateways/paypal-standard.php, line 767.
rpress_exchange_paypal_oauth_code()#
Exchanges a PayPal OAuth authorization code for an access token.
Uses the stored REST client ID and secret and tries each token endpoint with Basic auth and with body credentials. On success it keeps the returned ID token in a 15 minute transient for the current user. On failure it returns a WP_Error whose data holds paypal_error, paypal_error_description and response_code, and reports a mode mismatch when the credentials belong to the other mode.
rpress_exchange_paypal_oauth_code($authorization_code, $oauth_mode = '')
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$authorization_code | string | Required | OAuth authorization code. |
$oauth_mode | string | '' | Optional mode override, sandbox or live. |
Returns string|WP_Error: The access token, or a WP_Error (rpress_paypal_missing_credentials or rpress_paypal_token_failed).
Note: Makes remote HTTP requests.
Internal. Defined in includes/gateways/paypal-standard.php, line 860.
rpress_extract_paypal_profile_email()#
Extracts the account email from a PayPal profile response.
Collects email and the emails list. In sandbox mode an address ending in @business.example.com is preferred.
rpress_extract_paypal_profile_email($decoded, $oauth_mode = '')
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$decoded | array | Required | Decoded profile response. |
$oauth_mode | string | '' | Mode, sandbox or live. |
Returns string: Email address, or an empty string.
Internal. Defined in includes/gateways/paypal-standard.php, line 960.
rpress_extract_paypal_profile_payer_id()#
Extracts the merchant or payer ID from a PayPal profile response.
Checks payer_id, payerId and merchant_id, then looks for an identity/user/ segment in user_id or sub.
rpress_extract_paypal_profile_payer_id($decoded)
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$decoded | array | Required | Decoded profile response. |
Returns string: Payer ID, or an empty string.
Internal. Defined in includes/gateways/paypal-standard.php, line 1010.
rpress_extract_paypal_profile_account_type()#
Extracts the account type from a PayPal profile response.
Reads account_type or accountType and uppercases it.
rpress_extract_paypal_profile_account_type($decoded)
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$decoded | array | Required | Decoded profile response. |
Returns string: Account type, or an empty string.
Internal. Defined in includes/gateways/paypal-standard.php, line 1042.
rpress_base64url_decode()#
Decodes a base64url string.
Converts URL-safe characters, restores padding and decodes in strict mode.
rpress_base64url_decode($value)
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$value | string | Required | Base64url value. |
Returns string: Decoded string, or an empty string on invalid input.
Example
$json = rpress_base64url_decode( $jwt_part );
Defined in includes/gateways/paypal-standard.php, line 1066.
rpress_get_paypal_account_from_id_token()#
Extracts account details from the payload of a PayPal ID token.
Decodes the second segment of the token without verifying its signature.
rpress_get_paypal_account_from_id_token($id_token, $oauth_mode = '')
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$id_token | string | Required | ID token. |
$oauth_mode | string | '' | Mode, sandbox or live. |
Returns array: Array with email and payer_id, plus account_type when the token could be decoded. Values are empty on failure.
Note: The token signature is not verified.
Internal. Defined in includes/gateways/paypal-standard.php, line 1094.
rpress_get_paypal_profile_endpoints()#
Returns the PayPal profile endpoint URLs to try.
rpress_get_paypal_profile_endpoints($oauth_mode = '')
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$oauth_mode | string | '' | Optional mode override, sandbox or live. Defaults to sandbox in test mode, live otherwise. |
Returns array: Four userinfo endpoint URLs for the mode.
Internal. Defined in includes/gateways/paypal-standard.php, line 1141.
rpress_get_paypal_oauth_account()#
Retrieves account details from PayPal's user info endpoints.
Tries each profile endpoint with the bearer token and returns the first response that contains an email or merchant ID. If none does, it falls back to the stored ID token of the current user.
rpress_get_paypal_oauth_account($access_token, $oauth_mode = '')
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$access_token | string | Required | OAuth access token. |
$oauth_mode | string | '' | Optional mode override, sandbox or live. |
Returns array|WP_Error: Array with email, payer_id and account_type, or a WP_Error rpress_paypal_profile_failed.
Note: Makes remote HTTP requests.
Internal. Defined in includes/gateways/paypal-standard.php, line 1161.
rpress_store_connected_paypal_account()#
Saves the connected PayPal account details in the RestroPress settings.
Writes paypal_email, paypal_id, paypal_account_type, paypal_connected_at and paypal_connected_mode into the rpress_settings option. Returns a WP_Error with code rpress_paypal_missing_email_scope if no email is available.
rpress_store_connected_paypal_account($account, $oauth_mode = '')
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$account | array | Required | Account values with email, payer_id and account_type. |
$oauth_mode | string | '' | Optional mode override, sandbox or live. |
Returns true|WP_Error: True on success, or a WP_Error when no email is available.
Note: Updates the rpress_settings option.
Internal. Defined in includes/gateways/paypal-standard.php, line 1252.
rpress_get_paypal_merchant_identifier()#
Returns the PayPal merchant identifier used as the business value at checkout.
Uses the paypal_email setting, and falls back to paypal_id.
rpress_get_paypal_merchant_identifier()
Returns string: Merchant email or ID, or an empty string if neither is set.
Example
$merchant = rpress_get_paypal_merchant_identifier();
Defined in includes/gateways/paypal-standard.php, line 1313.
rpress_get_paypal_checkout_currency()#
Returns the currency code used for a PayPal Standard checkout.
Normally the store currency in uppercase. In test mode, INR is replaced with USD, filterable through rpress_paypal_sandbox_fallback_currency.
rpress_get_paypal_checkout_currency($store_currency = '')
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$store_currency | string | '' | Currency code. Defaults to the store currency. |
Returns string: Currency code to send to PayPal.
Example
$currency = rpress_get_paypal_checkout_currency();
Defined in includes/gateways/paypal-standard.php, line 1338.
rpress_process_paypal_purchase()#
Creates a pending order and redirects the customer to PayPal.
Hooked to rpress_gateway_paypal. Verifies the gateway nonce, checks that a merchant is configured and that the buyer is not the merchant account, inserts the order and builds the PayPal redirect. The redirect arguments can be changed through rpress_paypal_redirect_args.
rpress_process_paypal_purchase($purchase_data)
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$purchase_data | array | Required | Purchase data, including gateway_nonce. |
Note: Redirects and exits. Sends the customer back to checkout with an error on failure.
Internal. Defined in includes/gateways/paypal-standard.php, line 1367.
rpress_listen_for_paypal_ipn()#
Detects a PayPal IPN request and starts its verification.
Runs on init. When rpress-listener=IPN is in the request it fires rpress_verify_paypal_ipn. It sleeps eight seconds first if a paypal_identity_token is configured.
rpress_listen_for_paypal_ipn()
Internal. Defined in includes/gateways/paypal-standard.php, line 1481.
rpress_process_paypal_ipn()#
Verifies a PayPal IPN request and dispatches it to the matching action.
Hooked to rpress_verify_paypal_ipn. Handles POST requests only. Unless disable_paypal_verification is set, it posts the data back to PayPal and requires a VERIFIED reply. It resolves the order ID, then fires rpress_paypal_{txn_type} if something listens to it, or rpress_paypal_web_accept otherwise. The data is filterable through rpress_process_paypal_ipn_data.
rpress_process_paypal_ipn()
Note: Ends the request with exit after dispatching.
Internal. Defined in includes/gateways/paypal-standard.php, line 1506.
rpress_process_paypal_web_accept_and_cart()#
Handles web accept and cart IPN notifications and completes or fails the order.
Hooked to rpress_paypal_web_accept. Checks the receiver ID or email, currency, amount and purchase key against the order, marks it failed with a note on a mismatch, records the customer's details when the order has no email, and sets the order to publish for a Completed payment. Refunded or reversed payments go to rpress_process_paypal_refund(). Data is filterable through rpress_paypal_web_accept_and_cart_data.
rpress_process_paypal_web_accept_and_cart($data, $payment_id)
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$data | array | Required | Verified IPN data. |
$payment_id | int | Required | Order ID. |
Internal. Defined in includes/gateways/paypal-standard.php, line 1627.
rpress_process_paypal_refund()#
Marks an order as refunded after a PayPal refund IPN.
A refund smaller than the order amount only adds a note. A full refund adds notes and sets the order status to refunded. Does nothing if the order is already refunded. Data is filterable through rpress_process_paypal_refund_data.
rpress_process_paypal_refund($data, $payment_id = 0)
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$data | array | Required | IPN data. |
$payment_id | int | 0 | Order ID. |
Internal. Defined in includes/gateways/paypal-standard.php, line 1801.
rpress_get_paypal_redirect()#
Returns the PayPal URL for checkout redirects or IPN verification.
Uses the sandbox hosts in test mode. With $ipn set it returns the ipnpb endpoint. Filterable through rpress_paypal_uri.
rpress_get_paypal_redirect($ssl_check = false, $ipn = false)
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$ssl_check | bool | false | When true, the protocol follows is_ssl(); otherwise https is used. |
$ipn | bool | false | True to get the IPN verification endpoint. |
Returns string: PayPal URL.
Example
$url = rpress_get_paypal_redirect();
Defined in includes/gateways/paypal-standard.php, line 1839.
rpress_get_paypal_image_url()#
Returns the image URL shown on the PayPal purchase page.
Reads the paypal_image_url setting. Filterable through rpress_paypal_image_url.
rpress_get_paypal_image_url()
Returns string: Image URL, empty if not set.
Internal. Defined in includes/gateways/paypal-standard.php, line 1869.
rpress_paypal_success_page_content()#
Replaces the success page content while a PayPal order is still pending.
Filter callback for rpress_payment_confirm_paypal. Published orders empty the cart and show the normal content, pending or processing orders show the payment/processing template, and other statuses show a payment-failed message with a checkout link.
rpress_paypal_success_page_content($content)
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$content | string | Required | Success page content. |
Returns string: Content to display.
Internal. Defined in includes/gateways/paypal-standard.php, line 1882.
rpress_paypal_process_pdt_on_return()#
Verifies a PayPal payment with PDT when the customer returns to the success page.
Runs on template_redirect. Needs payment-id and tx in the request, a paypal_identity_token setting and an active PayPal gateway. It posts a _notify-synch request, then sets the order to publish, failed or pending based on the reply and amount.
rpress_paypal_process_pdt_on_return()
Note: Makes a remote HTTP request.
Internal. Defined in includes/gateways/paypal-standard.php, line 1923.
rpress_paypal_get_payment_transaction_id()#
Reads the PayPal transaction ID from an order's notes.
Filter callback for rpress_get_payment_transaction_id-paypal. Looks for a note beginning with PayPal Transaction ID:. Filterable through rpress_paypal_set_payment_transaction_id.
rpress_paypal_get_payment_transaction_id($payment_id)
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$payment_id | int | Required | Order ID. |
Returns string: Transaction ID, or an empty string.
Internal. Defined in includes/gateways/paypal-standard.php, line 2049.
rpress_paypal_link_transaction_id()#
Returns an HTML link to a PayPal transaction for the order details screen.
Filter callback for rpress_payment_details_transaction_id-paypal. Uses the sandbox host for test mode orders. Filterable through rpress_paypal_link_payment_details_transaction_id.
rpress_paypal_link_transaction_id($transaction_id, $payment_id)
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$transaction_id | string | Required | Transaction ID. |
$payment_id | int | Required | Order ID. |
Returns string: Anchor tag HTML.
Internal. Defined in includes/gateways/paypal-standard.php, line 2070.
rpress_paypal_refund_admin_js()#
Prints the script that adds a PayPal refund checkbox to the order details screen.
Hooked to rpress_view_order_details_before. Outputs nothing unless the order was paid with PayPal and the PayPal API username, password and signature for its mode are set.
rpress_paypal_refund_admin_js($payment_id = 0)
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$payment_id | int | 0 | Order ID. |
Note: Echoes a script tag.
Internal. Defined in includes/gateways/paypal-standard.php, line 2087.
rpress_maybe_refund_paypal_purchase()#
Refunds a PayPal order in PayPal when the refund checkbox was ticked.
Hooked to rpress_pre_refund_payment at priority 999. Requires the edit_shop_payments capability and the rpress-paypal-refund field, and only acts on PayPal orders that were publish or revoked and not already refunded through PayPal.
rpress_maybe_refund_paypal_purchase(RPRESS_Payment $payment)
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$payment | RPRESS_Payment | Required | Order being refunded. |
Internal. Defined in includes/gateways/paypal-standard.php, line 2128.
rpress_refund_paypal_purchase()#
Issues a full refund through the PayPal NVP API.
Accepts an order object or ID. Sends a RefundTransaction request with the API credentials saved for the order's mode. On success it stores _rpress_paypal_refunded and adds a note with the refund transaction ID, otherwise adds a failure note. Fires rpress_paypal_refund_purchase afterwards. Request parts are filterable through rpress_paypal_refund_api_credentials, rpress_paypal_refund_body_args, rpress_paypal_refund_header_args and rpress_paypal_refund_request_args.
rpress_refund_paypal_purchase($payment)
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$payment | RPRESS_Payment|int | Required | Order object or ID. |
Example
rpress_refund_paypal_purchase( $payment_id );
Note: Makes a remote HTTP request. Does not change the order status.
Defined in includes/gateways/paypal-standard.php, line 2161.
rpress_core_stripe_extension_installed()#
Checks whether the separate RestroPress Stripe extension is active.
Looks for the extension's constant, class or functions, then for its plugin file among the active plugins (including network-active plugins). The plugin paths are filterable through rpress_core_stripe_extension_plugin_paths. Core Stripe stays inactive while the extension is active.
rpress_core_stripe_extension_installed()
Returns bool: True if the extension is active.
Example
if ( rpress_core_stripe_extension_installed() ) {
// The Stripe extension handles payments.
}
Defined in includes/gateways/stripe.php, line 26.
rpress_core_stripe_is_extension_plugin_file()#
Checks whether a plugin file belongs to the Stripe extension.
Compares the file, case-insensitively, with the known paths, and also matches any file inside a restropress-stripe/ or rpress-stripe/ folder.
rpress_core_stripe_is_extension_plugin_file( $plugin_file, $plugin_paths )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$plugin_file | string | Required | Active plugin file. |
$plugin_paths | array | Required | Known Stripe extension plugin paths. |
Returns bool: True if the file belongs to the extension.
Internal. Defined in includes/gateways/stripe.php, line 82.
rpress_core_stripe_is_available()#
Checks whether the built-in Stripe gateway is available.
Core Stripe is available only when the Stripe extension is not active.
rpress_core_stripe_is_available()
Returns bool: True if core Stripe can be used.
Example
if ( rpress_core_stripe_is_available() ) {
$key = rpress_core_stripe_get_secret_key();
}
Defined in includes/gateways/stripe.php, line 100.
rpress_core_stripe_default_hosted_checkout()#
Makes Stripe hosted checkout default to on when the setting has no value.
Filter callback for rpress_get_option_stripe_self_hosted. When core Stripe is available and the value is false, null or empty, it returns 1.
rpress_core_stripe_default_hosted_checkout( $value, $key, $default )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$value | mixed | Required | Option value. |
$key | string | Required | Option key. |
$default | mixed | Required | Default value. |
Returns mixed: The option value, or 1 when unset.
Internal. Defined in includes/gateways/stripe.php, line 113.
rpress_core_stripe_remove_cc_form()#
Suppresses the card form for core Stripe.
Callback for rpress_stripe_cc_form. Core Stripe redirects to Stripe hosted checkout and shows no card fields.
rpress_core_stripe_remove_cc_form()
Returns false: Always false.
Internal. Defined in includes/gateways/stripe.php, line 132.
rpress_core_stripe_register_runtime_hooks()#
Registers the core Stripe hooks when core Stripe is available.
Runs on plugins_loaded at priority 20. Adds the gateway action rpress_gateway_stripe, the return and webhook handlers, the redirect host filter and the transaction ID filters. Does nothing when the Stripe extension is active.
rpress_core_stripe_register_runtime_hooks()
Internal. Defined in includes/gateways/stripe.php, line 142.
rpress_core_stripe_register_gateway()#
Registers the Stripe gateway when the Stripe extension is not installed.
Filter callback for rpress_payment_gateways. Adds a stripe entry that supports buy_now.
rpress_core_stripe_register_gateway( $gateways )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$gateways | array | Required | Payment gateways. |
Returns array: Gateways, with stripe added when core Stripe is available.
Internal. Defined in includes/gateways/stripe.php, line 165.
rpress_core_stripe_register_settings_section()#
Registers the Stripe subsection in the gateway settings.
Filter callback for rpress_settings_sections_gateways. Skipped when the Stripe extension is active.
rpress_core_stripe_register_settings_section( $sections )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$sections | array | Required | Gateway settings sections. |
Returns array: Sections, with stripe added when available.
Internal. Defined in includes/gateways/stripe.php, line 189.
rpress_core_stripe_register_gateway_settings()#
Registers the core Stripe settings fields.
Filter callback for rpress_settings_gateways. Adds the hosted checkout toggle, test and live keys and webhook secret under the stripe key, and shows the webhook URL (index.php?rpress-listener=stripe). The fields are filterable through rpress_core_stripe_settings.
rpress_core_stripe_register_gateway_settings( $gateway_settings )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$gateway_settings | array | Required | Gateway settings. |
Returns array: Gateway settings, with the Stripe fields added when available.
Internal. Defined in includes/gateways/stripe.php, line 207.
rpress_core_stripe_get_secret_key()#
Returns the Stripe secret key for the current mode.
Reads test_secret_key in test mode and live_secret_key otherwise, trimmed. Filterable through rpress_core_stripe_secret_key.
rpress_core_stripe_get_secret_key()
Returns string: Secret key, or an empty string.
Example
$key = rpress_core_stripe_get_secret_key();
Defined in includes/gateways/stripe.php, line 290.
rpress_core_stripe_get_webhook_secret()#
Returns the Stripe webhook signing secret from the settings.
Reads the stripe_webhook_secret option.
rpress_core_stripe_get_webhook_secret()
Returns string: Signing secret, or an empty string.
Internal. Defined in includes/gateways/stripe.php, line 302.
rpress_core_stripe_hosted_checkout_enabled()#
Checks whether Stripe hosted checkout is enabled.
True when the stripe_self_hosted option is 1. Core Stripe only works with hosted checkout.
rpress_core_stripe_hosted_checkout_enabled()
Returns bool: True if enabled.
Defined in includes/gateways/stripe.php, line 312.
rpress_core_stripe_process_purchase()#
Creates a pending order and redirects the customer to Stripe Checkout.
Hooked to rpress_gateway_stripe. Verifies the gateway nonce, requires hosted checkout and a secret key, inserts the order with status private, creates a Checkout Session through the Stripe API and stores its ID in the _stripe_checkout_sessions_key meta. On errors it records them, sets a checkout error and returns to checkout.
rpress_core_stripe_process_purchase( $purchase_data )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$purchase_data | array | Required | Purchase data, including gateway_nonce. |
Note: Redirects and exits.
Internal. Defined in includes/gateways/stripe.php, line 323.
rpress_core_stripe_allowed_redirect_hosts()#
Allows wp_safe_redirect() to send customers to Stripe.
Filter callback for allowed_redirect_hosts. Adds checkout.stripe.com and stripe.com.
rpress_core_stripe_allowed_redirect_hosts( $hosts )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$hosts | array | Required | Allowed redirect hosts. |
Returns array: Hosts including Stripe's.
Internal. Defined in includes/gateways/stripe.php, line 435.
rpress_core_stripe_api_request()#
Sends a request to the Stripe API.
Authenticates with the secret key from rpress_core_stripe_get_secret_key(). For GET requests the parameters go in the query string, otherwise in the body.
rpress_core_stripe_api_request( $method, $endpoint, $params = array() )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$method | string | Required | HTTP method. |
$endpoint | string | Required | Endpoint path under https://api.stripe.com/v1/. |
$params | array | array() | Request parameters. |
Returns array: Decoded response body.
Example
try {
$session = rpress_core_stripe_api_request( 'GET', 'checkout/sessions/' . rawurlencode( $session_id ) );
} catch ( Exception $e ) {
rpress_record_gateway_error( 'Stripe Error', $e->getMessage() );
}
Note: Throws an Exception when the key is missing, the request fails, the response is invalid or Stripe returns a non-2xx status.
Defined in includes/gateways/stripe.php, line 452.
rpress_core_stripe_get_amount()#
Converts an amount to Stripe minor units.
Multiplies by 100 and rounds, or only rounds for zero-decimal currencies. Uses the store currency and returns an absolute value.
rpress_core_stripe_get_amount( $amount )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$amount | float | Required | Amount in the store currency. |
Returns int: Amount in minor units.
Example
$minor = rpress_core_stripe_get_amount( 12.5 );
Defined in includes/gateways/stripe.php, line 504.
rpress_core_stripe_is_zero_decimal_currency()#
Checks whether the store currency is a zero-decimal currency in Stripe.
Compares the store currency with a built-in list (BIF, CLP, DJF, GNF, JPY, KMF, KRW, MGA, PYG, RWF, VND, VUV, XAF, XOF, XPF).
rpress_core_stripe_is_zero_decimal_currency()
Returns bool: True for zero-decimal currencies.
Defined in includes/gateways/stripe.php, line 520.
rpress_core_stripe_get_payment_description()#
Builds a short Stripe payment description from the cart items.
Joins the item names with commas and cuts the text at 250 characters. Falls back to "RestroPress order" when there are no names.
rpress_core_stripe_get_payment_description( $cart_details )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$cart_details | array | Required | Cart details. |
Returns string: Description text.
Internal. Defined in includes/gateways/stripe.php, line 549.
rpress_core_stripe_process_return()#
Tries to complete an order when the customer returns from Stripe Checkout.
Runs on template_redirect. On the success page with payment-confirmation=stripe and a payment-id, it looks up the stored Checkout Session and calls rpress_core_stripe_update_payment_from_session().
rpress_core_stripe_process_return()
Internal. Defined in includes/gateways/stripe.php, line 579.
rpress_core_stripe_success_page_content()#
Shows the processing template while a Stripe order is still pending.
Filter callback for rpress_payment_confirm_stripe. Empties the cart and, for orders with status pending or private, replaces the content with the payment/processing template.
rpress_core_stripe_success_page_content( $content )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$content | string | Required | Success page content. |
Returns string: Content to display.
Internal. Defined in includes/gateways/stripe.php, line 605.
rpress_core_stripe_event_listener()#
Receives and processes Stripe webhooks.
Runs on init. Responds only to rpress-listener=stripe. Verifies the signature, then handles checkout.session.completed, checkout.session.async_payment_succeeded, checkout.session.async_payment_failed and checkout.session.expired.
rpress_core_stripe_event_listener()
Note: Prints a short status message and exits when handling a webhook request.
Internal. Defined in includes/gateways/stripe.php, line 636.
rpress_core_stripe_verify_webhook_signature()#
Verifies the signature of a Stripe webhook.
Parses the t and v1 parts of the header, rejects timestamps older than the tolerance (300 seconds by default, filterable through rpress_core_stripe_webhook_tolerance) and compares an HMAC SHA-256 in constant time.
rpress_core_stripe_verify_webhook_signature( $payload, $header, $secret )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$payload | string | Required | Raw request body. |
$header | string | Required | Stripe-Signature header value. |
$secret | string | Required | Webhook signing secret. |
Returns bool: True if a signature matches.
Internal. Defined in includes/gateways/stripe.php, line 710.
rpress_core_stripe_hash_equals()#
Compares two strings in constant time.
Uses hash_equals() when available, with a manual fallback.
rpress_core_stripe_hash_equals( $known_string, $user_string )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$known_string | string | Required | Known string. |
$user_string | string | Required | User-supplied string. |
Returns bool: True if the strings are equal.
Internal. Defined in includes/gateways/stripe.php, line 760.
rpress_core_stripe_get_payment_id_by_checkout_session()#
Finds the order ID that stores a Stripe Checkout Session ID.
Queries the postmeta table for _stripe_checkout_sessions_key.
rpress_core_stripe_get_payment_id_by_checkout_session( $session_id )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$session_id | string | Required | Checkout Session ID. |
Returns int: Order ID, 0 if none.
Internal. Defined in includes/gateways/stripe.php, line 786.
rpress_core_stripe_update_payment_from_session()#
Completes an order from a Stripe Checkout Session when it has been paid.
Skips orders that are not Stripe orders or are already complete. Fetches the session from Stripe when none is passed. If the session is paid and its total is at least the order total, it stores the PaymentIntent as transaction ID, sets the order to publish and deletes the session meta. A lower total marks the order as failed.
rpress_core_stripe_update_payment_from_session( $session_id, $payment_id, $checkout_session = array() )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$session_id | string | Required | Checkout Session ID. |
$payment_id | int | Required | Order ID. |
$checkout_session | array | array() | Optional Checkout Session object. |
Note: May make a remote request to Stripe.
Internal. Defined in includes/gateways/stripe.php, line 808.
rpress_core_stripe_amount_from_minor_units()#
Converts a Stripe amount in minor units to a store amount.
Divides by 100, or returns the value unchanged for zero-decimal currencies.
rpress_core_stripe_amount_from_minor_units( $amount )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$amount | int | Required | Amount in Stripe minor units. |
Returns float: Amount in the store currency.
Example
$amount = rpress_core_stripe_amount_from_minor_units( 1250 );
Defined in includes/gateways/stripe.php, line 866.
rpress_core_stripe_get_payment_transaction_id()#
Returns the stored transaction ID of an order.
Filter callback for rpress_get_payment_transaction_id-stripe. Reads _rpress_payment_transaction_id.
rpress_core_stripe_get_payment_transaction_id( $payment_id )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$payment_id | int | Required | Order ID. |
Returns string: Transaction ID.
Internal. Defined in includes/gateways/stripe.php, line 883.
rpress_core_stripe_link_transaction_id()#
Returns a link to the Stripe dashboard for a transaction.
Filter callback for rpress_payment_details_transaction_id-stripe. Uses the test dashboard path for test mode orders.
rpress_core_stripe_link_transaction_id( $transaction_id, $payment_id )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$transaction_id | string | Required | Transaction ID. |
$payment_id | int | Required | Order ID. |
Returns string: Anchor tag HTML, or an empty string when there is no transaction ID.
Internal. Defined in includes/gateways/stripe.php, line 895.
