mock_chargebee 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/Gemfile +2 -0
- data/LICENSE +21 -0
- data/README.md +2 -0
- data/lib/mock_chargebee/environment.rb +13 -0
- data/lib/mock_chargebee/errors.rb +15 -0
- data/lib/mock_chargebee/fixtures/coupon.json +18 -0
- data/lib/mock_chargebee/fixtures/customer.json +35 -0
- data/lib/mock_chargebee/fixtures/subscription.json +29 -0
- data/lib/mock_chargebee/fixtures/subscription_cancel_response.json +140 -0
- data/lib/mock_chargebee/fixtures/subscription_create_response.json +138 -0
- data/lib/mock_chargebee/fixtures/subscription_reactivate_response.json +110 -0
- data/lib/mock_chargebee/fixtures/webhooks/addon_created.json +32 -0
- data/lib/mock_chargebee/fixtures/webhooks/addon_deleted.json +29 -0
- data/lib/mock_chargebee/fixtures/webhooks/addon_updated.json +32 -0
- data/lib/mock_chargebee/fixtures/webhooks/authorization_succeeded.json +37 -0
- data/lib/mock_chargebee/fixtures/webhooks/authorization_voided.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/card_added.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/card_deleted.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/card_expired.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/card_expiry_reminder.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/card_updated.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/coupon_codes_added.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/coupon_codes_deleted.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/coupon_codes_updated.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/coupon_created.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/coupon_deleted.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/coupon_set_created.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/coupon_set_deleted.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/coupon_set_updated.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/coupon_updated.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/credit_note_created.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/credit_note_deleted.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/credit_note_updated.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/customer_changed.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/customer_created.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/customer_deleted.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/customer_moved_in.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/customer_moved_out.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/gift_cancelled.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/gift_claimed.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/gift_expired.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/gift_scheduled.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/gift_unclaimed.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/invoice_deleted.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/invoice_generated.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/invoice_updated.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/order_cancelled.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/order_created.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/order_delivered.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/order_ready_to_process.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/order_ready_to_ship.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/order_returned.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/order_updated.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/payment_failed.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/payment_initiated.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/payment_intent_created.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/payment_intent_updated.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/payment_refunded.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/payment_source_added.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/payment_source_deleted.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/payment_source_updated.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/payment_succeeded.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/pending_invoice_created.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/pending_invoice_updated.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/plan_created.json +37 -0
- data/lib/mock_chargebee/fixtures/webhooks/plan_deleted.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/plan_updated.json +39 -0
- data/lib/mock_chargebee/fixtures/webhooks/promotional_credits_added.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/promotional_credits_deducted.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/refund_initiated.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/subscription_activated.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/subscription_cancellation_reminder.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/subscription_cancellation_scheduled.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/subscription_cancelled.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/subscription_changed.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/subscription_changes_scheduled.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/subscription_created.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/subscription_deleted.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/subscription_pause_scheduled.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/subscription_paused.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/subscription_reactivated.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/subscription_renewal_reminder.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/subscription_renewed.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/subscription_resumed.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/subscription_resumption_scheduled.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/subscription_scheduled_cancellation_removed.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/subscription_scheduled_changes_removed.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/subscription_scheduled_pause_removed.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/subscription_scheduled_resumption_removed.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/subscription_shipping_address_updated.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/subscription_started.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/subscription_trial_end_reminder.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/transaction_created.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/transaction_deleted.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/transaction_updated.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/unbilled_charges_created.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/unbilled_charges_deleted.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/unbilled_charges_invoiced.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/unbilled_charges_voided.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/virtual_bank_account_added.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/virtual_bank_account_deleted.json +1 -0
- data/lib/mock_chargebee/fixtures/webhooks/virtual_bank_account_updated.json +1 -0
- data/lib/mock_chargebee/models/base.rb +24 -0
- data/lib/mock_chargebee/models/coupon.rb +25 -0
- data/lib/mock_chargebee/models/customer.rb +23 -0
- data/lib/mock_chargebee/models/subscription.rb +68 -0
- data/lib/mock_chargebee/repositories.rb +25 -0
- data/lib/mock_chargebee/request.rb +19 -0
- data/lib/mock_chargebee/request_handlers/base.rb +37 -0
- data/lib/mock_chargebee/request_handlers/coupons.rb +15 -0
- data/lib/mock_chargebee/request_handlers/customers.rb +26 -0
- data/lib/mock_chargebee/request_handlers/subscriptions.rb +43 -0
- data/lib/mock_chargebee/services/apply_coupons.rb +40 -0
- data/lib/mock_chargebee/util.rb +48 -0
- data/lib/mock_chargebee/validations/base.rb +11 -0
- data/lib/mock_chargebee/validations/coupons.rb +11 -0
- data/lib/mock_chargebee/validations/subscriptions.rb +11 -0
- data/lib/mock_chargebee/validations/webhooks.rb +15 -0
- data/lib/mock_chargebee/version.rb +5 -0
- data/lib/mock_chargebee/webhook.rb +26 -0
- data/lib/mock_chargebee.rb +43 -0
- data/mock_chargebee.gemspec +29 -0
- metadata +250 -0
@@ -0,0 +1 @@
|
|
1
|
+
{"id":"ev_16BgX7SC8QzzQ4nbm","occurred_at":1601524835,"source":"scheduled_job","object":"event","api_version":"v2","content":{"subscription":{"id":"AzqgumSAxXl3xAxW","customer_id":"16CHTnSAxXWqMAg8","plan_id":"test-company-custom-pro-plan","plan_quantity":1,"plan_unit_price":960000,"plan_amount":960000,"billing_period":1,"billing_period_unit":"year","plan_free_quantity":0,"status":"cancelled","created_at":1600447774,"cancelled_at":1601524835,"cancel_reason":"no_card","updated_at":1601524835,"has_scheduled_changes":false,"resource_version":1601524835836,"deleted":false,"object":"subscription","cancel_reason_code":"No Card","currency_code":"USD","due_invoices_count":0,"mrr":0},"customer":{"id":"16CHTnSAxXWqMAg8","company":"Test Company with Plan","auto_collection":"on","net_term_days":0,"allow_direct_debit":false,"created_at":1600447719,"taxability":"taxable","updated_at":1600447805,"locale":"en","pii_cleared":"active","resource_version":1600447805030,"deleted":false,"object":"customer","card_status":"no_card","promotional_credits":0,"refundable_credits":0,"excess_payments":0,"unbilled_charges":0,"preferred_currency_code":"USD"}},"event_type":"subscription_cancelled","webhook_status":"not_configured"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"id":"ev_AzZlwkSJGPYNWQd3","occurred_at":1608055631,"source":"admin_console","user":"user@example.com","object":"event","api_version":"v2","content":{"subscription":{"id":"AzZlzTSI7x9cAg30","plan_id":"__TEST__plan_1","plan_quantity":300,"plan_unit_price":3600,"billing_period":1,"billing_period_unit":"year","start_date":1609736400,"customer_id":"AzZlzTSI7x16Ufzr","plan_amount":1080000,"plan_free_quantity":0,"status":"future","next_billing_at":1641272400,"created_at":1607014520,"updated_at":1608055631,"has_scheduled_changes":false,"resource_version":1608055631889,"deleted":false,"object":"subscription","currency_code":"USD","due_invoices_count":0,"meta_data":{"minimum_quantity":300}},"customer":{"id":"AzZlzTSI7x16Ufzr","first_name":"Hydro","last_name":"Flask","email":"hydroflask@test.com","phone":"2124444444","company":"Hydro Flask®","auto_collection":"off","net_term_days":30,"allow_direct_debit":false,"created_at":1607014487,"taxability":"taxable","updated_at":1607977117,"locale":"en","pii_cleared":"active","resource_version":1607977117460,"deleted":false,"object":"customer","card_status":"no_card","promotional_credits":0,"refundable_credits":0,"excess_payments":0,"unbilled_charges":0,"preferred_currency_code":"USD"}},"event_type":"subscription_changed","webhook_status":"re_scheduled","webhook_failure_reason":"Received error code 404 from server. Your server has indicated that the page does not exist. Please check the URL","webhooks":[{"id":"whv2_16BjqVSJBcR3hZth","webhook_status":"re_scheduled","object":"webhook"}]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"id":"ev_16BjsrSIh6USvrIY","occurred_at":1607533916,"source":"admin_console","user":"user@example.com","object":"event","api_version":"v2","content":{"subscription":{"id":"16BjsrSIh6ByYrG1","plan_id":"__TEST__plan_1","plan_quantity":1,"plan_unit_price":3240,"billing_period":1,"billing_period_unit":"year","trial_end":1610125845,"customer_id":"169mBgSIh5VD5qka","plan_amount":3240,"plan_free_quantity":0,"status":"in_trial","trial_start":1607533845,"next_billing_at":1610125845,"created_at":1607533845,"started_at":1607533845,"updated_at":1607533916,"has_scheduled_changes":true,"resource_version":1607533916854,"deleted":false,"object":"subscription","currency_code":"USD","due_invoices_count":0,"shipping_address":{"state_code":"MD","state":"Maryland","country":"US","zip":"20745","validation_status":"not_validated","object":"shipping_address"}},"customer":{"id":"169mBgSIh5VD5qka","first_name":"Tax","last_name":"Customer 3","auto_collection":"on","net_term_days":0,"allow_direct_debit":false,"created_at":1607533681,"taxability":"taxable","updated_at":1607533702,"pii_cleared":"active","resource_version":1607533702528,"deleted":false,"object":"customer","billing_address":{"state_code":"MD","state":"Maryland","country":"US","zip":"20745","validation_status":"not_validated","object":"billing_address"},"card_status":"no_card","promotional_credits":0,"refundable_credits":0,"excess_payments":0,"unbilled_charges":0,"preferred_currency_code":"USD"}},"event_type":"subscription_changes_scheduled","webhook_status":"not_configured"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"id":"ev_AzqgumSAxXl56AxY","occurred_at":1600447774,"source":"admin_console","user":"user@example.com","object":"event","api_version":"v2","content":{"subscription":{"id":"AzqgumSAxXl3xAxW","customer_id":"16CHTnSAxXWqMAg8","plan_id":"test-company-custom-pro-plan","plan_quantity":1,"plan_unit_price":960000,"plan_amount":960000,"billing_period":1,"billing_period_unit":"year","plan_free_quantity":0,"status":"future","start_date":1601524800,"next_billing_at":1601524800,"created_at":1600447774,"updated_at":1600447774,"has_scheduled_changes":false,"resource_version":1600447774293,"deleted":false,"object":"subscription","currency_code":"USD","due_invoices_count":0},"customer":{"id":"16CHTnSAxXWqMAg8","company":"Test Company with Plan","auto_collection":"on","net_term_days":0,"allow_direct_debit":false,"created_at":1600447719,"taxability":"taxable","updated_at":1600447719,"locale":"en","pii_cleared":"active","resource_version":1600447719572,"deleted":false,"object":"customer","card_status":"no_card","promotional_credits":0,"refundable_credits":0,"excess_payments":0,"unbilled_charges":0,"preferred_currency_code":"USD"}},"event_type":"subscription_created","webhook_status":"not_configured"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"id":"ev_16BdGGSIsYup61CLM","occurred_at":1607703231,"source":"admin_console","user":"user@example.com","object":"event","api_version":"v2","content":{"subscription":{"id":"tax customer test","plan_id":"__TEST__plan_1","plan_quantity":1,"plan_unit_price":3240,"billing_period":1,"billing_period_unit":"year","trial_end":1610294795,"auto_collection":"off","customer_id":"16BjsrSIh4AdLqkD","plan_amount":3240,"plan_free_quantity":0,"status":"in_trial","trial_start":1607702795,"next_billing_at":1610294795,"created_at":1607702795,"started_at":1607702795,"updated_at":1607703231,"has_scheduled_changes":false,"resource_version":1607703231030,"deleted":true,"object":"subscription","currency_code":"USD","due_invoices_count":0,"shipping_address":{"state_code":"OH","state":"Ohio","country":"US","zip":"44145","validation_status":"valid","object":"shipping_address"}},"customer":{"id":"16BjsrSIh4AdLqkD","first_name":"Tax","last_name":"Customer","email":"taxes@test.com","auto_collection":"on","net_term_days":0,"allow_direct_debit":false,"created_at":1607533363,"taxability":"taxable","updated_at":1607703231,"locale":"en-US","pii_cleared":"active","resource_version":1607703231029,"deleted":false,"object":"customer","billing_address":{"state_code":"OH","state":"Ohio","country":"US","zip":"44145","validation_status":"not_validated","object":"billing_address"},"card_status":"no_card","promotional_credits":0,"refundable_credits":0,"excess_payments":0,"unbilled_charges":0,"preferred_currency_code":"USD"}},"event_type":"subscription_deleted","webhook_status":"not_configured"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"id":"ev_XpbG6hnQqGGAIg3a","occurred_at":1365018091,"source":"api","user":"full_access_key_v1","object":"event","api_version":"v2","content":{"subscription":{"id":"3Nl7oGgQqGFprj9","customer_id":"3Nl7oGgQqGFprj9","plan_id":"no_trial","plan_quantity":1,"plan_unit_price":1000,"billing_period":1,"billing_period_unit":"month","plan_free_quantity":0,"status":"active","trial_start":1341690024,"trial_end":1344368424,"current_term_start":1364845254,"current_term_end":1367437254,"created_at":1341085225,"started_at":1341690024,"activated_at":1362166854,"updated_at":1365018091,"has_scheduled_changes":false,"resource_version":1365018091000,"deleted":false,"object":"subscription","currency_code":"USD","addons":[{"id":"data_usage","quantity":1,"unit_price":95,"object":"addon"}],"due_invoices_count":1,"due_since":1364845254,"total_dues":224,"mrr":1095,"exchange_rate":1.0,"base_currency_code":"USD","pause_date":1367437254,"resume_date":1367610091},"customer":{"id":"3Nl7oGgQqGFprj9","first_name":"Joe","last_name":"Ross","email":"Benjamin@test.com","auto_collection":"on","net_term_days":0,"allow_direct_debit":false,"created_at":1341085225,"taxability":"taxable","updated_at":1364845255,"resource_version":1364845255000,"deleted":false,"object":"customer","card_status":"valid","primary_payment_source_id":"pm_3Nl7oGgQqGG6Jr42","payment_method":{"object":"payment_method","type":"card","reference_id":"tok_3Nl7oGgQqGG6Jl41","gateway":"chargebee","gateway_account_id":"gw_3Nl7oGgQqGFlba2","status":"valid"},"promotional_credits":0,"refundable_credits":0,"excess_payments":0,"unbilled_charges":0,"preferred_currency_code":"USD"}},"event_type":"subscription_pause_scheduled","webhook_status":"not_configured"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"id":"ev_XpbG6hnQqGGBCj3c","occurred_at":1365622909,"source":"api","user":"full_access_key_v1","object":"event","api_version":"v2","content":{"subscription":{"id":"3Nl7oGgQqGFprj9","customer_id":"3Nl7oGgQqGFprj9","plan_id":"no_trial","plan_quantity":1,"plan_unit_price":1000,"billing_period":1,"billing_period_unit":"month","plan_free_quantity":0,"status":"paused","trial_start":1341690024,"trial_end":1344368424,"current_term_start":1364845254,"current_term_end":1367437254,"created_at":1341085225,"started_at":1341690024,"activated_at":1362166854,"updated_at":1365622909,"has_scheduled_changes":false,"resource_version":1365622909000,"deleted":false,"object":"subscription","currency_code":"USD","addons":[{"id":"data_usage","quantity":1,"unit_price":95,"object":"addon"}],"due_invoices_count":1,"due_since":1364845254,"total_dues":224,"mrr":0,"pause_date":1365622909},"customer":{"id":"3Nl7oGgQqGFprj9","first_name":"Joe","last_name":"Ross","email":"Benjamin@test.com","auto_collection":"on","net_term_days":0,"allow_direct_debit":false,"created_at":1341085225,"taxability":"taxable","updated_at":1364845255,"resource_version":1364845255000,"deleted":false,"object":"customer","card_status":"valid","primary_payment_source_id":"pm_3Nl7oGgQqGG6Jr42","payment_method":{"object":"payment_method","type":"card","reference_id":"tok_3Nl7oGgQqGG6Jl41","gateway":"chargebee","gateway_account_id":"gw_3Nl7oGgQqGFlba2","status":"valid"},"promotional_credits":0,"refundable_credits":0,"excess_payments":0,"unbilled_charges":0,"preferred_currency_code":"USD"}},"event_type":"subscription_paused","webhook_status":"not_configured"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"id":"ev_3Nl7oGgQqGFzNh3B","occurred_at":1362166855,"source":"admin_console","object":"event","api_version":"v2","content":{"subscription":{"id":"3Nl7oGgQqGFprj9","customer_id":"3Nl7oGgQqGFprj9","plan_id":"basic","plan_quantity":1,"plan_unit_price":900,"billing_period":1,"billing_period_unit":"month","plan_free_quantity":0,"status":"active","trial_start":1341690024,"trial_end":1344368424,"current_term_start":1362166854,"current_term_end":1364845254,"next_billing_at":1364845254,"created_at":1341085225,"started_at":1341690024,"activated_at":1362166854,"updated_at":1362166855,"has_scheduled_changes":false,"resource_version":1362166855000,"deleted":false,"object":"subscription","currency_code":"USD","addons":[{"id":"data_usage","quantity":1,"unit_price":95,"object":"addon"}],"due_invoices_count":0,"mrr":995,"exchange_rate":1.0,"base_currency_code":"USD"},"customer":{"id":"3Nl7oGgQqGFprj9","first_name":"Benjamin","last_name":"Ross","email":"Benjamin@test.com","auto_collection":"on","net_term_days":0,"allow_direct_debit":false,"created_at":1341085225,"taxability":"taxable","updated_at":1349120450,"resource_version":1349120450000,"deleted":false,"object":"customer","card_status":"valid","primary_payment_source_id":"pm_3Nl7oGgQqGFwhb1k","payment_method":{"object":"payment_method","type":"card","reference_id":"tok_3Nl7oGgQqGFwhM1j","gateway":"chargebee","gateway_account_id":"gw_3Nl7oGgQqGFlba2","status":"valid"},"promotional_credits":0,"refundable_credits":0,"excess_payments":0,"unbilled_charges":0,"preferred_currency_code":"USD"},"invoice":{"id":"3","customer_id":"3Nl7oGgQqGFprj9","subscription_id":"3Nl7oGgQqGFprj9","recurring":true,"status":"paid","price_type":"tax_exclusive","date":1362166855,"due_date":1362166855,"net_term_days":0,"exchange_rate":1.0,"total":995,"amount_paid":995,"amount_adjusted":0,"write_off_amount":0,"credits_applied":0,"amount_due":0,"paid_at":1362166855,"updated_at":1362166855,"resource_version":1362166855000,"deleted":false,"object":"invoice","first_invoice":false,"amount_to_collect":0,"round_off_amount":0,"has_advance_charges":false,"currency_code":"USD","base_currency_code":"USD","tax":0,"line_items":[{"id":"li_3Nl7oGgQqGFzGn34","date_from":1362166854,"date_to":1364845254,"unit_amount":900,"quantity":1,"is_taxed":false,"tax_amount":0,"object":"line_item","subscription_id":"3Nl7oGgQqGFprj9","amount":900,"description":"Basic","entity_type":"plan","entity_id":"basic","tax_exempt_reason":"tax_not_configured","discount_amount":0,"item_level_discount_amount":0},{"id":"li_3Nl7oGgQqGFzHL35","date_from":1362166854,"date_to":1364845254,"unit_amount":95,"quantity":1,"is_taxed":false,"tax_amount":0,"object":"line_item","subscription_id":"3Nl7oGgQqGFprj9","amount":95,"description":"Data Usage","entity_type":"addon","entity_id":"data_usage","tax_exempt_reason":"tax_not_configured","discount_amount":0,"item_level_discount_amount":0}],"sub_total":995,"linked_payments":[{"txn_id":"txn_3Nl7oGgQqGFzJR36","applied_amount":995,"applied_at":1362166855,"txn_status":"success","txn_date":1362166855,"txn_amount":995}],"applied_credits":[],"adjustment_credit_notes":[],"issued_credit_notes":[],"linked_orders":[],"billing_address":{"first_name":"Benjamin","last_name":"Ross","validation_status":"not_validated","object":"billing_address"}}},"event_type":"subscription_reactivated","webhook_status":"not_configured"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"id":"ev_AzZbmXSCU0Fkn1uYQ","occurred_at":1601843541,"source":"scheduled_job","object":"event","api_version":"v2","content":{"subscription":{"id":"16CHTSRvVVFWPYD5","customer_id":"169yKyRvVEpMaX5Y","plan_id":"pro-monthly","plan_quantity":5,"plan_unit_price":500,"plan_amount":2500,"billing_period":1,"billing_period_unit":"month","plan_free_quantity":0,"status":"active","current_term_start":1599510735,"current_term_end":1602102735,"next_billing_at":1602102735,"created_at":1586291535,"started_at":1586291535,"activated_at":1586291535,"created_from_ip":"174.58.50.4","updated_at":1599510742,"has_scheduled_changes":false,"payment_source_id":"pm_16CHTSRvVErFsTzP","resource_version":1599510742262,"deleted":false,"object":"subscription","currency_code":"USD","due_invoices_count":0,"mrr":2500,"exchange_rate":1.0,"base_currency_code":"USD","shipping_address":{"first_name":"Michael","last_name":"Paravati","line1":"285 12th Avenue","city":"San Francisco","state_code":"AL","state":"Alabama","country":"US","zip":"94118","validation_status":"not_validated","object":"shipping_address"}},"customer":{"id":"169yKyRvVEpMaX5Y","first_name":"Michael","last_name":"Paravati","email":"michael@chargebee.com","phone":"2034703337","company":"Chargebee","auto_collection":"on","net_term_days":0,"allow_direct_debit":false,"created_at":1586287532,"taxability":"taxable","updated_at":1586291535,"pii_cleared":"active","resource_version":1586291535867,"deleted":false,"object":"customer","billing_address":{"first_name":"Michael","last_name":"Paravati","line1":"285 12th Avenue","city":"San Francisco","state_code":"AL","state":"Alabama","country":"US","zip":"94118","validation_status":"not_validated","object":"billing_address"},"card_status":"valid","promotional_credits":0,"refundable_credits":0,"excess_payments":0,"unbilled_charges":0,"preferred_currency_code":"USD","primary_payment_source_id":"pm_16CHTSRvVErFsTzP","payment_method":{"object":"payment_method","type":"card","reference_id":"tok_16CHTSRvVErFjTzO","gateway":"chargebee","gateway_account_id":"gw_AzqP3mRvV74yLIb","status":"valid"}}},"event_type":"subscription_renewal_reminder","webhook_status":"not_configured"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"id":"ev_16BgPKSClXogU2Eif","occurred_at":1602102737,"source":"scheduled_job","object":"event","api_version":"v2","content":{"subscription":{"id":"16CHTSRvVVFWPYD5","customer_id":"169yKyRvVEpMaX5Y","plan_id":"pro-monthly","plan_quantity":5,"plan_unit_price":500,"plan_amount":2500,"billing_period":1,"billing_period_unit":"month","plan_free_quantity":0,"status":"active","current_term_start":1602102735,"current_term_end":1604784735,"next_billing_at":1604784735,"created_at":1586291535,"started_at":1586291535,"activated_at":1586291535,"created_from_ip":"174.58.50.4","updated_at":1602102737,"has_scheduled_changes":false,"payment_source_id":"pm_16CHTSRvVErFsTzP","resource_version":1602102737750,"deleted":false,"object":"subscription","currency_code":"USD","due_invoices_count":0,"mrr":2500,"exchange_rate":1.0,"base_currency_code":"USD","shipping_address":{"first_name":"Michael","last_name":"Paravati","line1":"285 12th Avenue","city":"San Francisco","state_code":"AL","state":"Alabama","country":"US","zip":"94118","validation_status":"not_validated","object":"shipping_address"}},"customer":{"id":"169yKyRvVEpMaX5Y","first_name":"Michael","last_name":"Paravati","email":"michael@chargebee.com","phone":"2034703337","company":"Chargebee","auto_collection":"on","net_term_days":0,"allow_direct_debit":false,"created_at":1586287532,"taxability":"taxable","updated_at":1586291535,"pii_cleared":"active","resource_version":1586291535867,"deleted":false,"object":"customer","billing_address":{"first_name":"Michael","last_name":"Paravati","line1":"285 12th Avenue","city":"San Francisco","state_code":"AL","state":"Alabama","country":"US","zip":"94118","validation_status":"not_validated","object":"billing_address"},"card_status":"valid","promotional_credits":0,"refundable_credits":0,"excess_payments":0,"unbilled_charges":0,"preferred_currency_code":"USD","primary_payment_source_id":"pm_16CHTSRvVErFsTzP","payment_method":{"object":"payment_method","type":"card","reference_id":"tok_16CHTSRvVErFjTzO","gateway":"chargebee","gateway_account_id":"gw_AzqP3mRvV74yLIb","status":"valid"}},"invoice":{"id":"draft_inv_16BgPKSClXofl2Eic","customer_id":"169yKyRvVEpMaX5Y","subscription_id":"16CHTSRvVVFWPYD5","recurring":true,"status":"pending","price_type":"tax_exclusive","date":1602102735,"net_term_days":0,"exchange_rate":1.0,"total":2500,"amount_paid":0,"amount_adjusted":0,"write_off_amount":0,"credits_applied":0,"amount_due":2500,"updated_at":1602102737,"resource_version":1602102737738,"deleted":false,"object":"invoice","first_invoice":false,"amount_to_collect":2500,"round_off_amount":0,"has_advance_charges":false,"currency_code":"USD","base_currency_code":"USD","is_gifted":false,"term_finalized":true,"tax":0,"line_items":[{"id":"li_16BgPKSClXofU2Eib","date_from":1602102735,"date_to":1604784735,"unit_amount":500,"quantity":5,"amount":2500,"pricing_model":"per_unit","is_taxed":false,"tax_amount":0,"object":"line_item","subscription_id":"16CHTSRvVVFWPYD5","customer_id":"169yKyRvVEpMaX5Y","description":"Pro MONTHLY","entity_type":"plan","entity_id":"pro-monthly","discount_amount":0,"item_level_discount_amount":0}],"sub_total":2500,"linked_payments":[],"dunning_attempts":[],"applied_credits":[],"adjustment_credit_notes":[],"issued_credit_notes":[],"linked_orders":[]}},"event_type":"subscription_renewed","webhook_status":"not_configured"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"id":"ev_XpbG6hnQqGGBdj3f","occurred_at":1366832511,"source":"api","user":"full_access_key_v1","object":"event","api_version":"v2","content":{"subscription":{"id":"3Nl7oGgQqGFprj9","customer_id":"3Nl7oGgQqGFprj9","plan_id":"no_trial","plan_quantity":1,"plan_unit_price":1000,"billing_period":1,"billing_period_unit":"month","plan_free_quantity":0,"status":"active","trial_start":1341690024,"trial_end":1344368424,"current_term_start":1364845254,"current_term_end":1367437254,"next_billing_at":1367437254,"created_at":1341085225,"started_at":1341690024,"activated_at":1362166854,"updated_at":1366832511,"has_scheduled_changes":false,"resource_version":1366832511000,"deleted":false,"object":"subscription","currency_code":"USD","addons":[{"id":"data_usage","quantity":1,"unit_price":95,"object":"addon"}],"due_invoices_count":0,"mrr":1095,"exchange_rate":1.0,"base_currency_code":"USD"},"customer":{"id":"3Nl7oGgQqGFprj9","first_name":"Joe","last_name":"Ross","email":"Benjamin@test.com","auto_collection":"on","net_term_days":0,"allow_direct_debit":false,"created_at":1341085225,"taxability":"taxable","updated_at":1366832511,"resource_version":1366832511000,"deleted":false,"object":"customer","card_status":"valid","primary_payment_source_id":"pm_3Nl7oGgQqGGBWR5i","payment_method":{"object":"payment_method","type":"card","reference_id":"tok_3Nl7oGgQqGGBWG5h","gateway":"chargebee","gateway_account_id":"gw_3Nl7oGgQqGFlba2","status":"valid"},"promotional_credits":0,"refundable_credits":0,"excess_payments":0,"unbilled_charges":0,"preferred_currency_code":"USD"}},"event_type":"subscription_resumed","webhook_status":"not_configured"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"id":"ev_XpbG6hnQqGGBJz3d","occurred_at":1365968510,"source":"api","user":"full_access_key_v1","object":"event","api_version":"v2","content":{"subscription":{"id":"3Nl7oGgQqGFprj9","customer_id":"3Nl7oGgQqGFprj9","plan_id":"no_trial","plan_quantity":1,"plan_unit_price":1000,"billing_period":1,"billing_period_unit":"month","plan_free_quantity":0,"status":"paused","trial_start":1341690024,"trial_end":1344368424,"current_term_start":1364845254,"current_term_end":1367437254,"created_at":1341085225,"started_at":1341690024,"activated_at":1362166854,"updated_at":1365968510,"has_scheduled_changes":false,"resource_version":1365968510000,"deleted":false,"object":"subscription","currency_code":"USD","addons":[{"id":"data_usage","quantity":1,"unit_price":95,"object":"addon"}],"due_invoices_count":1,"due_since":1364845254,"total_dues":224,"mrr":0,"pause_date":1365622909,"resume_date":1368560510},"customer":{"id":"3Nl7oGgQqGFprj9","first_name":"Joe","last_name":"Ross","email":"Benjamin@test.com","auto_collection":"on","net_term_days":0,"allow_direct_debit":false,"created_at":1341085225,"taxability":"taxable","updated_at":1364845255,"resource_version":1364845255000,"deleted":false,"object":"customer","card_status":"valid","primary_payment_source_id":"pm_3Nl7oGgQqGG6Jr42","payment_method":{"object":"payment_method","type":"card","reference_id":"tok_3Nl7oGgQqGG6Jl41","gateway":"chargebee","gateway_account_id":"gw_3Nl7oGgQqGFlba2","status":"valid"},"promotional_credits":0,"refundable_credits":0,"excess_payments":0,"unbilled_charges":0,"preferred_currency_code":"USD"}},"event_type":"subscription_resumption_scheduled","webhook_status":"not_configured"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"id":"ev_3Nl7oGgQqGFzaO3J","occurred_at":1362253265,"source":"admin_console","object":"event","api_version":"v2","content":{"subscription":{"id":"3Nl7oGgQqGFprj9","customer_id":"3Nl7oGgQqGFprj9","plan_id":"basic","plan_quantity":1,"plan_unit_price":900,"billing_period":1,"billing_period_unit":"month","plan_free_quantity":0,"status":"active","trial_start":1341690024,"trial_end":1344368424,"current_term_start":1362166854,"current_term_end":1364845254,"next_billing_at":1364845254,"created_at":1341085225,"started_at":1341690024,"activated_at":1362166854,"updated_at":1362253264,"has_scheduled_changes":false,"resource_version":1362253264000,"deleted":false,"object":"subscription","currency_code":"USD","addons":[{"id":"data_usage","quantity":1,"unit_price":95,"object":"addon"}],"due_invoices_count":0,"mrr":995,"exchange_rate":1.0,"base_currency_code":"USD"},"customer":{"id":"3Nl7oGgQqGFprj9","first_name":"Benjamin","last_name":"Ross","email":"Benjamin@test.com","auto_collection":"on","net_term_days":0,"allow_direct_debit":false,"created_at":1341085225,"taxability":"taxable","updated_at":1349120450,"resource_version":1349120450000,"deleted":false,"object":"customer","card_status":"valid","primary_payment_source_id":"pm_3Nl7oGgQqGFwhb1k","payment_method":{"object":"payment_method","type":"card","reference_id":"tok_3Nl7oGgQqGFwhM1j","gateway":"chargebee","gateway_account_id":"gw_3Nl7oGgQqGFlba2","status":"valid"},"promotional_credits":0,"refundable_credits":0,"excess_payments":0,"unbilled_charges":0,"preferred_currency_code":"USD"}},"event_type":"subscription_scheduled_cancellation_removed","webhook_status":"not_configured"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"id":"ev_XpbG6hnQqGFzn73W","occurred_at":1362253265,"source":"api","user":"full_access_key_v1","object":"event","api_version":"v2","content":{"subscription":{"id":"3Nl7oGgQqGFprj9","customer_id":"3Nl7oGgQqGFprj9","plan_id":"basic","plan_quantity":1,"plan_unit_price":900,"billing_period":1,"billing_period_unit":"month","plan_free_quantity":0,"status":"active","trial_start":1341690024,"trial_end":1344368424,"current_term_start":1362166854,"current_term_end":1364845254,"next_billing_at":1364845254,"created_at":1341085225,"started_at":1341690024,"activated_at":1362166854,"updated_at":1362253265,"has_scheduled_changes":false,"resource_version":1362253265000,"deleted":false,"object":"subscription","currency_code":"USD","addons":[{"id":"data_usage","quantity":1,"unit_price":95,"object":"addon"}],"due_invoices_count":0,"mrr":995,"exchange_rate":1.0,"base_currency_code":"USD"},"customer":{"id":"3Nl7oGgQqGFprj9","first_name":"Benjamin","last_name":"Ross","email":"Benjamin@test.com","auto_collection":"on","net_term_days":0,"allow_direct_debit":false,"created_at":1341085225,"taxability":"taxable","updated_at":1349120450,"resource_version":1349120450000,"deleted":false,"object":"customer","card_status":"valid","primary_payment_source_id":"pm_3Nl7oGgQqGFwhb1k","payment_method":{"object":"payment_method","type":"card","reference_id":"tok_3Nl7oGgQqGFwhM1j","gateway":"chargebee","gateway_account_id":"gw_3Nl7oGgQqGFlba2","status":"valid"},"promotional_credits":0,"refundable_credits":0,"excess_payments":0,"unbilled_charges":0,"preferred_currency_code":"USD"}},"event_type":"subscription_scheduled_changes_removed","webhook_status":"not_configured"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"id":"ev_XpbG6hnQqGGAzq3b","occurred_at":1365536507,"source":"api","user":"full_access_key_v1","object":"event","api_version":"v2","content":{"subscription":{"id":"3Nl7oGgQqGFprj9","customer_id":"3Nl7oGgQqGFprj9","plan_id":"no_trial","plan_quantity":1,"plan_unit_price":1000,"billing_period":1,"billing_period_unit":"month","plan_free_quantity":0,"status":"active","trial_start":1341690024,"trial_end":1344368424,"current_term_start":1364845254,"current_term_end":1367437254,"next_billing_at":1367437254,"created_at":1341085225,"started_at":1341690024,"activated_at":1362166854,"updated_at":1365536507,"has_scheduled_changes":false,"resource_version":1365536507000,"deleted":false,"object":"subscription","currency_code":"USD","addons":[{"id":"data_usage","quantity":1,"unit_price":95,"object":"addon"}],"due_invoices_count":1,"due_since":1364845254,"total_dues":224,"mrr":1095,"exchange_rate":1.0,"base_currency_code":"USD"},"customer":{"id":"3Nl7oGgQqGFprj9","first_name":"Joe","last_name":"Ross","email":"Benjamin@test.com","auto_collection":"on","net_term_days":0,"allow_direct_debit":false,"created_at":1341085225,"taxability":"taxable","updated_at":1364845255,"resource_version":1364845255000,"deleted":false,"object":"customer","card_status":"valid","primary_payment_source_id":"pm_3Nl7oGgQqGG6Jr42","payment_method":{"object":"payment_method","type":"card","reference_id":"tok_3Nl7oGgQqGG6Jl41","gateway":"chargebee","gateway_account_id":"gw_3Nl7oGgQqGFlba2","status":"valid"},"promotional_credits":0,"refundable_credits":0,"excess_payments":0,"unbilled_charges":0,"preferred_currency_code":"USD"}},"event_type":"subscription_scheduled_pause_removed","webhook_status":"not_configured"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"id":"ev_XpbG6hnQqGGBQW3e","occurred_at":1366400511,"source":"api","user":"full_access_key_v1","object":"event","api_version":"v2","content":{"subscription":{"id":"3Nl7oGgQqGFprj9","customer_id":"3Nl7oGgQqGFprj9","plan_id":"no_trial","plan_quantity":1,"plan_unit_price":1000,"billing_period":1,"billing_period_unit":"month","plan_free_quantity":0,"status":"paused","trial_start":1341690024,"trial_end":1344368424,"current_term_start":1364845254,"current_term_end":1367437254,"created_at":1341085225,"started_at":1341690024,"activated_at":1362166854,"updated_at":1366400510,"has_scheduled_changes":false,"resource_version":1366400510000,"deleted":false,"object":"subscription","currency_code":"USD","addons":[{"id":"data_usage","quantity":1,"unit_price":95,"object":"addon"}],"due_invoices_count":1,"due_since":1364845254,"total_dues":224,"mrr":0,"pause_date":1365622909},"customer":{"id":"3Nl7oGgQqGFprj9","first_name":"Joe","last_name":"Ross","email":"Benjamin@test.com","auto_collection":"on","net_term_days":0,"allow_direct_debit":false,"created_at":1341085225,"taxability":"taxable","updated_at":1364845255,"resource_version":1364845255000,"deleted":false,"object":"customer","card_status":"valid","primary_payment_source_id":"pm_3Nl7oGgQqGG6Jr42","payment_method":{"object":"payment_method","type":"card","reference_id":"tok_3Nl7oGgQqGG6Jl41","gateway":"chargebee","gateway_account_id":"gw_3Nl7oGgQqGFlba2","status":"valid"},"promotional_credits":0,"refundable_credits":0,"excess_payments":0,"unbilled_charges":0,"preferred_currency_code":"USD"}},"event_type":"subscription_scheduled_resumption_removed","webhook_status":"not_configured"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"id":"ev_3Nl7oGgQqGGCuE6R","occurred_at":1367523714,"source":"admin_console","object":"event","api_version":"v2","content":{"subscription":{"id":"3Nl7oGgQqGFprj9","customer_id":"3Nl7oGgQqGFprj9","plan_id":"no_trial","plan_quantity":1,"plan_unit_price":1000,"billing_period":1,"billing_period_unit":"month","plan_free_quantity":0,"status":"active","trial_start":1341690024,"trial_end":1344368424,"current_term_start":1367437254,"current_term_end":1370115654,"next_billing_at":1370115654,"created_at":1341085225,"started_at":1341690024,"activated_at":1362166854,"updated_at":1367523714,"has_scheduled_changes":false,"resource_version":1367523714000,"deleted":false,"object":"subscription","currency_code":"USD","addons":[{"id":"data_usage","quantity":1,"unit_price":95,"object":"addon"}],"due_invoices_count":1,"due_since":1367437254,"total_dues":1095,"mrr":1095,"exchange_rate":1.0,"base_currency_code":"USD","shipping_address":{"first_name":"Benjamin","last_name":"Ross","company":"Acme Inc","phone":"+1 (614) 226-4809","line1":"345, Redington Av","line2":"Suite 1200","city":"Los Angeles","state_code":"CA","state":"California","country":"US","validation_status":"not_validated","object":"shipping_address"}},"customer":{"id":"3Nl7oGgQqGFprj9","first_name":"Joe","last_name":"Ross","email":"Benjamin@test.com","auto_collection":"off","net_term_days":0,"allow_direct_debit":false,"created_at":1341085225,"taxability":"taxable","updated_at":1367523714,"resource_version":1367523714000,"deleted":false,"object":"customer","card_status":"no_card","promotional_credits":0,"refundable_credits":0,"excess_payments":0,"unbilled_charges":0,"preferred_currency_code":"USD"}},"event_type":"subscription_shipping_address_updated","webhook_status":"not_configured"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"id":"ev_3Nl7oGgQqGFr8LT","occurred_at":1341690025,"source":"scheduled_job","object":"event","api_version":"v2","content":{"subscription":{"id":"3Nl7oGgQqGFprj9","customer_id":"3Nl7oGgQqGFprj9","plan_id":"basic","plan_quantity":1,"plan_unit_price":900,"billing_period":1,"billing_period_unit":"month","plan_free_quantity":0,"status":"in_trial","trial_start":1341690024,"trial_end":1344368424,"next_billing_at":1344368424,"created_at":1341085225,"started_at":1341690024,"updated_at":1341690025,"has_scheduled_changes":false,"resource_version":1341690025000,"deleted":false,"object":"subscription","currency_code":"USD","addons":[{"id":"data_usage","quantity":1,"unit_price":95,"object":"addon"}],"due_invoices_count":0},"customer":{"id":"3Nl7oGgQqGFprj9","first_name":"Benjamin","last_name":"Ross","email":"Benjamin@test.com","auto_collection":"on","net_term_days":0,"allow_direct_debit":false,"created_at":1341085225,"taxability":"taxable","updated_at":1341085225,"resource_version":1341085225000,"deleted":false,"object":"customer","card_status":"valid","primary_payment_source_id":"pm_3Nl7oGgQqGFpzgB","payment_method":{"object":"payment_method","type":"card","reference_id":"tok_3Nl7oGgQqGFpzJA","gateway":"chargebee","gateway_account_id":"gw_3Nl7oGgQqGFlba2","status":"valid"},"promotional_credits":0,"refundable_credits":0,"excess_payments":0,"unbilled_charges":0,"preferred_currency_code":"USD"}},"event_type":"subscription_started","webhook_status":"not_configured"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"id":"ev_3Nl7oGgQqGFrabZ","occurred_at":1343850025,"source":"scheduled_job","object":"event","api_version":"v2","content":{"subscription":{"id":"3Nl7oGgQqGFprj9","customer_id":"3Nl7oGgQqGFprj9","plan_id":"basic","plan_quantity":1,"plan_unit_price":900,"billing_period":1,"billing_period_unit":"month","plan_free_quantity":0,"status":"in_trial","trial_start":1341690024,"trial_end":1344368424,"next_billing_at":1344368424,"created_at":1341085225,"started_at":1341690024,"updated_at":1341690026,"has_scheduled_changes":false,"resource_version":1341690026000,"deleted":false,"object":"subscription","currency_code":"USD","addons":[{"id":"data_usage","quantity":1,"unit_price":95,"object":"addon"}],"due_invoices_count":0},"customer":{"id":"3Nl7oGgQqGFprj9","first_name":"Benjamin","last_name":"Ross","email":"Benjamin@test.com","auto_collection":"on","net_term_days":0,"allow_direct_debit":false,"created_at":1341085225,"taxability":"taxable","updated_at":1341085225,"resource_version":1341085225000,"deleted":false,"object":"customer","card_status":"valid","primary_payment_source_id":"pm_3Nl7oGgQqGFpzgB","payment_method":{"object":"payment_method","type":"card","reference_id":"tok_3Nl7oGgQqGFpzJA","gateway":"chargebee","gateway_account_id":"gw_3Nl7oGgQqGFlba2","status":"valid"},"promotional_credits":0,"refundable_credits":0,"excess_payments":0,"unbilled_charges":0,"preferred_currency_code":"USD"}},"event_type":"subscription_trial_end_reminder","webhook_status":"not_configured"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"id":"ev_XpbG6hnQqGGHFY3p","occurred_at":1367523730,"source":"admin_console","user":"rr@mannar.com","object":"event","api_version":"v2","content":{"transaction":{"id":"txn_XpbG6hnQqGGHEQ3m","customer_id":"3Nl7oGgQqGFqO7H","payment_method":"check","gateway":"not_applicable","type":"payment","date":1367523733,"exchange_rate":1.0,"amount":100000,"status":"success","updated_at":1367523730,"resource_version":1367523730000,"deleted":false,"object":"transaction","currency_code":"USD","base_currency_code":"USD","amount_unused":100000,"linked_invoices":[],"linked_refunds":[]}},"event_type":"transaction_created","webhook_status":"not_configured"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"id":"ev_XpbG6hnQqGGLN33v","occurred_at":1367523746,"source":"admin_console","user":"rr@mannar.com","object":"event","api_version":"v2","content":{"transaction":{"id":"txn_XpbG6hnQqGGJZz3q","customer_id":"XpbG6hnQqGGD0P3g","payment_method":"cash","gateway":"not_applicable","type":"refund","date":1367523742,"exchange_rate":1.0,"amount":50000,"status":"success","updated_at":1367523746,"resource_version":1367523746000,"deleted":true,"object":"transaction","linked_credit_notes":[],"currency_code":"USD","base_currency_code":"USD"}},"event_type":"transaction_deleted","webhook_status":"not_configured"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"id":"ev_3Nl7oGgQqGG6GP3t","occurred_at":1362253290,"source":"admin_console","object":"event","api_version":"v2","content":{"transaction":{"id":"txn_3Nl7oGgQqGG4tN3n","customer_id":"createSubs","subscription_id":"createSubs","gateway_account_id":"gw_3Nl7oGgQqGFoyZ6","payment_source_id":"pm_XpbG6hnQqGG3Xo3X","payment_method":"direct_debit","gateway":"authorize_net","type":"payment","date":1362253285,"settled_at":1362253290,"exchange_rate":1.0,"amount":1000,"id_at_gateway":"60102328511","status":"success","updated_at":1362253290,"resource_version":1362253290000,"deleted":false,"object":"transaction","currency_code":"USD","base_currency_code":"USD","amount_unused":0,"linked_invoices":[{"invoice_id":"4","applied_amount":1000,"applied_at":1362253290,"invoice_date":1362253285,"invoice_total":1000,"invoice_status":"paid"}],"linked_refunds":[]}},"event_type":"transaction_updated","webhook_status":"not_configured"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"id":"ev_16BjsrSIh5vgNrBz","occurred_at":1607533783,"source":"admin_console","user":"user@example.com","object":"event","api_version":"v2","content":{"unbilled_charges":[{"id":"li_16BjsrSIh5vfKrBx","customer_id":"16BjsrSIh4AdLqkD","subscription_id":"16BjsrSIh5veWrBv","date_from":1607533783,"date_to":1639069783,"unit_amount":5400,"pricing_model":"per_unit","quantity":6,"amount":32400,"discount_amount":0,"description":"Test Plan","entity_id":"__TEST__plan_1","is_voided":false,"deleted":false,"object":"unbilled_charge","entity_type":"plan","currency_code":"USD"}]},"event_type":"unbilled_charges_created","webhook_status":"not_configured"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"id":"ev_Azyu6ASIsZb4ef2C","occurred_at":1607703393,"source":"admin_console","user":"user@example.com","object":"event","api_version":"v2","content":{"unbilled_charges":[{"id":"li_169mBgSIh62TSqrV","customer_id":"AzyuGwSIh59g5r9P","subscription_id":"169mBgSIh62SzqrT","date_from":1607533809,"date_to":1610212209,"unit_amount":300,"pricing_model":"per_unit","quantity":72,"amount":21600,"discount_amount":0,"description":"Test Plan","entity_id":"__TEST__plan_1","is_voided":false,"deleted":true,"object":"unbilled_charge","entity_type":"plan","currency_code":"USD"}]},"event_type":"unbilled_charges_deleted","webhook_status":"not_configured"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"id":"ev_Azyu6ASIsVQnoe0R","occurred_at":1607702400,"source":"admin_console","user":"user@example.com","object":"event","api_version":"v2","content":{"unbilled_charges":[{"id":"li_16BjsrSIh5vfKrBx","customer_id":"16BjsrSIh4AdLqkD","subscription_id":"16BjsrSIh5veWrBv","date_from":1607533783,"date_to":1639069783,"unit_amount":5400,"pricing_model":"per_unit","quantity":6,"amount":32400,"discount_amount":0,"description":"Test Plan","entity_id":"__TEST__plan_1","is_voided":false,"deleted":false,"object":"unbilled_charge","entity_type":"plan","currency_code":"USD"}],"invoice":{"id":"21","customer_id":"16BjsrSIh4AdLqkD","subscription_id":"16BjsrSIh5veWrBv","recurring":true,"status":"payment_due","price_type":"tax_exclusive","date":1607702400,"due_date":1607702400,"net_term_days":0,"exchange_rate":1.0,"total":32400,"amount_paid":0,"amount_adjusted":0,"write_off_amount":0,"credits_applied":0,"amount_due":32400,"dunning_status":"in_progress","next_retry_at":1607788800,"updated_at":1607702400,"resource_version":1607702400628,"deleted":false,"object":"invoice","first_invoice":true,"amount_to_collect":32400,"round_off_amount":0,"new_sales_amount":32400,"has_advance_charges":false,"currency_code":"USD","base_currency_code":"USD","is_gifted":false,"term_finalized":true,"tax":0,"line_items":[{"id":"li_16BjsrSIh5vfKrBx","date_from":1607533783,"date_to":1639069783,"unit_amount":5400,"quantity":6,"amount":32400,"pricing_model":"per_unit","is_taxed":false,"tax_amount":0,"object":"line_item","subscription_id":"16BjsrSIh5veWrBv","customer_id":"16BjsrSIh4AdLqkD","description":"Test Plan","entity_type":"plan","entity_id":"__TEST__plan_1","discount_amount":0,"item_level_discount_amount":0}],"sub_total":32400,"linked_payments":[],"dunning_attempts":[],"applied_credits":[],"adjustment_credit_notes":[],"issued_credit_notes":[],"linked_orders":[],"billing_address":{"first_name":"Tax","last_name":"Customer","state_code":"OH","state":"Ohio","country":"US","zip":"44145","validation_status":"not_validated","object":"billing_address"},"shipping_address":{"state_code":"OH","state":"Ohio","country":"US","zip":"44145","validation_status":"valid","object":"shipping_address"}}},"event_type":"unbilled_charges_invoiced","webhook_status":"not_configured"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"id":"ev_XpbG6hnQqGGQ5c4N","occurred_at":1357069367,"source":"api","user":"full_access_key_v1","object":"event","api_version":"v2","content":{"unbilled_charges":[{"id":"li_XpbG6hnQqGGPt14E","customer_id":"ubc_create","subscription_id":"ubc_create","date_from":1357069366,"date_to":1359747766,"unit_amount":1000,"quantity":4,"amount":4000,"discount_amount":0,"description":"No Trial","entity_id":"no_trial","is_voided":true,"voided_at":1357069367,"deleted":false,"object":"unbilled_charge","entity_type":"plan","currency_code":"USD"}]},"event_type":"unbilled_charges_voided","webhook_status":"not_configured"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"id":"ev_XpbG6hnQqGGiNL4i","occurred_at":1368301437,"source":"api","user":"full_access_key_v1","object":"event","api_version":"v2","content":{"customer":{"id":"XpbG6hnQqGGhhG4e","first_name":"Mannar","last_name":"Test","email":"sample@sample.com","auto_collection":"on","net_term_days":0,"allow_direct_debit":false,"created_at":1368301435,"taxability":"taxable","updated_at":1368301437,"resource_version":1368301437000,"deleted":false,"object":"customer","billing_address":{"city":"SA","country":"US","validation_status":"not_validated","object":"billing_address"},"card_status":"no_card","promotional_credits":0,"refundable_credits":0,"excess_payments":0,"unbilled_charges":0,"preferred_currency_code":"GBP"},"virtual_bank_account":{"id":"vba_XpbG6hnQqGGiMj4h","email":"sample@sample.com","bank_name":"TEST BANK","account_number":"test_bc817c0528d3","routing_number":"110000000","swift_code":"TSTEZ122","gateway":"stripe","gateway_account_id":"gw_3Nl7oGgQqGFoyq8","deleted":false,"object":"virtual_bank_account","customer_id":"XpbG6hnQqGGhhG4e","reference_id":"cus_CkOJ9535cKdXZf/src_CkOJvdrGfy3BJa"}},"event_type":"virtual_bank_account_added","webhook_status":"scheduled"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"id":"ev_XpbG6hnQqGGihm4l","occurred_at":1368301438,"source":"api","user":"full_access_key_v1","object":"event","api_version":"v2","content":{"virtual_bank_account":{"id":"vba_XpbG6hnQqGGiMj4h","email":"sample2@sample.com","bank_name":"TEST BANK","account_number":"test_bc817c0528d3","routing_number":"110000000","swift_code":"TSTEZ122","gateway":"stripe","gateway_account_id":"gw_3Nl7oGgQqGFoyq8","deleted":true,"object":"virtual_bank_account","customer_id":"XpbG6hnQqGGhhG4e","reference_id":"cus_CkOJ9535cKdXZf/src_CkOJvdrGfy3BJa"}},"event_type":"virtual_bank_account_deleted","webhook_status":"scheduled"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"id":"ev_XpbG6hnQqGGiYA4j","occurred_at":1368301438,"source":"api","user":"full_access_key_v1","object":"event","api_version":"v2","content":{"customer":{"id":"XpbG6hnQqGGhhG4e","first_name":"Mannar","last_name":"Test","email":"sample2@sample.com","auto_collection":"on","net_term_days":0,"allow_direct_debit":false,"created_at":1368301435,"taxability":"taxable","updated_at":1368301438,"resource_version":1368301438000,"deleted":false,"object":"customer","billing_address":{"city":"SA","country":"US","validation_status":"not_validated","object":"billing_address"},"card_status":"no_card","promotional_credits":0,"refundable_credits":0,"excess_payments":0,"unbilled_charges":0,"preferred_currency_code":"GBP"},"virtual_bank_account":{"id":"vba_XpbG6hnQqGGiMj4h","email":"sample2@sample.com","bank_name":"TEST BANK","account_number":"test_bc817c0528d3","routing_number":"110000000","swift_code":"TSTEZ122","gateway":"stripe","gateway_account_id":"gw_3Nl7oGgQqGFoyq8","deleted":false,"object":"virtual_bank_account","customer_id":"XpbG6hnQqGGhhG4e","reference_id":"cus_CkOJ9535cKdXZf/src_CkOJvdrGfy3BJa"}},"event_type":"virtual_bank_account_updated","webhook_status":"scheduled"}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MockChargebee
|
4
|
+
module Models
|
5
|
+
class Base
|
6
|
+
def self.repositories
|
7
|
+
MockChargebee.environment.repositories
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.unique_id
|
11
|
+
Util.generate_id(self::RESOURCE_ID_PREFIX)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.load_fixtures(*args)
|
15
|
+
args.each do |arg|
|
16
|
+
define_singleton_method("#{arg}_fixture") do
|
17
|
+
instance_variable_get("@#{arg}_fixture") ||
|
18
|
+
instance_variable_set("@#{arg}_fixture", JSON.parse(File.read("#{File.dirname(__FILE__)}/../fixtures/#{arg}.json")))
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MockChargebee
|
4
|
+
module Models
|
5
|
+
class Coupon < Base
|
6
|
+
RESOURCE_ID_PREFIX = "coup"
|
7
|
+
|
8
|
+
load_fixtures :coupon
|
9
|
+
|
10
|
+
def self.find(id)
|
11
|
+
repositories.coupons.fetch(id)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.create(params)
|
15
|
+
Validations::Coupons::CreateParams.validate_required(params)
|
16
|
+
|
17
|
+
params["id"] ||= unique_id
|
18
|
+
coupon = coupon_fixture.merge(params)
|
19
|
+
repositories.coupons.store(coupon["id"], coupon)
|
20
|
+
|
21
|
+
coupon
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MockChargebee
|
4
|
+
module Models
|
5
|
+
class Customer < Base
|
6
|
+
RESOURCE_ID_PREFIX = "cust"
|
7
|
+
|
8
|
+
load_fixtures :customer
|
9
|
+
|
10
|
+
def self.find(id)
|
11
|
+
repositories.customers.fetch(id)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.create(params)
|
15
|
+
params["id"] ||= unique_id
|
16
|
+
customer = customer_fixture.merge(params)
|
17
|
+
repositories.customers.store(customer["id"], customer)
|
18
|
+
|
19
|
+
customer
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MockChargebee
|
4
|
+
module Models
|
5
|
+
class Subscription < Base
|
6
|
+
RESOURCE_ID_PREFIX = "sub"
|
7
|
+
|
8
|
+
load_fixtures :subscription
|
9
|
+
|
10
|
+
def self.find(id)
|
11
|
+
repositories.subscriptions.fetch(id)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.create(params)
|
15
|
+
Validations::Subscriptions::CreateParams.validate_required(params)
|
16
|
+
params["id"] ||= unique_id
|
17
|
+
|
18
|
+
customer_params = params.delete("customer")
|
19
|
+
customer = Customer.create(customer_params)
|
20
|
+
|
21
|
+
coupon_ids = params.delete("coupon_ids")
|
22
|
+
params["coupons"] = Services::CouponsForSubscription.new(coupon_ids).call
|
23
|
+
|
24
|
+
params["customer_id"] = customer["id"]
|
25
|
+
|
26
|
+
subscription = subscription_fixture.merge(params)
|
27
|
+
|
28
|
+
repositories.subscriptions.store(params["id"], subscription)
|
29
|
+
|
30
|
+
[subscription, customer]
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.create_for_customer(customer, params)
|
34
|
+
params["id"] ||= unique_id
|
35
|
+
subscription = subscription_fixture.merge(params)
|
36
|
+
subscription["customer_id"] = customer["id"]
|
37
|
+
|
38
|
+
repositories.subscriptions.store(subscription["id"], subscription)
|
39
|
+
|
40
|
+
subscription
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.update(id, params)
|
44
|
+
subscription = find(id)
|
45
|
+
subscription.merge!(params)
|
46
|
+
repositories.subscriptions.store(subscription["id"], subscription)
|
47
|
+
|
48
|
+
subscription
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.cancel(id, params)
|
52
|
+
subscription = find(id)
|
53
|
+
subscription.merge!(params.merge({ "status" => "cancelled", "canceled_at" => Time.now.to_i }))
|
54
|
+
repositories.subscriptions.store(subscription["id"], subscription)
|
55
|
+
|
56
|
+
subscription
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.reactivate(id, params)
|
60
|
+
subscription = find(id)
|
61
|
+
subscription.merge!(params.merge({ "status" => "active", "started_at" => Time.now.to_i }))
|
62
|
+
repositories.subscriptions.store(subscription["id"], subscription)
|
63
|
+
|
64
|
+
subscription
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MockChargebee
|
4
|
+
class Repositories
|
5
|
+
def self.add_repositories(*args)
|
6
|
+
args.each do |arg|
|
7
|
+
define_method(arg) do
|
8
|
+
instance_variable_get("@#{arg}") || instance_variable_set("@#{arg}", RepoHash.new)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
add_repositories :customers,
|
14
|
+
:subscriptions,
|
15
|
+
:coupons
|
16
|
+
|
17
|
+
class RepoHash < Hash
|
18
|
+
def fetch(*)
|
19
|
+
super
|
20
|
+
rescue KeyError => e
|
21
|
+
raise ChargeBee::InvalidRequestError.new(404, message: "#{e.key} not found")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MockChargebee
|
4
|
+
module Request
|
5
|
+
def self.request(method, url, _env, params = {}, _headers = {})
|
6
|
+
parsed_path = Util.parse_path_from_url(url)
|
7
|
+
parsed_params = Util.parse_params(params)
|
8
|
+
|
9
|
+
handler = RequestHandlers.const_get(parsed_path.resource.capitalize)
|
10
|
+
resp = handler.call(method, parsed_path, parsed_params)
|
11
|
+
resp = ChargeBee::Util.symbolize_keys(resp)
|
12
|
+
resp
|
13
|
+
rescue NameError => e
|
14
|
+
raise MockChargebee::MissingRequestHandler parsed_path.resource if e.message.match?(/uninitialized constant #{parsed_path.resource.capitalize}/)
|
15
|
+
|
16
|
+
raise e
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MockChargebee
|
4
|
+
module RequestHandlers
|
5
|
+
class Base
|
6
|
+
def self.call(http_method, parsed_path, params = {})
|
7
|
+
new(http_method, parsed_path, params).call
|
8
|
+
end
|
9
|
+
|
10
|
+
def initialize(http_method, parsed_path, params)
|
11
|
+
@http_method = http_method
|
12
|
+
@parsed_path = parsed_path
|
13
|
+
@params = params
|
14
|
+
@env = MockChargebee.environment
|
15
|
+
end
|
16
|
+
|
17
|
+
def call
|
18
|
+
send("#{http_method}#{sub_command}")
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
attr_reader :http_method, :parsed_path, :params, :env
|
24
|
+
|
25
|
+
delegate :id, :sub_command, to: :parsed_path
|
26
|
+
|
27
|
+
def self.load_fixtures(*args)
|
28
|
+
args.each do |arg|
|
29
|
+
define_method("#{arg}_fixture") do
|
30
|
+
instance_variable_get("@#{arg}_fixture") ||
|
31
|
+
instance_variable_set("@#{arg}_fixture", JSON.parse(File.read("#{File.dirname(__FILE__)}/../fixtures/#{arg}.json")))
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MockChargebee
|
4
|
+
module RequestHandlers
|
5
|
+
class Customers < Base
|
6
|
+
private
|
7
|
+
|
8
|
+
def post
|
9
|
+
customer = Models::Customer.create(params)
|
10
|
+
{ customer: customer }
|
11
|
+
end
|
12
|
+
|
13
|
+
def get
|
14
|
+
customer = Models::Customer.find(id)
|
15
|
+
{ customer: customer }
|
16
|
+
end
|
17
|
+
|
18
|
+
def post_subscriptions
|
19
|
+
customer = Models::Customer.find(id)
|
20
|
+
subscription = Models::Subscription.create_for_customer(customer, params)
|
21
|
+
|
22
|
+
{ subscription: subscription, customer: customer }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MockChargebee
|
4
|
+
module RequestHandlers
|
5
|
+
class Subscriptions < Base
|
6
|
+
load_fixtures :subscription_create_response,
|
7
|
+
:subscription_cancel_response,
|
8
|
+
:subscription_reactivate_response
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def post
|
13
|
+
if id.nil?
|
14
|
+
subscription, customer = Models::Subscription.create(params)
|
15
|
+
subscription_create_response_fixture.merge(subscription: subscription, customer: customer)
|
16
|
+
else
|
17
|
+
subscription = Models::Subscription.update(id, params)
|
18
|
+
|
19
|
+
{ subscription: subscription }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def post_cancel
|
24
|
+
subscription = Models::Subscription.cancel(id, params)
|
25
|
+
customer = Models::Customer.find(subscription["customer_id"])
|
26
|
+
|
27
|
+
subscription_cancel_response_fixture.merge(subscription: subscription, customer: customer)
|
28
|
+
end
|
29
|
+
|
30
|
+
def post_reactivate
|
31
|
+
subscription = Models::Subscription.reactivate(id, params)
|
32
|
+
customer = Models::Customer.find(subscription["customer_id"])
|
33
|
+
|
34
|
+
subscription_reactivate_response_fixture.merge(subscription: subscription, customer: customer)
|
35
|
+
end
|
36
|
+
|
37
|
+
def get
|
38
|
+
subscription = Models::Subscription.find(id)
|
39
|
+
{ subscription: subscription }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MockChargebee
|
4
|
+
module Services
|
5
|
+
class CouponsForSubscription
|
6
|
+
def initialize(coupon_ids)
|
7
|
+
@coupon_ids = coupon_ids
|
8
|
+
end
|
9
|
+
|
10
|
+
def call
|
11
|
+
return [] if coupon_ids.empty?
|
12
|
+
|
13
|
+
coupons.map do |coupon|
|
14
|
+
{
|
15
|
+
"coupon_id" => coupon["id"],
|
16
|
+
"apply_till" => apply_till_from(coupon),
|
17
|
+
"applied_count" => 1,
|
18
|
+
"coupon_code" => nil,
|
19
|
+
}
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def coupon_ids
|
26
|
+
@coupon_ids || []
|
27
|
+
end
|
28
|
+
|
29
|
+
def coupons
|
30
|
+
coupon_ids.values.map { |id| Models::Coupon.find(id) }
|
31
|
+
end
|
32
|
+
|
33
|
+
def apply_till_from(coupon)
|
34
|
+
return nil unless coupon["duration_period"] == "limited_period"
|
35
|
+
|
36
|
+
(Date.today >> coupon["duration_month"]).to_time.to_i
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|