Title: Payment button in custom form
Last modified: August 30, 2016

---

# Payment button in custom form

 *  Resolved [CheeVT](https://wordpress.org/support/users/cheevt/)
 * (@cheevt)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/payment-button-in-custom-form/)
 * Hi,
 * I want to use your plugin to pay my custom ads.
    I’ve created custom post type
   for ads, and I want that user pay for posting it. How can I implement payment
   button in my form? Is it possible?
 * When user fill all required fields, click button, fill popup for payment and 
   after that ads store in database.
 * Thanks in advance.
 * Best regards
 * [https://wordpress.org/plugins/stripe/](https://wordpress.org/plugins/stripe/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Phil Derksen](https://wordpress.org/support/users/pderksen/)
 * (@pderksen)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/payment-button-in-custom-form/#post-6894977)
 * [@cheevt](https://wordpress.org/support/users/cheevt/): I’m not sure how that
   would be done and it sounds like some custom development would be needed. You’re
   welcome to check out our code snippet library to see if there are any WP actions
   or filters that could help.
 * [https://github.com/moonstonemedia/WP-Simple-Pay-Library](https://github.com/moonstonemedia/WP-Simple-Pay-Library)
 *  [aryanduntley](https://wordpress.org/support/users/dunar21/)
 * (@dunar21)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/payment-button-in-custom-form/#post-6895046)
 * I would suggest using their query args hook. Here is the example they provide:
 *     ```
       function sc_redirect_args_example( $args, $charge ) {
           // Append the customer ID  to the redirect URL
           $args['cust_id'] = $charge->customer;
           return $args;
       }
       add_filter( 'sc_redirect_args', 'sc_redirect_args_example', 10, 2 );
       ```
   
 * =======================
 * So, for your specific use case, I would either use their shortcodes for creating
   custom form fields, or if you don’t want to send the data to stripe and only 
   use locally, I would hook into this to create my own fields:
 * `$html .= apply_filters( 'sc_before_payment_button', $filter_html );`
 * So, that would look something like this:
 *     ```
       function customStripeFields($hmel){
       	$hmel .= '<input id="arbitrary_field" name="arbitrary_field" type="hidden" value="tricledsummersaltingwaterwaysdispropiddled"/>';
       	return $hmel;
       }
       add_filter('sc_before_payment_button', 'customStripeFields', 10);
       ```
   
 * The data will now be available in the $_POST global for use with further hooks.
 * They have an action hook in the payment processing code:
 * `do_action( 'sc_redirect_before' );`
 * But if you use that, you will have to build the entire redirect yourself (which
   is what the extensions -pro and -subscriptions do).
 * So instead, you would use the query args filter and access the $_POST global,
   adding to the query arg list:
 * `wp_redirect( esc_url_raw( add_query_arg( apply_filters( 'sc_redirect_args', 
   $query_args, $charge ), apply_filters( 'sc_redirect', $redirect, $failed ) ) ));`
 * Which would look something like this:
 *     ```
       function someCustomArgs($query_args, $charge){
       	if(isset($_POST["arbitrary_field"])){
       		$query_args["arbitrary_field"] = $_POST["arbitrary_field"];
                       /*
                        Or if you do not want certain data sent visibly,
                        you can process it here and store in the db, or
                        whatever.
                       */
       	}
       	return $query_args;
       }
       add_filter('sc_redirect_args', 'someCustomArgs', 10, 2);
       ```
   
 * Now that you have the variables available in the $_GET global, you can access
   them in your redirect page. If you do not want to send certain data visibly in
   the url query args, you can deal with the data within the sc_redirect_args function
   above and use the $_POST data directly, storing things in the db, sending emails,
   whatever you want. Just return the $query_args var when done.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Payment button in custom form’ is closed to new replies.

 * ![](https://ps.w.org/stripe/assets/icon-256x256.png?rev=2784844)
 * [Stripe Payment Forms by WP Simple Pay - Accept Credit Card Payments + Subscriptions with Stripe](https://wordpress.org/plugins/stripe/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/stripe/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/stripe/)
 * [Active Topics](https://wordpress.org/support/plugin/stripe/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/stripe/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/stripe/reviews/)

 * 2 replies
 * 3 participants
 * Last reply from: [aryanduntley](https://wordpress.org/support/users/dunar21/)
 * Last activity: [10 years, 3 months ago](https://wordpress.org/support/topic/payment-button-in-custom-form/#post-6895046)
 * Status: resolved