Function
Payments (Apple Pay, Google Pay) functions
On this page
- rpress_payments_to_payment_object()
- rpress_get_payment_paid_state()
- rpress_get_payment_paid_label()
- rpress_payments_stripe_settings()
- rpress_payments_stripe_webhook_endpoint_field()
- rpress_payments_sanitize_apple_pay_file()
- rpress_payments_serve_apple_pay_file()
- rpress_payments_stripe_publishable_key()
- rpress_payments_stripe_wallets_enabled()
- rpress_payments_stripe_wallet_total()
- rpress_payments_stripe_wallet_scripts()
- rpress_payments_stripe_wallet_markup()
- rpress_payments_stripe_wallet_total_ajax()
- rpress_payments_stripe_wallet_process()
- rpress_payments_stripe_wallet_return()
- rpress_payments_stripe_site_key()
- rpress_payments_stripe_webhook_url()
- rpress_payments_stripe_webhook_events()
- rpress_payments_stripe_verify_signature()
- rpress_payments_stripe_event_processed()
- rpress_payments_stripe_remember_event()
- rpress_payments_stripe_handle_webhook()
- rpress_payments_stripe_dispatch_event()
- rpress_payments_stripe_find_payment()
- rpress_payments_stripe_on_intent_succeeded()
- rpress_payments_stripe_mark_paid()
- rpress_payments_stripe_on_intent_failed()
- rpress_payments_stripe_on_charge_refunded()
Functions for Stripe Apple Pay and Google Pay, the hardened Stripe webhook and the Paid and Not paid order labels.
28 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_payments_to_payment_object()#
Converts a payment ID, WP_Post or RPRESS_Payment into an RPRESS_Payment object.
Numeric values above zero are turned into a new RPRESS_Payment. Anything else returns null.
rpress_payments_to_payment_object( $payment )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$payment | mixed | Required | Payment ID, WP_Post or RPRESS_Payment. |
Returns RPRESS_Payment|null: The payment object, or null when the value is not usable.
Example
$payment = rpress_payments_to_payment_object( 123 );
if ( $payment ) {
$total = $payment->total;
}
Defined in includes/features/payments/payment-state.php, line 21.
rpress_get_payment_paid_state()#
Returns the money state of an order: paid, unpaid, refunded, failed or abandoned.
Maps the payment status to a state. A completed order on an offline gateway such as cash counts as paid. The result passes through the rpress_payment_paid_state filter.
rpress_get_payment_paid_state( $payment )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$payment | int|WP_Post|RPRESS_Payment | Required | Payment ID or object. |
Returns string: One of paid, unpaid, refunded, failed or abandoned (unless filtered).
Example
if ( 'paid' === rpress_get_payment_paid_state( $payment_id ) ) {
// Money has been received.
}
Defined in includes/features/payments/payment-state.php, line 41.
rpress_get_payment_paid_label()#
Returns the translated label for an order's money state.
Paid, Refunded, Payment failed or Abandoned; for unpaid orders, Not paid yet for offline gateways or Awaiting payment for online ones. Filterable through rpress_payment_paid_label.
rpress_get_payment_paid_label( $payment )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$payment | int|WP_Post|RPRESS_Payment | Required | Payment ID or object. |
Returns string: The label text.
Example
echo esc_html( rpress_get_payment_paid_label( $payment_id ) );
Defined in includes/features/payments/payment-state.php, line 76.
rpress_payments_stripe_settings()#
Adds the wallet toggle and Apple Pay file fields to the Stripe settings and swaps in the webhook URL field.
Hooked to rpress_core_stripe_settings. Adds stripe_wallets (show or hide) and stripe_apple_pay_domain_association after live_publishable_key, and replaces stripe_webhook_description with a stripe_webhook_endpoint field.
rpress_payments_stripe_settings( $settings )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$settings | array | Required | Core Stripe settings. |
Returns array: The modified settings.
Internal. Defined in includes/features/payments/settings.php, line 22.
rpress_payments_stripe_webhook_endpoint_field()#
Echoes the webhook URL field with a copy button and the list of events to subscribe to.
Hooked to rpress_stripe_webhook_endpoint. Also warns when no webhook signing secret is saved.
rpress_payments_stripe_webhook_endpoint_field()
Note: Echoes output instead of returning it.
Internal. Defined in includes/features/payments/settings.php, line 73.
rpress_payments_sanitize_apple_pay_file()#
Limits the pasted Apple Pay domain file to printable ASCII on save.
Hooked to rpress_settings_sanitize_textarea. Only acts on the stripe_apple_pay_domain_association setting; other keys pass through unchanged.
rpress_payments_sanitize_apple_pay_file( $value, $key = '' )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$value | mixed | Required | Value. |
$key | string | '' | Setting key. |
Returns mixed: The cleaned string for the Apple Pay setting, otherwise the value unchanged.
Internal. Defined in includes/features/payments/settings.php, line 123.
rpress_payments_serve_apple_pay_file()#
Serves the Apple Pay domain association file from the saved setting.
Runs on init at priority 1. When the request path is /.well-known/apple-developer-merchantid-domain-association and the setting is not empty, outputs it as text/plain and exits. Works only if the request reaches WordPress.
rpress_payments_serve_apple_pay_file()
Note: Echoes the file and calls exit when the path matches.
Internal. Defined in includes/features/payments/settings.php, line 139.
rpress_payments_stripe_publishable_key()#
Returns the Stripe publishable key for the current test or live mode.
Filterable through rpress_core_stripe_publishable_key.
rpress_payments_stripe_publishable_key()
Returns string: The trimmed key, or an empty string.
Example
$key = rpress_payments_stripe_publishable_key();
Defined in includes/features/payments/stripe-wallets.php, line 27.
rpress_payments_stripe_wallets_enabled()#
Checks whether the Apple Pay and Google Pay button should be offered.
Requires Stripe to be available and active, the stripe_wallets setting not set to hide, and both a publishable and a secret key. Filterable through rpress_payments_stripe_wallets_enabled.
rpress_payments_stripe_wallets_enabled()
Returns bool: True when the wallet button is offered.
Example
if ( rpress_payments_stripe_wallets_enabled() ) {
// Wallet payments are available at checkout.
}
Defined in includes/features/payments/stripe-wallets.php, line 38.
rpress_payments_stripe_wallet_total()#
Returns the current cart total in the form the wallet payment sheet needs.
Amount is in Stripe minor units via rpress_core_stripe_get_amount(); currency is lowercase; label is the site name or Order total.
rpress_payments_stripe_wallet_total()
Returns array: Array with amount, currency and label.
Internal. Defined in includes/features/payments/stripe-wallets.php, line 55.
rpress_payments_stripe_wallet_scripts()#
Enqueues Stripe.js and the wallet script on the checkout page.
Does nothing off checkout or when wallets are not enabled. Loads Stripe.js from js.stripe.com and passes the key, country, AJAX URL, nonce and total to the script as rpress_stripe_wallet.
rpress_payments_stripe_wallet_scripts()
Internal. Defined in includes/features/payments/stripe-wallets.php, line 71.
rpress_payments_stripe_wallet_markup()#
Echoes the hidden container for the wallet button above the checkout submit area.
Hooked to rpress_purchase_form_before_submit. Outputs nothing when wallets are not enabled.
rpress_payments_stripe_wallet_markup()
Note: Echoes output instead of returning it.
Internal. Defined in includes/features/payments/stripe-wallets.php, line 105.
rpress_payments_stripe_wallet_total_ajax()#
Handles the AJAX request for the current cart total in Stripe minor units.
Checks the rpress-stripe-wallet nonce in the security field (403 on failure) and that wallets are enabled (400 otherwise). Available to logged-out visitors.
rpress_payments_stripe_wallet_total_ajax()
Internal. Defined in includes/features/payments/stripe-wallets.php, line 125.
rpress_payments_stripe_wallet_process()#
Creates the order and a confirmed PaymentIntent for a wallet payment at checkout, and replies with JSON.
Hooked to rpress_gateway_stripe at priority 5. Returns without doing anything when rpress_stripe_wallet_pm is absent from post_data. Otherwise verifies the gateway nonce, the pm_ id format and that the shown amount equals the server total, inserts a private payment, calls Stripe, and replies with result success, requires_action, total_changed or error, then exits. A succeeded intent is marked paid through rpress_payments_stripe_mark_paid().
rpress_payments_stripe_wallet_process( $purchase_data )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$purchase_data | array | Required | Purchase data from checkout. |
Note: Sends a JSON response and exits for wallet checkouts; failed orders are set to failed.
Internal. Defined in includes/features/payments/stripe-wallets.php, line 144.
rpress_payments_stripe_wallet_return()#
Finishes a wallet order when the customer returns to the success page after 3D Secure.
Runs on template_redirect at priority 9 when payment-confirmation=stripe and payment-id are in the URL. Reads the PaymentIntent from Stripe and marks the order paid on succeeded, or failed on requires_payment_method. It only changes orders that are not already paid or refunded.
rpress_payments_stripe_wallet_return()
Internal. Defined in includes/features/payments/stripe-wallets.php, line 274.
rpress_payments_stripe_site_key()#
Returns a short key that identifies this site in Stripe metadata.
The first 12 characters of an md5 of the home URL. Webhooks for objects tagged with another site key are ignored.
rpress_payments_stripe_site_key()
Returns string: A 12 character key.
Internal. Defined in includes/features/payments/stripe-webhooks.php, line 33.
rpress_payments_stripe_webhook_url()#
Returns the webhook endpoint URL to register in the Stripe dashboard.
rpress_payments_stripe_webhook_url()
Returns string: The URL, home_url( 'index.php?rpress-listener=stripe' ).
Example
echo esc_url( rpress_payments_stripe_webhook_url() );
Defined in includes/features/payments/stripe-webhooks.php, line 43.
rpress_payments_stripe_webhook_events()#
Returns the Stripe event types the webhook endpoint acts on.
rpress_payments_stripe_webhook_events()
Returns array: List of event type strings.
Defined in includes/features/payments/stripe-webhooks.php, line 53.
rpress_payments_stripe_verify_signature()#
Verifies a Stripe-Signature header against the raw payload and a signing secret.
Parses the t and v1 parts, compares the HMAC-SHA256 of timestamp.payload with hash_equals(), and then checks the timestamp is within the tolerance. A tolerance of 0 or less skips the time check.
rpress_payments_stripe_verify_signature( $payload, $header, $secret, $tolerance = 300, $now = null )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$payload | string | Required | Raw request body. |
$header | string | Required | Stripe-Signature header value. |
$secret | string | Required | Webhook signing secret. |
$tolerance | int | 300 | Allowed clock difference in seconds. |
$now | int|null | null | Current unix time, for tests; defaults to time(). |
Returns true|WP_Error: True when valid, or a WP_Error with code missing_signature, bad_signature or stale_timestamp.
Example
$check = rpress_payments_stripe_verify_signature( $payload, $header, $secret );
if ( is_wp_error( $check ) ) {
$code = $check->get_error_code();
}
Defined in includes/features/payments/stripe-webhooks.php, line 76.
rpress_payments_stripe_event_processed()#
Checks whether a Stripe event ID was already processed.
Looks in the rpress_stripe_processed_events option.
rpress_payments_stripe_event_processed( $event_id )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$event_id | string | Required | Stripe event ID. |
Returns bool: True when the event was handled before.
Internal. Defined in includes/features/payments/stripe-webhooks.php, line 124.
rpress_payments_stripe_remember_event()#
Stores a processed Stripe event ID so a repeat delivery is ignored.
Drops entries older than 7 days and keeps at most the 500 most recent events in the rpress_stripe_processed_events option.
rpress_payments_stripe_remember_event( $event_id )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$event_id | string | Required | Stripe event ID. |
Internal. Defined in includes/features/payments/stripe-webhooks.php, line 137.
rpress_payments_stripe_handle_webhook()#
Verifies and processes one Stripe webhook delivery and returns a status array.
Uses the saved signing secret when none is passed. Rejects missing secrets, bad signatures (tolerance filterable via rpress_core_stripe_webhook_tolerance) and invalid payloads with code 400; duplicates return 200. Otherwise dispatches the event and remembers its ID. It does not read the request or send output.
rpress_payments_stripe_handle_webhook( $payload, $signature_header, $secret = null )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$payload | string | Required | Raw request body. |
$signature_header | string | Required | Stripe-Signature header value. |
$secret | string|null | null | Signing secret; defaults to the saved setting. |
Returns array: Array with code (HTTP status), message and action.
Internal. Defined in includes/features/payments/stripe-webhooks.php, line 165.
rpress_payments_stripe_dispatch_event()#
Routes a verified Stripe event to its handler.
Handles checkout.session.completed, checkout.session.async_payment_succeeded, checkout.session.async_payment_failed, checkout.session.expired, payment_intent.succeeded, payment_intent.payment_failed and charge.refunded. Other types go through the rpress_payments_stripe_webhook_unhandled filter, default ignored.
rpress_payments_stripe_dispatch_event( $event )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$event | array | Required | Decoded Stripe event. |
Returns string: A short result such as session_completed, paid, failed, refunded or ignored.
Internal. Defined in includes/features/payments/stripe-webhooks.php, line 205.
rpress_payments_stripe_find_payment()#
Finds the RestroPress order a Stripe PaymentIntent or Charge belongs to.
Checks metadata.rpress_payment_id first, then the stored transaction ID. Returns null for objects tagged for another site, non-Stripe orders, a transaction ID that points to a different PaymentIntent, or a test/live mismatch.
rpress_payments_stripe_find_payment( $object, $intent_id, $live )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$object | array | Required | Stripe PaymentIntent or Charge. |
$intent_id | string | Required | PaymentIntent ID. |
$live | bool | Required | Event livemode. |
Returns RPRESS_Payment|null: The payment, or null when no safe match.
Internal. Defined in includes/features/payments/stripe-webhooks.php, line 270.
rpress_payments_stripe_on_intent_succeeded()#
Handles payment_intent.succeeded by marking the matching order paid.
rpress_payments_stripe_on_intent_succeeded( $intent, $live )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$intent | array | Required | PaymentIntent. |
$live | bool | Required | Event livemode. |
Returns string: no_order, or the result of rpress_payments_stripe_mark_paid().
Internal. Defined in includes/features/payments/stripe-webhooks.php, line 315.
rpress_payments_stripe_mark_paid()#
Marks an order paid from a succeeded PaymentIntent, safely and repeatably.
Returns early for missing orders, orders already publish, complete or refunded, and intents that have not succeeded. If the amount received is below the order total or the currency differs, it adds an order note and leaves the status alone. Otherwise stores the transaction ID, sets the status to publish and adds a note.
rpress_payments_stripe_mark_paid( $payment_id, $intent, $source )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$payment_id | int | Required | Payment ID. |
$intent | array | Required | PaymentIntent. |
$source | string | Required | Who confirmed it, used in the order note. |
Returns string: One of no_order, already_{status}, not_succeeded, amount_mismatch or paid.
Example
$result = rpress_payments_stripe_mark_paid( $payment_id, $intent, 'manual check' );
Note: Intended for a verified Stripe PaymentIntent array; it does not call Stripe itself.
Defined in includes/features/payments/stripe-webhooks.php, line 335.
rpress_payments_stripe_on_intent_failed()#
Handles payment_intent.payment_failed by marking the order failed unless it is already settled.
Skips orders that are publish, complete, refunded or failed. Adds a note with the decline reason.
rpress_payments_stripe_on_intent_failed( $intent, $live )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$intent | array | Required | PaymentIntent. |
$live | bool | Required | Event livemode. |
Returns string: no_order, already_{status} or failed.
Internal. Defined in includes/features/payments/stripe-webhooks.php, line 394.
rpress_payments_stripe_on_charge_refunded()#
Handles charge.refunded: full refunds mark the order refunded, partial refunds add a note.
Saves the refunded amount in minor units to the _rpress_stripe_amount_refunded meta. Full refunds set the status to refunded.
rpress_payments_stripe_on_charge_refunded( $charge, $live )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$charge | array | Required | Stripe Charge. |
$live | bool | Required | Event livemode. |
Returns string: no_order, already_refunded, partial_refund or refunded.
Internal. Defined in includes/features/payments/stripe-webhooks.php, line 430.
