### Basic Stripe API Usage Example Source: https://github.com/wpsharks/s2member-pro/blob/dev/src/includes/classes/gateways/stripe/stripe-sdk/README.md Set your API key and create a charge using the Stripe PHP library. Ensure you have the necessary dependencies installed. ```php \Stripe\Stripe::setApiKey('sk_test_BQokikJOvBiI2HlWgH4olfQ2'); $charge = \Stripe\Charge::create(['amount' => 2000, 'currency' => 'usd', 'source' => 'tok_189fqt2eZvKYlo2CTGBeg6Uq']); echo $charge; ``` -------------------------------- ### Install Composer Dependencies Source: https://github.com/wpsharks/s2member-pro/blob/dev/src/includes/classes/gateways/stripe/stripe-sdk/README.md Install project dependencies using Composer. This command fetches all required libraries listed in the composer.json file. ```bash composer install ``` -------------------------------- ### Manual Installation of Stripe PHP Bindings Source: https://github.com/wpsharks/s2member-pro/blob/dev/src/includes/classes/gateways/stripe/stripe-sdk/README.md If not using Composer, download the latest release and include the init.php file to use the bindings. ```php require_once('/path/to/stripe-php/init.php'); ``` -------------------------------- ### Install Stripe PHP Bindings via Composer Source: https://github.com/wpsharks/s2member-pro/blob/dev/src/includes/classes/gateways/stripe/stripe-sdk/README.md Use Composer to install the Stripe PHP library. This is the recommended method for managing dependencies. ```bash composer require stripe/stripe-php ``` -------------------------------- ### Run Stripe Mock Server Source: https://github.com/wpsharks/s2member-pro/blob/dev/src/includes/classes/gateways/stripe/stripe-sdk/README.md Start the stripe-mock server, which is a dependency for running the test suite. This mock server simulates Stripe API responses. ```bash go get -u github.com/stripe/stripe-mock stripe-mock ``` -------------------------------- ### Include Composer Autoloader Source: https://github.com/wpsharks/s2member-pro/blob/dev/src/includes/classes/gateways/stripe/stripe-sdk/README.md After installing via Composer, include the autoloader to use the Stripe bindings in your PHP application. ```php require_once('vendor/autoload.php'); ``` -------------------------------- ### Legacy Stripe API Usage (PHP 5.2) Source: https://github.com/wpsharks/s2member-pro/blob/dev/src/includes/classes/gateways/stripe/stripe-sdk/README.md Example of how to use the Stripe API with a legacy version (v1.18.0) of the PHP bindings, typically for PHP 5.2. ```php Stripe::setApiKey('d8e8fca2dc0f896fd7cb4cb0031ba249'); $charge = Stripe_Charge::create(array('source' => 'tok_XXXXXXXX', 'amount' => 2000, 'currency' => 'usd')); echo $charge; ``` -------------------------------- ### Mailchimp Example Group Title Update Source: https://github.com/wpsharks/s2member-pro/blob/dev/readme.txt The Mailchimp integration example has been updated to use 'Group Category' instead of 'Group Title' to match Mailchimp's current terminology. This ensures consistency when configuring Mailchimp lists. ```php s2Member integration with Mailchimp requires setting up 'Group Categories' in your Mailchimp audience settings. ``` -------------------------------- ### Disable Automatic Background Updates for s2Member Framework Source: https://github.com/wpsharks/s2member-pro/blob/dev/readme.txt When s2Member Pro is installed, automatic background updates for the s2Member Framework are disabled to prevent site functionality issues. This is a necessary precaution. ```php /** * Disable automatic background updates for the s2Member Framework plugin * when s2Member Pro is installed and active. */ function s2member_pro_disable_auto_updates_framework() { if ( is_plugin_active( 's2member-pro/s2member-pro.php' ) && is_plugin_active( 's2member/s2member.php' ) ) { // Disable auto-updates for s2Member Framework. update_site_option( 'auto_update_plugins', array_diff( get_site_option( 'auto_update_plugins', array() ), array( 's2member/s2member.php' ) ) ); } } add_action( 'admin_init', 's2member_pro_disable_auto_updates_framework' ); ``` -------------------------------- ### Accept Bitcoin via Stripe Configuration Source: https://github.com/wpsharks/s2member-pro/blob/dev/readme.txt Instructions on how to enable Bitcoin payments through Stripe within s2Member Pro. ```text Dashboard → s2Member Pro → Stripe Options → Account Details → Accept Bitcoin ``` -------------------------------- ### Run PHPUnit Test Suite Source: https://github.com/wpsharks/s2member-pro/blob/dev/src/includes/classes/gateways/stripe/stripe-sdk/README.md Execute the entire test suite using PHPUnit. This command runs all tests defined in the project. ```bash ./vendor/bin/phpunit ``` -------------------------------- ### Set Stripe App Information Source: https://github.com/wpsharks/s2member-pro/blob/dev/src/includes/classes/gateways/stripe/stripe-sdk/README.md Use `setAppInfo` to identify your plugin when integrating the Stripe SDK. Call this once before any API requests. The second and third parameters are optional. ```php \Stripe\Stripe::setAppInfo("MyAwesomePlugin", "1.2.34", "https://myawesomeplugin.info"); ``` -------------------------------- ### Configure Other Gateways Reminder Source: https://github.com/wpsharks/s2member-pro/blob/dev/readme.txt First-time s2Member Pro users will see a reminder to configure their 'Other Gateways'. ```text Dashboard → s2Member Pro → Other Gateways ``` -------------------------------- ### Configure Google URL Shortener API Key Source: https://github.com/wpsharks/s2member-pro/blob/dev/readme.txt When using the Google URL Shortener service in s2Member, an API key is now required. Without it, API calls will fail, and s2Member will revert to using tinyURL. Configure this in s2Member → General Options → URL Shortening Service Preference. ```text s2Member → General Options → URL Shortening Service Preference ``` -------------------------------- ### Run Individual PHPUnit Test File Source: https://github.com/wpsharks/s2member-pro/blob/dev/src/includes/classes/gateways/stripe/stripe-sdk/README.md Execute a specific test file within the PHPUnit test suite. This is useful for running targeted tests during development. ```bash ./vendor/bin/phpunit tests/UtilTest.php ``` -------------------------------- ### Format Code with PHP CS Fixer Source: https://github.com/wpsharks/s2member-pro/blob/dev/src/includes/classes/gateways/stripe/stripe-sdk/README.md Apply code formatting rules to the project using PHP CS Fixer. This command ensures consistent code style across the codebase before submitting pull requests. ```bash ./vendor/bin/php-cs-fixer fix -v . ``` -------------------------------- ### Format User Date Fields with s2Get Shortcode Source: https://github.com/wpsharks/s2member-pro/blob/dev/readme.txt The `[s2Get /]` shortcode supports date formatting for user fields ending in `_time`. Provide a `date_format` argument to display dates in a human-readable format instead of a UNIX timestamp. ```shortcode [s2Get user_field="s2member_last_payment_time" date_format="M jS, Y, g:i a T" /] ``` -------------------------------- ### Generate Gift/Redemption Codes with s2Member Pro Source: https://github.com/wpsharks/s2member-pro/blob/dev/readme.txt Use the `[s2Member-Gift-Codes /]` shortcode to generate and sell access to gift or redemption codes. This is useful for scenarios where multiple accounts need to be purchased and distributed. ```shortcode [s2Member-Gift-Codes /] ``` -------------------------------- ### Set Per-Request API Key and Stripe Account Source: https://github.com/wpsharks/s2member-pro/blob/dev/src/includes/classes/gateways/stripe/stripe-sdk/README.md Configure specific API keys and Stripe account IDs for individual requests, which is useful for applications managing multiple keys or accounts, such as those using Stripe Connect. ```php \Stripe\Charge::all([], [ 'api_key' => 'sk_test_...', 'stripe_account' => 'acct_...' ]); \Stripe\Charge::retrieve("ch_18atAXCdGbJFKhCuBAa4532Z", [ 'api_key' => 'sk_test_...', 'stripe_account' => 'acct_...' ]); ``` -------------------------------- ### Conditional for User Gateway Source: https://github.com/wpsharks/s2member-pro/blob/dev/readme.txt Use this shortcode to conditionally display content based on the user's current payment gateway. Useful for sites with multiple payment options. ```php [s2If current_user_gateway_is(stripe)] ... ``` -------------------------------- ### Configure PSR-3 Logger for Stripe SDK Source: https://github.com/wpsharks/s2member-pro/blob/dev/src/includes/classes/gateways/stripe/stripe-sdk/README.md Integrate a PSR-3 compatible logger with the Stripe SDK to redirect log messages from error_log to your chosen logger. This allows for centralized logging of SDK activities. ```php \Stripe\Stripe::setLogger($logger); ``` -------------------------------- ### Configure Custom CA Bundle Path Source: https://github.com/wpsharks/s2member-pro/blob/dev/src/includes/classes/gateways/stripe/stripe-sdk/README.md Specify a custom path to a CA certificate bundle for the Stripe SDK. This overrides the library's internal bundle and is useful for custom security configurations. ```php \Stripe\Stripe::setCABundlePath("path/to/ca/bundle"); ``` -------------------------------- ### Stripe API Version Configuration Source: https://github.com/wpsharks/s2member-pro/blob/dev/readme.txt Forces a specific version of the Stripe API in all communication to ensure compatibility. ```text Stripe API version: 2015-02-18 ``` -------------------------------- ### Configure Automatic Network Retries Source: https://github.com/wpsharks/s2member-pro/blob/dev/src/includes/classes/gateways/stripe/stripe-sdk/README.md Enable and set the maximum number of automatic retries for network requests that fail due to intermittent issues. This enhances request reliability. ```php \Stripe\Stripe::setMaxNetworkRetries(2); ``` -------------------------------- ### Set Custom cURL Options for Stripe SDK Source: https://github.com/wpsharks/s2member-pro/blob/dev/src/includes/classes/gateways/stripe/stripe-sdk/README.md Configure the Stripe SDK to use a custom cURL client with specific options, such as setting a proxy. This ensures all HTTP requests made by the SDK adhere to these default cURL settings. ```php // set up your tweaked Curl client $curl = new \Stripe\HttpClient\CurlClient([CURLOPT_PROXY => 'proxy.local:80']); // tell Stripe to use the tweaked client \Stripe\ApiRequestor::setHttpClient($curl); ``` -------------------------------- ### Bug Fix for [s2Member-List /] Pagination Source: https://github.com/wpsharks/s2member-pro/blob/dev/readme.txt Resolves an issue with pagination in the [s2Member-List /] shortcode after recent changes in the WP_User_Query class. ```php [s2Member-List /] ``` -------------------------------- ### Display s2Member Current User Constants with s2Get Shortcode Source: https://github.com/wpsharks/s2member-pro/blob/dev/readme.txt Use the s2Get shortcode to display current user constants. This is useful for custom integrations and displaying user-specific data. ```php [s2Get constant="S2MEMBER_CURRENT_USER_DISPLAY_NAME" /] ``` -------------------------------- ### Display User Profile Summary with s2Member-Summary Shortcode Source: https://github.com/wpsharks/s2member-pro/blob/dev/readme.txt Use the `[s2Member-Summary /]` shortcode to display a user's profile summary, including their avatar, on any WordPress Post or Page. Optionally, it can display a login box if the user is not logged in. ```shortcode [s2Member-Summary /] ``` -------------------------------- ### Display Login Box with s2Member-Login Shortcode Source: https://github.com/wpsharks/s2member-pro/blob/dev/readme.txt Use the `[s2Member-Login /]` shortcode to display a login box on any WordPress Post or Page. It can also show a user's profile summary including their avatar. ```shortcode [s2Member-Login /] ``` -------------------------------- ### Allow Custom Redirect Domains with allowed_redirect_hosts Filter Source: https://github.com/wpsharks/s2member-pro/blob/dev/readme.txt To use a domain different than the site's for checkout success redirection URLs, allow it using WordPress's `allowed_redirect_hosts` filter. This ensures safe redirection by validating URLs with `wp_validate_redirect`. ```php add_filter( 'allowed_redirect_hosts', 'my_allowed_redirect_hosts' ); function my_allowed_redirect_hosts( $allowed_hosts ) { $allowed_hosts[] = 'example.com'; // Add your custom domain here return $allowed_hosts; } ``` -------------------------------- ### Security Badge Size Fix Source: https://github.com/wpsharks/s2member-pro/blob/dev/readme.txt Corrects miscalculated dimensions for the [s2Member-Security-Badge /] shortcode when using v="2" or v="3". ```php [s2Member-Security-Badge v="1" /] ``` -------------------------------- ### s2If Conditional Functions Whitelist Source: https://github.com/wpsharks/s2member-pro/blob/dev/readme.txt Allows custom conditional functions to be whitelisted for use with the s2If shortcode. This provides flexibility for advanced conditional logic in content restrictions. ```php add_filter( 'ws_plugin__s2member_pro_s2if_whitelist', 'my_s2if_whitelist' ); function my_s2if_whitelist( $whitelist ) { $whitelist[] = 'my_custom_conditional_function'; // Add your custom function name here return $whitelist; } ``` -------------------------------- ### Update Bundled CA Certificates Source: https://github.com/wpsharks/s2member-pro/blob/dev/src/includes/classes/gateways/stripe/stripe-sdk/README.md Update the internal bundle of CA certificates used by the library by fetching the latest release from Mozilla's cURL release. This ensures secure connections. ```bash ./update_certs.php ``` -------------------------------- ### Stripe Integration Action Hooks Source: https://github.com/wpsharks/s2member-pro/blob/dev/readme.txt These action hooks are available in the Stripe endpoint to allow for customizations and new event handlers within the Stripe integration. ```php ws_plugin__s2member_pro_before_stripe_notify_event_switch ws_plugin__s2member_pro_after_stripe_notify_event_switch ```