首页 文章

条纹创建帐户并为卡充电

提问于
浏览
-4

尝试使用Stripe创建帐户,收取卡并注册订阅,该订阅将在15-30天后开始 .

我想做的是:

1)预先收集使用信息(电子邮件,地址,名/姓,卡信息等),这将在条带和我的数据库中添加客户 .

2)做初始费用(不是订阅费用),如果通过将在stipe和我的数据库上创建帐户 .

3)确保我的数据库中的客户有Stipe的信息,以便在以后收费 . 还没有决定我是否会按月收取费用或者让Stripe执行此操作 .

4)如果订阅付款结束(通过不良信用卡月费或其他原因),限制用户登录时看到的内容 . 这就是为什么我想要一个cron运行,如果它被标记为需要付款,请执行有限的视图 .

提前感谢您的帮助和建议!

1 回答

  • 0

    显然我冒犯了几个人 . 我也忘了提到我试图用AJAX做这件事,这是我试图解决的主要问题 .

    我实际上找到了一些相关的链接,最后,这似乎指出了我正在寻找的正确方向 . 这主要是我想要的 .

    以下是迄今为止帮助我的链接 . 希望他们能帮助任何寻找同样事物的人 .

    https://youtu.be/EildM6OMcoQ

    不知道为什么这个最终出现在我的搜索上?猜猜没有正确地搜索我的搜索...

    Make a Stripe payment with Jquery AJAX? (Javascript ONLY)

    还有一两个链接,但我必须找到它们 . 一旦找到它我会添加它们....

    这是我的测试脚本,主要用于检查传递令牌...需要看看是否可以使用STRIPE V3 API ...

    form.php的

    <?php session_start(); ?>
       <!DOCTYPE html>
       <html lang="en">
       <head>
       <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
       <title>Stripe Getting Started Form</title>
    
       <!-- The required Stripe lib -->
       <script type="text/javascript" src="https://js.stripe.com/v2/"></script>
    
       <!-- jQuery is used only for this example; it isn't required to use Stripe -->
       <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
    
       <script type="text/javascript">
       // This identifies your website in the createToken call below
       Stripe.setPublishableKey('__YOUR__PUBLIC__HERE__);
    
       var stripeResponseHandler = function(status, response) {
       var $form = $('#payment-form');
    
       if (response.error) {
       // Show the errors on the form
       $form.find('.payment-errors').text(response.error.message);
       $form.find('button').prop('disabled', false);
       } else {
       // token contains id, last4, and card type
       var token = response.id;
       // Insert the token into the form so it gets submitted to the server
       $form.append($('<input type="hidden" name="stripeToken" />').val(token));
       // and re-submit
       //$form.get(0).submit();
    
       // Serialize the form
       var data=$('#payment-form').serialize(); 
    
       // Send form to server with POST method
       $(function() {
           $.ajax({
               type: "POST",
               url: "./testphp.php",
               data: data,
               success: function(returndata){
                   $form.find('button').prop('disabled', false);
                   $('.payment-errors').text(returndata);
               }
           });
       });
    
       // Prevent page from refreshing
       return false;
    
       }
       };
    
       // ONCLICK RESPONSE 
       jQuery(function($) {
       $('#thebutton').on('click', function(e) {
           var $form = $('#payment-form');
    
           // Disable the submit button to prevent repeated clicks
           $form.find('button').prop('disabled', true);
    
           Stripe.card.createToken($form, stripeResponseHandler);
    
           // Prevent the form from submitting with the default action
           return false;
           });
       });
       </script>
    
       </head>
       <body>
    
       <?php 
       //$_SESSION['token'] = "12345";
       echo $_SESSION['token']; // will only show if page is reloaded
                                // will not be the same as new token
                                // used to check against after submit
       ?>
    
       <h1>Charge $10 with Stripe</h1>
    
       <form action="" method="POST" id="payment-form">
       <span class="payment-errors"></span>
    
       <div class="form-row">
       <label>
       <span>Card Number</span>
    
       <input type="text" size="20" data-stripe="number" value="424242424242424"/>
    
       </label>
       </div>
    
       <div class="form-row">
       <label>
       <span>CVC</span>
       <input type="text" size="4" data-stripe="cvc" value="424" />
       </label>
       </div>
    
       <div class="form-row">
       <label>
       <span>Expiration (MM/YYYY)</span>
       <input type="text" size="2" data-stripe="exp-month" value="01"/>
       </label>
       <span> / </span>
       <input type="text" size="4" data-stripe="exp-year" value="2019"/>
       </div>
    
       <button type="submit" id="thebutton">Submit Payment</button>
       </form>
       </body>
       </html>
    

    testphp.php

    <?php
        // Start the session
        session_start();
    
        // Store the received token string in a session variable
        if($_POST){
            $_SESSION['token']=$_POST['stripeToken'];
        }
        echo $_POST['stripeToken'];
        echo "\n";
        print_r($_SESSION);
    ?>
    

    我还有很多其他事情需要解决,但这主要是我正在寻找建议的方向....

相关问题