Reputation: 73
Why i got Customer id and invoice id cus_0000000000000 and in_0000000000000 like these? in stripe webhook response. I am checking my events and response in my account in this i got response 200 ok,but got customer id and invoice id got like these.why? i am checking send test webhook event at this i got response like these.
public function actionStripeHook() {
if (Yii::app()->request->isPostRequest) {
try {
$postdata = file_get_contents("php://input");
$event = json_decode($postdata);
switch ($event->type) {
case 'invoice.payment_succeeded':
Yii::log('', 'trace', 'stripe');
Yii::log('==================================', 'trace', 'stripe');
Yii::log('==== Event (' . $event->type . ') ====', 'trace', 'stripe');
Yii::log('==================================', 'trace', 'stripe');
$customer_id = $event->data->object->customer;
$customer = Stripe_Customer::retrieve($customer_id);
$invoice = Stripe_Invoice::retrieve($event->data->object->id);
}
What's Wrong in my code Its my action in Webhook endpoint in stripe,I got event type invoice.payment_succeeeed its coming from that case,but cant get customer id and invoice id correctly in my Response.why?
Upvotes: 0
Views: 1886
Reputation: 17533
Nothing is wrong with your code -- the "Send test webhook" button sends a correctly formatted JSON event, but all the resources IDs are xxx_000000000
.
The "Send test webhook" button is mostly useful for testing connectivity between Stripe and your webhook handler. If you want to test actual functionality, you should generate the events "organically", i.e. by sending the requests that will trigger the events you want.
For instance, to generate an invoice.payment_succeeded
event, you should:
Upon creating the subscription, an invoice will be created and payment will be immediately attempted. If the payment is successful, then an invoice.payment_succeeded
event will be emitted (with valid IDs).
Upvotes: 5