{"__v":0,"_id":"56d88886b159f10b0030461b","category":{"__v":1,"_id":"56d88885b159f10b0030460e","pages":["56d88886b159f10b00304618","56d88886b159f10b00304619","56d88886b159f10b0030461a","56d88886b159f10b0030461b"],"project":"549a321bf876ae0b00f33623","version":"56d88884b159f10b00304609","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-01-27T21:23:44.048Z","from_sync":false,"order":4,"slug":"stripe-gateway-extension","title":"Stripe Payment Gateway Extension"},"parentDoc":null,"project":"549a321bf876ae0b00f33623","user":"549a320d5b50c21400fae689","version":{"__v":3,"_id":"56d88884b159f10b00304609","project":"549a321bf876ae0b00f33623","createdAt":"2016-03-03T18:55:00.567Z","releaseDate":"2016-03-03T18:55:00.567Z","categories":["56d88885b159f10b0030460a","56d88885b159f10b0030460b","56d88885b159f10b0030460c","56d88885b159f10b0030460d","56d88885b159f10b0030460e","56d88885b159f10b0030460f","56d88885b159f10b00304610","56d88885b159f10b00304611","56d88885b159f10b00304612","56d88885b159f10b00304613","56d88885b159f10b00304614","56d89250b159f10b003046d4","56da13977222d50b0070167c"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"2.2.1","version":"2.2.1"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-01-27T21:29:46.332Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":3,"body":"[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"llms_stripe_confirm_payment_method_text\"\n}\n[/block]\nUse this filter to change the text of the \"Payment Method\" on the \"Confirm Payment\" screen during LifterLMS Stripe Checkout.\n\nDefault is \"Credit Card (Stripe)\"\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n/**\\n * Change the text of the \\\"Payment Method\\\" on the \\\"Confirm Payment\\\" screen during LifterLMS Stripe Checkout\\n * :::at:::return string\\n */\\nfunction my_custom_function( $text )\\n{\\n\\n\\t$text = 'Credit Card'; // default is \\\"Credit Card (Stripe)\\\"\\n\\n\\treturn $text;\\n\\n}\\nadd_filter( 'llms_stripe_confirm_payment_method_text', 'my_custom_function', 10, 1 );\\n?>\",\n      \"language\": \"php\",\n      \"name\": \"llms_stripe_confirm_payment_method_text.php\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"llms_stripe_customer_metadata\"\n}\n[/block]\nAdd custom metadata to the Stripe Customer during Customer Creation.\n\nLifterLMS Stripe passes the LifterLMS Student ID by default, you may use this filter to add your own information into Stripe using the Metadata API. \n\nFor more information, see Stripe's [Metadata Documentation](https://stripe.com/docs/api#metadata).\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n/**\\n * Add or modify metadata passed to Stripe during the creation of a Customer\\n * @param  array $metadata   associative array of metadata\\n * @param  obj   $user       Instance of the WP_User whom the customer is being created for\\n * @return array\\n */\\nfunction my_custom_function( $metadata, $user )\\n{\\n\\n\\t$metadata['My Custom Meta'] = get_user_meta( $user->ID, 'my_custom_meta_key', true );\\n\\treturn $metadata;\\n\\n}\\nadd_filter( 'llms_stripe_customer_metadata', 'my_custom_function', 10, 2 );\\n?>\",\n      \"language\": \"php\",\n      \"name\": \"llms_stripe_customer_metadata.php\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"llms_stripe_plan_id\"\n}\n[/block]\nUse this filter to modify how LifterLMS Stripe creates Stripe Plan IDs during LifterLMS checkout.\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"Be Cautious and ensure Uniqueness of your custom IDs\",\n  \"body\": \"By default, the IDs generated by LifterLMS Stripe are generated dynamically based on variables specific to the plan and are timestamped to guarantee uniqueness.\\n\\nStripe currently does *not* respond with an error if you create a plan with a non-unique ID, but  you will experience issues attempting to subscribe users when duplicate IDs exist.\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n/**\\n * Create your own function for generating Stripe Plan IDs\\n * @param  string $id       default ID\\n * @param  obj    $plan_obj Instance of LLMS_Stripe_Plan\\n * @return string\\n */\\nfunction my_custom_function( $id, $plan_obj )\\n{\\n\\n\\t// $plan_obj can access the following variables\\n\\t// $plan_obj->product_id        // WordPress Post ID of the Course or Membership\\n\\t// $plan_obj->initial_amount    // First Payment Amount (must be in cents)\\n\\t// $plan_obj->recurring_amount  // Recurring Payment Amount (must be in cents)\\n\\t// $plan_obj->billing_period    // day, week, month, year\\n\\t// $plan_obj->billing_frequency // billing frequency (every month would be \\\"1\\\" with billing_period of \\\"month\\\")\\n\\t// $plan_obj->billing_cycles    // number of cycles to charge the customer, 0 = unlimited\\n\\t// $plan_obj->currency          // currency for the order\\n\\t// $plan_obj->coupon            // object of coupon data\\n\\n\\t$id = 'my-plan-id-' . uniqid();\\n\\n\\treturn $id;\\n\\n}\\nadd_filter( 'llms_stripe_plan_id', 'my_custom_function', 10, 2 );\\n?>\",\n      \"language\": \"php\",\n      \"name\": \"llms_stripe_plan_id.php\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"llms_stripe_plan_metadata\"\n}\n[/block]\nAdd custom metadata to the Stripe Plan during Plan Creation.\n\nLifterLMS default metadata includes Coupon information (when used) as well as the product name and product post id.\n\nFor more information, see Stripe's [Metadata Documentation](https://stripe.com/docs/api#metadata).\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n/**\\n * Add custom metadata to a Stripe Plan during plan creation\\n * @param  array  $id       default metadata\\n * @param  obj    $plan_obj Instance of LLMS_Stripe_Plan\\n * @return array\\n */\\nfunction my_custom_function( $metadata, $plan_obj )\\n{\\n\\n\\t// $plan_obj can access the following variables\\n\\t// $plan_obj->product_id        // WordPress Post ID of the Course or Membership\\n\\t// $plan_obj->initial_amount    // First Payment Amount (must be in cents)\\n\\t// $plan_obj->recurring_amount  // Recurring Payment Amount (must be in cents)\\n\\t// $plan_obj->billing_period    // day, week, month, year\\n\\t// $plan_obj->billing_frequency // billing frequency (every month would be \\\"1\\\" with billing_period of \\\"month\\\")\\n\\t// $plan_obj->billing_cycles    // number of cycles to charge the customer, 0 = unlimited\\n\\t// $plan_obj->currency          // currency for the order\\n\\t// $plan_obj->coupon            // object of coupon data\\n\\n\\t// add custom post meta from the product to the stripe plan\\n\\t$metadata['My Custom Data'] = get_post_meta( $plan_obj->product_id, 'my_custom_postmeta_key', true );\\n\\n\\treturn $metadata;\\n\\n}\\nadd_filter( 'llms_stripe_plan_metadata', 'my_custom_function', 10, 2 );\\n?>\",\n      \"language\": \"php\",\n      \"name\": \"llms_stripe_plan_metadata.php\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"llms_stripe_plan_name\"\n}\n[/block]\nUse this filter to create your own function for naming Stripe Plans during plan creation.\n\nBy default, LifterLMS includes the Course or Membership title, the frequency and billing period, and any discount information into the title.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n/**\\n * Create your own function for generating Stripe Plan names during Plan creation\\n * @param  string $name     default plan name generated by LifterLMS\\n * @param  obj $plan_obj    Instance of LLMS_Stripe_Plan\\n * @return string\\n */\\nfunction my_custom_function( $name, $plan_obj )\\n{\\n\\n\\t// $plan_obj can access the following variables\\n\\t// $plan_obj->product_id        // WordPress Post ID of the Course or Membership\\n\\t// $plan_obj->initial_amount    // First Payment Amount (must be in cents)\\n\\t// $plan_obj->recurring_amount  // Recurring Payment Amount (must be in cents)\\n\\t// $plan_obj->billing_period    // day, week, month, year\\n\\t// $plan_obj->billing_frequency // billing frequency (every month would be \\\"1\\\" with billing_period of \\\"month\\\")\\n\\t// $plan_obj->billing_cycles    // number of cycles to charge the customer, 0 = unlimited\\n\\t// $plan_obj->currency          // currency for the order\\n\\t// $plan_obj->coupon            // object of coupon data\\n\\n\\t// rename the plan name to match the title of the membership or course being purchased\\n\\t$name = get_the_title( $plan_obj->product_id );\\n\\n\\treturn $name;\\n\\n}\\nadd_filter( 'llms_stripe_plan_name', 'my_custom_function', 10, 2 );\\n?>\",\n      \"language\": \"php\",\n      \"name\": \"llms_stripe_plan_name.php\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"llms_stripe_processing_error_message\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n/**\\n * Modify error messages output by LifterLMS Stripe during payment processing errors\\n * @param  string $msg   error message generated by Stripe or LifterLMS Stripe\\n * @return string\\n */\\nfunction my_custom_function( $msg )\\n{\\n\\n\\t// add a condescending error message when the user's card is declined\\n\\tif( $msg == 'Your card was declined.' ) {\\n\\n\\t\\t$msg = 'Your credit card was declined. Are you sure you should be spending money online if you\\\\'re broke?';\\n\\n\\t}\\n\\n\\treturn $msg;\\n\\n}\\nadd_filter( 'llms_stripe_processing_error_message', 'my_custom_function', 10, 1 );\\n?>\",\n      \"language\": \"php\",\n      \"name\": \"llms_stripe_processing_error_message.php\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"llms_stripe_single_charge_metadata\"\n}\n[/block]\nUse this filter to add Stripe metadata during the processing of a single charge.\n\nBy default, LifterLMS includes product name, id, and coupon data where applicable.\n\nFor more information, see Stripe's [Metadata Documentation](https://stripe.com/docs/api#metadata).\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n/**\\n * Modify metadata passed to stripe during a single payment charge\\n * @param  array $metadata  associative array of metadata\\n * @param  obj   $order     Object of LifterLMS order data\\n * @param  obj   $coupon    Object of LifterLMS coupon data\\n * @return array\\n */\\nfunction my_custom_function( $metadata, $order, $coupon )\\n{\\n\\n\\t// add custom post meta from the product to the stripe charge\\n\\t$metadata['My Custom Data'] = get_post_meta( $order->product_id, 'my_custom_postmeta_key', true );\\n\\n\\n\\treturn $metadata;\\n\\n}\\nadd_filter( 'llms_stripe_single_charge_metadata', 'my_custom_function', 10, 3 );\\n?>\",\n      \"language\": \"php\",\n      \"name\": \"llms_stripe_single_charge_metadata.php\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"llms_stripe_subscription_metadata\"\n}\n[/block]\nUse this filter to add Stripe metadata during the processing of a single charge.\n\nBy default, LifterLMS does not include any metadata on the Subscription record.\n\nFor more information, see Stripe's [Metadata Documentation](https://stripe.com/docs/api#metadata).\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n/**\\n * Modify metadata passed to stripe during a user subscription creation\\n * @param  array $metadata  associative array of metadata\\n * @param  obj   $order     Object of LifterLMS order data\\n * @param  obj   $coupon    Object of LifterLMS coupon data\\n * @return array\\n */\\nfunction my_custom_function( $metadata, $order, $coupon )\\n{\\n\\n\\t// add custom post meta from the product to the stripe subscription\\n\\t$metadata['My Custom Data'] = get_post_meta( $order->product_id, 'my_custom_postmeta_key', true );\\n\\n\\treturn $metadata;\\n\\n}\\nadd_filter( 'llms_stripe_subscription_metadata', 'my_custom_function', 10, 3 );\\n?>\",\n      \"language\": \"php\",\n      \"name\": \"llms_stripe_subscription_metadata.php\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"filters-for-lifterlms-stripe-payment-gateway-extension","type":"basic","title":"Filters for LifterLMS Stripe Payment Gateway Extension"}

Filters for LifterLMS Stripe Payment Gateway Extension


[block:api-header] { "type": "basic", "title": "llms_stripe_confirm_payment_method_text" } [/block] Use this filter to change the text of the "Payment Method" on the "Confirm Payment" screen during LifterLMS Stripe Checkout. Default is "Credit Card (Stripe)" [block:code] { "codes": [ { "code": "<?php\n/**\n * Change the text of the \"Payment Method\" on the \"Confirm Payment\" screen during LifterLMS Stripe Checkout\n * @return string\n */\nfunction my_custom_function( $text )\n{\n\n\t$text = 'Credit Card'; // default is \"Credit Card (Stripe)\"\n\n\treturn $text;\n\n}\nadd_filter( 'llms_stripe_confirm_payment_method_text', 'my_custom_function', 10, 1 );\n?>", "language": "php", "name": "llms_stripe_confirm_payment_method_text.php" } ] } [/block] [block:api-header] { "type": "basic", "title": "llms_stripe_customer_metadata" } [/block] Add custom metadata to the Stripe Customer during Customer Creation. LifterLMS Stripe passes the LifterLMS Student ID by default, you may use this filter to add your own information into Stripe using the Metadata API. For more information, see Stripe's [Metadata Documentation](https://stripe.com/docs/api#metadata). [block:code] { "codes": [ { "code": "<?php\n/**\n * Add or modify metadata passed to Stripe during the creation of a Customer\n * @param array $metadata associative array of metadata\n * @param obj $user Instance of the WP_User whom the customer is being created for\n * @return array\n */\nfunction my_custom_function( $metadata, $user )\n{\n\n\t$metadata['My Custom Meta'] = get_user_meta( $user->ID, 'my_custom_meta_key', true );\n\treturn $metadata;\n\n}\nadd_filter( 'llms_stripe_customer_metadata', 'my_custom_function', 10, 2 );\n?>", "language": "php", "name": "llms_stripe_customer_metadata.php" } ] } [/block] [block:api-header] { "type": "basic", "title": "llms_stripe_plan_id" } [/block] Use this filter to modify how LifterLMS Stripe creates Stripe Plan IDs during LifterLMS checkout. [block:callout] { "type": "warning", "title": "Be Cautious and ensure Uniqueness of your custom IDs", "body": "By default, the IDs generated by LifterLMS Stripe are generated dynamically based on variables specific to the plan and are timestamped to guarantee uniqueness.\n\nStripe currently does *not* respond with an error if you create a plan with a non-unique ID, but you will experience issues attempting to subscribe users when duplicate IDs exist." } [/block] [block:code] { "codes": [ { "code": "<?php\n/**\n * Create your own function for generating Stripe Plan IDs\n * @param string $id default ID\n * @param obj $plan_obj Instance of LLMS_Stripe_Plan\n * @return string\n */\nfunction my_custom_function( $id, $plan_obj )\n{\n\n\t// $plan_obj can access the following variables\n\t// $plan_obj->product_id // WordPress Post ID of the Course or Membership\n\t// $plan_obj->initial_amount // First Payment Amount (must be in cents)\n\t// $plan_obj->recurring_amount // Recurring Payment Amount (must be in cents)\n\t// $plan_obj->billing_period // day, week, month, year\n\t// $plan_obj->billing_frequency // billing frequency (every month would be \"1\" with billing_period of \"month\")\n\t// $plan_obj->billing_cycles // number of cycles to charge the customer, 0 = unlimited\n\t// $plan_obj->currency // currency for the order\n\t// $plan_obj->coupon // object of coupon data\n\n\t$id = 'my-plan-id-' . uniqid();\n\n\treturn $id;\n\n}\nadd_filter( 'llms_stripe_plan_id', 'my_custom_function', 10, 2 );\n?>", "language": "php", "name": "llms_stripe_plan_id.php" } ] } [/block] [block:api-header] { "type": "basic", "title": "llms_stripe_plan_metadata" } [/block] Add custom metadata to the Stripe Plan during Plan Creation. LifterLMS default metadata includes Coupon information (when used) as well as the product name and product post id. For more information, see Stripe's [Metadata Documentation](https://stripe.com/docs/api#metadata). [block:code] { "codes": [ { "code": "<?php\n/**\n * Add custom metadata to a Stripe Plan during plan creation\n * @param array $id default metadata\n * @param obj $plan_obj Instance of LLMS_Stripe_Plan\n * @return array\n */\nfunction my_custom_function( $metadata, $plan_obj )\n{\n\n\t// $plan_obj can access the following variables\n\t// $plan_obj->product_id // WordPress Post ID of the Course or Membership\n\t// $plan_obj->initial_amount // First Payment Amount (must be in cents)\n\t// $plan_obj->recurring_amount // Recurring Payment Amount (must be in cents)\n\t// $plan_obj->billing_period // day, week, month, year\n\t// $plan_obj->billing_frequency // billing frequency (every month would be \"1\" with billing_period of \"month\")\n\t// $plan_obj->billing_cycles // number of cycles to charge the customer, 0 = unlimited\n\t// $plan_obj->currency // currency for the order\n\t// $plan_obj->coupon // object of coupon data\n\n\t// add custom post meta from the product to the stripe plan\n\t$metadata['My Custom Data'] = get_post_meta( $plan_obj->product_id, 'my_custom_postmeta_key', true );\n\n\treturn $metadata;\n\n}\nadd_filter( 'llms_stripe_plan_metadata', 'my_custom_function', 10, 2 );\n?>", "language": "php", "name": "llms_stripe_plan_metadata.php" } ] } [/block] [block:api-header] { "type": "basic", "title": "llms_stripe_plan_name" } [/block] Use this filter to create your own function for naming Stripe Plans during plan creation. By default, LifterLMS includes the Course or Membership title, the frequency and billing period, and any discount information into the title. [block:code] { "codes": [ { "code": "<?php\n/**\n * Create your own function for generating Stripe Plan names during Plan creation\n * @param string $name default plan name generated by LifterLMS\n * @param obj $plan_obj Instance of LLMS_Stripe_Plan\n * @return string\n */\nfunction my_custom_function( $name, $plan_obj )\n{\n\n\t// $plan_obj can access the following variables\n\t// $plan_obj->product_id // WordPress Post ID of the Course or Membership\n\t// $plan_obj->initial_amount // First Payment Amount (must be in cents)\n\t// $plan_obj->recurring_amount // Recurring Payment Amount (must be in cents)\n\t// $plan_obj->billing_period // day, week, month, year\n\t// $plan_obj->billing_frequency // billing frequency (every month would be \"1\" with billing_period of \"month\")\n\t// $plan_obj->billing_cycles // number of cycles to charge the customer, 0 = unlimited\n\t// $plan_obj->currency // currency for the order\n\t// $plan_obj->coupon // object of coupon data\n\n\t// rename the plan name to match the title of the membership or course being purchased\n\t$name = get_the_title( $plan_obj->product_id );\n\n\treturn $name;\n\n}\nadd_filter( 'llms_stripe_plan_name', 'my_custom_function', 10, 2 );\n?>", "language": "php", "name": "llms_stripe_plan_name.php" } ] } [/block] [block:api-header] { "type": "basic", "title": "llms_stripe_processing_error_message" } [/block] [block:code] { "codes": [ { "code": "<?php\n/**\n * Modify error messages output by LifterLMS Stripe during payment processing errors\n * @param string $msg error message generated by Stripe or LifterLMS Stripe\n * @return string\n */\nfunction my_custom_function( $msg )\n{\n\n\t// add a condescending error message when the user's card is declined\n\tif( $msg == 'Your card was declined.' ) {\n\n\t\t$msg = 'Your credit card was declined. Are you sure you should be spending money online if you\\'re broke?';\n\n\t}\n\n\treturn $msg;\n\n}\nadd_filter( 'llms_stripe_processing_error_message', 'my_custom_function', 10, 1 );\n?>", "language": "php", "name": "llms_stripe_processing_error_message.php" } ] } [/block] [block:api-header] { "type": "basic", "title": "llms_stripe_single_charge_metadata" } [/block] Use this filter to add Stripe metadata during the processing of a single charge. By default, LifterLMS includes product name, id, and coupon data where applicable. For more information, see Stripe's [Metadata Documentation](https://stripe.com/docs/api#metadata). [block:code] { "codes": [ { "code": "<?php\n/**\n * Modify metadata passed to stripe during a single payment charge\n * @param array $metadata associative array of metadata\n * @param obj $order Object of LifterLMS order data\n * @param obj $coupon Object of LifterLMS coupon data\n * @return array\n */\nfunction my_custom_function( $metadata, $order, $coupon )\n{\n\n\t// add custom post meta from the product to the stripe charge\n\t$metadata['My Custom Data'] = get_post_meta( $order->product_id, 'my_custom_postmeta_key', true );\n\n\n\treturn $metadata;\n\n}\nadd_filter( 'llms_stripe_single_charge_metadata', 'my_custom_function', 10, 3 );\n?>", "language": "php", "name": "llms_stripe_single_charge_metadata.php" } ] } [/block] [block:api-header] { "type": "basic", "title": "llms_stripe_subscription_metadata" } [/block] Use this filter to add Stripe metadata during the processing of a single charge. By default, LifterLMS does not include any metadata on the Subscription record. For more information, see Stripe's [Metadata Documentation](https://stripe.com/docs/api#metadata). [block:code] { "codes": [ { "code": "<?php\n/**\n * Modify metadata passed to stripe during a user subscription creation\n * @param array $metadata associative array of metadata\n * @param obj $order Object of LifterLMS order data\n * @param obj $coupon Object of LifterLMS coupon data\n * @return array\n */\nfunction my_custom_function( $metadata, $order, $coupon )\n{\n\n\t// add custom post meta from the product to the stripe subscription\n\t$metadata['My Custom Data'] = get_post_meta( $order->product_id, 'my_custom_postmeta_key', true );\n\n\treturn $metadata;\n\n}\nadd_filter( 'llms_stripe_subscription_metadata', 'my_custom_function', 10, 3 );\n?>", "language": "php", "name": "llms_stripe_subscription_metadata.php" } ] } [/block]