【发布时间】:2019-12-23 15:53:44
【问题描述】:
我希望有人可以在这里帮助我。
我正在尝试通过条带处理订阅付款
<script>
var stripe = Stripe('pk_test_CJ3p2EuKzHOC0mQrx9AIDZ3R00TR4ysmyS');
document.getElementById("checkout-button").addEventListener('click', function () {
stripe.redirectToCheckout({
items: [{
// Define the product and plan in the Dashboard first, and use the plan
// ID in your client-side code.
plan: 'plan_Fd6dQD8JT0sl0C',
quantity: 1,
}],
successUrl: 'https://www.example.com/success',
cancelUrl: 'https://www.example.com/cancel'
});
});
</script>
然后,我设置了一个 webhook,以便在完成后进行一些处理:
<?php
require_once('vendor/autoload.php');
Stripe\Stripe::setApiKey("TEST KEY");
// retrieve the request's body and parse it as JSON
$body = @file_get_contents('php://input');
$event_json = json_decode($body);
// for extra security, retrieve from the Stripe API
$event_id = $event_json->id;
$event = \Stripe\Event::retrieve($event_id);
// This will send receipts on succesful invoices
if ($event->type == 'invoice.payment_succeeded') {
include 'email_template_functions/email_function.php';
include 'email_template_functions/password_reset_email_templatetest.php';
sendemail('triggertraders.com','richard@triggertraders.com','Bluebanana1995',465,'richard@triggertraders.com', 'Richard','rglass5565@gmail.com','richard@triggertraders.com',
'Information','Reset Password Trigger Trader','This has worked!!','This is the body in plain text for non-HTML mail clients');
}
所以这很好用,并且付款正在进行中,这是我想知道的下一步。
我的数据库中有一个实体表,其中包含所有具有 entity_id 的“客户”数据。我正在尝试找出一种方法将条带 customer_id 链接到我本地数据库中的 entity_id,以便在付款时更新他们的帐户,但我不知道该怎么做。
有没有什么方法可以在设置付款时发送我自己的 entity_id 进行条带化,这样当我从 webhook 检索该数据并可以正确更新我的数据库时?
【问题讨论】:
标签: php stripe-payments webhooks