Storing Stripe Recurring Payment information in Da

2020-07-22 09:42发布

I am new to stripe payment gateway and I have created a stripe account where I have my plans and subscriptions. It is working fine. Below are my plans and subscriptions in image format.

My Stripe subscription plan enter image description here

My Stripe Subscriptions enter image description here

Below is my checkout page

<form action="charge.php" method="POST">
<script
    src="https://checkout.stripe.com/checkout.js" class="stripe-button"
    data-key="pk_test_ZCRfEl8XeRIbPHGIifY3THYC"
    data-amount="999"
    data-name="Demo Site"
    data-description="Widget"
    data-image="https://stripe.com/img/documentation/checkout/marketplace.png"
    data-locale="auto">
</script>

I want to insert customer info like amount of transaction, customer id etc.., into my database when recurring payment occurs in stripe method. Can anyone help me?

2条回答
何必那么认真
2楼-- · 2020-07-22 10:10

You have to use webhook to get the data when recurring payment happen.

  1. Create an endpoint in your application to parse the webhook data and store as you want
  2. Add the created endpoint to your stripe dashboard's webhook to indicate Stripe to request on the endpoint.
查看更多
欢心
3楼-- · 2020-07-22 10:18

You can do with $customer varibale after successful Payment .you can Collect whole information about payment by $customer If you want to access the collecting card and recurring information after successful payment, you'd need to do

$StripeId = $customer['id'];    
$card = $customer->sources->data[0];
$Stripe_City = $card->address_city;
$Stripe_Country = $card->address_country;
$Stripe_Address = $card->address_line1;
$Stripe_State = $card->address_state;
$Stripe_Zip = $card->address_zip;
$Stripe_card = $card->last4;
$Stripe_Brand = $card->brand;

for storing information about customer you need to add this on process:

$customer = Stripe_Customer::create(array(
'email' => $_SESSION['userEmail'],
'card' => $_POST['stripeToken'],
'plan' => $plan_id,
 ));`

stripe also provide you information about payment, see all object by print_r($customer).A $customer can have more than one source at the same time. The source property on the Customer is a list as documented here.

查看更多
登录 后发表回答