{"action":"created","comment":{"url":"https://api.github.com/repos/mollie/WooCommerce/pulls/comments/198769881","pull_request_review_id":132757319,"id":198769881,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5ODc2OTg4MQ==","diff_hunk":"@@ -844,11 +870,233 @@ protected function handlePayedOrderWebhook( $order, $payment ) {\n \n \t}\n \n+\t/**\n+\t * @param WC_Order                     $order\n+\t * @param Mollie\\Api\\Resources\\Payment $payment\n+\t */\n+\tprotected function processRefunds( WC_Order $order, Mollie\\Api\\Resources\\Payment $payment ) {\n+\n+\t\t// Get order ID in the correct way depending on WooCommerce version\n+\t\tif ( version_compare( WC_VERSION, '3.0', '<' ) ) {\n+\t\t\t$order_id = $order->id;\n+\t\t} else {\n+\t\t\t$order_id = $order->get_id();\n+\t\t}\n+\n+\t\t// Debug log ID (order id/payment id)\n+\t\t$log_id = 'order ' . $order_id . ' / payment ' . $payment->id;\n+\n+\t\t// Add message to log\n+\t\tMollie_WC_Plugin::debug( __METHOD__ . ' called for ' . $log_id );\n+\t\t\n+\t\t// Make sure there are refunds to process at all\n+\t\tif ( $payment->_links->refunds->href == null ) {\n+\t\t\tMollie_WC_Plugin::debug( __METHOD__ . \": No refunds to process for {$log_id}\", true );\n+\t\t}\n+\n+\t\t// Check for new refund\n+\t\ttry {\n+\n+\t\t\t// Get all refunds for this payment\n+\t\t\t$refunds = $payment->refunds();\n+\n+\t\t\t// Collect all refund IDs in one array\n+\t\t\t$refund_ids = array ();\n+\t\t\tforeach ( $refunds as $refund ) {\n+\t\t\t\t$refund_ids[] = $refund->id;\n+\t\t\t}\n+\n+\n+\t\t\tMollie_WC_Plugin::debug( __METHOD__ . ' All refund IDs for ' . $log_id . ': ' . json_encode( $refund_ids ) );\n+\n+\t\t\t// Get possibly already processed refunds\n+\t\t\tif ( $order->meta_exists( '_mollie_processed_refund_ids' ) ) {\n+\t\t\t\t$processed_refund_ids = $order->get_meta( '_mollie_processed_refund_ids', true );\n+\t\t\t} else {\n+\t\t\t\t$processed_refund_ids = array ();\n+\t\t\t}\n+\n+\t\t\tMollie_WC_Plugin::debug( __METHOD__ . ' Already processed refunds for ' . $log_id . ': ' . json_encode( $processed_refund_ids ) );\n+\n+\t\t\t// Order the refund arrays by value (refund ID)\n+\t\t\tasort( $refund_ids );\n+\t\t\tasort( $processed_refund_ids );\n+\n+\t\t\t// Check if there are new refunds that need processing\n+\t\t\tif ( $refund_ids != $processed_refund_ids ) {\n+\t\t\t\t// There are new refunds.\n+\t\t\t\t$refunds_to_process = array_diff( $refund_ids, $processed_refund_ids );\n+\t\t\t\tMollie_WC_Plugin::debug( __METHOD__ . ' Refunds that need to be processed for ' . $log_id . ': ' . json_encode( $refunds_to_process ) );\n+\n+\t\t\t} else {\n+\t\t\t\t// No new refunds, stop processing.\n+\t\t\t\tMollie_WC_Plugin::debug( __METHOD__ . ' No new refunds, stop processing for ' . $log_id );\n+\n+\t\t\t\treturn;\n+\t\t\t}\n+\n+\t\t\t$data_helper = Mollie_WC_Plugin::getDataHelper();\n+\t\t\t$order       = $data_helper->getWcOrder( $order_id );\n+\n+\t\t\tforeach ( $refunds_to_process as $refund_to_process ) {\n+\n+\t\t\t\tMollie_WC_Plugin::debug( __METHOD__ . ' New refund ' . $refund_to_process . ' processed in Mollie Dashboard for ' . $log_id . '. Order note added, but order not updated.' );\n+\n+\t\t\t\t$order->add_order_note( sprintf(\n+\t\t\t\t\t__( 'New refund %s processed in Mollie Dashboard! Order note added, but order not updated.', 'mollie-payments-for-woocommerce' ),\n+\t\t\t\t\t$refund_to_process\n+\t\t\t\t) );\n+\n+\t\t\t\t$processed_refund_ids[] = $refund_to_process;\n+\n+\t\t\t}\n+\n+\t\t\t$order->update_meta_data( '_mollie_processed_refund_ids', $processed_refund_ids );\n+\t\t\tMollie_WC_Plugin::debug( __METHOD__ . ' Updated, all processed refunds for ' . $log_id . ': ' . json_encode( $processed_refund_ids ) );\n+\n+\t\t\t$order->save();\n+\n+\t\t\treturn;\n+\n+\t\t}\n+\t\tcatch ( \\Mollie\\Api\\Exceptions\\ApiException $e ) {\n+\t\t\tMollie_WC_Plugin::debug( __FUNCTION__ . \": Could not load refunds for $payment->id: \" . $e->getMessage() . ' (' . get_class( $e ) . ')' );\n+\t\t}\n+\n+\t}\n+\n+\t/**\n+\t * @param WC_Order                     $order\n+\t * @param Mollie\\Api\\Resources\\Payment $payment\n+\t */\n+\tprotected function processChargebacks( WC_Order $order, Mollie\\Api\\Resources\\Payment $payment ) {\n+\n+\t\t// Get order ID in the correct way depending on WooCommerce version\n+\t\tif ( version_compare( WC_VERSION, '3.0', '<' ) ) {\n+\t\t\t$order_id = $order->id;\n+\t\t} else {\n+\t\t\t$order_id = $order->get_id();\n+\t\t}\n+\n+\t\t// Debug log ID (order id/payment id)\n+\t\t$log_id = 'order ' . $order_id . ' / payment ' . $payment->id;\n+\n+\t\t// Add message to log\n+\t\tMollie_WC_Plugin::debug( __METHOD__ . ' called for ' . $log_id );\n+\n+\t\t// Make sure there are chargebacks to process at all\n+\t\tif ( $payment->_links->chargebacks->href == null ) {","path":"mollie-payments-for-woocommerce/includes/mollie/wc/gateway/abstract.php","position":null,"original_position":587,"commit_id":"ab5bd8873a30cc514ab291df51b8531dc0be8415","original_commit_id":"cf51b9b1d5cd619dc4fe8f4ab4e1e8a23a15c5c3","user":{"login":"davdebcom","id":524491,"node_id":"MDQ6VXNlcjUyNDQ5MQ==","avatar_url":"https://avatars0.githubusercontent.com/u/524491?v=4","gravatar_id":"","url":"https://api.github.com/users/davdebcom","html_url":"https://github.com/davdebcom","followers_url":"https://api.github.com/users/davdebcom/followers","following_url":"https://api.github.com/users/davdebcom/following{/other_user}","gists_url":"https://api.github.com/users/davdebcom/gists{/gist_id}","starred_url":"https://api.github.com/users/davdebcom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davdebcom/subscriptions","organizations_url":"https://api.github.com/users/davdebcom/orgs","repos_url":"https://api.github.com/users/davdebcom/repos","events_url":"https://api.github.com/users/davdebcom/events{/privacy}","received_events_url":"https://api.github.com/users/davdebcom/received_events","type":"User","site_admin":false},"body":"https://github.com/mollie/WooCommerce/commit/ab5bd8873a30cc514ab291df51b8531dc0be8415\r\n","created_at":"2018-06-28T09:16:50Z","updated_at":"2018-06-28T09:16:50Z","html_url":"https://github.com/mollie/WooCommerce/pull/214#discussion_r198769881","pull_request_url":"https://api.github.com/repos/mollie/WooCommerce/pulls/214","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/mollie/WooCommerce/pulls/comments/198769881"},"html":{"href":"https://github.com/mollie/WooCommerce/pull/214#discussion_r198769881"},"pull_request":{"href":"https://api.github.com/repos/mollie/WooCommerce/pulls/214"}},"in_reply_to_id":198456397},"pull_request":{"url":"https://api.github.com/repos/mollie/WooCommerce/pulls/214","id":194589889,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk0NTg5ODg5","html_url":"https://github.com/mollie/WooCommerce/pull/214","diff_url":"https://github.com/mollie/WooCommerce/pull/214.diff","patch_url":"https://github.com/mollie/WooCommerce/pull/214.patch","issue_url":"https://api.github.com/repos/mollie/WooCommerce/issues/214","number":214,"state":"open","locked":false,"title":"API v2 migration","user":{"login":"willemstuursma","id":701299,"node_id":"MDQ6VXNlcjcwMTI5OQ==","avatar_url":"https://avatars0.githubusercontent.com/u/701299?v=4","gravatar_id":"","url":"https://api.github.com/users/willemstuursma","html_url":"https://github.com/willemstuursma","followers_url":"https://api.github.com/users/willemstuursma/followers","following_url":"https://api.github.com/users/willemstuursma/following{/other_user}","gists_url":"https://api.github.com/users/willemstuursma/gists{/gist_id}","starred_url":"https://api.github.com/users/willemstuursma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/willemstuursma/subscriptions","organizations_url":"https://api.github.com/users/willemstuursma/orgs","repos_url":"https://api.github.com/users/willemstuursma/repos","events_url":"https://api.github.com/users/willemstuursma/events{/privacy}","received_events_url":"https://api.github.com/users/willemstuursma/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-06-13T13:39:45Z","updated_at":"2018-06-28T09:16:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9fe32b5d0f563bba598b653d366367f23e8e0bb3","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/mollie/WooCommerce/pulls/214/commits","review_comments_url":"https://api.github.com/repos/mollie/WooCommerce/pulls/214/comments","review_comment_url":"https://api.github.com/repos/mollie/WooCommerce/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mollie/WooCommerce/issues/214/comments","statuses_url":"https://api.github.com/repos/mollie/WooCommerce/statuses/ab5bd8873a30cc514ab291df51b8531dc0be8415","head":{"label":"mollie:apiv2","ref":"apiv2","sha":"ab5bd8873a30cc514ab291df51b8531dc0be8415","user":{"login":"mollie","id":1327170,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzMjcxNzA=","avatar_url":"https://avatars3.githubusercontent.com/u/1327170?v=4","gravatar_id":"","url":"https://api.github.com/users/mollie","html_url":"https://github.com/mollie","followers_url":"https://api.github.com/users/mollie/followers","following_url":"https://api.github.com/users/mollie/following{/other_user}","gists_url":"https://api.github.com/users/mollie/gists{/gist_id}","starred_url":"https://api.github.com/users/mollie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mollie/subscriptions","organizations_url":"https://api.github.com/users/mollie/orgs","repos_url":"https://api.github.com/users/mollie/repos","events_url":"https://api.github.com/users/mollie/events{/privacy}","received_events_url":"https://api.github.com/users/mollie/received_events","type":"Organization","site_admin":false},"repo":{"id":17252386,"node_id":"MDEwOlJlcG9zaXRvcnkxNzI1MjM4Ng==","name":"WooCommerce","full_name":"mollie/WooCommerce","owner":{"login":"mollie","id":1327170,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzMjcxNzA=","avatar_url":"https://avatars3.githubusercontent.com/u/1327170?v=4","gravatar_id":"","url":"https://api.github.com/users/mollie","html_url":"https://github.com/mollie","followers_url":"https://api.github.com/users/mollie/followers","following_url":"https://api.github.com/users/mollie/following{/other_user}","gists_url":"https://api.github.com/users/mollie/gists{/gist_id}","starred_url":"https://api.github.com/users/mollie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mollie/subscriptions","organizations_url":"https://api.github.com/users/mollie/orgs","repos_url":"https://api.github.com/users/mollie/repos","events_url":"https://api.github.com/users/mollie/events{/privacy}","received_events_url":"https://api.github.com/users/mollie/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mollie/WooCommerce","description":"Official Mollie extension for WooCommerce","fork":false,"url":"https://api.github.com/repos/mollie/WooCommerce","forks_url":"https://api.github.com/repos/mollie/WooCommerce/forks","keys_url":"https://api.github.com/repos/mollie/WooCommerce/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mollie/WooCommerce/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mollie/WooCommerce/teams","hooks_url":"https://api.github.com/repos/mollie/WooCommerce/hooks","issue_events_url":"https://api.github.com/repos/mollie/WooCommerce/issues/events{/number}","events_url":"https://api.github.com/repos/mollie/WooCommerce/events","assignees_url":"https://api.github.com/repos/mollie/WooCommerce/assignees{/user}","branches_url":"https://api.github.com/repos/mollie/WooCommerce/branches{/branch}","tags_url":"https://api.github.com/repos/mollie/WooCommerce/tags","blobs_url":"https://api.github.com/repos/mollie/WooCommerce/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mollie/WooCommerce/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mollie/WooCommerce/git/refs{/sha}","trees_url":"https://api.github.com/repos/mollie/WooCommerce/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mollie/WooCommerce/statuses/{sha}","languages_url":"https://api.github.com/repos/mollie/WooCommerce/languages","stargazers_url":"https://api.github.com/repos/mollie/WooCommerce/stargazers","contributors_url":"https://api.github.com/repos/mollie/WooCommerce/contributors","subscribers_url":"https://api.github.com/repos/mollie/WooCommerce/subscribers","subscription_url":"https://api.github.com/repos/mollie/WooCommerce/subscription","commits_url":"https://api.github.com/repos/mollie/WooCommerce/commits{/sha}","git_commits_url":"https://api.github.com/repos/mollie/WooCommerce/git/commits{/sha}","comments_url":"https://api.github.com/repos/mollie/WooCommerce/comments{/number}","issue_comment_url":"https://api.github.com/repos/mollie/WooCommerce/issues/comments{/number}","contents_url":"https://api.github.com/repos/mollie/WooCommerce/contents/{+path}","compare_url":"https://api.github.com/repos/mollie/WooCommerce/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mollie/WooCommerce/merges","archive_url":"https://api.github.com/repos/mollie/WooCommerce/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mollie/WooCommerce/downloads","issues_url":"https://api.github.com/repos/mollie/WooCommerce/issues{/number}","pulls_url":"https://api.github.com/repos/mollie/WooCommerce/pulls{/number}","milestones_url":"https://api.github.com/repos/mollie/WooCommerce/milestones{/number}","notifications_url":"https://api.github.com/repos/mollie/WooCommerce/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mollie/WooCommerce/labels{/name}","releases_url":"https://api.github.com/repos/mollie/WooCommerce/releases{/id}","deployments_url":"https://api.github.com/repos/mollie/WooCommerce/deployments","created_at":"2014-02-27T14:53:45Z","updated_at":"2018-06-05T10:19:18Z","pushed_at":"2018-06-28T09:15:15Z","git_url":"git://github.com/mollie/WooCommerce.git","ssh_url":"git@github.com:mollie/WooCommerce.git","clone_url":"https://github.com/mollie/WooCommerce.git","svn_url":"https://github.com/mollie/WooCommerce","homepage":"https://wordpress.org/plugins/mollie-payments-for-woocommerce/","size":3317,"stargazers_count":78,"watchers_count":78,"language":"PHP","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":20,"mirror_url":null,"archived":false,"open_issues_count":19,"license":null,"forks":20,"open_issues":19,"watchers":78,"default_branch":"master"}},"base":{"label":"mollie:master","ref":"master","sha":"5dd88e31ec28822263eff2c7f63fea18282737ef","user":{"login":"mollie","id":1327170,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzMjcxNzA=","avatar_url":"https://avatars3.githubusercontent.com/u/1327170?v=4","gravatar_id":"","url":"https://api.github.com/users/mollie","html_url":"https://github.com/mollie","followers_url":"https://api.github.com/users/mollie/followers","following_url":"https://api.github.com/users/mollie/following{/other_user}","gists_url":"https://api.github.com/users/mollie/gists{/gist_id}","starred_url":"https://api.github.com/users/mollie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mollie/subscriptions","organizations_url":"https://api.github.com/users/mollie/orgs","repos_url":"https://api.github.com/users/mollie/repos","events_url":"https://api.github.com/users/mollie/events{/privacy}","received_events_url":"https://api.github.com/users/mollie/received_events","type":"Organization","site_admin":false},"repo":{"id":17252386,"node_id":"MDEwOlJlcG9zaXRvcnkxNzI1MjM4Ng==","name":"WooCommerce","full_name":"mollie/WooCommerce","owner":{"login":"mollie","id":1327170,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzMjcxNzA=","avatar_url":"https://avatars3.githubusercontent.com/u/1327170?v=4","gravatar_id":"","url":"https://api.github.com/users/mollie","html_url":"https://github.com/mollie","followers_url":"https://api.github.com/users/mollie/followers","following_url":"https://api.github.com/users/mollie/following{/other_user}","gists_url":"https://api.github.com/users/mollie/gists{/gist_id}","starred_url":"https://api.github.com/users/mollie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mollie/subscriptions","organizations_url":"https://api.github.com/users/mollie/orgs","repos_url":"https://api.github.com/users/mollie/repos","events_url":"https://api.github.com/users/mollie/events{/privacy}","received_events_url":"https://api.github.com/users/mollie/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mollie/WooCommerce","description":"Official Mollie extension for WooCommerce","fork":false,"url":"https://api.github.com/repos/mollie/WooCommerce","forks_url":"https://api.github.com/repos/mollie/WooCommerce/forks","keys_url":"https://api.github.com/repos/mollie/WooCommerce/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mollie/WooCommerce/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mollie/WooCommerce/teams","hooks_url":"https://api.github.com/repos/mollie/WooCommerce/hooks","issue_events_url":"https://api.github.com/repos/mollie/WooCommerce/issues/events{/number}","events_url":"https://api.github.com/repos/mollie/WooCommerce/events","assignees_url":"https://api.github.com/repos/mollie/WooCommerce/assignees{/user}","branches_url":"https://api.github.com/repos/mollie/WooCommerce/branches{/branch}","tags_url":"https://api.github.com/repos/mollie/WooCommerce/tags","blobs_url":"https://api.github.com/repos/mollie/WooCommerce/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mollie/WooCommerce/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mollie/WooCommerce/git/refs{/sha}","trees_url":"https://api.github.com/repos/mollie/WooCommerce/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mollie/WooCommerce/statuses/{sha}","languages_url":"https://api.github.com/repos/mollie/WooCommerce/languages","stargazers_url":"https://api.github.com/repos/mollie/WooCommerce/stargazers","contributors_url":"https://api.github.com/repos/mollie/WooCommerce/contributors","subscribers_url":"https://api.github.com/repos/mollie/WooCommerce/subscribers","subscription_url":"https://api.github.com/repos/mollie/WooCommerce/subscription","commits_url":"https://api.github.com/repos/mollie/WooCommerce/commits{/sha}","git_commits_url":"https://api.github.com/repos/mollie/WooCommerce/git/commits{/sha}","comments_url":"https://api.github.com/repos/mollie/WooCommerce/comments{/number}","issue_comment_url":"https://api.github.com/repos/mollie/WooCommerce/issues/comments{/number}","contents_url":"https://api.github.com/repos/mollie/WooCommerce/contents/{+path}","compare_url":"https://api.github.com/repos/mollie/WooCommerce/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mollie/WooCommerce/merges","archive_url":"https://api.github.com/repos/mollie/WooCommerce/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mollie/WooCommerce/downloads","issues_url":"https://api.github.com/repos/mollie/WooCommerce/issues{/number}","pulls_url":"https://api.github.com/repos/mollie/WooCommerce/pulls{/number}","milestones_url":"https://api.github.com/repos/mollie/WooCommerce/milestones{/number}","notifications_url":"https://api.github.com/repos/mollie/WooCommerce/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mollie/WooCommerce/labels{/name}","releases_url":"https://api.github.com/repos/mollie/WooCommerce/releases{/id}","deployments_url":"https://api.github.com/repos/mollie/WooCommerce/deployments","created_at":"2014-02-27T14:53:45Z","updated_at":"2018-06-05T10:19:18Z","pushed_at":"2018-06-28T09:15:15Z","git_url":"git://github.com/mollie/WooCommerce.git","ssh_url":"git@github.com:mollie/WooCommerce.git","clone_url":"https://github.com/mollie/WooCommerce.git","svn_url":"https://github.com/mollie/WooCommerce","homepage":"https://wordpress.org/plugins/mollie-payments-for-woocommerce/","size":3317,"stargazers_count":78,"watchers_count":78,"language":"PHP","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":20,"mirror_url":null,"archived":false,"open_issues_count":19,"license":null,"forks":20,"open_issues":19,"watchers":78,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mollie/WooCommerce/pulls/214"},"html":{"href":"https://github.com/mollie/WooCommerce/pull/214"},"issue":{"href":"https://api.github.com/repos/mollie/WooCommerce/issues/214"},"comments":{"href":"https://api.github.com/repos/mollie/WooCommerce/issues/214/comments"},"review_comments":{"href":"https://api.github.com/repos/mollie/WooCommerce/pulls/214/comments"},"review_comment":{"href":"https://api.github.com/repos/mollie/WooCommerce/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mollie/WooCommerce/pulls/214/commits"},"statuses":{"href":"https://api.github.com/repos/mollie/WooCommerce/statuses/ab5bd8873a30cc514ab291df51b8531dc0be8415"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"davdebcom"}}