{"action":"created","comment":{"url":"https://api.github.com/repos/tipsi/tipsi-stripe/pulls/comments/89624889","pull_request_review_id":10168938,"id":89624889,"diff_hunk":"@@ -0,0 +1,166 @@\n+package com.gettipsi.stripe.dialog;\n+\n+import android.app.Dialog;\n+import android.app.DialogFragment;\n+import android.content.DialogInterface;\n+import android.os.Bundle;\n+import android.view.LayoutInflater;\n+import android.view.View;\n+import android.view.ViewGroup;\n+import android.widget.Button;\n+import android.widget.EditText;\n+import android.widget.ProgressBar;\n+import android.widget.Spinner;\n+import android.widget.Toast;\n+\n+import com.facebook.react.bridge.Arguments;\n+import com.facebook.react.bridge.Promise;\n+import com.facebook.react.bridge.WritableMap;\n+import com.gettipsi.stripe.R;\n+import com.gettipsi.stripe.R2;\n+import com.stripe.android.Stripe;\n+import com.stripe.android.TokenCallback;\n+import com.stripe.android.model.Card;\n+import com.stripe.android.model.Token;\n+\n+import butterknife.BindView;\n+import butterknife.ButterKnife;\n+import butterknife.OnClick;\n+\n+public class AddCardDialogFragment extends DialogFragment {\n+\n+  private static final String CURRENCY_UNSPECIFIED = \"Unspecified\";\n+  private static final String KEY = \"KEY\";\n+  private String PUBLISHABLE_KEY;\n+\n+  @BindView(R2.id.number)\n+  EditText number;\n+  @BindView(R2.id.cvc)\n+  EditText cvc;\n+  @BindView(R2.id.expMonth)\n+  Spinner monthSpinner;\n+  @BindView(R2.id.expYear)\n+  Spinner yearSpinner;\n+  @BindView(R2.id.currency)\n+  Spinner currencySpinner;\n+  @BindView(R2.id.save)\n+  Button saveButton;\n+  @BindView(R2.id.buttonProgress)\n+  ProgressBar progressBar;\n+\n+  private Promise promise;\n+  private boolean succesful;\n+\n+  public static AddCardDialogFragment newInstance(final String PUBLISHABLE_KEY) {\n+    Bundle args = new Bundle();\n+    args.putString(KEY, PUBLISHABLE_KEY);\n+    AddCardDialogFragment fragment = new AddCardDialogFragment();\n+    fragment.setArguments(args);\n+    return fragment;\n+  }\n+\n+  public static AddCardDialogFragment newInstance() {\n+    return new AddCardDialogFragment();\n+  }\n+\n+  public void setPromise(Promise promise) {\n+    this.promise = promise;\n+  }\n+\n+  @Override\n+  public void onCreate(Bundle savedInstanceState) {\n+    super.onCreate(savedInstanceState);\n+    if (getArguments() != null)\n+      PUBLISHABLE_KEY = getArguments().getString(KEY);\n+  }\n+\n+  @Override\n+  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {\n+    View view = inflater.inflate(R.layout.payment_form_fragment, container, false);\n+    ButterKnife.bind(this, view);\n+    return view;\n+  }\n+\n+  @OnClick(R2.id.save)\n+  public void onSaveCLick() {\n+    saveButton.setEnabled(false);\n+    progressBar.setVisibility(View.VISIBLE);\n+    final Card card = new Card(\n+            number.getText().toString(),\n+            getInteger(this.monthSpinner),\n+            getInteger(this.yearSpinner),\n+            cvc.getText().toString());\n+\n+    String errorMessage = validateCard(card);\n+    if (errorMessage == null) {\n+      new Stripe().createToken(\n+              card,\n+              PUBLISHABLE_KEY,\n+              new TokenCallback() {\n+                public void onSuccess(Token token) {\n+                  final WritableMap newToken = Arguments.createMap();\n+                  newToken.putString(\"token\", token.getId());\n+                  newToken.putBoolean(\"live_mode\", token.getLivemode());\n+                  newToken.putBoolean(\"user\", token.getUsed());\n+                  if (promise != null) {\n+                    promise.resolve(newToken);\n+                    promise = null;\n+                  }\n+                  succesful = true;\n+                  dismiss();\n+                }\n+\n+                public void onError(Exception error) {\n+                  saveButton.setEnabled(true);\n+                  progressBar.setVisibility(View.GONE);\n+                  Toast.makeText(getActivity(), error.getLocalizedMessage(), Toast.LENGTH_LONG).show();\n+                }\n+              });\n+    } else {\n+      saveButton.setEnabled(true);\n+      progressBar.setVisibility(View.GONE);\n+      Toast.makeText(getActivity(), errorMessage, Toast.LENGTH_LONG).show();\n+    }\n+  }\n+\n+  @Override\n+  public Dialog onCreateDialog(Bundle savedInstanceState) {\n+    succesful = false;\n+    return super.onCreateDialog(savedInstanceState);\n+  }\n+\n+\n+  @Override\n+  public void onDismiss(DialogInterface dialog) {\n+    if (!succesful && promise != null) {\n+      promise.reject(\"User cancel dialog. No card added!\");\n+      promise = null;\n+    }\n+    super.onDismiss(dialog);\n+  }\n+\n+  private String validateCard(Card card) {\n+    if (!card.validateNumber()) {\n+      return \"The card number that you entered is invalid\";\n+    } else if (!card.validateExpiryDate()) {\n+      return \"The expiration date that you entered is invalid\";\n+    } else if (!card.validateCVC()) {\n+      return \"The CVC code that you entered is invalid\";","path":"android/src/main/java/com/gettipsi/stripe/dialog/AddCardDialogFragment.java","position":148,"original_position":148,"commit_id":"2645a2fca75ea48e5b65ad736f984d01b32013e3","original_commit_id":"2645a2fca75ea48e5b65ad736f984d01b32013e3","user":{"login":"cybergrind","id":192182,"avatar_url":"https://avatars.githubusercontent.com/u/192182?v=3","gravatar_id":"","url":"https://api.github.com/users/cybergrind","html_url":"https://github.com/cybergrind","followers_url":"https://api.github.com/users/cybergrind/followers","following_url":"https://api.github.com/users/cybergrind/following{/other_user}","gists_url":"https://api.github.com/users/cybergrind/gists{/gist_id}","starred_url":"https://api.github.com/users/cybergrind/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cybergrind/subscriptions","organizations_url":"https://api.github.com/users/cybergrind/orgs","repos_url":"https://api.github.com/users/cybergrind/repos","events_url":"https://api.github.com/users/cybergrind/events{/privacy}","received_events_url":"https://api.github.com/users/cybergrind/received_events","type":"User","site_admin":false},"body":"Please use constants instead of hardcoded strings","created_at":"2016-11-25T14:29:52Z","updated_at":"2016-11-25T14:35:33Z","html_url":"https://github.com/tipsi/tipsi-stripe/pull/5#discussion_r89624889","pull_request_url":"https://api.github.com/repos/tipsi/tipsi-stripe/pulls/5","_links":{"self":{"href":"https://api.github.com/repos/tipsi/tipsi-stripe/pulls/comments/89624889"},"html":{"href":"https://github.com/tipsi/tipsi-stripe/pull/5#discussion_r89624889"},"pull_request":{"href":"https://api.github.com/repos/tipsi/tipsi-stripe/pulls/5"}}},"pull_request":{"url":"https://api.github.com/repos/tipsi/tipsi-stripe/pulls/5","id":95270555,"html_url":"https://github.com/tipsi/tipsi-stripe/pull/5","diff_url":"https://github.com/tipsi/tipsi-stripe/pull/5.diff","patch_url":"https://github.com/tipsi/tipsi-stripe/pull/5.patch","issue_url":"https://api.github.com/repos/tipsi/tipsi-stripe/issues/5","number":5,"state":"open","locked":false,"title":"Dev android two","user":{"login":"fAns1k","id":4946753,"avatar_url":"https://avatars.githubusercontent.com/u/4946753?v=3","gravatar_id":"","url":"https://api.github.com/users/fAns1k","html_url":"https://github.com/fAns1k","followers_url":"https://api.github.com/users/fAns1k/followers","following_url":"https://api.github.com/users/fAns1k/following{/other_user}","gists_url":"https://api.github.com/users/fAns1k/gists{/gist_id}","starred_url":"https://api.github.com/users/fAns1k/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fAns1k/subscriptions","organizations_url":"https://api.github.com/users/fAns1k/orgs","repos_url":"https://api.github.com/users/fAns1k/repos","events_url":"https://api.github.com/users/fAns1k/events{/privacy}","received_events_url":"https://api.github.com/users/fAns1k/received_events","type":"User","site_admin":false},"body":"Stripe Android implementation","created_at":"2016-11-25T09:11:11Z","updated_at":"2016-11-25T14:35:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ee15219d9e4e547f78c8def7d7eef2c01ff4fe1b","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/tipsi/tipsi-stripe/pulls/5/commits","review_comments_url":"https://api.github.com/repos/tipsi/tipsi-stripe/pulls/5/comments","review_comment_url":"https://api.github.com/repos/tipsi/tipsi-stripe/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tipsi/tipsi-stripe/issues/5/comments","statuses_url":"https://api.github.com/repos/tipsi/tipsi-stripe/statuses/2645a2fca75ea48e5b65ad736f984d01b32013e3","head":{"label":"tipsi:dev_android_two","ref":"dev_android_two","sha":"2645a2fca75ea48e5b65ad736f984d01b32013e3","user":{"login":"tipsi","id":16418909,"avatar_url":"https://avatars.githubusercontent.com/u/16418909?v=3","gravatar_id":"","url":"https://api.github.com/users/tipsi","html_url":"https://github.com/tipsi","followers_url":"https://api.github.com/users/tipsi/followers","following_url":"https://api.github.com/users/tipsi/following{/other_user}","gists_url":"https://api.github.com/users/tipsi/gists{/gist_id}","starred_url":"https://api.github.com/users/tipsi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tipsi/subscriptions","organizations_url":"https://api.github.com/users/tipsi/orgs","repos_url":"https://api.github.com/users/tipsi/repos","events_url":"https://api.github.com/users/tipsi/events{/privacy}","received_events_url":"https://api.github.com/users/tipsi/received_events","type":"Organization","site_admin":false},"repo":{"id":72090557,"name":"tipsi-stripe","full_name":"tipsi/tipsi-stripe","owner":{"login":"tipsi","id":16418909,"avatar_url":"https://avatars.githubusercontent.com/u/16418909?v=3","gravatar_id":"","url":"https://api.github.com/users/tipsi","html_url":"https://github.com/tipsi","followers_url":"https://api.github.com/users/tipsi/followers","following_url":"https://api.github.com/users/tipsi/following{/other_user}","gists_url":"https://api.github.com/users/tipsi/gists{/gist_id}","starred_url":"https://api.github.com/users/tipsi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tipsi/subscriptions","organizations_url":"https://api.github.com/users/tipsi/orgs","repos_url":"https://api.github.com/users/tipsi/repos","events_url":"https://api.github.com/users/tipsi/events{/privacy}","received_events_url":"https://api.github.com/users/tipsi/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/tipsi/tipsi-stripe","description":"React Native Stripe binding for iOS/Andriod platforms","fork":false,"url":"https://api.github.com/repos/tipsi/tipsi-stripe","forks_url":"https://api.github.com/repos/tipsi/tipsi-stripe/forks","keys_url":"https://api.github.com/repos/tipsi/tipsi-stripe/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tipsi/tipsi-stripe/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tipsi/tipsi-stripe/teams","hooks_url":"https://api.github.com/repos/tipsi/tipsi-stripe/hooks","issue_events_url":"https://api.github.com/repos/tipsi/tipsi-stripe/issues/events{/number}","events_url":"https://api.github.com/repos/tipsi/tipsi-stripe/events","assignees_url":"https://api.github.com/repos/tipsi/tipsi-stripe/assignees{/user}","branches_url":"https://api.github.com/repos/tipsi/tipsi-stripe/branches{/branch}","tags_url":"https://api.github.com/repos/tipsi/tipsi-stripe/tags","blobs_url":"https://api.github.com/repos/tipsi/tipsi-stripe/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tipsi/tipsi-stripe/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tipsi/tipsi-stripe/git/refs{/sha}","trees_url":"https://api.github.com/repos/tipsi/tipsi-stripe/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tipsi/tipsi-stripe/statuses/{sha}","languages_url":"https://api.github.com/repos/tipsi/tipsi-stripe/languages","stargazers_url":"https://api.github.com/repos/tipsi/tipsi-stripe/stargazers","contributors_url":"https://api.github.com/repos/tipsi/tipsi-stripe/contributors","subscribers_url":"https://api.github.com/repos/tipsi/tipsi-stripe/subscribers","subscription_url":"https://api.github.com/repos/tipsi/tipsi-stripe/subscription","commits_url":"https://api.github.com/repos/tipsi/tipsi-stripe/commits{/sha}","git_commits_url":"https://api.github.com/repos/tipsi/tipsi-stripe/git/commits{/sha}","comments_url":"https://api.github.com/repos/tipsi/tipsi-stripe/comments{/number}","issue_comment_url":"https://api.github.com/repos/tipsi/tipsi-stripe/issues/comments{/number}","contents_url":"https://api.github.com/repos/tipsi/tipsi-stripe/contents/{+path}","compare_url":"https://api.github.com/repos/tipsi/tipsi-stripe/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tipsi/tipsi-stripe/merges","archive_url":"https://api.github.com/repos/tipsi/tipsi-stripe/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tipsi/tipsi-stripe/downloads","issues_url":"https://api.github.com/repos/tipsi/tipsi-stripe/issues{/number}","pulls_url":"https://api.github.com/repos/tipsi/tipsi-stripe/pulls{/number}","milestones_url":"https://api.github.com/repos/tipsi/tipsi-stripe/milestones{/number}","notifications_url":"https://api.github.com/repos/tipsi/tipsi-stripe/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tipsi/tipsi-stripe/labels{/name}","releases_url":"https://api.github.com/repos/tipsi/tipsi-stripe/releases{/id}","deployments_url":"https://api.github.com/repos/tipsi/tipsi-stripe/deployments","created_at":"2016-10-27T09:03:49Z","updated_at":"2016-11-22T20:30:14Z","pushed_at":"2016-11-25T12:48:45Z","git_url":"git://github.com/tipsi/tipsi-stripe.git","ssh_url":"git@github.com:tipsi/tipsi-stripe.git","clone_url":"https://github.com/tipsi/tipsi-stripe.git","svn_url":"https://github.com/tipsi/tipsi-stripe","homepage":"","size":379,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":2,"default_branch":"master"}},"base":{"label":"tipsi:master","ref":"master","sha":"db7405d1b7f4cd55366e77d959e15c59613482a4","user":{"login":"tipsi","id":16418909,"avatar_url":"https://avatars.githubusercontent.com/u/16418909?v=3","gravatar_id":"","url":"https://api.github.com/users/tipsi","html_url":"https://github.com/tipsi","followers_url":"https://api.github.com/users/tipsi/followers","following_url":"https://api.github.com/users/tipsi/following{/other_user}","gists_url":"https://api.github.com/users/tipsi/gists{/gist_id}","starred_url":"https://api.github.com/users/tipsi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tipsi/subscriptions","organizations_url":"https://api.github.com/users/tipsi/orgs","repos_url":"https://api.github.com/users/tipsi/repos","events_url":"https://api.github.com/users/tipsi/events{/privacy}","received_events_url":"https://api.github.com/users/tipsi/received_events","type":"Organization","site_admin":false},"repo":{"id":72090557,"name":"tipsi-stripe","full_name":"tipsi/tipsi-stripe","owner":{"login":"tipsi","id":16418909,"avatar_url":"https://avatars.githubusercontent.com/u/16418909?v=3","gravatar_id":"","url":"https://api.github.com/users/tipsi","html_url":"https://github.com/tipsi","followers_url":"https://api.github.com/users/tipsi/followers","following_url":"https://api.github.com/users/tipsi/following{/other_user}","gists_url":"https://api.github.com/users/tipsi/gists{/gist_id}","starred_url":"https://api.github.com/users/tipsi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tipsi/subscriptions","organizations_url":"https://api.github.com/users/tipsi/orgs","repos_url":"https://api.github.com/users/tipsi/repos","events_url":"https://api.github.com/users/tipsi/events{/privacy}","received_events_url":"https://api.github.com/users/tipsi/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/tipsi/tipsi-stripe","description":"React Native Stripe binding for iOS/Andriod platforms","fork":false,"url":"https://api.github.com/repos/tipsi/tipsi-stripe","forks_url":"https://api.github.com/repos/tipsi/tipsi-stripe/forks","keys_url":"https://api.github.com/repos/tipsi/tipsi-stripe/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tipsi/tipsi-stripe/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tipsi/tipsi-stripe/teams","hooks_url":"https://api.github.com/repos/tipsi/tipsi-stripe/hooks","issue_events_url":"https://api.github.com/repos/tipsi/tipsi-stripe/issues/events{/number}","events_url":"https://api.github.com/repos/tipsi/tipsi-stripe/events","assignees_url":"https://api.github.com/repos/tipsi/tipsi-stripe/assignees{/user}","branches_url":"https://api.github.com/repos/tipsi/tipsi-stripe/branches{/branch}","tags_url":"https://api.github.com/repos/tipsi/tipsi-stripe/tags","blobs_url":"https://api.github.com/repos/tipsi/tipsi-stripe/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tipsi/tipsi-stripe/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tipsi/tipsi-stripe/git/refs{/sha}","trees_url":"https://api.github.com/repos/tipsi/tipsi-stripe/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tipsi/tipsi-stripe/statuses/{sha}","languages_url":"https://api.github.com/repos/tipsi/tipsi-stripe/languages","stargazers_url":"https://api.github.com/repos/tipsi/tipsi-stripe/stargazers","contributors_url":"https://api.github.com/repos/tipsi/tipsi-stripe/contributors","subscribers_url":"https://api.github.com/repos/tipsi/tipsi-stripe/subscribers","subscription_url":"https://api.github.com/repos/tipsi/tipsi-stripe/subscription","commits_url":"https://api.github.com/repos/tipsi/tipsi-stripe/commits{/sha}","git_commits_url":"https://api.github.com/repos/tipsi/tipsi-stripe/git/commits{/sha}","comments_url":"https://api.github.com/repos/tipsi/tipsi-stripe/comments{/number}","issue_comment_url":"https://api.github.com/repos/tipsi/tipsi-stripe/issues/comments{/number}","contents_url":"https://api.github.com/repos/tipsi/tipsi-stripe/contents/{+path}","compare_url":"https://api.github.com/repos/tipsi/tipsi-stripe/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tipsi/tipsi-stripe/merges","archive_url":"https://api.github.com/repos/tipsi/tipsi-stripe/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tipsi/tipsi-stripe/downloads","issues_url":"https://api.github.com/repos/tipsi/tipsi-stripe/issues{/number}","pulls_url":"https://api.github.com/repos/tipsi/tipsi-stripe/pulls{/number}","milestones_url":"https://api.github.com/repos/tipsi/tipsi-stripe/milestones{/number}","notifications_url":"https://api.github.com/repos/tipsi/tipsi-stripe/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tipsi/tipsi-stripe/labels{/name}","releases_url":"https://api.github.com/repos/tipsi/tipsi-stripe/releases{/id}","deployments_url":"https://api.github.com/repos/tipsi/tipsi-stripe/deployments","created_at":"2016-10-27T09:03:49Z","updated_at":"2016-11-22T20:30:14Z","pushed_at":"2016-11-25T12:48:45Z","git_url":"git://github.com/tipsi/tipsi-stripe.git","ssh_url":"git@github.com:tipsi/tipsi-stripe.git","clone_url":"https://github.com/tipsi/tipsi-stripe.git","svn_url":"https://github.com/tipsi/tipsi-stripe","homepage":"","size":379,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tipsi/tipsi-stripe/pulls/5"},"html":{"href":"https://github.com/tipsi/tipsi-stripe/pull/5"},"issue":{"href":"https://api.github.com/repos/tipsi/tipsi-stripe/issues/5"},"comments":{"href":"https://api.github.com/repos/tipsi/tipsi-stripe/issues/5/comments"},"review_comments":{"href":"https://api.github.com/repos/tipsi/tipsi-stripe/pulls/5/comments"},"review_comment":{"href":"https://api.github.com/repos/tipsi/tipsi-stripe/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tipsi/tipsi-stripe/pulls/5/commits"},"statuses":{"href":"https://api.github.com/repos/tipsi/tipsi-stripe/statuses/2645a2fca75ea48e5b65ad736f984d01b32013e3"}}}}
{"actor":{"display_login":"cybergrind"}}