{"action":"created","comment":{"url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/comments/150435584","pull_request_review_id":75983935,"id":150435584,"diff_hunk":"@@ -5,50 +5,100 @@\n  */\n \n import creditcards from 'creditcards';\n-import { capitalize, compact, inRange, isArray, isEmpty } from 'lodash';\n+import capitalize from 'lodash/capitalize';\n+import compact from 'lodash/compact';\n+import inRange from 'lodash/inRange';\n+import isArray from 'lodash/isArray';\n+import isEmpty from 'lodash/isEmpty';\n+import pick from 'lodash/pick';\n import i18n from 'i18n-calypso';\n \n-function creditCardFieldRules() {\n-\treturn {\n-\t\tname: {\n-\t\t\tdescription: i18n.translate( 'Name on Card', {\n-\t\t\t\tcontext: 'Upgrades: Card holder name label on credit card form',\n-\t\t\t\ttextOnly: true,\n-\t\t\t} ),\n-\t\t\trules: [ 'required' ],\n-\t\t},\n+/**\n+ * Internal dependencies\n+ */\n+import { isEbanx, isValidCPF } from 'lib/credit-card-details/ebanx';\n+import { PAYMENT_PROCESSOR_EBANX_COUNTRIES } from './constants';\n \n-\t\tnumber: {\n-\t\t\tdescription: i18n.translate( 'Card Number', {\n-\t\t\t\tcontext: 'Upgrades: Card number label on credit card form',\n-\t\t\t\ttextOnly: true,\n-\t\t\t} ),\n-\t\t\trules: [ 'required', 'validCreditCardNumber' ],\n-\t\t},\n+function ebanxFieldRules( country ) {\n+\tconst requiredFields = PAYMENT_PROCESSOR_EBANX_COUNTRIES[ country ].requiredFields || [];\n \n-\t\t'expiration-date': {\n-\t\t\tdescription: i18n.translate( 'Credit Card Expiration Date' ),\n-\t\t\trules: [ 'required', 'validExpirationDate' ],\n-\t\t},\n+\treturn pick(\n+\t\t{\n+\t\t\tdocument: {\n+\t\t\t\tdescription: i18n.translate( 'Taxpayer Identification Number' ),","path":"client/lib/credit-card-details/validation.js","position":45,"original_position":45,"commit_id":"47f17ca7a7885f4fa311dd921b82508f64d0fc35","original_commit_id":"47f17ca7a7885f4fa311dd921b82508f64d0fc35","user":{"login":"a8ci18n","id":25137612,"avatar_url":"https://avatars0.githubusercontent.com/u/25137612?v=4","gravatar_id":"","url":"https://api.github.com/users/a8ci18n","html_url":"https://github.com/a8ci18n","followers_url":"https://api.github.com/users/a8ci18n/followers","following_url":"https://api.github.com/users/a8ci18n/following{/other_user}","gists_url":"https://api.github.com/users/a8ci18n/gists{/gist_id}","starred_url":"https://api.github.com/users/a8ci18n/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/a8ci18n/subscriptions","organizations_url":"https://api.github.com/users/a8ci18n/orgs","repos_url":"https://api.github.com/users/a8ci18n/repos","events_url":"https://api.github.com/users/a8ci18n/events{/privacy}","received_events_url":"https://api.github.com/users/a8ci18n/received_events","type":"User","site_admin":false},"body":"Hi! I've found a possible matching string that has already been translated **5** times:\n`translate( 'Taxpayer Identification Number (TIN)' )` *ES Score: 28*\n\nHelp me improve these suggestions: react with :thumbsdown: if the suggestion doesn't make any sense, or with :thumbsup: if it's a particularly good one (even if not implemented).","created_at":"2017-11-13T02:00:13Z","updated_at":"2017-11-13T02:00:13Z","html_url":"https://github.com/Automattic/wp-calypso/pull/19661#discussion_r150435584","pull_request_url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/19661","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/Automattic/wp-calypso/pulls/comments/150435584"},"html":{"href":"https://github.com/Automattic/wp-calypso/pull/19661#discussion_r150435584"},"pull_request":{"href":"https://api.github.com/repos/Automattic/wp-calypso/pulls/19661"}}},"pull_request":{"url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/19661","id":151808502,"html_url":"https://github.com/Automattic/wp-calypso/pull/19661","diff_url":"https://github.com/Automattic/wp-calypso/pull/19661.diff","patch_url":"https://github.com/Automattic/wp-calypso/pull/19661.patch","issue_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/19661","number":19661,"state":"open","locked":false,"title":"[WIP] Checkout: Add Ebanx credit card UI form fields and validation","user":{"login":"ramonjd","id":6458278,"avatar_url":"https://avatars0.githubusercontent.com/u/6458278?v=4","gravatar_id":"","url":"https://api.github.com/users/ramonjd","html_url":"https://github.com/ramonjd","followers_url":"https://api.github.com/users/ramonjd/followers","following_url":"https://api.github.com/users/ramonjd/following{/other_user}","gists_url":"https://api.github.com/users/ramonjd/gists{/gist_id}","starred_url":"https://api.github.com/users/ramonjd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ramonjd/subscriptions","organizations_url":"https://api.github.com/users/ramonjd/orgs","repos_url":"https://api.github.com/users/ramonjd/repos","events_url":"https://api.github.com/users/ramonjd/events{/privacy}","received_events_url":"https://api.github.com/users/ramonjd/received_events","type":"User","site_admin":false},"body":"This PR extends @yoavf 's  #18286 and adds the UI fields for processing Ebanx (or the equivalent) payments:\r\n\r\n- `document`\r\n- `phone-number`\r\n- `street-number`\r\n- `address`\r\n- `city`\r\n- `state`\r\n\r\nIn place of `address`, we've added two fields -`address-1` and `address-2` - to accommodate apartment information and so on.\r\n\r\n<img width=\"728\" alt=\"ui-fields\" src=\"https://user-images.githubusercontent.com/6458278/32636582-92ae6f28-c609-11e7-8d70-4c649dce3ff3.png\">\r\n\r\n\r\nInitially we've started with the required fields for payments made by individuals only. \r\n\r\nPayments made by companies involve [extra fields and validation].(https://developers.ebanx.com/guides/create-a-payment/brazil).\r\n\r\nThe fields apply both at [checkout](https://github.com/Automattic/wp-calypso/blob/add/ebanx-credit-card-form-fields/client/my-sites/checkout/checkout/new-card-form.jsx) and when adding a [new card](https://github.com/Automattic/wp-calypso/blob/add/ebanx-credit-card-form-fields/client/blocks/credit-card-form/index.jsx).\r\n\r\n### Where we're at\r\n\r\n- Abstract the required fields for Brazil into a sub-component (With React 16, we'll get fragments so we can return a list of nodes that will slot into the form without losing)\r\n- Revisit error handling (see below)\r\n- No API integration yet\r\n\r\n### A word on _Cadastro de Pessoas Físicas_ (CPF)\r\nThere is allegedly an 'official' [algorithm](http://www.geradorcpf.com/algoritmo_do_cpf.htm) to validate a Brazilian tax code. I thought it best to enforce weak validation, that is checking the string's format and not its constituent parts. If we decide to implement the stronger check at the API level, then there's less duplication should the validation requirements ever change. It's chunky, but I'm open to adding it on the front end as well however.\r\n\r\n### Error handling \r\nThe error handling for the credit card form isn't what it could be, actually it's not what it should be. Submitting empty fields create a colossal red blob that covers the form, and remains there until you dismiss it. \r\n\r\nWe might like to take a look at whacking these errors inline, or thinking about something less intrusive.\r\n\r\n<img width=\"765\" alt=\"ui-fields-error\" src=\"https://user-images.githubusercontent.com/6458278/32636814-90178ffa-c60a-11e7-9f53-4418f0e308ed.png\">\r\n\r\n\r\n","created_at":"2017-11-10T01:51:19Z","updated_at":"2017-11-13T02:00:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7c6daa9e50ea640f69fa919508a3e6d994b3e244","assignee":{"login":"ramonjd","id":6458278,"avatar_url":"https://avatars0.githubusercontent.com/u/6458278?v=4","gravatar_id":"","url":"https://api.github.com/users/ramonjd","html_url":"https://github.com/ramonjd","followers_url":"https://api.github.com/users/ramonjd/followers","following_url":"https://api.github.com/users/ramonjd/following{/other_user}","gists_url":"https://api.github.com/users/ramonjd/gists{/gist_id}","starred_url":"https://api.github.com/users/ramonjd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ramonjd/subscriptions","organizations_url":"https://api.github.com/users/ramonjd/orgs","repos_url":"https://api.github.com/users/ramonjd/repos","events_url":"https://api.github.com/users/ramonjd/events{/privacy}","received_events_url":"https://api.github.com/users/ramonjd/received_events","type":"User","site_admin":false},"assignees":[{"login":"ramonjd","id":6458278,"avatar_url":"https://avatars0.githubusercontent.com/u/6458278?v=4","gravatar_id":"","url":"https://api.github.com/users/ramonjd","html_url":"https://github.com/ramonjd","followers_url":"https://api.github.com/users/ramonjd/followers","following_url":"https://api.github.com/users/ramonjd/following{/other_user}","gists_url":"https://api.github.com/users/ramonjd/gists{/gist_id}","starred_url":"https://api.github.com/users/ramonjd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ramonjd/subscriptions","organizations_url":"https://api.github.com/users/ramonjd/orgs","repos_url":"https://api.github.com/users/ramonjd/repos","events_url":"https://api.github.com/users/ramonjd/events{/privacy}","received_events_url":"https://api.github.com/users/ramonjd/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/19661/commits","review_comments_url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/19661/comments","review_comment_url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/19661/comments","statuses_url":"https://api.github.com/repos/Automattic/wp-calypso/statuses/47f17ca7a7885f4fa311dd921b82508f64d0fc35","head":{"label":"Automattic:add/ebanx-ui-form-fields","ref":"add/ebanx-ui-form-fields","sha":"47f17ca7a7885f4fa311dd921b82508f64d0fc35","user":{"login":"Automattic","id":887802,"avatar_url":"https://avatars1.githubusercontent.com/u/887802?v=4","gravatar_id":"","url":"https://api.github.com/users/Automattic","html_url":"https://github.com/Automattic","followers_url":"https://api.github.com/users/Automattic/followers","following_url":"https://api.github.com/users/Automattic/following{/other_user}","gists_url":"https://api.github.com/users/Automattic/gists{/gist_id}","starred_url":"https://api.github.com/users/Automattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Automattic/subscriptions","organizations_url":"https://api.github.com/users/Automattic/orgs","repos_url":"https://api.github.com/users/Automattic/repos","events_url":"https://api.github.com/users/Automattic/events{/privacy}","received_events_url":"https://api.github.com/users/Automattic/received_events","type":"Organization","site_admin":false},"repo":{"id":45936895,"name":"wp-calypso","full_name":"Automattic/wp-calypso","owner":{"login":"Automattic","id":887802,"avatar_url":"https://avatars1.githubusercontent.com/u/887802?v=4","gravatar_id":"","url":"https://api.github.com/users/Automattic","html_url":"https://github.com/Automattic","followers_url":"https://api.github.com/users/Automattic/followers","following_url":"https://api.github.com/users/Automattic/following{/other_user}","gists_url":"https://api.github.com/users/Automattic/gists{/gist_id}","starred_url":"https://api.github.com/users/Automattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Automattic/subscriptions","organizations_url":"https://api.github.com/users/Automattic/orgs","repos_url":"https://api.github.com/users/Automattic/repos","events_url":"https://api.github.com/users/Automattic/events{/privacy}","received_events_url":"https://api.github.com/users/Automattic/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Automattic/wp-calypso","description":"The new JavaScript- and API-powered WordPress.com","fork":false,"url":"https://api.github.com/repos/Automattic/wp-calypso","forks_url":"https://api.github.com/repos/Automattic/wp-calypso/forks","keys_url":"https://api.github.com/repos/Automattic/wp-calypso/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Automattic/wp-calypso/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Automattic/wp-calypso/teams","hooks_url":"https://api.github.com/repos/Automattic/wp-calypso/hooks","issue_events_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/events{/number}","events_url":"https://api.github.com/repos/Automattic/wp-calypso/events","assignees_url":"https://api.github.com/repos/Automattic/wp-calypso/assignees{/user}","branches_url":"https://api.github.com/repos/Automattic/wp-calypso/branches{/branch}","tags_url":"https://api.github.com/repos/Automattic/wp-calypso/tags","blobs_url":"https://api.github.com/repos/Automattic/wp-calypso/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Automattic/wp-calypso/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Automattic/wp-calypso/git/refs{/sha}","trees_url":"https://api.github.com/repos/Automattic/wp-calypso/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Automattic/wp-calypso/statuses/{sha}","languages_url":"https://api.github.com/repos/Automattic/wp-calypso/languages","stargazers_url":"https://api.github.com/repos/Automattic/wp-calypso/stargazers","contributors_url":"https://api.github.com/repos/Automattic/wp-calypso/contributors","subscribers_url":"https://api.github.com/repos/Automattic/wp-calypso/subscribers","subscription_url":"https://api.github.com/repos/Automattic/wp-calypso/subscription","commits_url":"https://api.github.com/repos/Automattic/wp-calypso/commits{/sha}","git_commits_url":"https://api.github.com/repos/Automattic/wp-calypso/git/commits{/sha}","comments_url":"https://api.github.com/repos/Automattic/wp-calypso/comments{/number}","issue_comment_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/comments{/number}","contents_url":"https://api.github.com/repos/Automattic/wp-calypso/contents/{+path}","compare_url":"https://api.github.com/repos/Automattic/wp-calypso/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Automattic/wp-calypso/merges","archive_url":"https://api.github.com/repos/Automattic/wp-calypso/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Automattic/wp-calypso/downloads","issues_url":"https://api.github.com/repos/Automattic/wp-calypso/issues{/number}","pulls_url":"https://api.github.com/repos/Automattic/wp-calypso/pulls{/number}","milestones_url":"https://api.github.com/repos/Automattic/wp-calypso/milestones{/number}","notifications_url":"https://api.github.com/repos/Automattic/wp-calypso/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Automattic/wp-calypso/labels{/name}","releases_url":"https://api.github.com/repos/Automattic/wp-calypso/releases{/id}","deployments_url":"https://api.github.com/repos/Automattic/wp-calypso/deployments","created_at":"2015-11-10T20:00:16Z","updated_at":"2017-11-12T10:36:43Z","pushed_at":"2017-11-13T01:53:42Z","git_url":"git://github.com/Automattic/wp-calypso.git","ssh_url":"git@github.com:Automattic/wp-calypso.git","clone_url":"https://github.com/Automattic/wp-calypso.git","svn_url":"https://github.com/Automattic/wp-calypso","homepage":"https://developer.wordpress.com/calypso/","size":68238,"stargazers_count":9399,"watchers_count":9399,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1290,"mirror_url":null,"archived":false,"open_issues_count":2239,"forks":1290,"open_issues":2239,"watchers":9399,"default_branch":"master"}},"base":{"label":"Automattic:add/ebanx","ref":"add/ebanx","sha":"88a2ad772b2feb969173682ec924afa93988a5f4","user":{"login":"Automattic","id":887802,"avatar_url":"https://avatars1.githubusercontent.com/u/887802?v=4","gravatar_id":"","url":"https://api.github.com/users/Automattic","html_url":"https://github.com/Automattic","followers_url":"https://api.github.com/users/Automattic/followers","following_url":"https://api.github.com/users/Automattic/following{/other_user}","gists_url":"https://api.github.com/users/Automattic/gists{/gist_id}","starred_url":"https://api.github.com/users/Automattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Automattic/subscriptions","organizations_url":"https://api.github.com/users/Automattic/orgs","repos_url":"https://api.github.com/users/Automattic/repos","events_url":"https://api.github.com/users/Automattic/events{/privacy}","received_events_url":"https://api.github.com/users/Automattic/received_events","type":"Organization","site_admin":false},"repo":{"id":45936895,"name":"wp-calypso","full_name":"Automattic/wp-calypso","owner":{"login":"Automattic","id":887802,"avatar_url":"https://avatars1.githubusercontent.com/u/887802?v=4","gravatar_id":"","url":"https://api.github.com/users/Automattic","html_url":"https://github.com/Automattic","followers_url":"https://api.github.com/users/Automattic/followers","following_url":"https://api.github.com/users/Automattic/following{/other_user}","gists_url":"https://api.github.com/users/Automattic/gists{/gist_id}","starred_url":"https://api.github.com/users/Automattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Automattic/subscriptions","organizations_url":"https://api.github.com/users/Automattic/orgs","repos_url":"https://api.github.com/users/Automattic/repos","events_url":"https://api.github.com/users/Automattic/events{/privacy}","received_events_url":"https://api.github.com/users/Automattic/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Automattic/wp-calypso","description":"The new JavaScript- and API-powered WordPress.com","fork":false,"url":"https://api.github.com/repos/Automattic/wp-calypso","forks_url":"https://api.github.com/repos/Automattic/wp-calypso/forks","keys_url":"https://api.github.com/repos/Automattic/wp-calypso/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Automattic/wp-calypso/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Automattic/wp-calypso/teams","hooks_url":"https://api.github.com/repos/Automattic/wp-calypso/hooks","issue_events_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/events{/number}","events_url":"https://api.github.com/repos/Automattic/wp-calypso/events","assignees_url":"https://api.github.com/repos/Automattic/wp-calypso/assignees{/user}","branches_url":"https://api.github.com/repos/Automattic/wp-calypso/branches{/branch}","tags_url":"https://api.github.com/repos/Automattic/wp-calypso/tags","blobs_url":"https://api.github.com/repos/Automattic/wp-calypso/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Automattic/wp-calypso/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Automattic/wp-calypso/git/refs{/sha}","trees_url":"https://api.github.com/repos/Automattic/wp-calypso/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Automattic/wp-calypso/statuses/{sha}","languages_url":"https://api.github.com/repos/Automattic/wp-calypso/languages","stargazers_url":"https://api.github.com/repos/Automattic/wp-calypso/stargazers","contributors_url":"https://api.github.com/repos/Automattic/wp-calypso/contributors","subscribers_url":"https://api.github.com/repos/Automattic/wp-calypso/subscribers","subscription_url":"https://api.github.com/repos/Automattic/wp-calypso/subscription","commits_url":"https://api.github.com/repos/Automattic/wp-calypso/commits{/sha}","git_commits_url":"https://api.github.com/repos/Automattic/wp-calypso/git/commits{/sha}","comments_url":"https://api.github.com/repos/Automattic/wp-calypso/comments{/number}","issue_comment_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/comments{/number}","contents_url":"https://api.github.com/repos/Automattic/wp-calypso/contents/{+path}","compare_url":"https://api.github.com/repos/Automattic/wp-calypso/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Automattic/wp-calypso/merges","archive_url":"https://api.github.com/repos/Automattic/wp-calypso/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Automattic/wp-calypso/downloads","issues_url":"https://api.github.com/repos/Automattic/wp-calypso/issues{/number}","pulls_url":"https://api.github.com/repos/Automattic/wp-calypso/pulls{/number}","milestones_url":"https://api.github.com/repos/Automattic/wp-calypso/milestones{/number}","notifications_url":"https://api.github.com/repos/Automattic/wp-calypso/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Automattic/wp-calypso/labels{/name}","releases_url":"https://api.github.com/repos/Automattic/wp-calypso/releases{/id}","deployments_url":"https://api.github.com/repos/Automattic/wp-calypso/deployments","created_at":"2015-11-10T20:00:16Z","updated_at":"2017-11-12T10:36:43Z","pushed_at":"2017-11-13T01:53:42Z","git_url":"git://github.com/Automattic/wp-calypso.git","ssh_url":"git@github.com:Automattic/wp-calypso.git","clone_url":"https://github.com/Automattic/wp-calypso.git","svn_url":"https://github.com/Automattic/wp-calypso","homepage":"https://developer.wordpress.com/calypso/","size":68238,"stargazers_count":9399,"watchers_count":9399,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1290,"mirror_url":null,"archived":false,"open_issues_count":2239,"forks":1290,"open_issues":2239,"watchers":9399,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Automattic/wp-calypso/pulls/19661"},"html":{"href":"https://github.com/Automattic/wp-calypso/pull/19661"},"issue":{"href":"https://api.github.com/repos/Automattic/wp-calypso/issues/19661"},"comments":{"href":"https://api.github.com/repos/Automattic/wp-calypso/issues/19661/comments"},"review_comments":{"href":"https://api.github.com/repos/Automattic/wp-calypso/pulls/19661/comments"},"review_comment":{"href":"https://api.github.com/repos/Automattic/wp-calypso/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Automattic/wp-calypso/pulls/19661/commits"},"statuses":{"href":"https://api.github.com/repos/Automattic/wp-calypso/statuses/47f17ca7a7885f4fa311dd921b82508f64d0fc35"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"a8ci18n"}}