{"id":18728813,"url":"https://github.com/rubyonworld/2checkout-ruby","last_synced_at":"2025-10-05T19:34:33.875Z","repository":{"id":174007823,"uuid":"542152004","full_name":"RubyOnWorld/2checkout-ruby","owner":"RubyOnWorld","description":"This library provides developers with a simple set of bindings to the 2Checkout purchase routine, Instant Notification Service and Back Office API.","archived":false,"fork":false,"pushed_at":"2022-09-27T16:37:38.000Z","size":95,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-12-28T14:26:50.480Z","etag":null,"topics":["checkout","library","provide","purchase"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RubyOnWorld.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2022-09-27T15:16:39.000Z","updated_at":"2022-09-27T18:21:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"a0c80bf8-1147-47c8-bc37-9584013de5b6","html_url":"https://github.com/RubyOnWorld/2checkout-ruby","commit_stats":null,"previous_names":["rubyonworld/2checkout-ruby"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubyOnWorld%2F2checkout-ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubyOnWorld%2F2checkout-ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubyOnWorld%2F2checkout-ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubyOnWorld%2F2checkout-ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RubyOnWorld","download_url":"https://codeload.github.com/RubyOnWorld/2checkout-ruby/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239599040,"owners_count":19665911,"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","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":["checkout","library","provide","purchase"],"created_at":"2024-11-07T14:24:26.160Z","updated_at":"2025-10-05T19:34:28.834Z","avatar_url":"https://github.com/RubyOnWorld.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"2Checkout Ruby Library\n=====================\n\nThis library provides developers with a simple set of bindings to the 2Checkout purchase routine, Instant Notification Service and Back Office API.\n\nTo use, install the `twocheckout` gem.\n\n```shell\ngem install twocheckout\n```\n\nOr import into your Gemfile.\n\n```ruby\ngem \"twocheckout\"\n```\n\nFull documentation for each binding is provided in the **[wiki](https://github.com/2Checkout/2checkout-ruby/wiki)**.\n\n\nExample Purchase API Usage\n-----------------\n\n*Example Usage:*\n\n```ruby\nTwocheckout::API.credentials = {\n    :seller_id =\u003e '1817037',\n    :private_key =\u003e '3508079E-5383-44D4-BF69-DC619C0D9811'\n}\n\nparams = {\n    :merchantOrderId     =\u003e '123',\n    :token          =\u003e 'ZmYyMzMyZGMtZTY2NS00NDAxLTlhYTQtMTgwZWIyZTgwMzQx',\n    :currency       =\u003e 'USD',\n    :total          =\u003e '1.00',\n    :billingAddr    =\u003e {\n        :name =\u003e 'Testing Tester',\n        :addrLine1 =\u003e '123 Test St',\n        :city =\u003e 'Columbus',\n        :state =\u003e 'OH',\n        :zipCode =\u003e '43123',\n        :country =\u003e 'USA',\n        :email =\u003e 'cchristenson@2co.com',\n        :phoneNumber =\u003e '555-555-5555'\n    }\n}\n\nbegin\n  result = Twocheckout::Checkout.authorize(params)\nrescue Exception =\u003e e\n  puts e.message\nend\n```\n\n*Example Response:*\n\n```ruby\n#\u003cTwocheckout::Checkout\u003e{\n\"type\"=\u003e\"AuthResponse\",\n \"lineItems\"=\u003e\n  [{\"options\"=\u003e[],\n    \"price\"=\u003e\"1.00\",\n    \"quantity\"=\u003e\"1\",\n    \"recurrence\"=\u003enil,\n    \"startupFee\"=\u003enil,\n    \"productId\"=\u003e\"\",\n    \"tangible\"=\u003e\"N\",\n    \"name\"=\u003e\"123\",\n    \"type\"=\u003e\"product\",\n    \"description\"=\u003e\"\",\n    \"duration\"=\u003enil}],\n \"transactionId\"=\u003e\"205180760223\",\n \"billingAddr\"=\u003e\n  {\"addrLine1\"=\u003e\"123 Test St\",\n   \"addrLine2\"=\u003enil,\n   \"city\"=\u003e\"Columbus\",\n   \"zipCode\"=\u003e\"43123\",\n   \"phoneNumber\"=\u003e\"555-555-5555\",\n   \"phoneExtension\"=\u003enil,\n   \"email\"=\u003e\"cchristenson@2co.com\",\n   \"name\"=\u003e\"Testing Tester\",\n   \"state\"=\u003e\"OH\",\n   \"country\"=\u003e\"USA\"},\n \"shippingAddr\"=\u003e\n  {\"addrLine1\"=\u003enil,\n   \"addrLine2\"=\u003enil,\n   \"city\"=\u003enil,\n   \"zipCode\"=\u003enil,\n   \"phoneNumber\"=\u003enil,\n   \"phoneExtension\"=\u003enil,\n   \"email\"=\u003enil,\n   \"name\"=\u003enil,\n   \"state\"=\u003enil,\n   \"country\"=\u003enil},\n \"merchantOrderId\"=\u003e\"123\",\n \"orderNumber\"=\u003e\"205180760214\",\n \"recurrentInstallmentId\"=\u003enil,\n \"responseMsg\"=\u003e\"Successfully authorized the provided credit card\",\n \"responseCode\"=\u003e\"APPROVED\",\n \"total\"=\u003e\"1.00\",\n \"currencyCode\"=\u003e\"USD\",\n \"errors\"=\u003enil}\n```\n\n\nExample Admin API Usage\n-----------------\n\n*Example Usage:*\n\n```ruby\nTwocheckout::API.credentials = { :username =\u003e 'APIuser1817037', :password =\u003e 'APIpass1817037' }\n\nsale = Twocheckout::Sale.find(:sale_id =\u003e 4838212958)\nsale.stop_recurring!\n```\n\n*Example Response:*\n\n```ruby\n[\n    #\u003cTwocheckout: : LineItem: 4838213015\u003e{\n        \"affiliate_vendor_id\"=\u003enil,\n        \"billing\"=\u003e#\u003cTwocheckout: : HashObject: 70259731127120\u003e{\n            \"amount\"=\u003e\"0.01\",\n            \"bill_method\"=\u003e\"paypal_int\",\n            \"billing_id\"=\u003e\"4838213024\",\n            \"customer_amount\"=\u003e\"0.01\",\n            \"customer_id\"=\u003e\"4838212964\",\n            \"date_deposited\"=\u003enil,\n            \"date_end\"=\u003enil,\n            \"date_fail\"=\u003e\"2012-10-30\",\n            \"date_next\"=\u003e\"2012-10-30\",\n            \"date_pending\"=\u003e\"2012-10-23\",\n            \"date_start\"=\u003e\"2012-10-25\",\n            \"lineitem_id\"=\u003e\"4838213015\",\n            \"recurring_status\"=\u003e\"active\",\n            \"status\"=\u003e\"bill\",\n            \"usd_amount\"=\u003e\"0.01\",\n            \"vendor_amount\"=\u003e\"0.01\"\n        },\n        \"commission\"=\u003enil,\n        \"commission_affiliate_vendor_id\"=\u003enil,\n        \"commission_flat_rate\"=\u003enil,\n        \"commission_percentage\"=\u003enil,\n        \"commission_type\"=\u003enil,\n        \"commission_usd_amount\"=\u003enil,\n        \"customer_amount\"=\u003e\"0.01\",\n        \"flat_rate\"=\u003enil,\n        \"installment\"=\u003e\"1\",\n        \"invoice_id\"=\u003e\"4838212967\",\n        \"lc_affiliate_vendor_id\"=\u003enil,\n        \"lc_usd_amount\"=\u003enil,\n        \"lineitem_id\"=\u003e\"4838213015\",\n        \"linked_id\"=\u003enil,\n        \"options\"=\u003e[\n            {\n                \"customer_surcharge\"=\u003e\"0.01\",\n                \"lineitem_id\"=\u003e\"4838213015\",\n                \"lineitem_option_id\"=\u003e\"4838213021\",\n                \"option_name\"=\u003e\"0.5\",\n                \"option_value\"=\u003e\"test1\",\n                \"usd_surcharge\"=\u003e\"0.01\",\n                \"vendor_surcharge\"=\u003e\"0.01\"\n            }\n        ],\n        \"percentage\"=\u003enil,\n        \"product_description\"=\u003e\"This is a test product!\",\n        \"product_duration\"=\u003e\"Forever\",\n        \"product_handling\"=\u003e\"0.00\",\n        \"product_id\"=\u003e\"4774388564\",\n        \"product_is_cart\"=\u003e\"0\",\n        \"product_name\"=\u003e\"Example Product\",\n        \"product_price\"=\u003e\"0.01\",\n        \"product_recurrence\"=\u003e\"1 Week\",\n        \"product_startup_fee\"=\u003enil,\n        \"product_tangible\"=\u003e\"0\",\n        \"sale_id\"=\u003e\"4838212958\",\n        \"status\"=\u003e\"bill\",\n        \"type\"=\u003enil,\n        \"usd_amount\"=\u003e\"0.01\",\n        \"usd_commission\"=\u003enil,\n        \"vendor_amount\"=\u003e\"0.01\",\n        \"vendor_product_id\"=\u003e\"example123\"\n    }\n]\n```\n\nExample Checkout Usage:\n-----------------------\n\n*Example Usage:*\n\n```ruby\nrequire \"sinatra\"\n\nget '/' do\n  @@form = Twocheckout::Checkout.submit({ 'sid' =\u003e '1817037', 'mode' =\u003e '2CO','li_0_name' =\u003e 'Example Product', 'li_0_price' =\u003e '1.00'})\n  @@form\nend\n```\n\n*Example Response:*\n\n```html\n\u003cform id=\"2checkout\" action=\"https://www.2checkout.com/checkout/spurchase\" method=\"post\"\u003e\n\u003cinput type=\"hidden\" name=\"sid\" value=\"1817037\" /\u003e\n\u003cinput type=\"hidden\" name=\"mode\" value=\"2CO\" /\u003e\n\u003cinput type=\"hidden\" name=\"li_0_name\" value=\"Example Product\" /\u003e\n\u003cinput type=\"hidden\" name=\"li_0_price\" value=\"1.00\" /\u003e\n\u003c/form\u003e\n\u003cscript type=\"text/javascript\"\u003edocument.getElementById('2checkout').submit();\u003c/script\u003e\n```\n\nExample Return Usage:\n---------------------\n\n*Example Usage:*\n\n```ruby\nrequire \"sinatra\"\n\npost '/' do\n  @@response = Twocheckout::ValidateResponse.purchase({:sid =\u003e 1817037, :secret =\u003e \"tango\", :order_number =\u003e params[:order_number], :total =\u003e params[:total], :key =\u003e params[:key]})\n  @@response.inspect\nend\n```\n\n*Example Response:*\n\n```ruby\n{\n    :code =\u003e \"PASS\",\n    :message =\u003e \"Hash Matched\"\n}\n```\n\nExample INS Usage:\n------------------\n\n*Example Usage:*\n\n```ruby\nrequire \"sinatra\"\n\npost '/' do\n @@response = Twocheckout::ValidateResponse.notification({:sale_id =\u003e params[:sale_id], :vendor_id =\u003e 1817037, :invoice_id =\u003e params[:invoice_id], :secret =\u003e \"tango\", :md5_hash =\u003e params[:md5_hash]})\n @@response.inspect\nend\n```\n\n*Example Response:*\n\n```ruby\n{\n    :code =\u003e \"PASS\",\n    :message =\u003e \"Hash Matched\"\n}\n```\n\nExceptions:\n------------------\n\n*Example Catch:*\n\nExceptions are thrown by if an error has returned. It is best to catch these exceptions so that they can be gracefully handled in your application.\n\n\n```ruby\nbegin\n  sale = Twocheckout::Sale.find(:sale_id =\u003e 4786293822)\n  last_invoice = sale.invoices.last\n  last_lineitem = last_invoice.lineitems.last\n  last_lineitem.stop_recurring!\nrescue Exception =\u003e e\n  puts e.message\nend\n```\n\n*Example Exception:*\n\n```ruby\n\"Lineitem is not scheduled to recur.\"\n```\n\nFull documentation for each binding is provided in the **[wiki](https://github.com/2Checkout/2checkout-ruby/wiki)**.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubyonworld%2F2checkout-ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frubyonworld%2F2checkout-ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubyonworld%2F2checkout-ruby/lists"}