{"id":18131511,"url":"https://github.com/crownedgrouse/be2bill","last_synced_at":"2025-04-06T15:29:17.681Z","repository":{"id":71843047,"uuid":"73000759","full_name":"crownedgrouse/be2bill","owner":"crownedgrouse","description":"Be2bill's Erlang API","archived":false,"fork":false,"pushed_at":"2018-03-02T17:56:52.000Z","size":102,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-12T21:34:43.687Z","etag":null,"topics":["b2b","be2bill","be2bill-erlang-api","erlang","payment","transaction"],"latest_commit_sha":null,"homepage":null,"language":"Erlang","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/crownedgrouse.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":"2016-11-06T15:45:06.000Z","updated_at":"2016-11-06T15:54:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"29e4522b-3d93-478c-8357-cb5b3961ea39","html_url":"https://github.com/crownedgrouse/be2bill","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/crownedgrouse%2Fbe2bill","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crownedgrouse%2Fbe2bill/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crownedgrouse%2Fbe2bill/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crownedgrouse%2Fbe2bill/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/crownedgrouse","download_url":"https://codeload.github.com/crownedgrouse/be2bill/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247502598,"owners_count":20949297,"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":["b2b","be2bill","be2bill-erlang-api","erlang","payment","transaction"],"created_at":"2024-11-01T12:07:43.589Z","updated_at":"2025-04-06T15:29:17.675Z","avatar_url":"https://github.com/crownedgrouse.png","language":"Erlang","funding_links":[],"categories":[],"sub_categories":[],"readme":"# be2bill Erlang API #\n\n\nWork in progress...\n\n## Preamble ##\nThis project offer the use of [be2bill](https://www.be2bill.com/en/) services \nin [Erlang](http://www.erlang.org/) applications, mainly for Erlang CMS \nor commercial websites.\n\n## Note for non Erlangers ##\nThis API is trying to be as close as possible to the [PHP API](https://github.com/Be2bill/php-merchant-api) \nwith the notable difference that Erlang is a [functional langage](https://en.wikipedia.org/wiki/Erlang_(programming_language)), \nand not an Object Oriented langage.\n\nTo do so, objects are [records](http://erlang.org/doc/reference_manual/records.html), \nand class methods are callbacks in [gen_server](http://erlang.org/doc/design_principles/gen_server_concepts.html).\n\n## Other differences ##\nIn order to benefit of Erlang power (high availability, fault tolerance, ...), \nthis project is not only a client API, but a real [OTP application](http://erlang.org/doc/design_principles/applications.html#id80391) \nthat handles all the [be2bill logic](https://developer.be2bill.com/platform) \n(http request retries, switch to backup environment on long time error, batch mode, etc...).\n\nThis let the Erlang coder to concentrate on only the business logic in \nits own code, with a \"fire and forget\" approach, and having the insurance that \n_almost_ no transactions will be lost (see security paragraph hereafter).\n\nOn contrary of PHP API, the web developper(s) do not need to manipulate, and even know, the credentials to do requests.\nThose ones are handled by the be2bill application, from configuration.\nThe web developper just have to do requests on right environment (production or sandbox). \n\nThis project propose also some extra things, like metrics which can be usefull \nfor commercial website dealing with lot of transactions.\n\n## Security aspects ##\n### Git ###\nThis project comes with a `.gitignore` file that avoid any commit of `.config` configuration\nfiles potentially containing sensitive be2bill identifiers, either production or sandbox ones.\n(But this does not protect againt `-f` git argument however !) \n*DO NOT MODIFY OR REMOVE IT* if you fork this project ! \nKeep in mind that if you committed them once, they may be still tracked in the git history.\nConfiguration examples are coming with a `.config.dist` extension : *Never edit them*. \nSimply copy them by removing `.dist` extension and add your credentials there.\n\n### Runtime ###\nPayment processus imply to manipulate some sensitive data.\nTo prevent theft of sensitive data, Erlang processes linked to Production environment\nreceive a [flag 'sensitive'](http://erlang.org/doc/man/erlang.html#process_flag-2)\nat creation, and therefore cannot be traced or observed at runtime.\nThis is *not* the case for sandbox environment processes, for debugging purpose, \nyou are aware. \n\nOnly non sensitive requests (*) are stored on disk until they are commited.\nSo in case of a brutal machine crash, all pending transactions, but sensitive ones,\nwill be hopefully resumed at next start. \nThis is the only case which may lead to a transaction loose.\n`be2bill` application being stopped will refuse new transactions, \nand try to wait for current transactions to be finished before stopping.\n\nAs well, be2bill passwords in application environment variables, are hidden by stars at application start,\nin order to avoid (un)voluntary display on web site by web developpers.\n\n(*) Requests that do not manipulate credit card numbers. \nPayments using an alias are non sensitive, and therefore, are stored on disc.\n\n## Getting started ##\nProcedure below let you quickly start to test in a sanbox environment.\nThis is assumed that you got your own credentials from be2bill in order to use a sanbox.\n\n### Clone project ###\n```\n$\u003e git clone https://github.com/crownedgrouse/be2bill.git\n$\u003e cd be2bill/\n\n```\n\n### Compiling project ###\nFor `erlang.mk` users :\n\n```\n$\u003e make\n$\u003e make bootstrap-rel\n```\n\nFor `rebar` users :\n\n```\n$\u003e rebar compile\n```\n\n### Create a sandbox configuration ###\n\n```\n$\u003e cd priv/\n$\u003e cp sys.config.dist sys.config\n$\u003e cp production.config.dist production.config\n$\u003e cp sandbox.config.dist  sandbox.config\n$\u003e mv *.config ../rel/\n$\u003e cd ../rel/\n\n```\nThen edit `sandbox.config` (at least) in order to write your credentials to access be2bill's sandbox servers. \nThe same with `production.config` if you are ready to do so.\n\nAt same time other configuration parameters can be tuned, see [Configuration](https://github.com/crownedgrouse/be2bill/wiki/Configuration).\n\n### Starting release ###\nFor `erlang.mk` users :\n```\n$\u003e make run\n\n--- snip ---\n(all release start stuff)\n--- snip ---\n\nErlang/OTP 19 [erts-8.1] [source] [smp:2:2] [async-threads:10] [hipe] [kernel-poll:false]\n\nEshell V8.1  (abort with ^G)\n\n(be2bill@127.0.0.1)1\u003e whereis(production).\n\u003c0.198.0\u003e\n(be2bill@127.0.0.1)2\u003e whereis(sandbox).   \n\u003c0.200.0\u003e\n```\nAs you can see, each environment is reachable as a name (`production` or `sandbox`).\nThose processes are gen_server where you can perform requests by submitting records.\n\nNote if you are not using release but an interactive shell, simply run : \n```\n1\u003e application:start(be2bill).\nok\n```\nbut you will need to load the be2bill config by passing start argument to Erlang node, like : `erl -sname test -config priv/sys `\n\n### Testing manually some transactions ###\n\nOnce into an Erlang shell of an Erlang node where be2bill application is running, we can do manual transactions.\nTo do so, you need to load record definitions that will help you to compose valid be2bill records.\nThis is achieved by importing record definition available in `include/` directory.\n\n```\n(be2bill@127.0.0.1)3\u003e rr(\"lib/be2bill-X.Y.Z/include/be2bill_defs.hrl\").\n[authorization,authorizationOpts,\n buildAuthorizationFormButton,\n buildAuthorizationFormButtonOpts,buildPaymentFormButton,\n buildPaymentFormButtonOpts,capture,captureOpts,\n exportChargebacks,exportChargebacksOpts,\n exportReconciledTransactions,\n exportReconciledTransactionsOpts,exportReconciliation,\n exportReconciliationOpts,exportTransactions,\n exportTransactionsOpts,getTransactionsByOrderId,\n getTransactionsByOrderIdOpts,getTransactionsByTransactionId,\n getTransactionsByTransactionIdOpts,oneClickAuthorization,\n oneClickAuthorizationOpts,oneClickPayment,\n oneClickPaymentOpts,payment,paymentOpts,redirectForPayment,\n redirectForPaymentOpts,refund|...]\n```\n(Replace `X.Y.Z` by the be2bill release version you are running.)\n\nNote that if all record definitions are not needed, you can load only sub-definitions :\n`be2bill_authorization.hrl`, `be2bill_payment.hrl`, `be2bill_transaction.hrl` .\n\n`be2bill_defs.hrl` is only existing to load these three sub-definitions.\n\nSubmit a request is then simple as :\n```\n(be2bill@127.0.0.1)4\u003e A = #payment{'ORDERID'=\"000123\", 'DESCRIPTION'=\"art_123456\", 'AMOUNT' = 1000, 'CLIENTIDENT'=\"client_123\"}.   \n#payment{'VERSION' = \"2.0\",'CARDPAN' = undefined,'CARDDATE' = undefined,\n         'CARDCRYPTOGRAM' = undefined,'CARDFULLNAME' = undefined,\n         'AMOUNT' = 1000,'ORDERID' = \"000123\",\n         'CLIENTIDENT' = \"client_123\",'CLIENTEMAIL' = undefined,\n         'CLIENTIP' = undefined,'DESCRIPTION' = \"art_123456\",\n         'CLIENTUSERAGENT' = undefined,htmlOpts = undefined,\n         opts = undefined}\n(be2bill@127.0.0.1)5\u003e gen_server:call(sandbox, A).\nok\n```\nSame thing for production, except that calls have to be done on `production` gen_server.\n\n## Going further ##\nSee [Wiki](https://github.com/crownedgrouse/be2bill/wiki) .\n\n\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrownedgrouse%2Fbe2bill","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcrownedgrouse%2Fbe2bill","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrownedgrouse%2Fbe2bill/lists"}