{"id":18785677,"url":"https://github.com/dbackowski/simple_subscription_api","last_synced_at":"2025-08-04T06:14:22.026Z","repository":{"id":139747849,"uuid":"130870866","full_name":"dbackowski/simple_subscription_api","owner":"dbackowski","description":null,"archived":false,"fork":false,"pushed_at":"2018-05-03T09:25:26.000Z","size":44,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-21T09:55:59.604Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dbackowski.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-04-24T14:54:26.000Z","updated_at":"2018-05-03T09:25:28.000Z","dependencies_parsed_at":"2023-04-21T17:30:27.554Z","dependency_job_id":null,"html_url":"https://github.com/dbackowski/simple_subscription_api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dbackowski/simple_subscription_api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbackowski%2Fsimple_subscription_api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbackowski%2Fsimple_subscription_api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbackowski%2Fsimple_subscription_api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbackowski%2Fsimple_subscription_api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dbackowski","download_url":"https://codeload.github.com/dbackowski/simple_subscription_api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbackowski%2Fsimple_subscription_api/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268657473,"owners_count":24285509,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-04T02:00:09.867Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T20:49:24.995Z","updated_at":"2025-08-04T06:14:21.976Z","avatar_url":"https://github.com/dbackowski.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple Subscription API [![Build Status](https://travis-ci.org/dbackowski/simple_subscription_api.svg?branch=master)](https://travis-ci.org/dbackowski/simple_subscription_api) [![Coverage Status](https://coveralls.io/repos/github/dbackowski/simple_subscription_api/badge.svg?branch=master)](https://coveralls.io/github/dbackowski/simple_subscription_api?branch=master)\n\n## Billing Gateway API\n\nBilling Gateway API is stub on URL \"http://fake-billing-gateway.com\" with webmock gem as follows:\n\n* all Visa cards returns response status = 200 and paid = true\n\n```ruby\nrails c\n2.5.1 :001 \u003e HTTParty.get('http://fake-billing-gateway.com/?credit_card_number=4552021430083752303\u0026amount=100')\n=\u003e #\u003cHTTParty::Response:0x7f8c10366b10 parsed_response=\"{\\\"id\\\":\\\"dc6900fddc91f3fe\\\",\\\"paid\\\":true,\\\"failure_message\\\":null}\", @response=#\u003cNet::HTTPOK 200  readbody=true\u003e, @headers={}\u003e\n```\n\n* all Mastercard cards first request throws Net::OpenTimeout exception, second one and next returns status = 200 and paid = true\n\n```ruby\nrails c\n2.5.1 :001 \u003e HTTParty.get('http://fake-billing-gateway.com/?credit_card_number=2231644170212817\u0026amount=100')\nTraceback (most recent call last):\n        1: from (irb):9\nNet::OpenTimeout (execution expired)\nmastercard\n2.5.1 :002 \u003e HTTParty.get('http://fake-billing-gateway.com/?credit_card_number=2231644170212817\u0026amount=100')\n =\u003e #\u003cHTTParty::Response:0x2f7ecf0 parsed_response=\"{\\\"id\\\":\\\"7c9525cea676c332\\\",\\\"paid\\\":true,\\\"failure_message\\\":null}\", @response=#\u003cNet::HTTPOK 200  readbody=true\u003e, @headers={}\u003e\n```\n\n* all American Express cards first request throws Net::HTTPServiceUnavailable, second one and next returns status = 200 and paid = true\n\n```ruby\n2.5.1 :001 \u003e HTTParty.get('http://fake-billing-gateway.com/?credit_card_number=371173241821608\u0026amount=100')\n =\u003e #\u003cHTTParty::Response:0x472d630 parsed_response=\"Interval Server Error\", @response=#\u003cNet::HTTPServiceUnavailable 503  readbody=true\u003e, @headers={}\u003e\n2.5.1 :002 \u003e HTTParty.get('http://fake-billing-gateway.com/?credit_card_number=371173241821608\u0026amount=100')\n =\u003e #\u003cHTTParty::Response:0x7f8c1017e2f8 parsed_response=\"{\\\"id\\\":\\\"39c8279b11798f7d\\\",\\\"paid\\\":true,\\\"failure_message\\\":null}\", @response=#\u003cNet::HTTPOK 200  readbody=true\u003e, @headers={}\u003e\n```\n\n* all Maestro cards returns status = 200 and paid = false\n\n```ruby\n2.5.1 :001 \u003e HTTParty.get('http://fake-billing-gateway.com/?credit_card_number=62742036440476668\u0026amount=100')\n =\u003e #\u003cHTTParty::Response:0x3a56c40 parsed_response=\"{\\\"id\\\":\\\"20699734f2befe4f\\\",\\\"paid\\\":false,\\\"failure_message\\\":\\\"insufficient_funds\\\"}\", @response=#\u003cNet::HTTPOK 200  readbody=true\u003e, @headers={}\u003e\n```\n\n* all Discover cards throws timeout exception\n\n```\n2.5.1 :001 \u003e HTTParty.get('http://fake-billing-gateway.com/?credit_card_number=6441422827428017459\u0026amount=100')\nTraceback (most recent call last):\n        1: from (irb):1\nNet::OpenTimeout (execution expired)\n```\n\n## Subscriptions API\n\n### Listing subscriptions\n\n```\ncurl -H \"Content-Type: application/json\" -X GET http://localhost:3000/api/v1/subscriptions\n[{\"id\":1,\"credit_card_number\":\"4640814081369\",\"name\":\"Dwayne Kris\",\"address\":\"883 Glover Shores\",\"country\":\"Reunion\",\"next_billing_date\":\"2018-05-30\",\"created_at\":\"2018-04-30T08:14:41.323Z\",\"updated_at\":\"2018-04-30T08:14:41.323Z\"},{\"id\":2,\"credit_card_number\":\"2224430203084012\",\"name\":\"Xiao Crist\",\"address\":\"1867 Bruen Isle\",\"country\":\"Tokelau\",\"next_billing_date\":\"2018-05-30\",\"created_at\":\"2018-04-30T08:14:52.603Z\",\"updated_at\":\"2018-04-30T08:14:52.603Z\"},{\"id\":3,\"credit_card_number\":\"378380400053328\",\"name\":\"Xiao Crist\",\"address\":\"1867 Bruen Isle\",\"country\":\"Tokelau\",\"next_billing_date\":\"2018-05-30\",\"created_at\":\"2018-04-30T08:14:57.561Z\",\"updated_at\":\"2018-04-30T08:14:57.561Z\"}]\n```\n\n### Creating subscriptions\n\n* example with Visa card\n\n```\ncurl -H \"Content-Type: application/json\" -X POST -d '{\"data\":{\"credit_card_number\":\"4640814081369\",\"name\":\"Dwayne Kris\",\"address\": \"883 Glover Shores\",\"country\":\"Reunion\"}}' http://localhost:3000/api/v1/subscriptions\n{\"id\":1,\"credit_card_number\":\"4640814081369\",\"name\":\"Dwayne Kris\",\"address\":\"883 Glover Shores\",\"country\":\"Reunion\",\"next_billing_date\":\"2018-05-30\",\"created_at\":\"2018-04-30T07:59:28.321Z\",\"updated_at\":\"2018-04-30T07:59:28.321Z\"}\n```\n\n* example with MasterCard card\n\n```\ncurl -H \"Content-Type: application/json\" -X POST -d '{\"data\":{\"credit_card_number\":\"2224430203084012\",\"name\":\"Xiao Crist\",\"address\": \"1867 Bruen Isle\",\"country\":\"Tokelau\"}}' http://localhost:3000/api/v1/subscriptions\n{\"id\":2,\"credit_card_number\":\"2224430203084012\",\"name\":\"Xiao Crist\",\"address\":\"1867 Bruen Isle\",\"country\":\"Tokelau\",\"next_billing_date\":\"2018-05-30\",\"created_at\":\"2018-04-30T08:00:13.309Z\",\"updated_at\":\"2018-04-30T08:00:13.309Z\"}\n```\n\n* example with Amerrican Express card\n\n```\ncurl -H \"Content-Type: application/json\" -X POST -d '{\"data\":{\"credit_card_number\":\"378380400053328\",\"name\":\"Xiao Crist\",\"address\": \"1867 Bruen Isle\",\"country\":\"Tokelau\"}}' http://localhost:3000/api/v1/subscriptions\n{\"id\":3,\"credit_card_number\":\"378380400053328\",\"name\":\"Xiao Crist\",\"address\":\"1867 Bruen Isle\",\"country\":\"Tokelau\",\"next_billing_date\":\"2018-05-30\",\"created_at\":\"2018-04-30T08:00:55.751Z\",\"updated_at\":\"2018-04-30T08:00:55.751Z\"}\n```\n\n* example with Maestro card\n\n```\ncurl -H \"Content-Type: application/json\" -X POST -d '{\"data\":{\"credit_card_number\":\"6167883645588646\",\"name\":\"Craig Brown\",\"address\": \"81750 Johnston Crescent\",\"country\":\"New Zealand\"}}' http://localhost:3000/api/v1/subscriptions\n{\"errors\":\"insufficient_funds\"}\n```\n\n* example with invalid credit card number\n\n```\ncurl -H \"Content-Type: application/json\" -X POST -d '{\"data\":{\"credit_card_number\":\"4640814081361\",\"name\":\"Dwayne Kris\",\"address\": \"883 Glover Shores\",\"country\":\"Reunion\"}}' http://localhost:3000/api/v1/subscriptions\n{\"errors\":[\"Credit card number is invalid\"]}\n```\n\n* example with empty address\n\n```\ncurl -H \"Content-Type: application/json\" -X POST -d '{\"data\":{\"credit_card_number\":\"4640814081369\",\"name\":\"Dwayne Kris\",\"address\": \"\",\"country\":\"Reunion\"}}' http://localhost:3000/api/v1/subscriptions\n{\"errors\":[\"Address can't be blank\"]}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdbackowski%2Fsimple_subscription_api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdbackowski%2Fsimple_subscription_api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdbackowski%2Fsimple_subscription_api/lists"}