我沒有代碼,但我有訂閱付款的問題。 我使用條紋庫進行訂閱,我的問題是如何更新平臺電子商務中的不同用戶,以瞭解用戶訂閱是否已過期? 感謝Cron php與codeigniter
0
A
回答
1
可以使用條紋網絡掛接爲:
https://stripe.com/docs/webhooks
這將讓你建立一個端點,其中條紋會送您事件在您的帳戶中發生的事情。在你的情況下,你想看看invoice.payment_failed
或customer.subscription.updated
知道何時訂閱狀態變成past_due
。甚至在所有付款重試失敗時甚至可以撥打customer.subscription.deleted
。
0
我的訂閱條紋
public function checkout(){
$userid = $this->session->userdata('userid');
$email = $this->input->post('email');
$token = $this->input->post('stripeToken');
try {
$customer = \Stripe\Customer::create(array(
"email" => $email,
"source" => $token,
"description" => "Abonnement"
));
$subscription = \Stripe\Subscription::create(array(
"customer" => $customer->id,
"plan" => "premium",
));
$invoice = \Stripe\Invoiceitem::create(array(
"customer" => $customer->id,
"amount" => 2000,
"currency" => "eur",
"description" => "Abonnement",
));
// data captured
$data = array(
'id_user' => $userid ,
'prix_abon' => 20,
'date_abon' => date('Y-m-d H:i:s'),
'date_suspension' => date('Y-m-d H:i:s'),
'etat_abon' => 1,
'subscribe_id' => $subscription->id,
'customer_id' => $customer->id
);
$response = $this->md_abonnement->add($data);
if ($response) {
$this->sms .= "$.Notification.autoHideNotify('custom', 'top right', 'Abonnement effectué')";
$this->session->set_userdata('controller_message', $this->sms);
redirect($_SERVER['HTTP_REFERER'],"refresh");
print_r($customer->id);
print_r($subscription->id);
} else {
$this->sms .= "$.Notification.autoHideNotify('error', 'top right', 'Une erreur est survenu durant votre abonnement', 'Veuillez bien vérifier vos informations')";
$this->session->set_userdata('controller_message', $this->sms);
redirect($_SERVER['HTTP_REFERER'],"refresh");
}
} catch (Stripe_CardError $e) {
echo json_encode(array('status' => 500, 'error' => STRIPE_FAILED));
exit();
}
}
代碼的代碼,我試試這個代碼,並已經。我的問題是與webhook即每月捕獲客戶,並檢查他們的帳戶是否過期
相關問題
- 1. CRON作業codeigniter
- 2. cron工作與php
- 3. CodeIgniter框架內的PHP CRON Job
- 4. HMVC Codeigniter Cron問題
- 5. PHP睡眠與Cron-job
- 6. 比較cron與php日期()
- 7. CRON - PHP - file_get_contents與CRON運行PHP頁面和電子郵件
- 8. CodeIgniter +命令行+ Cron + Cpanel
- 9. Codeigniter類cron不工作
- 10. Codeigniter cron作業問題
- 11. 雙語CodeIgniter cron作業
- 12. codeigniter中的Cron作業
- 13. Codeigniter Cron Job的問題
- 14. Cron守護進程錯誤與PHP Cron作業
- 15. CodeIgniter的VALID_EMAIL()與PHP過濾
- 16. Node.js與PHP-Codeigniter和MongoDB
- 17. 如何使用PHP CodeIgniter創建Cron作業
- 18. PHP cron腳本與twitter(oauth問題)
- 19. 如何在ubuntu中設置codeigniter cron與apache
- 20. PHP,Email和Cron
- 21. cron scheduler for php
- 22. cron作業PHP
- 23. PHP Cron Manager/Scheduler
- 24. cron工作for codeigniter在parallels cpanel
- 25. CodeIgniter通過Cpanel的Cron作業
- 26. Codeigniter cron作業導致日誌錯誤
- 27. 在本地主機上運行CodeIgniter cron
- 28. 使用CodeIgniter運行cron作業
- 29. 如何通過CRON運行CodeIgniter文件?
- 30. delayed_job與cron
謝謝,我想試試這 –
所以,我不使用Web服務器上的Cron作業,但條紋webhooks。 –