LLMS_Transaction::generate_refund_id( string $method, float $amount, string $note = '' )
Generates a refund ID based on the refund method.
Description Description
When manually processing a refund an ID is generated, if processing via a gateway the data is passed to the LLMS_Transaction::process_refund_via_gateway() and ultimately passed to the gateway for processing (via the gateway’s API). For custom methods processing is handled via the `llms_{$method}_refund_id` filter.
Parameters Parameters
- $method
-
(string) (Required) Refund processing method ID.
- $amount
-
(float) (Required) The amount to refund.
- $note
-
(string) (Optional) Refund notes.
Default value: ''
Return Return
(string|boolean|WP_Error) Returns the generated refund ID string or an error object. If a falsy value is returned the refund processing will fail with a generic error message.
Source Source
File: includes/models/model.llms.transaction.php
protected function generate_refund_id( $method, $amount, $note = '' ) {
if ( 'manual' === $method ) {
/**
* Filters the refund id for manual refunds.
*
* The default refund ID is a microtime string generated by `uniqid()`.
*
* @since 3.0.0
*
* @param string $refund_id The refund ID.
*/
$refund_id = apply_filters( 'llms_manual_refund_id', (string) uniqid() );
} elseif ( 'gateway' === $method ) {
$refund_id = $this->process_refund_via_gateway( $amount, $note );
} else {
/**
* Filters the refund ID for custom refund methods.
*
* This filter should return a string representing the refund ID as generated by the custom refund method.
*
* The dynamic portion of this hook, `{$method}`, represents the ID of the custom refund method.
*
* @since 3.0.0
*
* @param string|boolean|WP_Error $refund_id The generated refund ID or an error object. Returning a falsy value
* will result in the default error handling and no refund being recorded.
* @param string $method The method ID.
* @param LLMS_Transaction $transaction The transaction object.
* @param float $amount The refund amount.
* @param string $note The user-submitted refund note.
*/
$refund_id = apply_filters( "llms_{$method}_refund_id", false, $method, $this, $amount, $note );
}
return $refund_id;
}
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 7.0.0 | Introduced. |