Home » Php » WordPress Stripe Connect Issue

WordPress Stripe Connect Issue

Posted by: admin June 30, 2018 Leave a comment


I have integrated Stripe connect using composer and get all files with vendor and autoload file with stripe folder with in folder and its working fine for core php on payment done payment details get save in sandbox account by hitting charge api and token api but same thing is not working while integrating it in wordpress site only token api is working actually iam using button type submit for payment form and providing action like url and then sucess page post-name and it gives error page not found if i hit that sucess page again it will execute error part. In core php i am passing only form action like sucess.php and and in sucess page including stripe vendor/autoad as require then stripe composer file its working properly.

<form action="<?php echo site_url();?>/index.php/stripe-sucess" method="POST" id="paymentFrm">
        <input type="text" name="name" size="50" />
        <input type="text" name="email" size="50" />
        <label>Card Number</label>
        <input type="text" name="card_num" size="20" autocomplete="off" class="card-number" />
        <input type="text" name="cvc" size="4" autocomplete="off" class="card-cvc" />
        <label>Expiration (MM/YYYY)</label>
        <input type="text" name="exp_month" size="2" class="card-expiry-month"/>
        <span> / </span>
        <input type="text" name="exp_year" size="4" class="card-expiry-year"/>

<button type="submit" id="payBtn">Submit Payment</button>

<script type="text/javascript">
//set your publishable key

//callback to handle the response from stripe
function stripeResponseHandler(status, response) {
    if (response.error) {
        //enable the submit button
        //display the errors on the form
    } else {
        var form$ = $("#paymentFrm");
        //get token id
        var token = response['id'];
       // alert(token);
        //insert the token into the form
        form$.append("<input type='hidden' name='stripeToken' value='" + token + "' />");
        //submit form to the server
$(document).ready(function() {
    //on form submit
    $("#paymentFrm").submit(function(event) {
        //disable the submit button to prevent repeated clicks
        $('#payBtn').attr("disabled", "disabled");

        //create single-use token to charge the user
            number: $('.card-number').val(),
            cvc: $('.card-cvc').val(),
            exp_month: $('.card-expiry-month').val(),
            exp_year: $('.card-expiry-year').val()
        }, stripeResponseHandler);

        //submit from callback
        return false;
paymentRequest.on('token', function(ev) {
  // Send the token to your server to charge it!
  fetch('/charges', {
    method: 'POST',
    body: JSON.stringify({token: ev.token.id}),
    headers: {'content-type': 'application/json'},
  .then(function(response) {
    if (response.ok) {
      // Report to the browser that the payment was successful, prompting
      // it to close the browser payment interface.
    } else {
      // Report to the browser that the payment failed, prompting it to
      // re-show the payment interface, or show an error message and close
      // the payment interface.