网络挂接PHP与笨

问题描述:

我有这样的代码为我的网络挂接条纹网络挂接PHP与笨

\Stripe\Stripe::setApiKey("you_api_key"); 

$postdata = @file_get_contents("php://input"); 
$event = json_decode($postdata); 
if ($event->type == 'invoice.payment_succeeded') { 
    $customer_id = $event->data->object->customer; 
    $customer = \Stripe\Customer::retrieve($customer_id); 
    $invoice = \Stripe\Invoice::retrieve($event->data->object->id); 

    // This is where we'd normally e-mail the invoice, but we'll just write out the invoice to a file instead. 
    $from = "From: Me"; 
    $to = "To: ".$customer->email; 
    $subject = "Subject: You have made a payment for another month of Wilde quotes"; 
    $body = "You have made a new payment for $".($invoice->total/100.0).":\n\n"; 

    foreach($invoice->lines->data as &$line) { 
     if ($line->type == 'subscription') { 
      $body .= "Subscription - ".$line->plan->name.": ".$line->amount."\n"; 
     } 
     else if ($line->type == 'invoiceitem') { 
      $body .= "Additional -".$line->description.": ".$line->amount; 
     } 
    } 

    $email_file = fopen($customer->id."-".$invoice->date, 'a'); 
    $email = $from."\n".$to."\n".$subject."\n".$body; 
    fwrite($email_file, $email); 
} 

我的问题是,如何通过网络挂接条纹接收电子邮件订阅或电子邮件费或其他

哪些活动您的网络挂接检索确定通过您在条纹仪表板中的设置。

我建议您接收所有事件类型并使用if语句,因为您有代码对您感兴趣的事件作出反应。确保您的应用程序始终返回200 OK状态,否则Stripe将重试WebHooks。

有响应未能支付这里发送电子邮件的例子: https://stripe.com/docs/recipes/sending-emails-for-failed-payments

由条纹发送的所有事件的列表在这里: https://stripe.com/docs/api/php#event_types

如果您有具体的实施问题,或越来越错误消息,我建议发邮件给Stripe支持,因为他们可以直接帮助您解决有关您的代码和帐户的问题。