Wordpress条纹连接问题

时间:2018-05-24 05:29:11

标签: php wordpress stripe-connect

我已经使用composer集成了Stripe连接,并使用带有文件夹的条带文件夹获取所有带有供应商和自动加载文件的文件,并且对于付费完成付款细节的核心php工作正常,通过点击费用api和令牌api保存在沙盒帐户中但是同样的事情是没有工作,而在wordpress网站集成它只有令牌api正在工作实际上我使用按钮类型提交付款表格和提供行动像网址,然后成功页面后名称,如果我点击该超级页面它给出错误页面找不到再次它将执行错误部分。在核心php中,我只传递像sucess.php这样的表单操作,并且在包含条带供应商/ autoad的sucess页面中,然后条纹作曲家文件正常工作。

<form action="<?php echo site_url();?>/index.php/stripe-sucess" method="POST" id="paymentFrm">
    <p>
        <label>Name</label>
        <input type="text" name="name" size="50" />
    </p>
    <p>
        <label>Email</label>
        <input type="text" name="email" size="50" />
    </p>
    <p>
        <label>Card Number</label>
        <input type="text" name="card_num" size="20" autocomplete="off" class="card-number" />
    </p>
    <p>
        <label>CVC</label>
        <input type="text" name="cvc" size="4" autocomplete="off" class="card-cvc" />
    </p>
    <p>
        <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"/>
    </p>

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

</form>
<script type="text/javascript">
//set your publishable key
Stripe.setPublishableKey('pk_test_uFOdE1YPIXhbssFt1FwH9RGQ');

//callback to handle the response from stripe
function stripeResponseHandler(status, response) {
    if (response.error) {
        //enable the submit button
        $('#payBtn').removeAttr("disabled");
        //display the errors on the form
        $(".payment-errors").html(response.error.message);
    } 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
    form$.get(0).submit();
    }
}
$(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
        Stripe.createToken({
            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.
      ev.complete('success');
    } 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.

      ev.complete('fail');
    }
  });
});
</script>

0 个答案:

没有答案