From 1a1b2739c2e9f1f14da2365624390aa642d4827e Mon Sep 17 00:00:00 2001 From: Juan Villegas Date: Tue, 6 May 2014 15:52:31 -0300 Subject: [PATCH] webhook fix --- logs/log.txt | 1500 ------------------------------------------------- s2-stripe.php | 17 +- 2 files changed, 14 insertions(+), 1503 deletions(-) delete mode 100644 logs/log.txt diff --git a/logs/log.txt b/logs/log.txt deleted file mode 100644 index 695e03f..0000000 --- a/logs/log.txt +++ /dev/null @@ -1,1500 +0,0 @@ -======================================== -New log @ 2014-04-23 12:04:15 -{ - "id": "evt_3u2M29kU2WfVAJ", - "created": 1398213073, - "livemode": false, - "type": "customer.subscription.deleted", - "data": { - "object": { - "id": "sub_3u2Jq7BKVZQ8bA", - "plan": { - "interval": "month", - "name": "Plan 2: Gold", - "created": 1392932610, - "amount": 2099, - "currency": "usd", - "id": "2", - "object": "plan", - "livemode": false, - "interval_count": 1, - "trial_period_days": null, - "metadata": { - }, - "statement_description": null - }, - "object": "subscription", - "start": 1398212850, - "status": "canceled", - "customer": "cus_3u2JekqcJppPus", - "cancel_at_period_end": false, - "current_period_start": 1398212850, - "current_period_end": 1400804850, - "ended_at": 1398213073, - "trial_start": null, - "trial_end": null, - "canceled_at": 1398213073, - "quantity": 1, - "application_fee_percent": null, - "discount": null - } - }, - "object": "event", - "pending_webhooks": 1, - "request": "iar_3u2MCVWNp92njd" -} - -======================================== -New log @ 2014-04-23 12:04:16 -{ - "id": "evt_3u2MxHrZjMORuE", - "created": 1398213073, - "livemode": false, - "type": "customer.deleted", - "data": { - "object": { - "object": "customer", - "created": 1398212850, - "id": "cus_3u2JekqcJppPus", - "livemode": false, - "description": null, - "email": "juan@sheologydigital.com", - "delinquent": false, - "metadata": { - "firstname": "Juan", - "lastname": "Villegas", - "s2_plan": "Silver Member" - }, - "subscriptions": { - "object": "list", - "total_count": 0, - "has_more": false, - "url": "/v1/customers/cus_3u2JekqcJppPus/subscriptions", - "data": [ - - ], - "count": 0 - }, - "discount": null, - "account_balance": 0, - "currency": "usd", - "cards": { - "object": "list", - "total_count": 1, - "has_more": false, - "url": "/v1/customers/cus_3u2JekqcJppPus/cards", - "data": [ - { - "id": "card_3u2Jfwi0w5U1ly", - "object": "card", - "last4": "4242", - "type": "Visa", - "exp_month": 6, - "exp_year": 2019, - "fingerprint": "rEQ5nJHd9DRH30xb", - "customer": "cus_3u2JekqcJppPus", - "country": "US", - "name": null, - "address_line1": null, - "address_line2": null, - "address_city": null, - "address_state": null, - "address_zip": null, - "address_country": null, - "cvc_check": "pass", - "address_line1_check": null, - "address_zip_check": null - } - ], - "count": 1 - }, - "default_card": "card_3u2Jfwi0w5U1ly" - } - }, - "object": "event", - "pending_webhooks": 1, - "request": "iar_3u2MCVWNp92njd" -} - -======================================== -New log @ 2014-04-23 12:04:10 -{ - "id": "evt_3u2P8DAorJdVGv", - "created": 1398213249, - "livemode": false, - "type": "customer.subscription.deleted", - "data": { - "object": { - "id": "sub_3r1PfiF3aHuWVx", - "plan": { - "interval": "month", - "name": "Plan 2: Gold", - "created": 1392932610, - "amount": 2099, - "currency": "usd", - "id": "2", - "object": "plan", - "livemode": false, - "interval_count": 1, - "trial_period_days": null, - "metadata": { - }, - "statement_description": null - }, - "object": "subscription", - "start": 1397517581, - "status": "canceled", - "customer": "cus_3r1Pn4Y5hQeltS", - "cancel_at_period_end": false, - "current_period_start": 1397517581, - "current_period_end": 1400109581, - "ended_at": 1398213249, - "trial_start": null, - "trial_end": null, - "canceled_at": 1398213249, - "quantity": 1, - "application_fee_percent": null, - "discount": null - } - }, - "object": "event", - "pending_webhooks": 1, - "request": "iar_3u2P97TEMKscTp" -} - -======================================== -New log @ 2014-04-23 12:04:10 -"event detected" - -======================================== -New log @ 2014-04-23 12:04:11 -{ - "id": "evt_3u2PRSra1nE7tf", - "created": 1398213249, - "livemode": false, - "type": "customer.deleted", - "data": { - "object": { - "object": "customer", - "created": 1397517581, - "id": "cus_3r1Pn4Y5hQeltS", - "livemode": false, - "description": null, - "email": "juan@sheologydigital.com", - "delinquent": false, - "metadata": { - "firstname": "Juan", - "lastname": "Villegas", - "s2_plan": "s2member_level2" - }, - "subscriptions": { - "object": "list", - "total_count": 0, - "has_more": false, - "url": "/v1/customers/cus_3r1Pn4Y5hQeltS/subscriptions", - "data": [ - - ], - "count": 0 - }, - "discount": null, - "account_balance": 0, - "currency": "usd", - "cards": { - "object": "list", - "total_count": 1, - "has_more": false, - "url": "/v1/customers/cus_3r1Pn4Y5hQeltS/cards", - "data": [ - { - "id": "card_3r1PT5VDtYKW6y", - "object": "card", - "last4": "4242", - "type": "Visa", - "exp_month": 9, - "exp_year": 2014, - "fingerprint": "rEQ5nJHd9DRH30xb", - "customer": "cus_3r1Pn4Y5hQeltS", - "country": "US", - "name": null, - "address_line1": null, - "address_line2": null, - "address_city": null, - "address_state": null, - "address_zip": null, - "address_country": null, - "cvc_check": "pass", - "address_line1_check": null, - "address_zip_check": null - } - ], - "count": 1 - }, - "default_card": "card_3r1PT5VDtYKW6y" - } - }, - "object": "event", - "pending_webhooks": 1, - "request": "iar_3u2P97TEMKscTp" -} - -======================================== -New log @ 2014-04-23 12:04:59 -{ - "id": "evt_3u2SiRENHqJ33V", - "created": 1398213416, - "livemode": false, - "type": "customer.deleted", - "data": { - "object": { - "object": "customer", - "created": 1397517352, - "id": "cus_3r1Ly8jAnlzJ8b", - "livemode": false, - "description": null, - "email": "juan@sheologydigital.com", - "delinquent": false, - "metadata": { - "firstname": "Juan", - "lastname": "Villegas", - "s2_plan": "s2member_level2" - }, - "subscriptions": { - "object": "list", - "total_count": 0, - "has_more": false, - "url": "/v1/customers/cus_3r1Ly8jAnlzJ8b/subscriptions", - "data": [ - - ], - "count": 0 - }, - "discount": null, - "account_balance": 0, - "currency": "usd", - "cards": { - "object": "list", - "total_count": 1, - "has_more": false, - "url": "/v1/customers/cus_3r1Ly8jAnlzJ8b/cards", - "data": [ - { - "id": "card_3r1LfFRXKwkoHc", - "object": "card", - "last4": "4242", - "type": "Visa", - "exp_month": 9, - "exp_year": 2014, - "fingerprint": "rEQ5nJHd9DRH30xb", - "customer": "cus_3r1Ly8jAnlzJ8b", - "country": "US", - "name": null, - "address_line1": null, - "address_line2": null, - "address_city": null, - "address_state": null, - "address_zip": null, - "address_country": null, - "cvc_check": "pass", - "address_line1_check": null, - "address_zip_check": null - } - ], - "count": 1 - }, - "default_card": "card_3r1LfFRXKwkoHc" - } - }, - "object": "event", - "pending_webhooks": 1, - "request": "iar_3u2SDRUncqc1nN" -} - -======================================== -New log @ 2014-04-23 12:04:59 -{ - "id": "evt_3u2SMU9RWLw85W", - "created": 1398213416, - "livemode": false, - "type": "customer.subscription.deleted", - "data": { - "object": { - "id": "sub_3r1Lhd82aC7VzU", - "plan": { - "interval": "month", - "name": "Plan 2: Gold", - "created": 1392932610, - "amount": 2099, - "currency": "usd", - "id": "2", - "object": "plan", - "livemode": false, - "interval_count": 1, - "trial_period_days": null, - "metadata": { - }, - "statement_description": null - }, - "object": "subscription", - "start": 1397517352, - "status": "canceled", - "customer": "cus_3r1Ly8jAnlzJ8b", - "cancel_at_period_end": false, - "current_period_start": 1397517352, - "current_period_end": 1400109352, - "ended_at": 1398213416, - "trial_start": null, - "trial_end": null, - "canceled_at": 1398213416, - "quantity": 1, - "application_fee_percent": null, - "discount": null - } - }, - "object": "event", - "pending_webhooks": 1, - "request": "iar_3u2SDRUncqc1nN" -} - -======================================== -New log @ 2014-04-23 12:04:59 -"event detected" - -======================================== -New log @ 2014-04-23 12:04:05 -{ - "id": "evt_3u2S5Z98gF8Eaj", - "created": 1398213422, - "livemode": false, - "type": "customer.deleted", - "data": { - "object": { - "object": "customer", - "created": 1397517319, - "id": "cus_3r1KdxOqOWncft", - "livemode": false, - "description": null, - "email": "juan@sheologydigital.com", - "delinquent": false, - "metadata": { - "firstname": "Juan", - "lastname": "Villegas", - "s2_plan": "s2member_level2" - }, - "subscriptions": { - "object": "list", - "total_count": 0, - "has_more": false, - "url": "/v1/customers/cus_3r1KdxOqOWncft/subscriptions", - "data": [ - - ], - "count": 0 - }, - "discount": null, - "account_balance": 0, - "currency": "usd", - "cards": { - "object": "list", - "total_count": 1, - "has_more": false, - "url": "/v1/customers/cus_3r1KdxOqOWncft/cards", - "data": [ - { - "id": "card_3r1KtC5S1DQ897", - "object": "card", - "last4": "4242", - "type": "Visa", - "exp_month": 9, - "exp_year": 2014, - "fingerprint": "rEQ5nJHd9DRH30xb", - "customer": "cus_3r1KdxOqOWncft", - "country": "US", - "name": null, - "address_line1": null, - "address_line2": null, - "address_city": null, - "address_state": null, - "address_zip": null, - "address_country": null, - "cvc_check": "pass", - "address_line1_check": null, - "address_zip_check": null - } - ], - "count": 1 - }, - "default_card": "card_3r1KtC5S1DQ897" - } - }, - "object": "event", - "pending_webhooks": 1, - "request": "iar_3u2Su2yG3UDZ9t" -} - -======================================== -New log @ 2014-04-23 12:04:06 -{ - "id": "evt_3u2SdeFM9MgRDl", - "created": 1398213422, - "livemode": false, - "type": "customer.subscription.deleted", - "data": { - "object": { - "id": "sub_3r1KVnCQoszvhx", - "plan": { - "interval": "month", - "name": "Plan 2: Gold", - "created": 1392932610, - "amount": 2099, - "currency": "usd", - "id": "2", - "object": "plan", - "livemode": false, - "interval_count": 1, - "trial_period_days": null, - "metadata": { - }, - "statement_description": null - }, - "object": "subscription", - "start": 1397517319, - "status": "canceled", - "customer": "cus_3r1KdxOqOWncft", - "cancel_at_period_end": false, - "current_period_start": 1397517319, - "current_period_end": 1400109319, - "ended_at": 1398213422, - "trial_start": null, - "trial_end": null, - "canceled_at": 1398213422, - "quantity": 1, - "application_fee_percent": null, - "discount": null - } - }, - "object": "event", - "pending_webhooks": 1, - "request": "iar_3u2Su2yG3UDZ9t" -} - -======================================== -New log @ 2014-04-23 12:04:06 -"event detected" - -======================================== -New log @ 2014-04-23 12:04:21 -{ - "id": "evt_3u2SUvrytcl3Jr", - "created": 1398213437, - "livemode": false, - "type": "customer.deleted", - "data": { - "object": { - "object": "customer", - "created": 1397516807, - "id": "cus_3r1CSe5QxS2PZy", - "livemode": false, - "description": null, - "email": "juan.villgs@gmail.com", - "delinquent": false, - "metadata": { - "firstname": "juan", - "lastname": "villegas", - "s2_plan": "s2member_level2" - }, - "subscriptions": { - "object": "list", - "total_count": 0, - "has_more": false, - "url": "/v1/customers/cus_3r1CSe5QxS2PZy/subscriptions", - "data": [ - - ], - "count": 0 - }, - "discount": null, - "account_balance": 0, - "currency": "usd", - "cards": { - "object": "list", - "total_count": 1, - "has_more": false, - "url": "/v1/customers/cus_3r1CSe5QxS2PZy/cards", - "data": [ - { - "id": "card_3r1CX8YtblXCVk", - "object": "card", - "last4": "4242", - "type": "Visa", - "exp_month": 9, - "exp_year": 2021, - "fingerprint": "rEQ5nJHd9DRH30xb", - "customer": "cus_3r1CSe5QxS2PZy", - "country": "US", - "name": null, - "address_line1": null, - "address_line2": null, - "address_city": null, - "address_state": null, - "address_zip": null, - "address_country": null, - "cvc_check": "pass", - "address_line1_check": null, - "address_zip_check": null - } - ], - "count": 1 - }, - "default_card": "card_3r1CX8YtblXCVk" - } - }, - "object": "event", - "pending_webhooks": 1, - "request": "iar_3u2SaZVMePjVzG" -} - -======================================== -New log @ 2014-04-23 12:04:26 -{ - "id": "evt_3u2To5PgqIBo8r", - "created": 1398213443, - "livemode": false, - "type": "customer.subscription.deleted", - "data": { - "object": { - "id": "sub_3r1Bb1XeeEvQP8", - "plan": { - "interval": "month", - "name": "Plan 2: Gold", - "created": 1392932610, - "amount": 2099, - "currency": "usd", - "id": "2", - "object": "plan", - "livemode": false, - "interval_count": 1, - "trial_period_days": null, - "metadata": { - }, - "statement_description": null - }, - "object": "subscription", - "start": 1397516775, - "status": "canceled", - "customer": "cus_3r1BY62AD8qpH4", - "cancel_at_period_end": false, - "current_period_start": 1397516775, - "current_period_end": 1400108775, - "ended_at": 1398213443, - "trial_start": null, - "trial_end": null, - "canceled_at": 1398213443, - "quantity": 1, - "application_fee_percent": null, - "discount": null - } - }, - "object": "event", - "pending_webhooks": 1, - "request": "iar_3u2TMSoBIfsiwZ" -} - -======================================== -New log @ 2014-04-23 12:04:26 -"event detected" - -======================================== -New log @ 2014-04-23 12:04:26 -{ - "id": "evt_3u2Tw3M2OUsewJ", - "created": 1398213443, - "livemode": false, - "type": "customer.deleted", - "data": { - "object": { - "object": "customer", - "created": 1397516775, - "id": "cus_3r1BY62AD8qpH4", - "livemode": false, - "description": null, - "email": "juan@sheologydigital.com", - "delinquent": false, - "metadata": { - "firstname": "juan", - "lastname": "villegas", - "s2_plan": "s2member_level2" - }, - "subscriptions": { - "object": "list", - "total_count": 0, - "has_more": false, - "url": "/v1/customers/cus_3r1BY62AD8qpH4/subscriptions", - "data": [ - - ], - "count": 0 - }, - "discount": null, - "account_balance": 0, - "currency": "usd", - "cards": { - "object": "list", - "total_count": 1, - "has_more": false, - "url": "/v1/customers/cus_3r1BY62AD8qpH4/cards", - "data": [ - { - "id": "card_3r1Bl7RIkbyRer", - "object": "card", - "last4": "4242", - "type": "Visa", - "exp_month": 8, - "exp_year": 2020, - "fingerprint": "rEQ5nJHd9DRH30xb", - "customer": "cus_3r1BY62AD8qpH4", - "country": "US", - "name": null, - "address_line1": null, - "address_line2": null, - "address_city": null, - "address_state": null, - "address_zip": null, - "address_country": null, - "cvc_check": "pass", - "address_line1_check": null, - "address_zip_check": null - } - ], - "count": 1 - }, - "default_card": "card_3r1Bl7RIkbyRer" - } - }, - "object": "event", - "pending_webhooks": 1, - "request": "iar_3u2TMSoBIfsiwZ" -} - -======================================== -New log @ 2014-04-23 12:04:33 -{ - "id": "evt_3u2TFXPsj5JNJf", - "created": 1398213451, - "livemode": false, - "type": "customer.subscription.deleted", - "data": { - "object": { - "id": "sub_3r1AsGpmke4TBV", - "plan": { - "interval": "month", - "name": "Plan 2: Gold", - "created": 1392932610, - "amount": 2099, - "currency": "usd", - "id": "2", - "object": "plan", - "livemode": false, - "interval_count": 1, - "trial_period_days": null, - "metadata": { - }, - "statement_description": null - }, - "object": "subscription", - "start": 1397516672, - "status": "canceled", - "customer": "cus_3r1AN10IQgP8DM", - "cancel_at_period_end": false, - "current_period_start": 1397516672, - "current_period_end": 1400108672, - "ended_at": 1398213451, - "trial_start": null, - "trial_end": null, - "canceled_at": 1398213451, - "quantity": 1, - "application_fee_percent": null, - "discount": null - } - }, - "object": "event", - "pending_webhooks": 1, - "request": "iar_3u2TlBR2lTqaJd" -} - -======================================== -New log @ 2014-04-23 12:04:33 -"event detected" - -======================================== -New log @ 2014-04-23 12:04:35 -{ - "id": "evt_3u2TLNGioNQRQi", - "created": 1398213451, - "livemode": false, - "type": "customer.deleted", - "data": { - "object": { - "object": "customer", - "created": 1397516672, - "id": "cus_3r1AN10IQgP8DM", - "livemode": false, - "description": null, - "email": "juan@sheologydigital.com", - "delinquent": false, - "metadata": { - "firstname": "jUAN", - "lastname": "Villegas", - "s2_plan": "s2member_level2" - }, - "subscriptions": { - "object": "list", - "total_count": 0, - "has_more": false, - "url": "/v1/customers/cus_3r1AN10IQgP8DM/subscriptions", - "data": [ - - ], - "count": 0 - }, - "discount": null, - "account_balance": 0, - "currency": "usd", - "cards": { - "object": "list", - "total_count": 1, - "has_more": false, - "url": "/v1/customers/cus_3r1AN10IQgP8DM/cards", - "data": [ - { - "id": "card_3r1AJIza9RlxBy", - "object": "card", - "last4": "4242", - "type": "Visa", - "exp_month": 10, - "exp_year": 2022, - "fingerprint": "rEQ5nJHd9DRH30xb", - "customer": "cus_3r1AN10IQgP8DM", - "country": "US", - "name": null, - "address_line1": null, - "address_line2": null, - "address_city": null, - "address_state": null, - "address_zip": null, - "address_country": null, - "cvc_check": "pass", - "address_line1_check": null, - "address_zip_check": null - } - ], - "count": 1 - }, - "default_card": "card_3r1AJIza9RlxBy" - } - }, - "object": "event", - "pending_webhooks": 1, - "request": "iar_3u2TlBR2lTqaJd" -} - -======================================== -New log @ 2014-04-23 12:04:53 -{ - "id": "evt_3u2SP5PIKNz0EE", - "created": 1398213437, - "livemode": false, - "type": "customer.subscription.deleted", - "data": { - "object": { - "id": "sub_3r1CIoBSc1ctdp", - "plan": { - "interval": "month", - "name": "Plan 2: Gold", - "created": 1392932610, - "amount": 2099, - "currency": "usd", - "id": "2", - "object": "plan", - "livemode": false, - "interval_count": 1, - "trial_period_days": null, - "metadata": { - }, - "statement_description": null - }, - "object": "subscription", - "start": 1397516807, - "status": "canceled", - "customer": "cus_3r1CSe5QxS2PZy", - "cancel_at_period_end": false, - "current_period_start": 1397516807, - "current_period_end": 1400108807, - "ended_at": 1398213437, - "trial_start": null, - "trial_end": null, - "canceled_at": 1398213437, - "quantity": 1, - "application_fee_percent": null, - "discount": null - } - }, - "object": "event", - "pending_webhooks": 1, - "request": "iar_3u2SaZVMePjVzG" -} - -======================================== -New log @ 2014-04-23 12:04:53 -"event detected" - -======================================== -New log @ 2014-04-23 12:04:30 -{ - "id": "evt_3u2ag4qIVlTeLI", - "created": 1398213868, - "livemode": false, - "type": "customer.deleted", - "data": { - "object": { - "object": "customer", - "created": 1396832781, - "id": "cus_3o3KdF3EGHHfuC", - "livemode": false, - "description": null, - "email": "juan.villgs@gmail.com", - "delinquent": false, - "metadata": { - "firstname": "Juan", - "lastname": "Villegas", - "s2_plan": "1" - }, - "subscriptions": { - "object": "list", - "total_count": 0, - "has_more": false, - "url": "/v1/customers/cus_3o3KdF3EGHHfuC/subscriptions", - "data": [ - - ], - "count": 0 - }, - "discount": null, - "account_balance": 0, - "currency": "usd", - "cards": { - "object": "list", - "total_count": 1, - "has_more": false, - "url": "/v1/customers/cus_3o3KdF3EGHHfuC/cards", - "data": [ - { - "id": "card_3o3J6ZrWL7JmDk", - "object": "card", - "last4": "4242", - "type": "Visa", - "exp_month": 4, - "exp_year": 2017, - "fingerprint": "rEQ5nJHd9DRH30xb", - "customer": "cus_3o3KdF3EGHHfuC", - "country": "US", - "name": null, - "address_line1": null, - "address_line2": null, - "address_city": null, - "address_state": null, - "address_zip": null, - "address_country": null, - "cvc_check": "pass", - "address_line1_check": null, - "address_zip_check": null - } - ], - "count": 1 - }, - "default_card": "card_3o3J6ZrWL7JmDk" - } - }, - "object": "event", - "pending_webhooks": 1, - "request": "iar_3u2arMzd4hzZh9" -} - -======================================== -New log @ 2014-04-23 12:04:32 -{ - "id": "evt_3u2aOCHtfR4cKJ", - "created": 1398213868, - "livemode": false, - "type": "customer.subscription.deleted", - "data": { - "object": { - "id": "sub_3o3KXZdQUpKC4d", - "plan": { - "interval": "month", - "name": "Plan 2: Gold", - "created": 1392932610, - "amount": 2099, - "currency": "usd", - "id": "2", - "object": "plan", - "livemode": false, - "interval_count": 1, - "trial_period_days": null, - "metadata": { - }, - "statement_description": null - }, - "object": "subscription", - "start": 1396832781, - "status": "canceled", - "customer": "cus_3o3KdF3EGHHfuC", - "cancel_at_period_end": false, - "current_period_start": 1396832781, - "current_period_end": 1399424781, - "ended_at": 1398213868, - "trial_start": null, - "trial_end": null, - "canceled_at": 1398213868, - "quantity": 1, - "application_fee_percent": null, - "discount": null - } - }, - "object": "event", - "pending_webhooks": 1, - "request": "iar_3u2arMzd4hzZh9" -} - -======================================== -New log @ 2014-04-23 12:04:32 -"event detected" - -======================================== -New log @ 2014-04-23 12:04:38 -{ - "id": "evt_3u2bFwoozlhMl3", - "created": 1398213936, - "livemode": false, - "type": "customer.subscription.created", - "data": { - "object": { - "id": "sub_3u2bsEy04e54C9", - "plan": { - "interval": "month", - "name": "Plan 2: Gold", - "created": 1392932610, - "amount": 2099, - "currency": "usd", - "id": "2", - "object": "plan", - "livemode": false, - "interval_count": 1, - "trial_period_days": null, - "metadata": { - }, - "statement_description": null - }, - "object": "subscription", - "start": 1398213935, - "status": "active", - "customer": "cus_3u2bDyKN14h9wJ", - "cancel_at_period_end": false, - "current_period_start": 1398213935, - "current_period_end": 1400805935, - "ended_at": null, - "trial_start": null, - "trial_end": null, - "canceled_at": null, - "quantity": 1, - "application_fee_percent": null, - "discount": null - } - }, - "object": "event", - "pending_webhooks": 1, - "request": "iar_3u2bnJUzHQtefL" -} - -======================================== -New log @ 2014-04-23 12:04:38 -{ - "id": "evt_3u2bno0hzkfsUa", - "created": 1398213935, - "livemode": false, - "type": "charge.succeeded", - "data": { - "object": { - "id": "ch_3u2bxQk1Gw8xJD", - "object": "charge", - "created": 1398213935, - "livemode": false, - "paid": true, - "amount": 2099, - "currency": "usd", - "refunded": false, - "card": { - "id": "card_3u2bQgAp1Tuf04", - "object": "card", - "last4": "4242", - "type": "Visa", - "exp_month": 1, - "exp_year": 2022, - "fingerprint": "rEQ5nJHd9DRH30xb", - "customer": "cus_3u2bDyKN14h9wJ", - "country": "US", - "name": null, - "address_line1": null, - "address_line2": null, - "address_city": null, - "address_state": null, - "address_zip": null, - "address_country": null, - "cvc_check": "pass", - "address_line1_check": null, - "address_zip_check": null - }, - "captured": true, - "refunds": [ - - ], - "balance_transaction": "txn_3u2bN6eGaYgixc", - "failure_message": null, - "failure_code": null, - "amount_refunded": 0, - "customer": "cus_3u2bDyKN14h9wJ", - "invoice": "in_3u2bwxFJ0yEdCe", - "description": null, - "dispute": null, - "metadata": { - }, - "statement_description": null - } - }, - "object": "event", - "pending_webhooks": 1, - "request": "iar_3u2bnJUzHQtefL" -} - -======================================== -New log @ 2014-04-23 12:04:39 -{ - "id": "evt_3u2b4qK4U9TUhz", - "created": 1398213935, - "livemode": false, - "type": "customer.created", - "data": { - "object": { - "object": "customer", - "created": 1398213935, - "id": "cus_3u2bDyKN14h9wJ", - "livemode": false, - "description": null, - "email": "juan@sheologydigital.com", - "delinquent": false, - "metadata": { - "firstname": "juan", - "lastname": "villegas", - "s2_plan": "Silver Member" - }, - "subscriptions": { - "object": "list", - "total_count": 1, - "has_more": false, - "url": "/v1/customers/cus_3u2bDyKN14h9wJ/subscriptions", - "data": [ - { - "id": "sub_3u2bsEy04e54C9", - "plan": { - "interval": "month", - "name": "Plan 2: Gold", - "created": 1392932610, - "amount": 2099, - "currency": "usd", - "id": "2", - "object": "plan", - "livemode": false, - "interval_count": 1, - "trial_period_days": null, - "metadata": { - }, - "statement_description": null - }, - "object": "subscription", - "start": 1398213935, - "status": "active", - "customer": "cus_3u2bDyKN14h9wJ", - "cancel_at_period_end": false, - "current_period_start": 1398213935, - "current_period_end": 1400805935, - "ended_at": null, - "trial_start": null, - "trial_end": null, - "canceled_at": null, - "quantity": 1, - "application_fee_percent": null, - "discount": null - } - ], - "count": 1 - }, - "discount": null, - "account_balance": 0, - "currency": "usd", - "cards": { - "object": "list", - "total_count": 1, - "has_more": false, - "url": "/v1/customers/cus_3u2bDyKN14h9wJ/cards", - "data": [ - { - "id": "card_3u2bQgAp1Tuf04", - "object": "card", - "last4": "4242", - "type": "Visa", - "exp_month": 1, - "exp_year": 2022, - "fingerprint": "rEQ5nJHd9DRH30xb", - "customer": "cus_3u2bDyKN14h9wJ", - "country": "US", - "name": null, - "address_line1": null, - "address_line2": null, - "address_city": null, - "address_state": null, - "address_zip": null, - "address_country": null, - "cvc_check": "pass", - "address_line1_check": null, - "address_zip_check": null - } - ], - "count": 1 - }, - "default_card": "card_3u2bQgAp1Tuf04" - } - }, - "object": "event", - "pending_webhooks": 1, - "request": "iar_3u2bnJUzHQtefL" -} - -======================================== -New log @ 2014-04-23 12:04:39 -{ - "id": "evt_3u2bHaH6KeAjrY", - "created": 1398213936, - "livemode": false, - "type": "invoice.payment_succeeded", - "data": { - "object": { - "date": 1398213935, - "id": "in_3u2bwxFJ0yEdCe", - "period_start": 1398213935, - "period_end": 1398213935, - "lines": { - "object": "list", - "total_count": 1, - "has_more": false, - "url": "/v1/invoices/in_3u2bwxFJ0yEdCe/lines", - "data": [ - { - "id": "sub_3u2bsEy04e54C9", - "object": "line_item", - "type": "subscription", - "livemode": false, - "amount": 2099, - "currency": "usd", - "proration": false, - "period": { - "start": 1398213935, - "end": 1400805935 - }, - "quantity": 1, - "plan": { - "interval": "month", - "name": "Plan 2: Gold", - "created": 1392932610, - "amount": 2099, - "currency": "usd", - "id": "2", - "object": "plan", - "livemode": false, - "interval_count": 1, - "trial_period_days": null, - "metadata": { - }, - "statement_description": null - }, - "description": null, - "metadata": null - } - ], - "count": 1 - }, - "subtotal": 2099, - "total": 2099, - "customer": "cus_3u2bDyKN14h9wJ", - "object": "invoice", - "attempted": true, - "closed": true, - "paid": true, - "livemode": false, - "attempt_count": 0, - "amount_due": 2099, - "currency": "usd", - "starting_balance": 0, - "ending_balance": 0, - "next_payment_attempt": null, - "charge": "ch_3u2bxQk1Gw8xJD", - "discount": null, - "application_fee": null, - "subscription": "sub_3u2bsEy04e54C9", - "metadata": { - }, - "description": null - } - }, - "object": "event", - "pending_webhooks": 1, - "request": "iar_3u2bnJUzHQtefL" -} - -======================================== -New log @ 2014-04-23 12:04:39 -{ - "id": "evt_3u2bbnW9QHjvaw", - "created": 1398213936, - "livemode": false, - "type": "invoice.created", - "data": { - "object": { - "date": 1398213935, - "id": "in_3u2bwxFJ0yEdCe", - "period_start": 1398213935, - "period_end": 1398213935, - "lines": { - "object": "list", - "total_count": 1, - "has_more": false, - "url": "/v1/invoices/in_3u2bwxFJ0yEdCe/lines", - "data": [ - { - "id": "sub_3u2bsEy04e54C9", - "object": "line_item", - "type": "subscription", - "livemode": false, - "amount": 2099, - "currency": "usd", - "proration": false, - "period": { - "start": 1398213935, - "end": 1400805935 - }, - "quantity": 1, - "plan": { - "interval": "month", - "name": "Plan 2: Gold", - "created": 1392932610, - "amount": 2099, - "currency": "usd", - "id": "2", - "object": "plan", - "livemode": false, - "interval_count": 1, - "trial_period_days": null, - "metadata": { - }, - "statement_description": null - }, - "description": null, - "metadata": null - } - ], - "count": 1 - }, - "subtotal": 2099, - "total": 2099, - "customer": "cus_3u2bDyKN14h9wJ", - "object": "invoice", - "attempted": true, - "closed": true, - "paid": true, - "livemode": false, - "attempt_count": 0, - "amount_due": 2099, - "currency": "usd", - "starting_balance": 0, - "ending_balance": 0, - "next_payment_attempt": null, - "charge": "ch_3u2bxQk1Gw8xJD", - "discount": null, - "application_fee": null, - "subscription": "sub_3u2bsEy04e54C9", - "metadata": { - }, - "description": null - } - }, - "object": "event", - "pending_webhooks": 1, - "request": "iar_3u2bnJUzHQtefL" -} - -======================================== -New log @ 2014-04-23 12:04:40 -{ - "id": "evt_3u2b0nwMaHaAWl", - "created": 1398213936, - "livemode": false, - "type": "customer.card.created", - "data": { - "object": { - "id": "card_3u2bQgAp1Tuf04", - "object": "card", - "last4": "4242", - "type": "Visa", - "exp_month": 1, - "exp_year": 2022, - "fingerprint": "rEQ5nJHd9DRH30xb", - "customer": "cus_3u2bDyKN14h9wJ", - "country": "US", - "name": null, - "address_line1": null, - "address_line2": null, - "address_city": null, - "address_state": null, - "address_zip": null, - "address_country": null, - "cvc_check": "pass", - "address_line1_check": null, - "address_zip_check": null - } - }, - "object": "event", - "pending_webhooks": 1, - "request": "iar_3u2bnJUzHQtefL" -} - -======================================== -New log @ 2014-04-23 12:04:47 -{ - "id": "evt_3u2eBSTrqEirKi", - "created": 1398214124, - "livemode": false, - "type": "customer.deleted", - "data": { - "object": { - "object": "customer", - "created": 1398213935, - "id": "cus_3u2bDyKN14h9wJ", - "livemode": false, - "description": null, - "email": "juan@sheologydigital.com", - "delinquent": false, - "metadata": { - "firstname": "juan", - "lastname": "villegas", - "s2_plan": "Silver Member" - }, - "subscriptions": { - "object": "list", - "total_count": 0, - "has_more": false, - "url": "/v1/customers/cus_3u2bDyKN14h9wJ/subscriptions", - "data": [ - - ], - "count": 0 - }, - "discount": null, - "account_balance": 0, - "currency": "usd", - "cards": { - "object": "list", - "total_count": 1, - "has_more": false, - "url": "/v1/customers/cus_3u2bDyKN14h9wJ/cards", - "data": [ - { - "id": "card_3u2bQgAp1Tuf04", - "object": "card", - "last4": "4242", - "type": "Visa", - "exp_month": 1, - "exp_year": 2022, - "fingerprint": "rEQ5nJHd9DRH30xb", - "customer": "cus_3u2bDyKN14h9wJ", - "country": "US", - "name": null, - "address_line1": null, - "address_line2": null, - "address_city": null, - "address_state": null, - "address_zip": null, - "address_country": null, - "cvc_check": "pass", - "address_line1_check": null, - "address_zip_check": null - } - ], - "count": 1 - }, - "default_card": "card_3u2bQgAp1Tuf04" - } - }, - "object": "event", - "pending_webhooks": 1, - "request": "iar_3u2eQpdT4Trwpd" -} - -======================================== -New log @ 2014-04-23 12:04:49 -{ - "id": "evt_3u2egy1hfp3nvn", - "created": 1398214124, - "livemode": false, - "type": "customer.subscription.deleted", - "data": { - "object": { - "id": "sub_3u2bsEy04e54C9", - "plan": { - "interval": "month", - "name": "Plan 2: Gold", - "created": 1392932610, - "amount": 2099, - "currency": "usd", - "id": "2", - "object": "plan", - "livemode": false, - "interval_count": 1, - "trial_period_days": null, - "metadata": { - }, - "statement_description": null - }, - "object": "subscription", - "start": 1398213935, - "status": "canceled", - "customer": "cus_3u2bDyKN14h9wJ", - "cancel_at_period_end": false, - "current_period_start": 1398213935, - "current_period_end": 1400805935, - "ended_at": 1398214124, - "trial_start": null, - "trial_end": null, - "canceled_at": 1398214124, - "quantity": 1, - "application_fee_percent": null, - "discount": null - } - }, - "object": "event", - "pending_webhooks": 1, - "request": "iar_3u2eQpdT4Trwpd" -} - -======================================== -New log @ 2014-04-23 12:04:49 -"event detected" - diff --git a/s2-stripe.php b/s2-stripe.php index 632f867..a733e81 100644 --- a/s2-stripe.php +++ b/s2-stripe.php @@ -630,8 +630,8 @@ function s2_stripe_webhook() { 'subscr_id' => $customer_id, 'txn_type' => 'subscr_cancel', 'txn_id' => 'stripe-cancel-'. time(), - 'item_number' => $plan_object->id, // TODO: i think we have to use the local s2 membership level here - 'item_name' => $plan_object->name // TODO: we have to test it without this parameter + 'item_number' => S2_Stripe::getRoleLevel(S2_Stripe::getRoleForStripePlan($plan_object->id)), // TODO: i think we have to use the local s2 membership level here + 'item_name' => S2_Stripe::getRoleForStripePlan($plan_object->id) // TODO: we have to test it without this parameter ); $fields_string = http_build_query($fields); @@ -688,7 +688,18 @@ static function getStripePlanForRole( $role ){ $map = S2_Stripe_DataManager::getPlansMap(); for( $i = 0; $i < count( $map ); $i = $i + 2 ){ if( $map[$i] == $role ){ - return $map[$i+1]; + return $map[$i + 1]; + } + } + return false; + } + + // inverse of getStripePlanForRole + static function getRoleForStripePlan( $stripePlan ){ + $map = S2_Stripe_DataManager::getPlansMap(); + for( $i = 0; $i < count( $map ); $i = $i + 2 ){ + if( $map[$i + 1] == $stripePlan ){ + return $map[$i]; } } return false;