{"action":"created","comment":{"url":"https://api.github.com/repos/lionelbarrow/braintree-go/pulls/comments/186952180","pull_request_review_id":118631832,"id":186952180,"diff_hunk":"@@ -1013,41 +1013,84 @@ func TestSubscriptionTransactions(t *testing.T) {\n \t}\n }\n \n-// In order to run this test you have to create a test subscription\n-// that has a status of \"Past Due\". You can get such a subscription\n-// by creating one with a trial period of one day and a price of 2000\n-// USD (this amount will fail in the sandbox environment). After the\n-// trial expires, the subscription will have the desired \"Past Due\"\n-// status. Then you can try to charge an amount lower than 2000 which\n-// then should work when we retry the charge.\n+// It is not possible to successfully retry a charge without manually creating\n+// a subcription with a card that will fail, waiting a day for it to be billed\n+// and fail which will cause the subscription to enter the PastDue status. This\n+// test instead attempts to retry a charge that is not PastDue and ensures the\n+// only errors returned is the status.\n+// Ref: https://developers.braintreepayments.com/guides/recurring-billing/overview#past-due\n func TestSubscriptionRetryCharge(t *testing.T) {\n-\tt.Skip(\"Needs manual setup\")\n \tt.Parallel()\n \n \tctx := context.Background()\n-\treqInvalidID := SubscriptionTransactionRequest{\n-\t\tSubscriptionID: \"nonExisting1223\",\n-\t\tAmount:         NewDecimal(1000, 2),\n-\t\tOptions: TransactionOptions{\n-\t\t\tSubmitForSettlement: true,\n+\n+\tcustomer, err := testGateway.Customer().Create(ctx, &CustomerRequest{})\n+\tif err != nil {\n+\t\tt.Fatal(err)\n+\t}\n+\tt.Log(\"customer\", customer)\n+\n+\tverifyCard := false\n+\tpaymentMethod, err := testGateway.PaymentMethod().Create(ctx, &PaymentMethodRequest{\n+\t\tCustomerId:         customer.Id,\n+\t\tPaymentMethodNonce: FakeNonceTransactable,\n+\t\tOptions: &PaymentMethodRequestOptions{\n+\t\t\tVerifyCard: &verifyCard,\n \t\t},\n-\t\tType: \"sale\",\n+\t})\n+\tif err != nil {\n+\t\tt.Fatal(err)\n \t}\n-\terr := testGateway.Subscription().RetryCharge(ctx, &reqInvalidID)\n-\tif err.Error() != \"Subscription ID is invalid.\" {\n-\t\tt.Errorf(\"RetryCharge returned wrong error. Want: 'Subscription ID is invalid.' Got: %q\", err)\n+\tt.Log(\"payment method\", paymentMethod)\n+\n+\tg := testGateway.Subscription()\n+\n+\t// Create Subscription\n+\tsub1, err := g.Create(ctx, &SubscriptionRequest{\n+\t\tPaymentMethodToken: paymentMethod.GetToken(),\n+\t\tPlanId:             \"test_plan\",\n+\t\tMerchantAccountId:  testMerchantAccountId,\n+\t\tPrice:              NewDecimal(100, 2),\n+\t\tOptions: &SubscriptionOptions{\n+\t\t\tStartImmediately: true,\n+\t\t},\n+\t})\n+\tif err != nil {\n+\t\tt.Fatal(err)\n \t}\n+\tt.Log(\"sub1\", sub1)\n \n-\treq := SubscriptionTransactionRequest{\n-\t\tSubscriptionID: \"replaceWithIDofTestPastDueSubscription\",\n-\t\tAmount:         NewDecimal(1000, 2),\n-\t\tOptions: TransactionOptions{\n+\t// Retry Charge\n+\terr = testGateway.Subscription().RetryCharge(ctx, &SubscriptionTransactionRequest{\n+\t\tSubscriptionID: sub1.Id,\n+\t\tAmount:         NewDecimal(0, 2),\n+\t\tOptions: &SubscriptionTransactionOptionsRequest{\n \t\t\tSubmitForSettlement: true,\n \t\t},\n-\t\tType: \"sale\",\n+\t})\n+\tif err != nil {\n+\t\tif err, ok := err.(*BraintreeError); ok {\n+\t\t\tt.Log(err)\n+\t\t\tfieldErrors := err.All()\n+\t\t\tif g, w := len(fieldErrors), 1; g != w {\n+\t\t\t\tt.Fatalf(\"got %d field errors, want %d\", g, w)\n+\t\t\t}\n+\t\t\tif g, w := fieldErrors[0].Code, \"91531\"; g != w {\n+\t\t\t\tt.Errorf(\"got error code %q, want %q\", g, w)\n+\t\t\t}\n+\t\t\tif g, w := fieldErrors[0].Message, \"Subscription status must be Past Due in order to retry.\"; g != w {\n+\t\t\t\tt.Errorf(\"got error message %q, want %q\", g, w)\n+\t\t\t}\n+\t\t} else {","path":"subscription_integration_test.go","position":73,"original_position":94,"commit_id":"6920d6339865c0b31e719ad8b062d2a4175f7286","original_commit_id":"2a036e1e209190e3f804f1e5e970af25907309db","user":{"login":"Shugyousha","id":500068,"avatar_url":"https://avatars3.githubusercontent.com/u/500068?v=4","gravatar_id":"","url":"https://api.github.com/users/Shugyousha","html_url":"https://github.com/Shugyousha","followers_url":"https://api.github.com/users/Shugyousha/followers","following_url":"https://api.github.com/users/Shugyousha/following{/other_user}","gists_url":"https://api.github.com/users/Shugyousha/gists{/gist_id}","starred_url":"https://api.github.com/users/Shugyousha/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shugyousha/subscriptions","organizations_url":"https://api.github.com/users/Shugyousha/orgs","repos_url":"https://api.github.com/users/Shugyousha/repos","events_url":"https://api.github.com/users/Shugyousha/events{/privacy}","received_events_url":"https://api.github.com/users/Shugyousha/received_events","type":"User","site_admin":false},"body":"You could get rid of one level of indentation by checking for\r\n\r\nif err, ok := err.(*BraintreeError); !ok {\r\n  t.Fatal(err)\r\n}\r\n\r\nabove","created_at":"2018-05-09T07:25:36Z","updated_at":"2018-05-09T07:25:37Z","html_url":"https://github.com/lionelbarrow/braintree-go/pull/221#discussion_r186952180","pull_request_url":"https://api.github.com/repos/lionelbarrow/braintree-go/pulls/221","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/lionelbarrow/braintree-go/pulls/comments/186952180"},"html":{"href":"https://github.com/lionelbarrow/braintree-go/pull/221#discussion_r186952180"},"pull_request":{"href":"https://api.github.com/repos/lionelbarrow/braintree-go/pulls/221"}}},"pull_request":{"url":"https://api.github.com/repos/lionelbarrow/braintree-go/pulls/221","id":184968667,"html_url":"https://github.com/lionelbarrow/braintree-go/pull/221","diff_url":"https://github.com/lionelbarrow/braintree-go/pull/221.diff","patch_url":"https://github.com/lionelbarrow/braintree-go/pull/221.patch","issue_url":"https://api.github.com/repos/lionelbarrow/braintree-go/issues/221","number":221,"state":"open","locked":false,"title":"Add RetryCharge function","user":{"login":"Shugyousha","id":500068,"avatar_url":"https://avatars3.githubusercontent.com/u/500068?v=4","gravatar_id":"","url":"https://api.github.com/users/Shugyousha","html_url":"https://github.com/Shugyousha","followers_url":"https://api.github.com/users/Shugyousha/followers","following_url":"https://api.github.com/users/Shugyousha/following{/other_user}","gists_url":"https://api.github.com/users/Shugyousha/gists{/gist_id}","starred_url":"https://api.github.com/users/Shugyousha/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shugyousha/subscriptions","organizations_url":"https://api.github.com/users/Shugyousha/orgs","repos_url":"https://api.github.com/users/Shugyousha/repos","events_url":"https://api.github.com/users/Shugyousha/events{/privacy}","received_events_url":"https://api.github.com/users/Shugyousha/received_events","type":"User","site_admin":false},"body":"We use this functionality in our code so we would like to see this function added.\r\n\r\nNote that the test needs some manual setup in order to be useful.\r\n\r\nLet me know if you want me to change something.","created_at":"2018-04-30T14:18:32Z","updated_at":"2018-05-09T07:25:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2326d83b16c70cc2bf30278cfd04683c9e296614","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":39414506,"url":"https://api.github.com/repos/lionelbarrow/braintree-go/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"milestone":{"url":"https://api.github.com/repos/lionelbarrow/braintree-go/milestones/10","html_url":"https://github.com/lionelbarrow/braintree-go/milestone/10","labels_url":"https://api.github.com/repos/lionelbarrow/braintree-go/milestones/10/labels","id":3157843,"number":10,"title":"v0.19.0","description":null,"creator":{"login":"leighmcculloch","id":351529,"avatar_url":"https://avatars0.githubusercontent.com/u/351529?v=4","gravatar_id":"","url":"https://api.github.com/users/leighmcculloch","html_url":"https://github.com/leighmcculloch","followers_url":"https://api.github.com/users/leighmcculloch/followers","following_url":"https://api.github.com/users/leighmcculloch/following{/other_user}","gists_url":"https://api.github.com/users/leighmcculloch/gists{/gist_id}","starred_url":"https://api.github.com/users/leighmcculloch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leighmcculloch/subscriptions","organizations_url":"https://api.github.com/users/leighmcculloch/orgs","repos_url":"https://api.github.com/users/leighmcculloch/repos","events_url":"https://api.github.com/users/leighmcculloch/events{/privacy}","received_events_url":"https://api.github.com/users/leighmcculloch/received_events","type":"User","site_admin":false},"open_issues":5,"closed_issues":4,"state":"open","created_at":"2018-03-03T01:20:43Z","updated_at":"2018-05-09T05:13:15Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/lionelbarrow/braintree-go/pulls/221/commits","review_comments_url":"https://api.github.com/repos/lionelbarrow/braintree-go/pulls/221/comments","review_comment_url":"https://api.github.com/repos/lionelbarrow/braintree-go/pulls/comments{/number}","comments_url":"https://api.github.com/repos/lionelbarrow/braintree-go/issues/221/comments","statuses_url":"https://api.github.com/repos/lionelbarrow/braintree-go/statuses/6920d6339865c0b31e719ad8b062d2a4175f7286","head":{"label":"Shugyousha:retrycharge","ref":"retrycharge","sha":"6920d6339865c0b31e719ad8b062d2a4175f7286","user":{"login":"Shugyousha","id":500068,"avatar_url":"https://avatars3.githubusercontent.com/u/500068?v=4","gravatar_id":"","url":"https://api.github.com/users/Shugyousha","html_url":"https://github.com/Shugyousha","followers_url":"https://api.github.com/users/Shugyousha/followers","following_url":"https://api.github.com/users/Shugyousha/following{/other_user}","gists_url":"https://api.github.com/users/Shugyousha/gists{/gist_id}","starred_url":"https://api.github.com/users/Shugyousha/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shugyousha/subscriptions","organizations_url":"https://api.github.com/users/Shugyousha/orgs","repos_url":"https://api.github.com/users/Shugyousha/repos","events_url":"https://api.github.com/users/Shugyousha/events{/privacy}","received_events_url":"https://api.github.com/users/Shugyousha/received_events","type":"User","site_admin":false},"repo":{"id":130382911,"name":"braintree-go","full_name":"Shugyousha/braintree-go","owner":{"login":"Shugyousha","id":500068,"avatar_url":"https://avatars3.githubusercontent.com/u/500068?v=4","gravatar_id":"","url":"https://api.github.com/users/Shugyousha","html_url":"https://github.com/Shugyousha","followers_url":"https://api.github.com/users/Shugyousha/followers","following_url":"https://api.github.com/users/Shugyousha/following{/other_user}","gists_url":"https://api.github.com/users/Shugyousha/gists{/gist_id}","starred_url":"https://api.github.com/users/Shugyousha/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shugyousha/subscriptions","organizations_url":"https://api.github.com/users/Shugyousha/orgs","repos_url":"https://api.github.com/users/Shugyousha/repos","events_url":"https://api.github.com/users/Shugyousha/events{/privacy}","received_events_url":"https://api.github.com/users/Shugyousha/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Shugyousha/braintree-go","description":"A Go client library for Braintree","fork":true,"url":"https://api.github.com/repos/Shugyousha/braintree-go","forks_url":"https://api.github.com/repos/Shugyousha/braintree-go/forks","keys_url":"https://api.github.com/repos/Shugyousha/braintree-go/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Shugyousha/braintree-go/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Shugyousha/braintree-go/teams","hooks_url":"https://api.github.com/repos/Shugyousha/braintree-go/hooks","issue_events_url":"https://api.github.com/repos/Shugyousha/braintree-go/issues/events{/number}","events_url":"https://api.github.com/repos/Shugyousha/braintree-go/events","assignees_url":"https://api.github.com/repos/Shugyousha/braintree-go/assignees{/user}","branches_url":"https://api.github.com/repos/Shugyousha/braintree-go/branches{/branch}","tags_url":"https://api.github.com/repos/Shugyousha/braintree-go/tags","blobs_url":"https://api.github.com/repos/Shugyousha/braintree-go/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Shugyousha/braintree-go/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Shugyousha/braintree-go/git/refs{/sha}","trees_url":"https://api.github.com/repos/Shugyousha/braintree-go/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Shugyousha/braintree-go/statuses/{sha}","languages_url":"https://api.github.com/repos/Shugyousha/braintree-go/languages","stargazers_url":"https://api.github.com/repos/Shugyousha/braintree-go/stargazers","contributors_url":"https://api.github.com/repos/Shugyousha/braintree-go/contributors","subscribers_url":"https://api.github.com/repos/Shugyousha/braintree-go/subscribers","subscription_url":"https://api.github.com/repos/Shugyousha/braintree-go/subscription","commits_url":"https://api.github.com/repos/Shugyousha/braintree-go/commits{/sha}","git_commits_url":"https://api.github.com/repos/Shugyousha/braintree-go/git/commits{/sha}","comments_url":"https://api.github.com/repos/Shugyousha/braintree-go/comments{/number}","issue_comment_url":"https://api.github.com/repos/Shugyousha/braintree-go/issues/comments{/number}","contents_url":"https://api.github.com/repos/Shugyousha/braintree-go/contents/{+path}","compare_url":"https://api.github.com/repos/Shugyousha/braintree-go/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Shugyousha/braintree-go/merges","archive_url":"https://api.github.com/repos/Shugyousha/braintree-go/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Shugyousha/braintree-go/downloads","issues_url":"https://api.github.com/repos/Shugyousha/braintree-go/issues{/number}","pulls_url":"https://api.github.com/repos/Shugyousha/braintree-go/pulls{/number}","milestones_url":"https://api.github.com/repos/Shugyousha/braintree-go/milestones{/number}","notifications_url":"https://api.github.com/repos/Shugyousha/braintree-go/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Shugyousha/braintree-go/labels{/name}","releases_url":"https://api.github.com/repos/Shugyousha/braintree-go/releases{/id}","deployments_url":"https://api.github.com/repos/Shugyousha/braintree-go/deployments","created_at":"2018-04-20T15:47:21Z","updated_at":"2018-04-20T15:47:23Z","pushed_at":"2018-05-09T05:14:52Z","git_url":"git://github.com/Shugyousha/braintree-go.git","ssh_url":"git@github.com:Shugyousha/braintree-go.git","clone_url":"https://github.com/Shugyousha/braintree-go.git","svn_url":"https://github.com/Shugyousha/braintree-go","homepage":null,"size":595,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"lionelbarrow:master","ref":"master","sha":"61096bb45c719906975d4d8c00e9502de6bb9731","user":{"login":"lionelbarrow","id":707118,"avatar_url":"https://avatars3.githubusercontent.com/u/707118?v=4","gravatar_id":"","url":"https://api.github.com/users/lionelbarrow","html_url":"https://github.com/lionelbarrow","followers_url":"https://api.github.com/users/lionelbarrow/followers","following_url":"https://api.github.com/users/lionelbarrow/following{/other_user}","gists_url":"https://api.github.com/users/lionelbarrow/gists{/gist_id}","starred_url":"https://api.github.com/users/lionelbarrow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lionelbarrow/subscriptions","organizations_url":"https://api.github.com/users/lionelbarrow/orgs","repos_url":"https://api.github.com/users/lionelbarrow/repos","events_url":"https://api.github.com/users/lionelbarrow/events{/privacy}","received_events_url":"https://api.github.com/users/lionelbarrow/received_events","type":"User","site_admin":false},"repo":{"id":10019656,"name":"braintree-go","full_name":"lionelbarrow/braintree-go","owner":{"login":"lionelbarrow","id":707118,"avatar_url":"https://avatars3.githubusercontent.com/u/707118?v=4","gravatar_id":"","url":"https://api.github.com/users/lionelbarrow","html_url":"https://github.com/lionelbarrow","followers_url":"https://api.github.com/users/lionelbarrow/followers","following_url":"https://api.github.com/users/lionelbarrow/following{/other_user}","gists_url":"https://api.github.com/users/lionelbarrow/gists{/gist_id}","starred_url":"https://api.github.com/users/lionelbarrow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lionelbarrow/subscriptions","organizations_url":"https://api.github.com/users/lionelbarrow/orgs","repos_url":"https://api.github.com/users/lionelbarrow/repos","events_url":"https://api.github.com/users/lionelbarrow/events{/privacy}","received_events_url":"https://api.github.com/users/lionelbarrow/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lionelbarrow/braintree-go","description":"A Go client library for Braintree","fork":false,"url":"https://api.github.com/repos/lionelbarrow/braintree-go","forks_url":"https://api.github.com/repos/lionelbarrow/braintree-go/forks","keys_url":"https://api.github.com/repos/lionelbarrow/braintree-go/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lionelbarrow/braintree-go/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lionelbarrow/braintree-go/teams","hooks_url":"https://api.github.com/repos/lionelbarrow/braintree-go/hooks","issue_events_url":"https://api.github.com/repos/lionelbarrow/braintree-go/issues/events{/number}","events_url":"https://api.github.com/repos/lionelbarrow/braintree-go/events","assignees_url":"https://api.github.com/repos/lionelbarrow/braintree-go/assignees{/user}","branches_url":"https://api.github.com/repos/lionelbarrow/braintree-go/branches{/branch}","tags_url":"https://api.github.com/repos/lionelbarrow/braintree-go/tags","blobs_url":"https://api.github.com/repos/lionelbarrow/braintree-go/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lionelbarrow/braintree-go/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lionelbarrow/braintree-go/git/refs{/sha}","trees_url":"https://api.github.com/repos/lionelbarrow/braintree-go/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lionelbarrow/braintree-go/statuses/{sha}","languages_url":"https://api.github.com/repos/lionelbarrow/braintree-go/languages","stargazers_url":"https://api.github.com/repos/lionelbarrow/braintree-go/stargazers","contributors_url":"https://api.github.com/repos/lionelbarrow/braintree-go/contributors","subscribers_url":"https://api.github.com/repos/lionelbarrow/braintree-go/subscribers","subscription_url":"https://api.github.com/repos/lionelbarrow/braintree-go/subscription","commits_url":"https://api.github.com/repos/lionelbarrow/braintree-go/commits{/sha}","git_commits_url":"https://api.github.com/repos/lionelbarrow/braintree-go/git/commits{/sha}","comments_url":"https://api.github.com/repos/lionelbarrow/braintree-go/comments{/number}","issue_comment_url":"https://api.github.com/repos/lionelbarrow/braintree-go/issues/comments{/number}","contents_url":"https://api.github.com/repos/lionelbarrow/braintree-go/contents/{+path}","compare_url":"https://api.github.com/repos/lionelbarrow/braintree-go/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lionelbarrow/braintree-go/merges","archive_url":"https://api.github.com/repos/lionelbarrow/braintree-go/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lionelbarrow/braintree-go/downloads","issues_url":"https://api.github.com/repos/lionelbarrow/braintree-go/issues{/number}","pulls_url":"https://api.github.com/repos/lionelbarrow/braintree-go/pulls{/number}","milestones_url":"https://api.github.com/repos/lionelbarrow/braintree-go/milestones{/number}","notifications_url":"https://api.github.com/repos/lionelbarrow/braintree-go/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lionelbarrow/braintree-go/labels{/name}","releases_url":"https://api.github.com/repos/lionelbarrow/braintree-go/releases{/id}","deployments_url":"https://api.github.com/repos/lionelbarrow/braintree-go/deployments","created_at":"2013-05-12T21:02:46Z","updated_at":"2018-05-06T18:36:22Z","pushed_at":"2018-05-09T05:14:53Z","git_url":"git://github.com/lionelbarrow/braintree-go.git","ssh_url":"git@github.com:lionelbarrow/braintree-go.git","clone_url":"https://github.com/lionelbarrow/braintree-go.git","svn_url":"https://github.com/lionelbarrow/braintree-go","homepage":null,"size":577,"stargazers_count":176,"watchers_count":176,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":87,"mirror_url":null,"archived":false,"open_issues_count":7,"license":null,"forks":87,"open_issues":7,"watchers":176,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/lionelbarrow/braintree-go/pulls/221"},"html":{"href":"https://github.com/lionelbarrow/braintree-go/pull/221"},"issue":{"href":"https://api.github.com/repos/lionelbarrow/braintree-go/issues/221"},"comments":{"href":"https://api.github.com/repos/lionelbarrow/braintree-go/issues/221/comments"},"review_comments":{"href":"https://api.github.com/repos/lionelbarrow/braintree-go/pulls/221/comments"},"review_comment":{"href":"https://api.github.com/repos/lionelbarrow/braintree-go/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/lionelbarrow/braintree-go/pulls/221/commits"},"statuses":{"href":"https://api.github.com/repos/lionelbarrow/braintree-go/statuses/6920d6339865c0b31e719ad8b062d2a4175f7286"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"Shugyousha"}}