diff --git a/fixture/vcr_cassettes/invoices_test/change.json b/fixture/vcr_cassettes/invoices_test/change.json new file mode 100644 index 00000000..88f38fa1 --- /dev/null +++ b/fixture/vcr_cassettes/invoices_test/change.json @@ -0,0 +1,36 @@ +[ + { + "request": { + "body": "closed=true", + "headers": { + "Authorization": "Bearer STRIPE_SECRET_KEY", + "Content-Type": "application/x-www-form-urlencoded", + "User-Agent": "Stripe/v1 stripity-stripe/1.4.0" + }, + "method": "post", + "options": [], + "request_body": "", + "url": "https://api.stripe.com/v1/invoices/in_1Ac79wCM35SG8uZjktE8OgYt" + }, + "response": { + "body": "{\n \"id\": \"in_1Ac79wCM35SG8uZjktE8OgYt\",\n \"object\": \"invoice\",\n \"amount_due\": 10,\n \"application_fee\": null,\n \"attempt_count\": 0,\n \"attempted\": false,\n \"charge\": null,\n \"closed\": true,\n \"currency\": \"usd\",\n \"customer\": \"cus_Ay3GqeMIz0WkEm\",\n \"date\": 1499236728,\n \"description\": null,\n \"discount\": null,\n \"ending_balance\": null,\n \"forgiven\": false,\n \"lines\": {\n \"object\": \"list\",\n \"data\": [\n {\n \"id\": \"ii_1Ac79wCM35SG8uZjg219Etgu\",\n \"object\": \"line_item\",\n \"amount\": 10,\n \"currency\": \"usd\",\n \"description\": null,\n \"discountable\": true,\n \"livemode\": false,\n \"metadata\": {},\n \"period\": {\n \"start\": 1499236728,\n \"end\": 1499236728\n },\n \"plan\": null,\n \"proration\": false,\n \"quantity\": null,\n \"subscription\": \"sub_Ay3GDAbPurf2VP\",\n \"type\": \"invoiceitem\"\n }\n ],\n \"has_more\": false,\n \"total_count\": 1,\n \"url\": \"/v1/invoices/in_1Ac79wCM35SG8uZjktE8OgYt/lines\"\n },\n \"livemode\": false,\n \"metadata\": {\n \"app_order_id\": \"ABC1234\",\n \"app_attr1\": \"xyz1\"\n },\n \"next_payment_attempt\": null,\n \"paid\": false,\n \"period_end\": 1499236728,\n \"period_start\": 1499236727,\n \"receipt_number\": null,\n \"starting_balance\": 0,\n \"statement_descriptor\": null,\n \"subscription\": \"sub_Ay3GDAbPurf2VP\",\n \"subtotal\": 10,\n \"tax\": null,\n \"tax_percent\": null,\n \"total\": 10,\n \"webhooks_delivered_at\": 1499236728\n}\n", + "headers": { + "Server": "nginx", + "Date": "Wed, 05 Jul 2017 06:38:54 GMT", + "Content-Type": "application/json", + "Content-Length": "1457", + "Connection": "keep-alive", + "Access-Control-Allow-Credentials": "true", + "Access-Control-Allow-Methods": "GET, POST, HEAD, OPTIONS, DELETE", + "Access-Control-Allow-Origin": "*", + "Access-Control-Max-Age": "300", + "Cache-Control": "no-cache, no-store", + "Request-Id": "req_Ay3G8KLLy1Yv6X", + "Stripe-Version": "2017-06-05", + "Strict-Transport-Security": "max-age=31556926; includeSubDomains" + }, + "status_code": 200, + "type": "ok" + } + } +] \ No newline at end of file diff --git a/fixture/vcr_cassettes/invoices_test/change_with_key.json b/fixture/vcr_cassettes/invoices_test/change_with_key.json new file mode 100644 index 00000000..1193c450 --- /dev/null +++ b/fixture/vcr_cassettes/invoices_test/change_with_key.json @@ -0,0 +1,36 @@ +[ + { + "request": { + "body": "description=Some+description&closed=true", + "headers": { + "Authorization": "Bearer STRIPE_SECRET_KEY", + "Content-Type": "application/x-www-form-urlencoded", + "User-Agent": "Stripe/v1 stripity-stripe/1.4.0" + }, + "method": "post", + "options": [], + "request_body": "", + "url": "https://api.stripe.com/v1/invoices/in_1Ac79wCM35SG8uZjktE8OgYt" + }, + "response": { + "body": "{\n \"id\": \"in_1Ac79wCM35SG8uZjktE8OgYt\",\n \"object\": \"invoice\",\n \"amount_due\": 10,\n \"application_fee\": null,\n \"attempt_count\": 0,\n \"attempted\": false,\n \"charge\": null,\n \"closed\": true,\n \"currency\": \"usd\",\n \"customer\": \"cus_Ay3GqeMIz0WkEm\",\n \"date\": 1499236728,\n \"description\": \"Some description\",\n \"discount\": null,\n \"ending_balance\": null,\n \"forgiven\": false,\n \"lines\": {\n \"object\": \"list\",\n \"data\": [\n {\n \"id\": \"ii_1Ac79wCM35SG8uZjg219Etgu\",\n \"object\": \"line_item\",\n \"amount\": 10,\n \"currency\": \"usd\",\n \"description\": null,\n \"discountable\": true,\n \"livemode\": false,\n \"metadata\": {},\n \"period\": {\n \"start\": 1499236728,\n \"end\": 1499236728\n },\n \"plan\": null,\n \"proration\": false,\n \"quantity\": null,\n \"subscription\": \"sub_Ay3GDAbPurf2VP\",\n \"type\": \"invoiceitem\"\n }\n ],\n \"has_more\": false,\n \"total_count\": 1,\n \"url\": \"/v1/invoices/in_1Ac79wCM35SG8uZjktE8OgYt/lines\"\n },\n \"livemode\": false,\n \"metadata\": {\n \"app_order_id\": \"ABC1234\",\n \"app_attr1\": \"xyz1\"\n },\n \"next_payment_attempt\": null,\n \"paid\": false,\n \"period_end\": 1499236728,\n \"period_start\": 1499236727,\n \"receipt_number\": null,\n \"starting_balance\": 0,\n \"statement_descriptor\": null,\n \"subscription\": \"sub_Ay3GDAbPurf2VP\",\n \"subtotal\": 10,\n \"tax\": null,\n \"tax_percent\": null,\n \"total\": 10,\n \"webhooks_delivered_at\": 1499236728\n}\n", + "headers": { + "Server": "nginx", + "Date": "Wed, 05 Jul 2017 06:38:54 GMT", + "Content-Type": "application/json", + "Content-Length": "1471", + "Connection": "keep-alive", + "Access-Control-Allow-Credentials": "true", + "Access-Control-Allow-Methods": "GET, POST, HEAD, OPTIONS, DELETE", + "Access-Control-Allow-Origin": "*", + "Access-Control-Max-Age": "300", + "Cache-Control": "no-cache, no-store", + "Request-Id": "req_Ay3GHpvn2KCuEW", + "Stripe-Version": "2017-06-05", + "Strict-Transport-Security": "max-age=31556926; includeSubDomains" + }, + "status_code": 200, + "type": "ok" + } + } +] \ No newline at end of file diff --git a/fixture/vcr_cassettes/invoices_test/metadata.json b/fixture/vcr_cassettes/invoices_test/metadata.json index 646d74dc..3ab22eaa 100644 --- a/fixture/vcr_cassettes/invoices_test/metadata.json +++ b/fixture/vcr_cassettes/invoices_test/metadata.json @@ -1,9 +1,9 @@ [ { "request": { - "body": "customer=cus_8r2jCf6wk8YLyU&subscription=sub_8r2j78r42DD6xb&metadata[app_order_id]=ABC123&metadata[app_attr1]=xyz", + "body": "customer=cus_Ay3G4eTAX3FgXd&subscription=sub_Ay3GRYIf5J5VBt&metadata[app_order_id]=ABC123&metadata[app_attr1]=xyz", "headers": { - "Authorization": "Bearer non_empty_secret_key_string", + "Authorization": "Bearer STRIPE_SECRET_KEY", "Content-Type": "application/x-www-form-urlencoded", "User-Agent": "Stripe/v1 stripity-stripe/1.4.0" }, @@ -13,24 +13,24 @@ "url": "https://api.stripe.com/v1/invoices" }, "response": { - "body": "{\n \"id\": \"in_8r2jKmLwYMLHlI\",\n \"object\": \"invoice\",\n \"amount_due\": 10,\n \"application_fee\": null,\n \"attempt_count\": 0,\n \"attempted\": false,\n \"charge\": null,\n \"closed\": false,\n \"currency\": \"usd\",\n \"customer\": \"cus_8r2jCf6wk8YLyU\",\n \"date\": 1469020927,\n \"description\": null,\n \"discount\": null,\n \"ending_balance\": null,\n \"forgiven\": false,\n \"lines\": {\n \"object\": \"list\",\n \"data\": [\n {\n \"id\": \"ii_8r2jQGLNFUFPyj\",\n \"object\": \"line_item\",\n \"amount\": 10,\n \"currency\": \"usd\",\n \"description\": null,\n \"discountable\": true,\n \"livemode\": false,\n \"metadata\": {},\n \"period\": {\n \"start\": 1469020927,\n \"end\": 1469020927\n },\n \"plan\": null,\n \"proration\": false,\n \"quantity\": null,\n \"subscription\": \"sub_8r2j78r42DD6xb\",\n \"type\": \"invoiceitem\"\n }\n ],\n \"has_more\": false,\n \"total_count\": 1,\n \"url\": \"/v1/invoices/in_8r2jKmLwYMLHlI/lines\"\n },\n \"livemode\": false,\n \"metadata\": {\n \"app_order_id\": \"ABC123\",\n \"app_attr1\": \"xyz\"\n },\n \"next_payment_attempt\": 1469024527,\n \"paid\": false,\n \"period_end\": 1469020927,\n \"period_start\": 1469020924,\n \"receipt_number\": null,\n \"starting_balance\": 0,\n \"statement_descriptor\": null,\n \"subscription\": \"sub_8r2j78r42DD6xb\",\n \"subtotal\": 10,\n \"tax\": null,\n \"tax_percent\": null,\n \"total\": 10,\n \"webhooks_delivered_at\": null\n}\n", + "body": "{\n \"id\": \"in_1Ac79xCM35SG8uZj5FxDwLZH\",\n \"object\": \"invoice\",\n \"amount_due\": 10,\n \"application_fee\": null,\n \"attempt_count\": 0,\n \"attempted\": false,\n \"charge\": null,\n \"closed\": false,\n \"currency\": \"usd\",\n \"customer\": \"cus_Ay3G4eTAX3FgXd\",\n \"date\": 1499236729,\n \"description\": null,\n \"discount\": null,\n \"ending_balance\": null,\n \"forgiven\": false,\n \"lines\": {\n \"object\": \"list\",\n \"data\": [\n {\n \"id\": \"ii_1Ac79uCM35SG8uZjpj88VkZX\",\n \"object\": \"line_item\",\n \"amount\": 10,\n \"currency\": \"usd\",\n \"description\": null,\n \"discountable\": true,\n \"livemode\": false,\n \"metadata\": {},\n \"period\": {\n \"start\": 1499236726,\n \"end\": 1499236726\n },\n \"plan\": null,\n \"proration\": false,\n \"quantity\": null,\n \"subscription\": \"sub_Ay3GRYIf5J5VBt\",\n \"type\": \"invoiceitem\"\n }\n ],\n \"has_more\": false,\n \"total_count\": 1,\n \"url\": \"/v1/invoices/in_1Ac79xCM35SG8uZj5FxDwLZH/lines\"\n },\n \"livemode\": false,\n \"metadata\": {\n \"app_order_id\": \"ABC123\",\n \"app_attr1\": \"xyz\"\n },\n \"next_payment_attempt\": 1499240329,\n \"paid\": false,\n \"period_end\": 1499236729,\n \"period_start\": 1499236725,\n \"receipt_number\": null,\n \"starting_balance\": 0,\n \"statement_descriptor\": null,\n \"subscription\": \"sub_Ay3GRYIf5J5VBt\",\n \"subtotal\": 10,\n \"tax\": null,\n \"tax_percent\": null,\n \"total\": 10,\n \"webhooks_delivered_at\": null\n}\n", "headers": { "Server": "nginx", - "Date": "Wed, 20 Jul 2016 13:22:07 GMT", + "Date": "Wed, 05 Jul 2017 06:38:49 GMT", "Content-Type": "application/json", - "Content-Length": "1426", + "Content-Length": "1456", "Connection": "keep-alive", "Access-Control-Allow-Credentials": "true", "Access-Control-Allow-Methods": "GET, POST, HEAD, OPTIONS, DELETE", "Access-Control-Allow-Origin": "*", "Access-Control-Max-Age": "300", "Cache-Control": "no-cache, no-store", - "Request-Id": "req_8r2jNGytTMKD07", - "Stripe-Version": "2016-07-06", + "Request-Id": "req_Ay3GJVxOOUjn60", + "Stripe-Version": "2017-06-05", "Strict-Transport-Security": "max-age=31556926; includeSubDomains" }, "status_code": 200, "type": "ok" } } -] +] \ No newline at end of file diff --git a/fixture/vcr_cassettes/invoices_test/pay.json b/fixture/vcr_cassettes/invoices_test/pay.json index 6f7e1992..c99ec469 100644 --- a/fixture/vcr_cassettes/invoices_test/pay.json +++ b/fixture/vcr_cassettes/invoices_test/pay.json @@ -1,9 +1,9 @@ [ { "request": { - "body": "customer=cus_8r2jCf6wk8YLyU&amount=10¤cy=usd&subscription=sub_8r2j78r42DD6xb", + "body": "customer=cus_Ay3G4eTAX3FgXd&amount=10¤cy=usd&subscription=sub_Ay3GRYIf5J5VBt", "headers": { - "Authorization": "Bearer non_empty_secret_key_string", + "Authorization": "Bearer STRIPE_SECRET_KEY", "Content-Type": "application/x-www-form-urlencoded", "User-Agent": "Stripe/v1 stripity-stripe/1.4.0" }, @@ -13,10 +13,10 @@ "url": "https://api.stripe.com/v1/invoiceitems" }, "response": { - "body": "{\n \"id\": \"ii_18joevGTLcoLJlYWnw0wFBA1\",\n \"object\": \"invoiceitem\",\n \"amount\": 10,\n \"currency\": \"usd\",\n \"customer\": \"cus_8r2jCf6wk8YLyU\",\n \"date\": 1471519565,\n \"description\": null,\n \"discountable\": true,\n \"invoice\": null,\n \"livemode\": false,\n \"metadata\": {},\n \"period\": {\n \"start\": 1471519565,\n \"end\": 1471519565\n },\n \"plan\": null,\n \"proration\": false,\n \"quantity\": null,\n \"subscription\": \"sub_8r2j78r42DD6xb\"\n}\n", + "body": "{\n \"id\": \"ii_1Ac7A0CM35SG8uZjh7T3IVLA\",\n \"object\": \"invoiceitem\",\n \"amount\": 10,\n \"currency\": \"usd\",\n \"customer\": \"cus_Ay3G4eTAX3FgXd\",\n \"date\": 1499236732,\n \"description\": null,\n \"discountable\": true,\n \"invoice\": null,\n \"livemode\": false,\n \"metadata\": {},\n \"period\": {\n \"start\": 1499236732,\n \"end\": 1499236732\n },\n \"plan\": null,\n \"proration\": false,\n \"quantity\": null,\n \"subscription\": \"sub_Ay3GRYIf5J5VBt\"\n}\n", "headers": { "Server": "nginx", - "Date": "Thu, 18 Aug 2016 11:26:05 GMT", + "Date": "Wed, 05 Jul 2017 06:38:52 GMT", "Content-Type": "application/json", "Content-Length": "433", "Connection": "keep-alive", @@ -25,8 +25,8 @@ "Access-Control-Allow-Origin": "*", "Access-Control-Max-Age": "300", "Cache-Control": "no-cache, no-store", - "Request-Id": "req_91sP1taoWesj9j", - "Stripe-Version": "2016-03-07", + "Request-Id": "req_Ay3GH3CJwV1qc2", + "Stripe-Version": "2017-06-05", "Strict-Transport-Security": "max-age=31556926; includeSubDomains" }, "status_code": 200, @@ -35,9 +35,9 @@ }, { "request": { - "body": "customer=cus_8r2jCf6wk8YLyU&subscription=sub_8r2j78r42DD6xb", + "body": "customer=cus_Ay3G4eTAX3FgXd&subscription=sub_Ay3GRYIf5J5VBt", "headers": { - "Authorization": "Bearer non_empty_secret_key_string", + "Authorization": "Bearer STRIPE_SECRET_KEY", "Content-Type": "application/x-www-form-urlencoded", "User-Agent": "Stripe/v1 stripity-stripe/1.4.0" }, @@ -47,10 +47,10 @@ "url": "https://api.stripe.com/v1/invoices" }, "response": { - "body": "{\n \"id\": \"in_18joevGTLcoLJlYWh0wfFUIS\",\n \"object\": \"invoice\",\n \"amount_due\": 10,\n \"application_fee\": null,\n \"attempt_count\": 0,\n \"attempted\": false,\n \"charge\": null,\n \"closed\": false,\n \"currency\": \"usd\",\n \"customer\": \"cus_8r2jCf6wk8YLyU\",\n \"date\": 1471519565,\n \"description\": null,\n \"discount\": null,\n \"ending_balance\": null,\n \"forgiven\": false,\n \"lines\": {\n \"object\": \"list\",\n \"data\": [\n {\n \"id\": \"ii_18joevGTLcoLJlYWnw0wFBA1\",\n \"object\": \"line_item\",\n \"amount\": 10,\n \"currency\": \"usd\",\n \"description\": null,\n \"discountable\": true,\n \"livemode\": false,\n \"metadata\": {},\n \"period\": {\n \"start\": 1471519565,\n \"end\": 1471519565\n },\n \"plan\": null,\n \"proration\": false,\n \"quantity\": null,\n \"subscription\": \"sub_8r2j78r42DD6xb\",\n \"type\": \"invoiceitem\"\n }\n ],\n \"has_more\": false,\n \"total_count\": 1,\n \"url\": \"/v1/invoices/in_18joevGTLcoLJlYWh0wfFUIS/lines\"\n },\n \"livemode\": false,\n \"metadata\": {},\n \"next_payment_attempt\": 1471523165,\n \"paid\": false,\n \"period_end\": 1471519565,\n \"period_start\": 1471519559,\n \"receipt_number\": null,\n \"starting_balance\": 0,\n \"statement_descriptor\": null,\n \"subscription\": \"sub_8r2j78r42DD6xb\",\n \"subtotal\": 10,\n \"tax\": null,\n \"tax_percent\": null,\n \"total\": 10,\n \"webhooks_delivered_at\": null\n}\n", + "body": "{\n \"id\": \"in_1Ac7A0CM35SG8uZjOA88KTjb\",\n \"object\": \"invoice\",\n \"amount_due\": 10,\n \"application_fee\": null,\n \"attempt_count\": 0,\n \"attempted\": false,\n \"charge\": null,\n \"closed\": false,\n \"currency\": \"usd\",\n \"customer\": \"cus_Ay3G4eTAX3FgXd\",\n \"date\": 1499236732,\n \"description\": null,\n \"discount\": null,\n \"ending_balance\": null,\n \"forgiven\": false,\n \"lines\": {\n \"object\": \"list\",\n \"data\": [\n {\n \"id\": \"ii_1Ac7A0CM35SG8uZjh7T3IVLA\",\n \"object\": \"line_item\",\n \"amount\": 10,\n \"currency\": \"usd\",\n \"description\": null,\n \"discountable\": true,\n \"livemode\": false,\n \"metadata\": {},\n \"period\": {\n \"start\": 1499236732,\n \"end\": 1499236732\n },\n \"plan\": null,\n \"proration\": false,\n \"quantity\": null,\n \"subscription\": \"sub_Ay3GRYIf5J5VBt\",\n \"type\": \"invoiceitem\"\n }\n ],\n \"has_more\": false,\n \"total_count\": 1,\n \"url\": \"/v1/invoices/in_1Ac7A0CM35SG8uZjOA88KTjb/lines\"\n },\n \"livemode\": false,\n \"metadata\": {},\n \"next_payment_attempt\": 1499240332,\n \"paid\": false,\n \"period_end\": 1499236732,\n \"period_start\": 1499236725,\n \"receipt_number\": null,\n \"starting_balance\": 0,\n \"statement_descriptor\": null,\n \"subscription\": \"sub_Ay3GRYIf5J5VBt\",\n \"subtotal\": 10,\n \"tax\": null,\n \"tax_percent\": null,\n \"total\": 10,\n \"webhooks_delivered_at\": null\n}\n", "headers": { "Server": "nginx", - "Date": "Thu, 18 Aug 2016 11:26:05 GMT", + "Date": "Wed, 05 Jul 2017 06:38:52 GMT", "Content-Type": "application/json", "Content-Length": "1400", "Connection": "keep-alive", @@ -59,8 +59,8 @@ "Access-Control-Allow-Origin": "*", "Access-Control-Max-Age": "300", "Cache-Control": "no-cache, no-store", - "Request-Id": "req_91sP4o4cjeggzt", - "Stripe-Version": "2016-03-07", + "Request-Id": "req_Ay3GHre3bvMf8c", + "Stripe-Version": "2017-06-05", "Strict-Transport-Security": "max-age=31556926; includeSubDomains" }, "status_code": 200, @@ -71,20 +71,20 @@ "request": { "body": "", "headers": { - "Authorization": "Bearer non_empty_secret_key_string", + "Authorization": "Bearer STRIPE_SECRET_KEY", "Content-Type": "application/x-www-form-urlencoded", "User-Agent": "Stripe/v1 stripity-stripe/1.4.0" }, "method": "post", "options": [], "request_body": "", - "url": "https://api.stripe.com/v1/invoices/in_18joevGTLcoLJlYWh0wfFUIS/pay" + "url": "https://api.stripe.com/v1/invoices/in_1Ac7A0CM35SG8uZjOA88KTjb/pay" }, "response": { - "body": "{\n \"id\": \"in_18joevGTLcoLJlYWh0wfFUIS\",\n \"object\": \"invoice\",\n \"amount_due\": 0,\n \"application_fee\": null,\n \"attempt_count\": 0,\n \"attempted\": true,\n \"charge\": null,\n \"closed\": true,\n \"currency\": \"usd\",\n \"customer\": \"cus_8r2jCf6wk8YLyU\",\n \"date\": 1471519565,\n \"description\": null,\n \"discount\": null,\n \"ending_balance\": 10,\n \"forgiven\": false,\n \"lines\": {\n \"object\": \"list\",\n \"data\": [\n {\n \"id\": \"ii_18joevGTLcoLJlYWnw0wFBA1\",\n \"object\": \"line_item\",\n \"amount\": 10,\n \"currency\": \"usd\",\n \"description\": null,\n \"discountable\": true,\n \"livemode\": false,\n \"metadata\": {},\n \"period\": {\n \"start\": 1471519565,\n \"end\": 1471519565\n },\n \"plan\": null,\n \"proration\": false,\n \"quantity\": null,\n \"subscription\": \"sub_8r2j78r42DD6xb\",\n \"type\": \"invoiceitem\"\n }\n ],\n \"has_more\": false,\n \"total_count\": 1,\n \"url\": \"/v1/invoices/in_18joevGTLcoLJlYWh0wfFUIS/lines\"\n },\n \"livemode\": false,\n \"metadata\": {},\n \"next_payment_attempt\": null,\n \"paid\": true,\n \"period_end\": 1471519565,\n \"period_start\": 1471519559,\n \"receipt_number\": null,\n \"starting_balance\": 0,\n \"statement_descriptor\": null,\n \"subscription\": \"sub_8r2j78r42DD6xb\",\n \"subtotal\": 10,\n \"tax\": null,\n \"tax_percent\": null,\n \"total\": 10,\n \"webhooks_delivered_at\": 1471519565\n}\n", + "body": "{\n \"id\": \"in_1Ac7A0CM35SG8uZjOA88KTjb\",\n \"object\": \"invoice\",\n \"amount_due\": 0,\n \"application_fee\": null,\n \"attempt_count\": 0,\n \"attempted\": true,\n \"charge\": null,\n \"closed\": true,\n \"currency\": \"usd\",\n \"customer\": \"cus_Ay3G4eTAX3FgXd\",\n \"date\": 1499236732,\n \"description\": null,\n \"discount\": null,\n \"ending_balance\": 10,\n \"forgiven\": false,\n \"lines\": {\n \"object\": \"list\",\n \"data\": [\n {\n \"id\": \"ii_1Ac7A0CM35SG8uZjh7T3IVLA\",\n \"object\": \"line_item\",\n \"amount\": 10,\n \"currency\": \"usd\",\n \"description\": null,\n \"discountable\": true,\n \"livemode\": false,\n \"metadata\": {},\n \"period\": {\n \"start\": 1499236732,\n \"end\": 1499236732\n },\n \"plan\": null,\n \"proration\": false,\n \"quantity\": null,\n \"subscription\": \"sub_Ay3GRYIf5J5VBt\",\n \"type\": \"invoiceitem\"\n }\n ],\n \"has_more\": false,\n \"total_count\": 1,\n \"url\": \"/v1/invoices/in_1Ac7A0CM35SG8uZjOA88KTjb/lines\"\n },\n \"livemode\": false,\n \"metadata\": {},\n \"next_payment_attempt\": null,\n \"paid\": true,\n \"period_end\": 1499236732,\n \"period_start\": 1499236725,\n \"receipt_number\": null,\n \"starting_balance\": 0,\n \"statement_descriptor\": null,\n \"subscription\": \"sub_Ay3GRYIf5J5VBt\",\n \"subtotal\": 10,\n \"tax\": null,\n \"tax_percent\": null,\n \"total\": 10,\n \"webhooks_delivered_at\": 1499236732\n}\n", "headers": { "Server": "nginx", - "Date": "Thu, 18 Aug 2016 11:26:06 GMT", + "Date": "Wed, 05 Jul 2017 06:38:53 GMT", "Content-Type": "application/json", "Content-Length": "1394", "Connection": "keep-alive", @@ -93,8 +93,8 @@ "Access-Control-Allow-Origin": "*", "Access-Control-Max-Age": "300", "Cache-Control": "no-cache, no-store", - "Request-Id": "req_91sP6YoQEIPIRz", - "Stripe-Version": "2016-03-07", + "Request-Id": "req_Ay3GBI1IKrTn0s", + "Stripe-Version": "2017-06-05", "Strict-Transport-Security": "max-age=31556926; includeSubDomains" }, "status_code": 200, diff --git a/fixture/vcr_cassettes/invoices_test/setup.json b/fixture/vcr_cassettes/invoices_test/setup.json index 65d275a3..a53c9135 100644 --- a/fixture/vcr_cassettes/invoices_test/setup.json +++ b/fixture/vcr_cassettes/invoices_test/setup.json @@ -3,7 +3,7 @@ "request": { "body": "currency=USD&id=test-std&name=Test+Plan+Standard&amount=100&interval=month", "headers": { - "Authorization": "Bearer non_empty_secret_key_string", + "Authorization": "Bearer STRIPE_SECRET_KEY", "Content-Type": "application/x-www-form-urlencoded", "User-Agent": "Stripe/v1 stripity-stripe/1.4.0" }, @@ -13,10 +13,10 @@ "url": "https://api.stripe.com/v1/plans" }, "response": { - "body": "{\n \"id\": \"test-std\",\n \"object\": \"plan\",\n \"amount\": 100,\n \"created\": 1469020923,\n \"currency\": \"usd\",\n \"interval\": \"month\",\n \"interval_count\": 1,\n \"livemode\": false,\n \"metadata\": {},\n \"name\": \"Test Plan Standard\",\n \"statement_descriptor\": null,\n \"trial_period_days\": null\n}\n", + "body": "{\n \"id\": \"test-std\",\n \"object\": \"plan\",\n \"amount\": 100,\n \"created\": 1499236723,\n \"currency\": \"usd\",\n \"interval\": \"month\",\n \"interval_count\": 1,\n \"livemode\": false,\n \"metadata\": {},\n \"name\": \"Test Plan Standard\",\n \"statement_descriptor\": null,\n \"trial_period_days\": null\n}\n", "headers": { "Server": "nginx", - "Date": "Wed, 20 Jul 2016 13:22:03 GMT", + "Date": "Wed, 05 Jul 2017 06:38:43 GMT", "Content-Type": "application/json", "Content-Length": "284", "Connection": "keep-alive", @@ -25,8 +25,8 @@ "Access-Control-Allow-Origin": "*", "Access-Control-Max-Age": "300", "Cache-Control": "no-cache, no-store", - "Request-Id": "req_8r2jo0DiB9Ncp9", - "Stripe-Version": "2016-07-06", + "Request-Id": "req_Ay3GzhnUOgNfcJ", + "Stripe-Version": "2017-06-05", "Strict-Transport-Security": "max-age=31556926; includeSubDomains" }, "status_code": 200, @@ -37,7 +37,7 @@ "request": { "body": "currency=USD&id=test-dlx&name=Test+Plan+Deluxe&amount=1000&interval=month", "headers": { - "Authorization": "Bearer non_empty_secret_key_string", + "Authorization": "Bearer STRIPE_SECRET_KEY", "Content-Type": "application/x-www-form-urlencoded", "User-Agent": "Stripe/v1 stripity-stripe/1.4.0" }, @@ -47,10 +47,10 @@ "url": "https://api.stripe.com/v1/plans" }, "response": { - "body": "{\n \"id\": \"test-dlx\",\n \"object\": \"plan\",\n \"amount\": 1000,\n \"created\": 1469020923,\n \"currency\": \"usd\",\n \"interval\": \"month\",\n \"interval_count\": 1,\n \"livemode\": false,\n \"metadata\": {},\n \"name\": \"Test Plan Deluxe\",\n \"statement_descriptor\": null,\n \"trial_period_days\": null\n}\n", + "body": "{\n \"id\": \"test-dlx\",\n \"object\": \"plan\",\n \"amount\": 1000,\n \"created\": 1499236724,\n \"currency\": \"usd\",\n \"interval\": \"month\",\n \"interval_count\": 1,\n \"livemode\": false,\n \"metadata\": {},\n \"name\": \"Test Plan Deluxe\",\n \"statement_descriptor\": null,\n \"trial_period_days\": null\n}\n", "headers": { "Server": "nginx", - "Date": "Wed, 20 Jul 2016 13:22:03 GMT", + "Date": "Wed, 05 Jul 2017 06:38:44 GMT", "Content-Type": "application/json", "Content-Length": "283", "Connection": "keep-alive", @@ -59,8 +59,8 @@ "Access-Control-Allow-Origin": "*", "Access-Control-Max-Age": "300", "Cache-Control": "no-cache, no-store", - "Request-Id": "req_8r2jUdqQtroEhx", - "Stripe-Version": "2016-07-06", + "Request-Id": "req_Ay3GvpFs95IFOt", + "Stripe-Version": "2017-06-05", "Strict-Transport-Security": "max-age=31556926; includeSubDomains" }, "status_code": 200, @@ -71,7 +71,7 @@ "request": { "body": "email=invoices_test1%40localhost&description=Test+Account&card[number]=4111111111111111&card[exp_month]=1&card[exp_year]=2018&card[cvc]=123&card[name]=Joe+Test+User", "headers": { - "Authorization": "Bearer non_empty_secret_key_string", + "Authorization": "Bearer STRIPE_SECRET_KEY", "Content-Type": "application/x-www-form-urlencoded", "User-Agent": "Stripe/v1 stripity-stripe/1.4.0" }, @@ -81,20 +81,20 @@ "url": "https://api.stripe.com/v1/customers" }, "response": { - "body": "{\n \"id\": \"cus_8r2jCf6wk8YLyU\",\n \"object\": \"customer\",\n \"account_balance\": 0,\n \"created\": 1469020923,\n \"currency\": null,\n \"default_source\": \"card_8r2jiBCQ5KUmlB\",\n \"delinquent\": false,\n \"description\": \"Test Account\",\n \"discount\": null,\n \"email\": \"invoices_test1@localhost\",\n \"livemode\": false,\n \"metadata\": {},\n \"shipping\": null,\n \"sources\": {\n \"object\": \"list\",\n \"data\": [\n {\n \"id\": \"card_8r2jiBCQ5KUmlB\",\n \"object\": \"card\",\n \"address_city\": null,\n \"address_country\": null,\n \"address_line1\": null,\n \"address_line1_check\": null,\n \"address_line2\": null,\n \"address_state\": null,\n \"address_zip\": null,\n \"address_zip_check\": null,\n \"brand\": \"Visa\",\n \"country\": \"US\",\n \"customer\": \"cus_8r2jCf6wk8YLyU\",\n \"cvc_check\": \"pass\",\n \"dynamic_last4\": null,\n \"exp_month\": 1,\n \"exp_year\": 2018,\n \"fingerprint\": \"Ze2h9CyiqlKZzGuV\",\n \"funding\": \"unknown\",\n \"last4\": \"1111\",\n \"metadata\": {},\n \"name\": \"Joe Test User\",\n \"tokenization_method\": null\n }\n ],\n \"has_more\": false,\n \"total_count\": 1,\n \"url\": \"/v1/customers/cus_8r2jCf6wk8YLyU/sources\"\n },\n \"subscriptions\": {\n \"object\": \"list\",\n \"data\": [],\n \"has_more\": false,\n \"total_count\": 0,\n \"url\": \"/v1/customers/cus_8r2jCf6wk8YLyU/subscriptions\"\n }\n}\n", + "body": "{\n \"id\": \"cus_Ay3G4eTAX3FgXd\",\n \"object\": \"customer\",\n \"account_balance\": 0,\n \"created\": 1499236724,\n \"currency\": null,\n \"default_source\": \"card_1Ac79sCM35SG8uZjRkWGg9Z9\",\n \"delinquent\": false,\n \"description\": \"Test Account\",\n \"discount\": null,\n \"email\": \"invoices_test1@localhost\",\n \"livemode\": false,\n \"metadata\": {},\n \"shipping\": null,\n \"sources\": {\n \"object\": \"list\",\n \"data\": [\n {\n \"id\": \"card_1Ac79sCM35SG8uZjRkWGg9Z9\",\n \"object\": \"card\",\n \"address_city\": null,\n \"address_country\": null,\n \"address_line1\": null,\n \"address_line1_check\": null,\n \"address_line2\": null,\n \"address_state\": null,\n \"address_zip\": null,\n \"address_zip_check\": null,\n \"brand\": \"Visa\",\n \"country\": \"US\",\n \"customer\": \"cus_Ay3G4eTAX3FgXd\",\n \"cvc_check\": \"pass\",\n \"dynamic_last4\": null,\n \"exp_month\": 1,\n \"exp_year\": 2018,\n \"fingerprint\": \"KTWhNpFM0faAWygq\",\n \"funding\": \"unknown\",\n \"last4\": \"1111\",\n \"metadata\": {},\n \"name\": \"Joe Test User\",\n \"tokenization_method\": null\n }\n ],\n \"has_more\": false,\n \"total_count\": 1,\n \"url\": \"/v1/customers/cus_Ay3G4eTAX3FgXd/sources\"\n },\n \"subscriptions\": {\n \"object\": \"list\",\n \"data\": [],\n \"has_more\": false,\n \"total_count\": 0,\n \"url\": \"/v1/customers/cus_Ay3G4eTAX3FgXd/subscriptions\"\n }\n}\n", "headers": { "Server": "nginx", - "Date": "Wed, 20 Jul 2016 13:22:03 GMT", + "Date": "Wed, 05 Jul 2017 06:38:44 GMT", "Content-Type": "application/json", - "Content-Length": "1403", + "Content-Length": "1423", "Connection": "keep-alive", "Access-Control-Allow-Credentials": "true", "Access-Control-Allow-Methods": "GET, POST, HEAD, OPTIONS, DELETE", "Access-Control-Allow-Origin": "*", "Access-Control-Max-Age": "300", "Cache-Control": "no-cache, no-store", - "Request-Id": "req_8r2j87vBMAyFGc", - "Stripe-Version": "2016-07-06", + "Request-Id": "req_Ay3GV5BkvIXbmf", + "Stripe-Version": "2017-06-05", "Strict-Transport-Security": "max-age=31556926; includeSubDomains" }, "status_code": 200, @@ -105,30 +105,30 @@ "request": { "body": "plan=test-std", "headers": { - "Authorization": "Bearer non_empty_secret_key_string", + "Authorization": "Bearer STRIPE_SECRET_KEY", "Content-Type": "application/x-www-form-urlencoded", "User-Agent": "Stripe/v1 stripity-stripe/1.4.0" }, "method": "post", "options": [], "request_body": "", - "url": "https://api.stripe.com/v1/customers/cus_8r2jCf6wk8YLyU/subscriptions" + "url": "https://api.stripe.com/v1/customers/cus_Ay3G4eTAX3FgXd/subscriptions" }, "response": { - "body": "{\n \"id\": \"sub_8r2j78r42DD6xb\",\n \"object\": \"subscription\",\n \"application_fee_percent\": null,\n \"cancel_at_period_end\": false,\n \"canceled_at\": null,\n \"created\": 1469020924,\n \"current_period_end\": 1471699324,\n \"current_period_start\": 1469020924,\n \"customer\": \"cus_8r2jCf6wk8YLyU\",\n \"discount\": null,\n \"ended_at\": null,\n \"livemode\": false,\n \"metadata\": {},\n \"plan\": {\n \"id\": \"test-std\",\n \"object\": \"plan\",\n \"amount\": 100,\n \"created\": 1469020923,\n \"currency\": \"usd\",\n \"interval\": \"month\",\n \"interval_count\": 1,\n \"livemode\": false,\n \"metadata\": {},\n \"name\": \"Test Plan Standard\",\n \"statement_descriptor\": null,\n \"trial_period_days\": null\n },\n \"quantity\": 1,\n \"start\": 1469020924,\n \"status\": \"active\",\n \"tax_percent\": null,\n \"trial_end\": null,\n \"trial_start\": null\n}\n", + "body": "{\n \"id\": \"sub_Ay3GRYIf5J5VBt\",\n \"object\": \"subscription\",\n \"application_fee_percent\": null,\n \"cancel_at_period_end\": false,\n \"canceled_at\": null,\n \"created\": 1499236725,\n \"current_period_end\": 1501915125,\n \"current_period_start\": 1499236725,\n \"customer\": \"cus_Ay3G4eTAX3FgXd\",\n \"discount\": null,\n \"ended_at\": null,\n \"items\": {\n \"object\": \"list\",\n \"data\": [\n {\n \"id\": \"si_1Ac79tCM35SG8uZjJW619dXs\",\n \"object\": \"subscription_item\",\n \"created\": 1499236725,\n \"plan\": {\n \"id\": \"test-std\",\n \"object\": \"plan\",\n \"amount\": 100,\n \"created\": 1499236723,\n \"currency\": \"usd\",\n \"interval\": \"month\",\n \"interval_count\": 1,\n \"livemode\": false,\n \"metadata\": {},\n \"name\": \"Test Plan Standard\",\n \"statement_descriptor\": null,\n \"trial_period_days\": null\n },\n \"quantity\": 1\n }\n ],\n \"has_more\": false,\n \"total_count\": 1,\n \"url\": \"/v1/subscription_items?subscription=sub_Ay3GRYIf5J5VBt\"\n },\n \"livemode\": false,\n \"metadata\": {},\n \"plan\": {\n \"id\": \"test-std\",\n \"object\": \"plan\",\n \"amount\": 100,\n \"created\": 1499236723,\n \"currency\": \"usd\",\n \"interval\": \"month\",\n \"interval_count\": 1,\n \"livemode\": false,\n \"metadata\": {},\n \"name\": \"Test Plan Standard\",\n \"statement_descriptor\": null,\n \"trial_period_days\": null\n },\n \"quantity\": 1,\n \"start\": 1499236725,\n \"status\": \"active\",\n \"tax_percent\": null,\n \"trial_end\": null,\n \"trial_start\": null\n}\n", "headers": { "Server": "nginx", - "Date": "Wed, 20 Jul 2016 13:22:07 GMT", + "Date": "Wed, 05 Jul 2017 06:38:45 GMT", "Content-Type": "application/json", - "Content-Length": "816", + "Content-Length": "1548", "Connection": "keep-alive", "Access-Control-Allow-Credentials": "true", "Access-Control-Allow-Methods": "GET, POST, HEAD, OPTIONS, DELETE", "Access-Control-Allow-Origin": "*", "Access-Control-Max-Age": "300", "Cache-Control": "no-cache, no-store", - "Request-Id": "req_8r2jJ0StmgJSmZ", - "Stripe-Version": "2016-07-06", + "Request-Id": "req_Ay3GWOLIliQszt", + "Stripe-Version": "2017-06-05", "Strict-Transport-Security": "max-age=31556926; includeSubDomains" }, "status_code": 200, @@ -137,9 +137,9 @@ }, { "request": { - "body": "customer=cus_8r2jCf6wk8YLyU&amount=10¤cy=usd&subscription=sub_8r2j78r42DD6xb", + "body": "customer=cus_Ay3G4eTAX3FgXd&amount=10¤cy=usd&subscription=sub_Ay3GRYIf5J5VBt", "headers": { - "Authorization": "Bearer non_empty_secret_key_string", + "Authorization": "Bearer STRIPE_SECRET_KEY", "Content-Type": "application/x-www-form-urlencoded", "User-Agent": "Stripe/v1 stripity-stripe/1.4.0" }, @@ -149,24 +149,160 @@ "url": "https://api.stripe.com/v1/invoiceitems" }, "response": { - "body": "{\n \"id\": \"ii_8r2jQGLNFUFPyj\",\n \"object\": \"invoiceitem\",\n \"amount\": 10,\n \"currency\": \"usd\",\n \"customer\": \"cus_8r2jCf6wk8YLyU\",\n \"date\": 1469020927,\n \"description\": null,\n \"discountable\": true,\n \"invoice\": null,\n \"livemode\": false,\n \"metadata\": {},\n \"period\": {\n \"start\": 1469020927,\n \"end\": 1469020927\n },\n \"plan\": null,\n \"proration\": false,\n \"quantity\": null,\n \"subscription\": \"sub_8r2j78r42DD6xb\"\n}\n", + "body": "{\n \"id\": \"ii_1Ac79uCM35SG8uZjpj88VkZX\",\n \"object\": \"invoiceitem\",\n \"amount\": 10,\n \"currency\": \"usd\",\n \"customer\": \"cus_Ay3G4eTAX3FgXd\",\n \"date\": 1499236726,\n \"description\": null,\n \"discountable\": true,\n \"invoice\": null,\n \"livemode\": false,\n \"metadata\": {},\n \"period\": {\n \"start\": 1499236726,\n \"end\": 1499236726\n },\n \"plan\": null,\n \"proration\": false,\n \"quantity\": null,\n \"subscription\": \"sub_Ay3GRYIf5J5VBt\"\n}\n", "headers": { "Server": "nginx", - "Date": "Wed, 20 Jul 2016 13:22:07 GMT", + "Date": "Wed, 05 Jul 2017 06:38:46 GMT", "Content-Type": "application/json", - "Content-Length": "423", + "Content-Length": "433", "Connection": "keep-alive", "Access-Control-Allow-Credentials": "true", "Access-Control-Allow-Methods": "GET, POST, HEAD, OPTIONS, DELETE", "Access-Control-Allow-Origin": "*", "Access-Control-Max-Age": "300", "Cache-Control": "no-cache, no-store", - "Request-Id": "req_8r2jIO2Fei1CDy", - "Stripe-Version": "2016-07-06", + "Request-Id": "req_Ay3GZJM9uoK7PD", + "Stripe-Version": "2017-06-05", + "Strict-Transport-Security": "max-age=31556926; includeSubDomains" + }, + "status_code": 200, + "type": "ok" + } + }, + { + "request": { + "body": "email=invoices_test2%40localhost&description=Test+Account&card[number]=4111111111111111&card[exp_month]=1&card[exp_year]=2018&card[cvc]=123&card[name]=Joe+Test+User", + "headers": { + "Authorization": "Bearer STRIPE_SECRET_KEY", + "Content-Type": "application/x-www-form-urlencoded", + "User-Agent": "Stripe/v1 stripity-stripe/1.4.0" + }, + "method": "post", + "options": [], + "request_body": "", + "url": "https://api.stripe.com/v1/customers" + }, + "response": { + "body": "{\n \"id\": \"cus_Ay3GqeMIz0WkEm\",\n \"object\": \"customer\",\n \"account_balance\": 0,\n \"created\": 1499236726,\n \"currency\": null,\n \"default_source\": \"card_1Ac79uCM35SG8uZjRucyPQvx\",\n \"delinquent\": false,\n \"description\": \"Test Account\",\n \"discount\": null,\n \"email\": \"invoices_test2@localhost\",\n \"livemode\": false,\n \"metadata\": {},\n \"shipping\": null,\n \"sources\": {\n \"object\": \"list\",\n \"data\": [\n {\n \"id\": \"card_1Ac79uCM35SG8uZjRucyPQvx\",\n \"object\": \"card\",\n \"address_city\": null,\n \"address_country\": null,\n \"address_line1\": null,\n \"address_line1_check\": null,\n \"address_line2\": null,\n \"address_state\": null,\n \"address_zip\": null,\n \"address_zip_check\": null,\n \"brand\": \"Visa\",\n \"country\": \"US\",\n \"customer\": \"cus_Ay3GqeMIz0WkEm\",\n \"cvc_check\": \"pass\",\n \"dynamic_last4\": null,\n \"exp_month\": 1,\n \"exp_year\": 2018,\n \"fingerprint\": \"KTWhNpFM0faAWygq\",\n \"funding\": \"unknown\",\n \"last4\": \"1111\",\n \"metadata\": {},\n \"name\": \"Joe Test User\",\n \"tokenization_method\": null\n }\n ],\n \"has_more\": false,\n \"total_count\": 1,\n \"url\": \"/v1/customers/cus_Ay3GqeMIz0WkEm/sources\"\n },\n \"subscriptions\": {\n \"object\": \"list\",\n \"data\": [],\n \"has_more\": false,\n \"total_count\": 0,\n \"url\": \"/v1/customers/cus_Ay3GqeMIz0WkEm/subscriptions\"\n }\n}\n", + "headers": { + "Server": "nginx", + "Date": "Wed, 05 Jul 2017 06:38:46 GMT", + "Content-Type": "application/json", + "Content-Length": "1423", + "Connection": "keep-alive", + "Access-Control-Allow-Credentials": "true", + "Access-Control-Allow-Methods": "GET, POST, HEAD, OPTIONS, DELETE", + "Access-Control-Allow-Origin": "*", + "Access-Control-Max-Age": "300", + "Cache-Control": "no-cache, no-store", + "Request-Id": "req_Ay3GCtDFhaWV5Z", + "Stripe-Version": "2017-06-05", + "Strict-Transport-Security": "max-age=31556926; includeSubDomains" + }, + "status_code": 200, + "type": "ok" + } + }, + { + "request": { + "body": "plan=test-std", + "headers": { + "Authorization": "Bearer STRIPE_SECRET_KEY", + "Content-Type": "application/x-www-form-urlencoded", + "User-Agent": "Stripe/v1 stripity-stripe/1.4.0" + }, + "method": "post", + "options": [], + "request_body": "", + "url": "https://api.stripe.com/v1/customers/cus_Ay3GqeMIz0WkEm/subscriptions" + }, + "response": { + "body": "{\n \"id\": \"sub_Ay3GDAbPurf2VP\",\n \"object\": \"subscription\",\n \"application_fee_percent\": null,\n \"cancel_at_period_end\": false,\n \"canceled_at\": null,\n \"created\": 1499236727,\n \"current_period_end\": 1501915127,\n \"current_period_start\": 1499236727,\n \"customer\": \"cus_Ay3GqeMIz0WkEm\",\n \"discount\": null,\n \"ended_at\": null,\n \"items\": {\n \"object\": \"list\",\n \"data\": [\n {\n \"id\": \"si_1Ac79vCM35SG8uZjMlydqV20\",\n \"object\": \"subscription_item\",\n \"created\": 1499236727,\n \"plan\": {\n \"id\": \"test-std\",\n \"object\": \"plan\",\n \"amount\": 100,\n \"created\": 1499236723,\n \"currency\": \"usd\",\n \"interval\": \"month\",\n \"interval_count\": 1,\n \"livemode\": false,\n \"metadata\": {},\n \"name\": \"Test Plan Standard\",\n \"statement_descriptor\": null,\n \"trial_period_days\": null\n },\n \"quantity\": 1\n }\n ],\n \"has_more\": false,\n \"total_count\": 1,\n \"url\": \"/v1/subscription_items?subscription=sub_Ay3GDAbPurf2VP\"\n },\n \"livemode\": false,\n \"metadata\": {},\n \"plan\": {\n \"id\": \"test-std\",\n \"object\": \"plan\",\n \"amount\": 100,\n \"created\": 1499236723,\n \"currency\": \"usd\",\n \"interval\": \"month\",\n \"interval_count\": 1,\n \"livemode\": false,\n \"metadata\": {},\n \"name\": \"Test Plan Standard\",\n \"statement_descriptor\": null,\n \"trial_period_days\": null\n },\n \"quantity\": 1,\n \"start\": 1499236727,\n \"status\": \"active\",\n \"tax_percent\": null,\n \"trial_end\": null,\n \"trial_start\": null\n}\n", + "headers": { + "Server": "nginx", + "Date": "Wed, 05 Jul 2017 06:38:47 GMT", + "Content-Type": "application/json", + "Content-Length": "1548", + "Connection": "keep-alive", + "Access-Control-Allow-Credentials": "true", + "Access-Control-Allow-Methods": "GET, POST, HEAD, OPTIONS, DELETE", + "Access-Control-Allow-Origin": "*", + "Access-Control-Max-Age": "300", + "Cache-Control": "no-cache, no-store", + "Request-Id": "req_Ay3GLQ5B4y7y3C", + "Stripe-Version": "2017-06-05", + "Strict-Transport-Security": "max-age=31556926; includeSubDomains" + }, + "status_code": 200, + "type": "ok" + } + }, + { + "request": { + "body": "customer=cus_Ay3GqeMIz0WkEm&amount=10¤cy=usd&subscription=sub_Ay3GDAbPurf2VP", + "headers": { + "Authorization": "Bearer STRIPE_SECRET_KEY", + "Content-Type": "application/x-www-form-urlencoded", + "User-Agent": "Stripe/v1 stripity-stripe/1.4.0" + }, + "method": "post", + "options": [], + "request_body": "", + "url": "https://api.stripe.com/v1/invoiceitems" + }, + "response": { + "body": "{\n \"id\": \"ii_1Ac79wCM35SG8uZjg219Etgu\",\n \"object\": \"invoiceitem\",\n \"amount\": 10,\n \"currency\": \"usd\",\n \"customer\": \"cus_Ay3GqeMIz0WkEm\",\n \"date\": 1499236728,\n \"description\": null,\n \"discountable\": true,\n \"invoice\": null,\n \"livemode\": false,\n \"metadata\": {},\n \"period\": {\n \"start\": 1499236728,\n \"end\": 1499236728\n },\n \"plan\": null,\n \"proration\": false,\n \"quantity\": null,\n \"subscription\": \"sub_Ay3GDAbPurf2VP\"\n}\n", + "headers": { + "Server": "nginx", + "Date": "Wed, 05 Jul 2017 06:38:48 GMT", + "Content-Type": "application/json", + "Content-Length": "433", + "Connection": "keep-alive", + "Access-Control-Allow-Credentials": "true", + "Access-Control-Allow-Methods": "GET, POST, HEAD, OPTIONS, DELETE", + "Access-Control-Allow-Origin": "*", + "Access-Control-Max-Age": "300", + "Cache-Control": "no-cache, no-store", + "Request-Id": "req_Ay3GBrWEx8nhHl", + "Stripe-Version": "2017-06-05", + "Strict-Transport-Security": "max-age=31556926; includeSubDomains" + }, + "status_code": 200, + "type": "ok" + } + }, + { + "request": { + "body": "customer=cus_Ay3GqeMIz0WkEm&subscription=sub_Ay3GDAbPurf2VP&metadata[app_order_id]=ABC1234&metadata[app_attr1]=xyz1", + "headers": { + "Authorization": "Bearer STRIPE_SECRET_KEY", + "Content-Type": "application/x-www-form-urlencoded", + "User-Agent": "Stripe/v1 stripity-stripe/1.4.0" + }, + "method": "post", + "options": [], + "request_body": "", + "url": "https://api.stripe.com/v1/invoices" + }, + "response": { + "body": "{\n \"id\": \"in_1Ac79wCM35SG8uZjktE8OgYt\",\n \"object\": \"invoice\",\n \"amount_due\": 10,\n \"application_fee\": null,\n \"attempt_count\": 0,\n \"attempted\": false,\n \"charge\": null,\n \"closed\": false,\n \"currency\": \"usd\",\n \"customer\": \"cus_Ay3GqeMIz0WkEm\",\n \"date\": 1499236728,\n \"description\": null,\n \"discount\": null,\n \"ending_balance\": null,\n \"forgiven\": false,\n \"lines\": {\n \"object\": \"list\",\n \"data\": [\n {\n \"id\": \"ii_1Ac79wCM35SG8uZjg219Etgu\",\n \"object\": \"line_item\",\n \"amount\": 10,\n \"currency\": \"usd\",\n \"description\": null,\n \"discountable\": true,\n \"livemode\": false,\n \"metadata\": {},\n \"period\": {\n \"start\": 1499236728,\n \"end\": 1499236728\n },\n \"plan\": null,\n \"proration\": false,\n \"quantity\": null,\n \"subscription\": \"sub_Ay3GDAbPurf2VP\",\n \"type\": \"invoiceitem\"\n }\n ],\n \"has_more\": false,\n \"total_count\": 1,\n \"url\": \"/v1/invoices/in_1Ac79wCM35SG8uZjktE8OgYt/lines\"\n },\n \"livemode\": false,\n \"metadata\": {\n \"app_order_id\": \"ABC1234\",\n \"app_attr1\": \"xyz1\"\n },\n \"next_payment_attempt\": 1499240328,\n \"paid\": false,\n \"period_end\": 1499236728,\n \"period_start\": 1499236727,\n \"receipt_number\": null,\n \"starting_balance\": 0,\n \"statement_descriptor\": null,\n \"subscription\": \"sub_Ay3GDAbPurf2VP\",\n \"subtotal\": 10,\n \"tax\": null,\n \"tax_percent\": null,\n \"total\": 10,\n \"webhooks_delivered_at\": null\n}\n", + "headers": { + "Server": "nginx", + "Date": "Wed, 05 Jul 2017 06:38:48 GMT", + "Content-Type": "application/json", + "Content-Length": "1458", + "Connection": "keep-alive", + "Access-Control-Allow-Credentials": "true", + "Access-Control-Allow-Methods": "GET, POST, HEAD, OPTIONS, DELETE", + "Access-Control-Allow-Origin": "*", + "Access-Control-Max-Age": "300", + "Cache-Control": "no-cache, no-store", + "Request-Id": "req_Ay3GbzRK2b0L0e", + "Stripe-Version": "2017-06-05", "Strict-Transport-Security": "max-age=31556926; includeSubDomains" }, "status_code": 200, "type": "ok" } } -] +] \ No newline at end of file diff --git a/fixture/vcr_cassettes/invoices_test/teardown.json b/fixture/vcr_cassettes/invoices_test/teardown.json index 79f3b7c6..badc1a30 100644 --- a/fixture/vcr_cassettes/invoices_test/teardown.json +++ b/fixture/vcr_cassettes/invoices_test/teardown.json @@ -3,30 +3,30 @@ "request": { "body": "", "headers": { - "Authorization": "Bearer non_empty_secret_key_string", + "Authorization": "Bearer STRIPE_SECRET_KEY", "Content-Type": "application/x-www-form-urlencoded", "User-Agent": "Stripe/v1 stripity-stripe/1.4.0" }, "method": "delete", "options": [], "request_body": "", - "url": "https://api.stripe.com/v1/customers/cus_8r2jCf6wk8YLyU/subscriptions/sub_8r2j78r42DD6xb" + "url": "https://api.stripe.com/v1/customers/cus_Ay3G4eTAX3FgXd/subscriptions/sub_Ay3GRYIf5J5VBt" }, "response": { - "body": "{\n \"id\": \"sub_8r2j78r42DD6xb\",\n \"object\": \"subscription\",\n \"application_fee_percent\": null,\n \"cancel_at_period_end\": false,\n \"canceled_at\": 1469020934,\n \"created\": 1469020924,\n \"current_period_end\": 1471699324,\n \"current_period_start\": 1469020924,\n \"customer\": \"cus_8r2jCf6wk8YLyU\",\n \"discount\": null,\n \"ended_at\": 1469020934,\n \"livemode\": false,\n \"metadata\": {},\n \"plan\": {\n \"id\": \"test-std\",\n \"object\": \"plan\",\n \"amount\": 100,\n \"created\": 1469020923,\n \"currency\": \"usd\",\n \"interval\": \"month\",\n \"interval_count\": 1,\n \"livemode\": false,\n \"metadata\": {},\n \"name\": \"Test Plan Standard\",\n \"statement_descriptor\": null,\n \"trial_period_days\": null\n },\n \"quantity\": 1,\n \"start\": 1469020924,\n \"status\": \"canceled\",\n \"tax_percent\": null,\n \"trial_end\": null,\n \"trial_start\": null\n}\n", + "body": "{\n \"id\": \"sub_Ay3GRYIf5J5VBt\",\n \"object\": \"subscription\",\n \"application_fee_percent\": null,\n \"cancel_at_period_end\": false,\n \"canceled_at\": 1499236735,\n \"created\": 1499236725,\n \"current_period_end\": 1501915125,\n \"current_period_start\": 1499236725,\n \"customer\": \"cus_Ay3G4eTAX3FgXd\",\n \"discount\": null,\n \"ended_at\": 1499236735,\n \"items\": {\n \"object\": \"list\",\n \"data\": [\n {\n \"id\": \"si_1Ac79tCM35SG8uZjJW619dXs\",\n \"object\": \"subscription_item\",\n \"created\": 1499236725,\n \"plan\": {\n \"id\": \"test-std\",\n \"object\": \"plan\",\n \"amount\": 100,\n \"created\": 1499236723,\n \"currency\": \"usd\",\n \"interval\": \"month\",\n \"interval_count\": 1,\n \"livemode\": false,\n \"metadata\": {},\n \"name\": \"Test Plan Standard\",\n \"statement_descriptor\": null,\n \"trial_period_days\": null\n },\n \"quantity\": 1\n }\n ],\n \"has_more\": false,\n \"total_count\": 1,\n \"url\": \"/v1/subscription_items?subscription=sub_Ay3GRYIf5J5VBt\"\n },\n \"livemode\": false,\n \"metadata\": {},\n \"plan\": {\n \"id\": \"test-std\",\n \"object\": \"plan\",\n \"amount\": 100,\n \"created\": 1499236723,\n \"currency\": \"usd\",\n \"interval\": \"month\",\n \"interval_count\": 1,\n \"livemode\": false,\n \"metadata\": {},\n \"name\": \"Test Plan Standard\",\n \"statement_descriptor\": null,\n \"trial_period_days\": null\n },\n \"quantity\": 1,\n \"start\": 1499236725,\n \"status\": \"canceled\",\n \"tax_percent\": null,\n \"trial_end\": null,\n \"trial_start\": null\n}\n", "headers": { "Server": "nginx", - "Date": "Wed, 20 Jul 2016 13:22:14 GMT", + "Date": "Wed, 05 Jul 2017 06:38:55 GMT", "Content-Type": "application/json", - "Content-Length": "830", + "Content-Length": "1562", "Connection": "keep-alive", "Access-Control-Allow-Credentials": "true", "Access-Control-Allow-Methods": "GET, POST, HEAD, OPTIONS, DELETE", "Access-Control-Allow-Origin": "*", "Access-Control-Max-Age": "300", "Cache-Control": "no-cache, no-store", - "Request-Id": "req_8r2jDwEyECrNId", - "Stripe-Version": "2016-07-06", + "Request-Id": "req_Ay3GUHQiuHgSCG", + "Stripe-Version": "2017-06-05", "Strict-Transport-Security": "max-age=31556926; includeSubDomains" }, "status_code": 200, @@ -37,20 +37,20 @@ "request": { "body": "", "headers": { - "Authorization": "Bearer non_empty_secret_key_string", + "Authorization": "Bearer STRIPE_SECRET_KEY", "Content-Type": "application/x-www-form-urlencoded", "User-Agent": "Stripe/v1 stripity-stripe/1.4.0" }, "method": "delete", "options": [], "request_body": "", - "url": "https://api.stripe.com/v1/customers/cus_8r2jCf6wk8YLyU" + "url": "https://api.stripe.com/v1/customers/cus_Ay3G4eTAX3FgXd" }, "response": { - "body": "{\n \"deleted\": true,\n \"id\": \"cus_8r2jCf6wk8YLyU\"\n}\n", + "body": "{\n \"deleted\": true,\n \"id\": \"cus_Ay3G4eTAX3FgXd\"\n}\n", "headers": { "Server": "nginx", - "Date": "Wed, 20 Jul 2016 13:22:15 GMT", + "Date": "Wed, 05 Jul 2017 06:38:56 GMT", "Content-Type": "application/json", "Content-Length": "52", "Connection": "keep-alive", @@ -59,8 +59,8 @@ "Access-Control-Allow-Origin": "*", "Access-Control-Max-Age": "300", "Cache-Control": "no-cache, no-store", - "Request-Id": "req_8r2jEL8kcBQ1PG", - "Stripe-Version": "2016-07-06", + "Request-Id": "req_Ay3GM7w6STXSAc", + "Stripe-Version": "2017-06-05", "Strict-Transport-Security": "max-age=31556926; includeSubDomains" }, "status_code": 200, @@ -71,7 +71,7 @@ "request": { "body": "", "headers": { - "Authorization": "Bearer non_empty_secret_key_string", + "Authorization": "Bearer STRIPE_SECRET_KEY", "Content-Type": "application/x-www-form-urlencoded", "User-Agent": "Stripe/v1 stripity-stripe/1.4.0" }, @@ -84,7 +84,7 @@ "body": "{\n \"deleted\": true,\n \"id\": \"test-std\"\n}\n", "headers": { "Server": "nginx", - "Date": "Wed, 20 Jul 2016 13:22:15 GMT", + "Date": "Wed, 05 Jul 2017 06:38:56 GMT", "Content-Type": "application/json", "Content-Length": "42", "Connection": "keep-alive", @@ -93,8 +93,8 @@ "Access-Control-Allow-Origin": "*", "Access-Control-Max-Age": "300", "Cache-Control": "no-cache, no-store", - "Request-Id": "req_8r2jRFJ5YTfxR1", - "Stripe-Version": "2016-07-06", + "Request-Id": "req_Ay3GwBClTB3ixK", + "Stripe-Version": "2017-06-05", "Strict-Transport-Security": "max-age=31556926; includeSubDomains" }, "status_code": 200, @@ -105,7 +105,7 @@ "request": { "body": "", "headers": { - "Authorization": "Bearer non_empty_secret_key_string", + "Authorization": "Bearer STRIPE_SECRET_KEY", "Content-Type": "application/x-www-form-urlencoded", "User-Agent": "Stripe/v1 stripity-stripe/1.4.0" }, @@ -118,7 +118,7 @@ "body": "{\n \"deleted\": true,\n \"id\": \"test-dlx\"\n}\n", "headers": { "Server": "nginx", - "Date": "Wed, 20 Jul 2016 13:22:15 GMT", + "Date": "Wed, 05 Jul 2017 06:38:57 GMT", "Content-Type": "application/json", "Content-Length": "42", "Connection": "keep-alive", @@ -127,12 +127,12 @@ "Access-Control-Allow-Origin": "*", "Access-Control-Max-Age": "300", "Cache-Control": "no-cache, no-store", - "Request-Id": "req_8r2jvHtTAISYVR", - "Stripe-Version": "2016-07-06", + "Request-Id": "req_Ay3GoZKY0U9GNF", + "Stripe-Version": "2017-06-05", "Strict-Transport-Security": "max-age=31556926; includeSubDomains" }, "status_code": 200, "type": "ok" } } -] +] \ No newline at end of file diff --git a/fixture/vcr_cassettes/invoices_test/upcoming.json b/fixture/vcr_cassettes/invoices_test/upcoming.json index 1899e437..8d557d0a 100644 --- a/fixture/vcr_cassettes/invoices_test/upcoming.json +++ b/fixture/vcr_cassettes/invoices_test/upcoming.json @@ -1,9 +1,9 @@ [ { "request": { - "body": "customer=cus_8r2jCf6wk8YLyU&subscription=sub_8r2j78r42DD6xb", + "body": "customer=cus_Ay3G4eTAX3FgXd&subscription=sub_Ay3GRYIf5J5VBt", "headers": { - "Authorization": "Bearer non_empty_secret_key_string", + "Authorization": "Bearer STRIPE_SECRET_KEY", "Content-Type": "application/x-www-form-urlencoded", "User-Agent": "Stripe/v1 stripity-stripe/1.4.0" }, @@ -13,24 +13,24 @@ "url": "https://api.stripe.com/v1/invoices/upcoming" }, "response": { - "body": "{\n \"object\": \"invoice\",\n \"amount_due\": 100,\n \"application_fee\": null,\n \"attempt_count\": 0,\n \"attempted\": false,\n \"charge\": null,\n \"closed\": false,\n \"currency\": \"usd\",\n \"customer\": \"cus_8r2jCf6wk8YLyU\",\n \"date\": 1471699324,\n \"description\": null,\n \"discount\": null,\n \"ending_balance\": null,\n \"forgiven\": false,\n \"lines\": {\n \"object\": \"list\",\n \"data\": [\n {\n \"id\": \"sub_8r2j78r42DD6xb\",\n \"object\": \"line_item\",\n \"amount\": 100,\n \"currency\": \"usd\",\n \"description\": null,\n \"discountable\": true,\n \"livemode\": false,\n \"metadata\": {},\n \"period\": {\n \"start\": 1471699324,\n \"end\": 1474377724\n },\n \"plan\": {\n \"id\": \"test-std\",\n \"object\": \"plan\",\n \"amount\": 100,\n \"created\": 1469020923,\n \"currency\": \"usd\",\n \"interval\": \"month\",\n \"interval_count\": 1,\n \"livemode\": false,\n \"metadata\": {},\n \"name\": \"Test Plan Standard\",\n \"statement_descriptor\": null,\n \"trial_period_days\": null\n },\n \"proration\": false,\n \"quantity\": 1,\n \"subscription\": null,\n \"type\": \"subscription\"\n }\n ],\n \"has_more\": false,\n \"total_count\": 1,\n \"url\": \"/v1/invoices/upcoming/lines?customer=cus_8r2jCf6wk8YLyU\\u0026subscription=sub_8r2j78r42DD6xb\"\n },\n \"livemode\": false,\n \"metadata\": {},\n \"next_payment_attempt\": 1471702924,\n \"paid\": false,\n \"period_end\": 1471699324,\n \"period_start\": 1469020924,\n \"receipt_number\": null,\n \"starting_balance\": 0,\n \"statement_descriptor\": null,\n \"subscription\": \"sub_8r2j78r42DD6xb\",\n \"subtotal\": 100,\n \"tax\": null,\n \"tax_percent\": null,\n \"total\": 100,\n \"webhooks_delivered_at\": null\n}\n", + "body": "{\n \"object\": \"invoice\",\n \"amount_due\": 100,\n \"application_fee\": null,\n \"attempt_count\": 0,\n \"attempted\": false,\n \"charge\": null,\n \"closed\": false,\n \"currency\": \"usd\",\n \"customer\": \"cus_Ay3G4eTAX3FgXd\",\n \"date\": 1501915125,\n \"description\": null,\n \"discount\": null,\n \"ending_balance\": null,\n \"forgiven\": false,\n \"lines\": {\n \"object\": \"list\",\n \"data\": [\n {\n \"id\": \"sub_Ay3GRYIf5J5VBt\",\n \"object\": \"line_item\",\n \"amount\": 100,\n \"currency\": \"usd\",\n \"description\": null,\n \"discountable\": true,\n \"livemode\": false,\n \"metadata\": {},\n \"period\": {\n \"start\": 1501915125,\n \"end\": 1504593525\n },\n \"plan\": {\n \"id\": \"test-std\",\n \"object\": \"plan\",\n \"amount\": 100,\n \"created\": 1499236723,\n \"currency\": \"usd\",\n \"interval\": \"month\",\n \"interval_count\": 1,\n \"livemode\": false,\n \"metadata\": {},\n \"name\": \"Test Plan Standard\",\n \"statement_descriptor\": null,\n \"trial_period_days\": null\n },\n \"proration\": false,\n \"quantity\": 1,\n \"subscription\": null,\n \"subscription_item\": \"si_1Ac79tCM35SG8uZjJW619dXs\",\n \"type\": \"subscription\"\n }\n ],\n \"has_more\": false,\n \"total_count\": 1,\n \"url\": \"/v1/invoices/upcoming/lines?customer=cus_Ay3G4eTAX3FgXd\\u0026subscription=sub_Ay3GRYIf5J5VBt\"\n },\n \"livemode\": false,\n \"metadata\": {},\n \"next_payment_attempt\": 1501918725,\n \"paid\": false,\n \"period_end\": 1501915125,\n \"period_start\": 1499236725,\n \"receipt_number\": null,\n \"starting_balance\": 0,\n \"statement_descriptor\": null,\n \"subscription\": \"sub_Ay3GRYIf5J5VBt\",\n \"subtotal\": 100,\n \"tax\": null,\n \"tax_percent\": null,\n \"total\": 100,\n \"webhooks_delivered_at\": null\n}\n", "headers": { "Server": "nginx", - "Date": "Wed, 20 Jul 2016 13:22:13 GMT", + "Date": "Wed, 05 Jul 2017 06:38:50 GMT", "Content-Type": "application/json", - "Content-Length": "1767", + "Content-Length": "1827", "Connection": "keep-alive", "Access-Control-Allow-Credentials": "true", "Access-Control-Allow-Methods": "GET, POST, HEAD, OPTIONS, DELETE", "Access-Control-Allow-Origin": "*", "Access-Control-Max-Age": "300", "Cache-Control": "no-cache, no-store", - "Request-Id": "req_8r2jmruFZjSHUO", - "Stripe-Version": "2016-07-06", + "Request-Id": "req_Ay3GlgwrzkJUdI", + "Stripe-Version": "2017-06-05", "Strict-Transport-Security": "max-age=31556926; includeSubDomains" }, "status_code": 200, "type": "ok" } } -] +] \ No newline at end of file diff --git a/fixture/vcr_cassettes/invoices_test/upcoming_with_key.json b/fixture/vcr_cassettes/invoices_test/upcoming_with_key.json index 44c0e9e7..dee351ed 100644 --- a/fixture/vcr_cassettes/invoices_test/upcoming_with_key.json +++ b/fixture/vcr_cassettes/invoices_test/upcoming_with_key.json @@ -1,9 +1,9 @@ [ { "request": { - "body": "customer=cus_8r2jCf6wk8YLyU", + "body": "customer=cus_Ay3G4eTAX3FgXd", "headers": { - "Authorization": "Bearer non_empty_secret_key_string", + "Authorization": "Bearer STRIPE_SECRET_KEY", "Content-Type": "application/x-www-form-urlencoded", "User-Agent": "Stripe/v1 stripity-stripe/1.4.0" }, @@ -13,24 +13,24 @@ "url": "https://api.stripe.com/v1/invoices/upcoming" }, "response": { - "body": "{\n \"object\": \"invoice\",\n \"amount_due\": 100,\n \"application_fee\": null,\n \"attempt_count\": 0,\n \"attempted\": false,\n \"charge\": null,\n \"closed\": false,\n \"currency\": \"usd\",\n \"customer\": \"cus_8r2jCf6wk8YLyU\",\n \"date\": 1471699324,\n \"description\": null,\n \"discount\": null,\n \"ending_balance\": null,\n \"forgiven\": false,\n \"lines\": {\n \"object\": \"list\",\n \"data\": [\n {\n \"id\": \"sub_8r2j78r42DD6xb\",\n \"object\": \"line_item\",\n \"amount\": 100,\n \"currency\": \"usd\",\n \"description\": null,\n \"discountable\": true,\n \"livemode\": false,\n \"metadata\": {},\n \"period\": {\n \"start\": 1471699324,\n \"end\": 1474377724\n },\n \"plan\": {\n \"id\": \"test-std\",\n \"object\": \"plan\",\n \"amount\": 100,\n \"created\": 1469020923,\n \"currency\": \"usd\",\n \"interval\": \"month\",\n \"interval_count\": 1,\n \"livemode\": false,\n \"metadata\": {},\n \"name\": \"Test Plan Standard\",\n \"statement_descriptor\": null,\n \"trial_period_days\": null\n },\n \"proration\": false,\n \"quantity\": 1,\n \"subscription\": null,\n \"type\": \"subscription\"\n }\n ],\n \"has_more\": false,\n \"total_count\": 1,\n \"url\": \"/v1/invoices/upcoming/lines?customer=cus_8r2jCf6wk8YLyU\"\n },\n \"livemode\": false,\n \"metadata\": {},\n \"next_payment_attempt\": 1471702924,\n \"paid\": false,\n \"period_end\": 1471699324,\n \"period_start\": 1469020924,\n \"receipt_number\": null,\n \"starting_balance\": 0,\n \"statement_descriptor\": null,\n \"subscription\": \"sub_8r2j78r42DD6xb\",\n \"subtotal\": 100,\n \"tax\": null,\n \"tax_percent\": null,\n \"total\": 100,\n \"webhooks_delivered_at\": null\n}\n", + "body": "{\n \"object\": \"invoice\",\n \"amount_due\": 100,\n \"application_fee\": null,\n \"attempt_count\": 0,\n \"attempted\": false,\n \"charge\": null,\n \"closed\": false,\n \"currency\": \"usd\",\n \"customer\": \"cus_Ay3G4eTAX3FgXd\",\n \"date\": 1501915125,\n \"description\": null,\n \"discount\": null,\n \"ending_balance\": null,\n \"forgiven\": false,\n \"lines\": {\n \"object\": \"list\",\n \"data\": [\n {\n \"id\": \"sub_Ay3GRYIf5J5VBt\",\n \"object\": \"line_item\",\n \"amount\": 100,\n \"currency\": \"usd\",\n \"description\": null,\n \"discountable\": true,\n \"livemode\": false,\n \"metadata\": {},\n \"period\": {\n \"start\": 1501915125,\n \"end\": 1504593525\n },\n \"plan\": {\n \"id\": \"test-std\",\n \"object\": \"plan\",\n \"amount\": 100,\n \"created\": 1499236723,\n \"currency\": \"usd\",\n \"interval\": \"month\",\n \"interval_count\": 1,\n \"livemode\": false,\n \"metadata\": {},\n \"name\": \"Test Plan Standard\",\n \"statement_descriptor\": null,\n \"trial_period_days\": null\n },\n \"proration\": false,\n \"quantity\": 1,\n \"subscription\": null,\n \"subscription_item\": \"si_1Ac79tCM35SG8uZjJW619dXs\",\n \"type\": \"subscription\"\n }\n ],\n \"has_more\": false,\n \"total_count\": 1,\n \"url\": \"/v1/invoices/upcoming/lines?customer=cus_Ay3G4eTAX3FgXd\"\n },\n \"livemode\": false,\n \"metadata\": {},\n \"next_payment_attempt\": 1501918725,\n \"paid\": false,\n \"period_end\": 1501915125,\n \"period_start\": 1499236725,\n \"receipt_number\": null,\n \"starting_balance\": 0,\n \"statement_descriptor\": null,\n \"subscription\": \"sub_Ay3GRYIf5J5VBt\",\n \"subtotal\": 100,\n \"tax\": null,\n \"tax_percent\": null,\n \"total\": 100,\n \"webhooks_delivered_at\": null\n}\n", "headers": { "Server": "nginx", - "Date": "Wed, 20 Jul 2016 13:22:14 GMT", + "Date": "Wed, 05 Jul 2017 06:38:51 GMT", "Content-Type": "application/json", - "Content-Length": "1730", + "Content-Length": "1790", "Connection": "keep-alive", "Access-Control-Allow-Credentials": "true", "Access-Control-Allow-Methods": "GET, POST, HEAD, OPTIONS, DELETE", "Access-Control-Allow-Origin": "*", "Access-Control-Max-Age": "300", "Cache-Control": "no-cache, no-store", - "Request-Id": "req_8r2j2X10vAeb9e", - "Stripe-Version": "2016-07-06", + "Request-Id": "req_Ay3G8MYwbfHR0E", + "Stripe-Version": "2017-06-05", "Strict-Transport-Security": "max-age=31556926; includeSubDomains" }, "status_code": 200, "type": "ok" } } -] +] \ No newline at end of file diff --git a/lib/stripe/invoices.ex b/lib/stripe/invoices.ex index 5164edb2..79379fb8 100644 --- a/lib/stripe/invoices.ex +++ b/lib/stripe/invoices.ex @@ -2,6 +2,7 @@ @moduledoc """ Main API for working with Invoices at Stripe. Through this API you can: -create + -update -retrieve single -list (paged, 100 max/page) -count @@ -154,6 +155,24 @@ |> Stripe.Util.handle_stripe_response end + @doc """ + Changes Invoice. See Stripe docs as to what you can change. + + ## Example + + ``` + {:ok, invoice} = Stripe.Invoices.change("invoice_id", [closed: true]) + ``` + """ + def change(id, params) do + change(id, params, Stripe.config_or_env_key) + end + + def change(id, params, key) do + Stripe.make_request_with_key(:post, "#{@endpoint}/#{id}", key, params) + |> Stripe.Util.handle_stripe_response + end + @doc """ Retrieve the upcoming invoice for a customer that will show you all the charges that are pending, including subscription renewal charges, invoice item charges, etc. It will also show you any discount that is applicable to the customer. NOTE: this is a preview, not a created invoice diff --git a/mix.lock b/mix.lock index a249f34b..2362f969 100644 --- a/mix.lock +++ b/mix.lock @@ -17,5 +17,5 @@ "mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], []}, "mock": {:hex, :mock, "0.1.3", "657937b03f88fce89b3f7d6becc9f1ec1ac19c71081aeb32117db9bc4d9b3980", [:mix], [{:meck, "~> 0.8.2", [hex: :meck, optional: false]}]}, "poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], []}, - "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.0", "edee20847c42e379bf91261db474ffbe373f8acb56e9079acb6038d4e0bf414f", [:rebar, :make], []}, + "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.0", "edee20847c42e379bf91261db474ffbe373f8acb56e9079acb6038d4e0bf414f", [:make, :rebar], []}, "ssl_verify_hostname": {:hex, :ssl_verify_hostname, "1.0.5"}} diff --git a/test/stripe/invoices_test.exs b/test/stripe/invoices_test.exs index c43c4be1..70a067b4 100644 --- a/test/stripe/invoices_test.exs +++ b/test/stripe/invoices_test.exs @@ -9,13 +9,34 @@ defmodule Stripe.InvoicesTest do customer1 = Helper.create_test_customer "invoices_test1@localhost" {:ok, sub1} = Stripe.Subscriptions.create customer1.id, [plan: "test-std"] - params = [ + invoice_items1_params = [ customer: customer1.id, amount: 10, currency: "usd", subscription: sub1.id ] - {:ok, _ } = Stripe.InvoiceItems.create params + {:ok, _ } = Stripe.InvoiceItems.create invoice_items1_params + + customer2 = Helper.create_test_customer "invoices_test2@localhost" + {:ok, sub2} = Stripe.Subscriptions.create customer2.id, [plan: "test-std"] + + invoice_items2_params = [ + customer: customer2.id, + amount: 10, + currency: "usd", + subscription: sub2.id + ] + {:ok, _ } = Stripe.InvoiceItems.create invoice_items2_params + + invoice_params = [ + subscription: sub2.id, + metadata: [ + app_order_id: "ABC1234", + app_attr1: "xyz1" + ] + ] + {:ok, invoice1} = Stripe.Invoices.create customer2.id, invoice_params + on_exit fn -> use_cassette "invoices_test/teardown", match_requests_on: [:query, :request_body] do Stripe.Subscriptions.cancel customer1.id, sub1.id @@ -23,7 +44,7 @@ defmodule Stripe.InvoicesTest do Helper.delete_test_plans end end - {:ok, [customer1: customer1, sub1: sub1]} + {:ok, [customer1: customer1, sub1: sub1, invoice1: invoice1]} end end @@ -169,4 +190,27 @@ defmodule Stripe.InvoicesTest do assert invoice.object == "invoice" end end + + @tag disabled: false + test "Invoice change", %{invoice1: invoice1} do + use_cassette "invoices_test/change", match_requests_on: [:query, :request_body] do + case Stripe.Invoices.change(invoice1.id, [closed: true]) do + {:ok, invoice} -> assert invoice.closed == true + {:error, err} -> flunk err + end + end + end + + @tag disabled: false + test "Invoice change w/key", %{invoice1: invoice1} do + use_cassette "invoices_test/change_with_key", match_requests_on: [:query, :request_body] do + params = [description: "Some description", closed: true] + case Stripe.Invoices.change(invoice1.id, params, Stripe.config_or_env_key) do + {:ok, invoice} -> + assert invoice.description == "Some description" + assert invoice.closed == true + {:error, err} -> flunk err + end + end + end end diff --git a/test/test_helper.exs b/test/test_helper.exs index f7d0f071..9667e365 100644 --- a/test/test_helper.exs +++ b/test/test_helper.exs @@ -60,4 +60,3 @@ defmodule Helper do res end end -