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>