dsf4354353452 2016-02-02 05:40
浏览 31

如何在PHP中点击条带中的接受按钮来充电卡

I am using stripe and trying to charge card by clicking on accept button. I have already created charge and created customer. and now trying to create charge by clicking accept button.

Please suggest me the way to do it.

Thanks in advance.

<?php
    function payment_show()
        {
        include ('config.inc');

        include ('charge.inc');
    ?>
    <?php
        $code = db_query("SELECT * FROM {stripe_payment}");
    ?>
         <table border='1'>
    <th>ID</th><th>Payment ID</th><th>Customer ID</th><th>Customer Email</th><th>Payment Amount</th><th>Payment Date</th><th>Refund</th><th>Accept</th>
    <?php
        foreach($code as $codes)
            {
             
                //$ch = StripeCharge::retrieve($Payment_id);
                $ch = \Stripe\Charge::retrieve($codes->payment_id);

    ?>
    <tr>
    <td><?php echo $codes->Id; ?></td>
    <td><?php echo $codes->payment_id; ?></td>
    <td><?php echo $codes->customer_id; ?></td>
    <td><?php echo $codes->customer_email; ?></td>
    <td><?php echo $codes->payment_amount; ?></td>
    <td><?php echo $codes->payment_date; ?></td>
    <td><a href="https://dashboard.stripe.com/payments/<?php echo $codes->payment_id; ?>">Refund</a></td><td><strike> <input type="button" value="Accept"  onclick="document.write('<?php $ch->capture(); ?>');" />    </strike></td></tr>
    <?php
            }

    ?>
            </table>
         <?php
        }

    ?>

$token  = $_POST['stripeToken'];
                    
              $customer = \Stripe\Customer::create(array(
                  'email' => $_POST['stripeEmail'],
                  'card'  => $token
              ));
            
           
        
           $charge = \Stripe\Charge::create(array(
                  'customer' => $customer->id,
                  'amount'   => 5000,
                  'currency' => 'usd',
                  'capture'  => false
              ))

    ;

 $ch = \Stripe\Charge::retrieve($codes->payment_id);
          $ch->capture();

</div>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度