{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla/payments-ui/pulls/comments/37900647","id":37900647,"diff_hunk":"@@ -0,0 +1,220 @@\n+import React, { Component, PropTypes } from 'react';\n+\n+import $ from 'jquery';\n+import PayMethodItem from 'components/pay-method-item';\n+import PayMethodDropDown from 'components/pay-method-drop-down';\n+import SubmitButton from 'components/submit-button';\n+import Subscription from 'components/subscription';\n+import Spinner from 'components/spinner';\n+\n+import { default as tracking } from 'tracking';\n+import { gettext, getPayMethodFromUri, setTitle } from 'utils';\n+\n+\n+export default class ConfirmDelPayMethod extends Component {\n+\n+  static propTypes = {\n+    affectedSubscriptions: PropTypes.array,\n+    delPayMethod: PropTypes.func.isRequired,\n+    error: PropTypes.func.isRequired,\n+    getSubsByPayMethod: PropTypes.func.isRequired,\n+    payMethodUri: PropTypes.string.isRequired,\n+    payMethods: PropTypes.array.isRequired,\n+    showDelPayMethod: PropTypes.func.isRequired,\n+    showPayMethods: PropTypes.func.isRequired,\n+    updateSubPayMethod: PropTypes.func.isRequired,\n+  }\n+\n+  constructor(props) {\n+    super(props);\n+    this.state = {\n+      payMethod: getPayMethodFromUri(\n+        this.props.payMethods, this.props.payMethodUri),\n+    };\n+  }\n+\n+  componentDidMount() {\n+    setTitle('Delete Payment Method?');\n+    tracking.setPage('/confirm-del-pay-method');\n+    this.props.getSubsByPayMethod(this.props.payMethodUri);\n+  }\n+\n+  handleSubmit = (e) => {\n+    e.preventDefault();\n+    this.setState({isSubmitting: true});\n+\n+    var affectedSubs = this.props.affectedSubscriptions;\n+\n+    var deletePayMethod = () => {\n+      return this.props.delPayMethod(this.props.payMethodUri).done(() => {\n+        this.props.showPayMethods();\n+      });\n+    };\n+\n+    // If there are affected subs...\n+    if (affectedSubs) {\n+      var deferreds = [];\n+      var select = e.target.querySelector('[name=\"new-pay-method\"]');\n+      //... and there's a select for choosing the new pay method\n+      if (select && select.options) {\n+        var newPayMethodUri = select.options[select.selectedIndex].value;\n+        // Update the list of subs to use newPayMethodUri\n+        for (var i = 0; i < affectedSubs.length; i += 1) {\n+          var sub = affectedSubs[i];\n+          deferreds.push(\n+            this.props.updateSubPayMethod(sub.resource_uri, newPayMethodUri));\n+        }\n+\n+        // Update all the affected subs.\n+        $.when(...deferreds).done(() => {\n+          // Delete the card in question.\n+          console.log('Subs update successful now deleting payMethod');\n+          deletePayMethod();\n+        }).fail(() => {\n+          // Abort any outstanding requests\n+          console.log('Aborting outstanding requests');\n+          for (var j = 0; j < deferreds.length; j += 1) {\n+            deferreds[j].abort();\n+          }\n+          this.props.error('Failed to update subscriptions');\n+        });\n+      } else {\n+        // What we're doing amounts to cancellation.","path":"public/js/views/management/confirm-del-pay-method.jsx","position":82,"original_position":82,"commit_id":"824c106011d5b3a6de9b65f1436c35fcd5bc7cb1","original_commit_id":"824c106011d5b3a6de9b65f1436c35fcd5bc7cb1","user":{"login":"kumar303","id":55398,"avatar_url":"https://avatars.githubusercontent.com/u/55398?v=3","gravatar_id":"","url":"https://api.github.com/users/kumar303","html_url":"https://github.com/kumar303","followers_url":"https://api.github.com/users/kumar303/followers","following_url":"https://api.github.com/users/kumar303/following{/other_user}","gists_url":"https://api.github.com/users/kumar303/gists{/gist_id}","starred_url":"https://api.github.com/users/kumar303/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kumar303/subscriptions","organizations_url":"https://api.github.com/users/kumar303/orgs","repos_url":"https://api.github.com/users/kumar303/repos","events_url":"https://api.github.com/users/kumar303/events{/privacy}","received_events_url":"https://api.github.com/users/kumar303/received_events","type":"User","site_admin":false},"body":"not sure you need this comment since the log message says it","created_at":"2015-08-25T18:24:20Z","updated_at":"2015-08-25T18:24:20Z","html_url":"https://github.com/mozilla/payments-ui/pull/333#discussion_r37900647","pull_request_url":"https://api.github.com/repos/mozilla/payments-ui/pulls/333","_links":{"self":{"href":"https://api.github.com/repos/mozilla/payments-ui/pulls/comments/37900647"},"html":{"href":"https://github.com/mozilla/payments-ui/pull/333#discussion_r37900647"},"pull_request":{"href":"https://api.github.com/repos/mozilla/payments-ui/pulls/333"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla/payments-ui/pulls/333","id":42396485,"html_url":"https://github.com/mozilla/payments-ui/pull/333","diff_url":"https://github.com/mozilla/payments-ui/pull/333.diff","patch_url":"https://github.com/mozilla/payments-ui/pull/333.patch","issue_url":"https://api.github.com/repos/mozilla/payments-ui/issues/333","number":333,"state":"open","locked":false,"title":"Add del confirmation (fixes #327, fixes #273, fixes #313)","user":{"login":"muffinresearch","id":1514,"avatar_url":"https://avatars.githubusercontent.com/u/1514?v=3","gravatar_id":"","url":"https://api.github.com/users/muffinresearch","html_url":"https://github.com/muffinresearch","followers_url":"https://api.github.com/users/muffinresearch/followers","following_url":"https://api.github.com/users/muffinresearch/following{/other_user}","gists_url":"https://api.github.com/users/muffinresearch/gists{/gist_id}","starred_url":"https://api.github.com/users/muffinresearch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/muffinresearch/subscriptions","organizations_url":"https://api.github.com/users/muffinresearch/orgs","repos_url":"https://api.github.com/users/muffinresearch/repos","events_url":"https://api.github.com/users/muffinresearch/events{/privacy}","received_events_url":"https://api.github.com/users/muffinresearch/received_events","type":"User","site_admin":false},"body":"This is rough around the edges. The actual data calls are not great because of the brittleness around iteration through subs to update them at the same time as the deletion.\r\n\r\nThat said we can definitely iterate from here.","created_at":"2015-08-13T20:41:36Z","updated_at":"2015-08-25T18:24:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c18b7d2da0111adc98f5d2474f47108b575550f3","assignee":{"login":"kumar303","id":55398,"avatar_url":"https://avatars.githubusercontent.com/u/55398?v=3","gravatar_id":"","url":"https://api.github.com/users/kumar303","html_url":"https://github.com/kumar303","followers_url":"https://api.github.com/users/kumar303/followers","following_url":"https://api.github.com/users/kumar303/following{/other_user}","gists_url":"https://api.github.com/users/kumar303/gists{/gist_id}","starred_url":"https://api.github.com/users/kumar303/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kumar303/subscriptions","organizations_url":"https://api.github.com/users/kumar303/orgs","repos_url":"https://api.github.com/users/kumar303/repos","events_url":"https://api.github.com/users/kumar303/events{/privacy}","received_events_url":"https://api.github.com/users/kumar303/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/mozilla/payments-ui/pulls/333/commits","review_comments_url":"https://api.github.com/repos/mozilla/payments-ui/pulls/333/comments","review_comment_url":"https://api.github.com/repos/mozilla/payments-ui/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla/payments-ui/issues/333/comments","statuses_url":"https://api.github.com/repos/mozilla/payments-ui/statuses/824c106011d5b3a6de9b65f1436c35fcd5bc7cb1","head":{"label":"muffinresearch:show-del-confirmation","ref":"show-del-confirmation","sha":"824c106011d5b3a6de9b65f1436c35fcd5bc7cb1","user":{"login":"muffinresearch","id":1514,"avatar_url":"https://avatars.githubusercontent.com/u/1514?v=3","gravatar_id":"","url":"https://api.github.com/users/muffinresearch","html_url":"https://github.com/muffinresearch","followers_url":"https://api.github.com/users/muffinresearch/followers","following_url":"https://api.github.com/users/muffinresearch/following{/other_user}","gists_url":"https://api.github.com/users/muffinresearch/gists{/gist_id}","starred_url":"https://api.github.com/users/muffinresearch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/muffinresearch/subscriptions","organizations_url":"https://api.github.com/users/muffinresearch/orgs","repos_url":"https://api.github.com/users/muffinresearch/repos","events_url":"https://api.github.com/users/muffinresearch/events{/privacy}","received_events_url":"https://api.github.com/users/muffinresearch/received_events","type":"User","site_admin":false},"repo":{"id":34340899,"name":"payments-ui","full_name":"muffinresearch/payments-ui","owner":{"login":"muffinresearch","id":1514,"avatar_url":"https://avatars.githubusercontent.com/u/1514?v=3","gravatar_id":"","url":"https://api.github.com/users/muffinresearch","html_url":"https://github.com/muffinresearch","followers_url":"https://api.github.com/users/muffinresearch/followers","following_url":"https://api.github.com/users/muffinresearch/following{/other_user}","gists_url":"https://api.github.com/users/muffinresearch/gists{/gist_id}","starred_url":"https://api.github.com/users/muffinresearch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/muffinresearch/subscriptions","organizations_url":"https://api.github.com/users/muffinresearch/orgs","repos_url":"https://api.github.com/users/muffinresearch/repos","events_url":"https://api.github.com/users/muffinresearch/events{/privacy}","received_events_url":"https://api.github.com/users/muffinresearch/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/muffinresearch/payments-ui","description":"The payments frontend interface","fork":true,"url":"https://api.github.com/repos/muffinresearch/payments-ui","forks_url":"https://api.github.com/repos/muffinresearch/payments-ui/forks","keys_url":"https://api.github.com/repos/muffinresearch/payments-ui/keys{/key_id}","collaborators_url":"https://api.github.com/repos/muffinresearch/payments-ui/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/muffinresearch/payments-ui/teams","hooks_url":"https://api.github.com/repos/muffinresearch/payments-ui/hooks","issue_events_url":"https://api.github.com/repos/muffinresearch/payments-ui/issues/events{/number}","events_url":"https://api.github.com/repos/muffinresearch/payments-ui/events","assignees_url":"https://api.github.com/repos/muffinresearch/payments-ui/assignees{/user}","branches_url":"https://api.github.com/repos/muffinresearch/payments-ui/branches{/branch}","tags_url":"https://api.github.com/repos/muffinresearch/payments-ui/tags","blobs_url":"https://api.github.com/repos/muffinresearch/payments-ui/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/muffinresearch/payments-ui/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/muffinresearch/payments-ui/git/refs{/sha}","trees_url":"https://api.github.com/repos/muffinresearch/payments-ui/git/trees{/sha}","statuses_url":"https://api.github.com/repos/muffinresearch/payments-ui/statuses/{sha}","languages_url":"https://api.github.com/repos/muffinresearch/payments-ui/languages","stargazers_url":"https://api.github.com/repos/muffinresearch/payments-ui/stargazers","contributors_url":"https://api.github.com/repos/muffinresearch/payments-ui/contributors","subscribers_url":"https://api.github.com/repos/muffinresearch/payments-ui/subscribers","subscription_url":"https://api.github.com/repos/muffinresearch/payments-ui/subscription","commits_url":"https://api.github.com/repos/muffinresearch/payments-ui/commits{/sha}","git_commits_url":"https://api.github.com/repos/muffinresearch/payments-ui/git/commits{/sha}","comments_url":"https://api.github.com/repos/muffinresearch/payments-ui/comments{/number}","issue_comment_url":"https://api.github.com/repos/muffinresearch/payments-ui/issues/comments{/number}","contents_url":"https://api.github.com/repos/muffinresearch/payments-ui/contents/{+path}","compare_url":"https://api.github.com/repos/muffinresearch/payments-ui/compare/{base}...{head}","merges_url":"https://api.github.com/repos/muffinresearch/payments-ui/merges","archive_url":"https://api.github.com/repos/muffinresearch/payments-ui/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/muffinresearch/payments-ui/downloads","issues_url":"https://api.github.com/repos/muffinresearch/payments-ui/issues{/number}","pulls_url":"https://api.github.com/repos/muffinresearch/payments-ui/pulls{/number}","milestones_url":"https://api.github.com/repos/muffinresearch/payments-ui/milestones{/number}","notifications_url":"https://api.github.com/repos/muffinresearch/payments-ui/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/muffinresearch/payments-ui/labels{/name}","releases_url":"https://api.github.com/repos/muffinresearch/payments-ui/releases{/id}","created_at":"2015-04-21T17:12:10Z","updated_at":"2015-05-13T13:54:48Z","pushed_at":"2015-08-25T17:11:58Z","git_url":"git://github.com/muffinresearch/payments-ui.git","ssh_url":"git@github.com:muffinresearch/payments-ui.git","clone_url":"https://github.com/muffinresearch/payments-ui.git","svn_url":"https://github.com/muffinresearch/payments-ui","homepage":null,"size":13749,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mozilla:master","ref":"master","sha":"108dc273bce8140c515191352cda78f92e90928d","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":34340650,"name":"payments-ui","full_name":"mozilla/payments-ui","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/payments-ui","description":"The payments frontend interface","fork":false,"url":"https://api.github.com/repos/mozilla/payments-ui","forks_url":"https://api.github.com/repos/mozilla/payments-ui/forks","keys_url":"https://api.github.com/repos/mozilla/payments-ui/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/payments-ui/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/payments-ui/teams","hooks_url":"https://api.github.com/repos/mozilla/payments-ui/hooks","issue_events_url":"https://api.github.com/repos/mozilla/payments-ui/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/payments-ui/events","assignees_url":"https://api.github.com/repos/mozilla/payments-ui/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/payments-ui/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/payments-ui/tags","blobs_url":"https://api.github.com/repos/mozilla/payments-ui/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/payments-ui/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/payments-ui/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/payments-ui/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/payments-ui/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/payments-ui/languages","stargazers_url":"https://api.github.com/repos/mozilla/payments-ui/stargazers","contributors_url":"https://api.github.com/repos/mozilla/payments-ui/contributors","subscribers_url":"https://api.github.com/repos/mozilla/payments-ui/subscribers","subscription_url":"https://api.github.com/repos/mozilla/payments-ui/subscription","commits_url":"https://api.github.com/repos/mozilla/payments-ui/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/payments-ui/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/payments-ui/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/payments-ui/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/payments-ui/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/payments-ui/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/payments-ui/merges","archive_url":"https://api.github.com/repos/mozilla/payments-ui/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/payments-ui/downloads","issues_url":"https://api.github.com/repos/mozilla/payments-ui/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/payments-ui/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/payments-ui/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/payments-ui/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/payments-ui/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/payments-ui/releases{/id}","created_at":"2015-04-21T17:07:06Z","updated_at":"2015-08-24T02:11:40Z","pushed_at":"2015-08-25T17:12:35Z","git_url":"git://github.com/mozilla/payments-ui.git","ssh_url":"git@github.com:mozilla/payments-ui.git","clone_url":"https://github.com/mozilla/payments-ui.git","svn_url":"https://github.com/mozilla/payments-ui","homepage":null,"size":33415,"stargazers_count":37,"watchers_count":37,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":6,"mirror_url":null,"open_issues_count":63,"forks":6,"open_issues":63,"watchers":37,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla/payments-ui/pulls/333"},"html":{"href":"https://github.com/mozilla/payments-ui/pull/333"},"issue":{"href":"https://api.github.com/repos/mozilla/payments-ui/issues/333"},"comments":{"href":"https://api.github.com/repos/mozilla/payments-ui/issues/333/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla/payments-ui/pulls/333/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla/payments-ui/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla/payments-ui/pulls/333/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla/payments-ui/statuses/824c106011d5b3a6de9b65f1436c35fcd5bc7cb1"}}}}