Skip to content

Instantly share code, notes, and snippets.

@thomasplevy
Last active March 16, 2018 22:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomasplevy/6aa432812f9fc753e61f6dab4bde0f4f to your computer and use it in GitHub Desktop.
Save thomasplevy/6aa432812f9fc753e61f6dab4bde0f4f to your computer and use it in GitHub Desktop.
<?php // don't copy this line to your functions.php file!
/**
* Change the Stripe API version used by LifterLMS Stripe
* See available API versions here: https://stripe.com/docs/upgrades#api-changelog
* LifterLMS Stripe currently uses version 2017-06-05
* Use at your own risk, especially with regards to MAJOR api versions!
* @param string $api_version default api version (2017-06-05)
* @return version
*/
function my_llms_stripe_api_version( $api_version ) {
return '2017-05-25'; // because you're silly and want to rollback?
}
add_filter( 'llms_stripe_api_version', 'my_llms_stripe_api_version', 10 );
<?php // don't copy this line to your functions.php file!
/**
* Allows customization of the charge description before being passed to stripe
* @param string $description Default Description
* @param string $order instance of the LLMS_Order for the related charge
* @return string
*/
function my_llms_stripe_charge_description( $description, $order ) {
return __( 'My Custom Charge Description', 'my-text-domain' );
}
add_filter( 'llms_stripe_charge_description', 'my_llms_stripe_charge_description', 10, 2 );
<?php // don't copy this line to your functions.php file!
/**
* Customize the settings passed to Stripe Elements
* @param array $settings default settings
* @return array
* @since 4.3.0
*/
function my_llms_stripe_elements_settings( $settings ) {
// change the locale to Spanish (localizes all text generated by Stripe Elements)
// see https://stripe.com/docs/stripe.js#stripe-elements for all available options
$settings['elements']['locale'] = 'es';
// disable postal code field
$settings['card']['hidePostalCode'] = true;
// adjust css settings of the Card element
// see https://stripe.com/docs/stripe.js#element-options for all available options
$settings['card']['style']['base']['color'] = '#000000';
$settings['card']['style']['base']['fontSize'] = '22px';
$settings['card']['style']['base']['fontWeight'] = 400;
return $settings;
}
add_filter( 'llms_stripe_elements_settings', 'my_llms_stripe_elements_settings' );
<?php // don't copy this line to your functions.php file!
/**
* Customize the Card description displayed on the admin panel and student dashboards
* @param string $description default card description
* @param obj $card Stripe Card object (https://stripe.com/docs/api#card_object)
* @return string
*/
function my_llms_stripe_get_card_desrcription( $description, $card ) {
// EG: Visa (Exp. 12/2019)
return sprintf( __( '%1$s (Exp. %2$d/%3$d)', 'my-text-domain' ), $card->brand, $card->exp_month, $card->exp_year );
}
add_filter( 'llms_stripe_get_card_desrcription', 'my_llms_stripe_get_card_desrcription', 10, 2 );
<?php // don't copy this line to your functions.php file!
/**
* Customize the final charge object sent to Stripe for a charge
* See https://stripe.com/docs/api#create_charge for more information on data format
* @param array $charge array of charge data
* @return array
*/
function my_llms_stripe_new_charge_data( $charge ) {
if ( ! isset( $charge['metadata'] ) ) {
$charge['metadata'] = array();
}
$charge['metadata']['my_custom_meta'] = 'My Custom Meta Value';
return $charge;
}
add_filter( 'llms_stripe_new_charge_data', 'my_llms_stripe_new_charge_data', 10 );
<?php // don't copy this line to your functions.php file!
/**
* Customize the final customer object sent to Stripe for a customer
* See https://stripe.com/docs/api#create_customer for more information on data format
* @param array $customer array of customer data
* @param int $user_id WP_User ID of the user a customer is being created for
* @return array
*/
function my_llms_stripe_new_customer_data( $customer, $user_id ) {
if ( ! isset( $customer['metadata'] ) ) {
$customer['metadata'] = array();
}
$customer['metadata']['my_custom_meta'] = 'My Custom Meta Value';
return $customer;
}
add_filter( 'llms_stripe_new_customer_data', 'my_llms_stripe_new_customer_data', 10, 2 );
<?php // don't copy this line to your functions.php file!
/**
* Customize the final refund object sent to Stripe for a refund
* See https://stripe.com/docs/api#create_refund for more information on data format
* @param array $refund array of refund data
* @return array
*/
function my_llms_stripe_refund_data( $refund ) {
if ( ! isset( $refund['metadata'] ) ) {
$refund['metadata'] = array();
}
$refund['metadata']['my_custom_meta'] = 'My Custom Meta Value';
return $refund;
}
add_filter( 'llms_stripe_refund_data', 'my_llms_stripe_refund_data', 10 );
<?php // don't copy this line to your functions.php file!
/**
* Allows customization of the statement descriptor before passing a charge to Stripe
* @param string $descriptor Default descriptor
* @param string $order instance of the LLMS_Order for the related charge
* @return string
*/
function my_llms_stripe_statement_descriptor( $descriptor, $order ) {
return __( 'My Custom Statement Descriptor', 'my-text-domain' );
}
add_filter( 'llms_stripe_statement_descriptor', 'my_llms_stripe_statement_descriptor', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment