{"id":17679974,"url":"https://github.com/costajob/dacom","last_synced_at":"2025-03-30T18:47:57.461Z","repository":{"id":59152679,"uuid":"55229425","full_name":"costajob/dacom","owner":"costajob","description":"A Ruby port of the Dacom/LGU+ payment library for Korea.","archived":false,"fork":false,"pushed_at":"2017-06-27T10:06:43.000Z","size":36,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-08T13:46:57.646Z","etag":null,"topics":["e-commerce","korea","lgu","payment-gateway","ruby"],"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/costajob.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-01T12:05:18.000Z","updated_at":"2018-11-29T11:13:28.000Z","dependencies_parsed_at":"2022-09-13T10:50:20.058Z","dependency_job_id":null,"html_url":"https://github.com/costajob/dacom","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/costajob%2Fdacom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/costajob%2Fdacom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/costajob%2Fdacom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/costajob%2Fdacom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/costajob","download_url":"https://codeload.github.com/costajob/dacom/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246365640,"owners_count":20765546,"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":["e-commerce","korea","lgu","payment-gateway","ruby"],"created_at":"2024-10-24T09:04:58.611Z","updated_at":"2025-03-30T18:47:57.241Z","avatar_url":"https://github.com/costajob.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Table of Contents\n\n* [Scope](#scope)\n* [Workflow](#workflow)\n  * [Client script](#client-script)\n  * [Collecting data](#collecting-data)\n* [Installation](#installation)\n  * [Configuration](#configuration)\n* [Usage](#usage)\n  * [Load credentials](#load-credentials)\n  * [Manage form data](#manage-form-data)\n    * [Set form data](#set-form-data)\n    * [Submit data](#submit-data)\n    * [Response](#response)\n    * [Rollback and error reporting](#rollback-and-error-reporting)\n  * [Logging](#logging)\n\n## Scope\nThis gem is a Ruby porting of the XPay client library used by the [LGU+ (former Dacom)](http://lgdacom.net/) payment gateway used in Korea.  \n\n## Workflow\nThe LGU+ XPay client is used to generate some unique keys mandatory to complete the\npayment process with LGU+.  \n\n### Client script\nThe payment workflow happens on LGU+ servers by including the following JavaScript into the checkout page:\n```\nhttps://xpay.lgdacom.net/xpay/js/xpay_crossplatform.js\n```\n\nThe JavaScript is responsible to:\n* reads the data generated by the ruby library and set some hidden fields present on the checkout page\n* set the form action\n* open an iframe window pointing to the LGU+ server\n* submit the form with parameters collected by LGU+ upon iframe closure\n\nThe official documentation is kind of private unless you have a valid LGU+ account, by checking the JavaScript source you should figure out how it works ;)\n\n### Collecting data \nThe data submitted by form need to be processed by the Ruby client and the response of the service has to be collected by site.\n\n## Installation\nAdd this line to your application's Gemfile:\n```ruby\ngem \"dacom\"\n```\n\nAnd then execute:\n```shell\nbundle\n```\n\nOr install it yourself as:\n```shell\ngem install dacom\n```\n### Configuration\nThis library assumes you have valid LGU+ credentials inside yaml file like that:\n```yaml\nurl: \"https://xpayclient.lgdacom.net/xpay/Gateway.do\"\ntest_url: \"https://xpayclient.lgdacom.net:7443/xpay/Gateway.do\"\naux_url: \"http://xpay.lgdacom.net:7080/xpay/Gateway.do\"\nserver_id: \"01\"\ntimeout: 60\nverify_cert: true\nverify_host: true\nreport_error: true\nauto_rollback: true\nmert_id: \"lgdacomxpay\"\nmert_key: \"\u003cyour-key\u003e\"\ntest_mert_id: \"tlgdacomxpay\"\ntest_mert_key: \"\u003cyour_merchant_id\u003e\"\ntest_mode: true\n```\n\n## Usage\n\n### Load credentials\nThe `Config` class is responsible to load the LGU+ credentials contained into the yaml file:\n```ruby\nrequire \"dacom\"\n\nconfig = Dacom::Config.new(\"./dacom.yml\") # default to \"~/dacom.yml\"\n```\n\n### Manage form data\nOnce you've collected the form data from the iframe, you need to send them back to LGU+ to complete the purchasing.  \nThe `Client` class is responsible to sign the form data with valid authorization codes and communicate them to LGU+:\n```ruby\nclient = Dacom::Client.new(config: config)\n```\n\n#### Set form data\nIn order to fill the client form data with the ones collected by the iframe, you can use the `#set` method:\n```ruby\nclient.set(\"LGD_TXNAME\", \"PaymentByKey\")\nclient.set(\"LGD_AMOUNT\", \u003corder_grand_total\u003e)\nclient.set(\"LGD_AMOUNTCHECKYN\", \"Y\")\n\n# these data are collected by form hidden fields filled by LGU+ iframe\nclient.set(\"LGD_PAYKEY\", params[\"LGD_PAYKEY\"])\nclient.set(\"LGD_PAYTYPE\", params[\"LGD_PAYTYPE\"])\nclient.set(\"LGD_FINANCENAME\", params[\"LGD_FINANCENAME\"])\nclient.set(\"LGD_FINANCECODE\", params[\"LGD_FINANCECODE\"])\nclient.set(\"LGD_ACCOUNTOWNER\", params[\"LGD_ACCOUNTOWNER\"])\n```\n\n#### Submit data\nOnce the form data are set you're ready to communicate them back to LGU+ along with the authorization data:\n```ruby\n res = client.tx\n\n# check response code\nif res.successful?\n  # process order\nelse\n  # present error page\nend\n```\n\nThe `tx` method also accept a block yielding request and response objects before any face-lifting:\n```ruby\nclient.tx do |req, res|\n  p req.body # inspecting the raw body\n  p res # inspecting raw response form LGU+\nend\n```\n\n#### Response\nThe `Response` object is a struct that contains parsed JSON data from LGU+, use it to provide feedback on success/failure:\n```ruby\nputs res\n# \"\u003cDacom::Response:70132949609560, code: \\\"XC01\\\", message: \\\"LGD_TXNAME 필드가 누락되었습니다.\\\", successful: false\u003e\"\n\np res.raw # check raw response\np res.code # check response LGU+ code (check constants.rb file)\np res.message# check message by LGU+ (in KR)\n```\n\n#### Rollback and error reporting\nIn case of payment issues the `Client` is responsible to communicate to LGU+ a rollback procedure and to report any error.  \nThese options are configurable by yaml values:\n```yaml\nreport_error: true  # set to false to avoid reporting on failure\nauto_rollback: true # set to false to avoid sending a rollback procedure\n```\n\n### Logging\nBy default the `Client` class accepts a logger pointing to `dev/null`. \nIn case you want to replace it with yours, just pass it to the constructor:\n```ruby\nmy_logger = Logger.new(STDOUT)\nmy_logger.log_level = Logger::WARN\nclient = Dacom::Client.new(config: config, logger: my_logger)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcostajob%2Fdacom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcostajob%2Fdacom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcostajob%2Fdacom/lists"}