{"action":"created","comment":{"url":"https://api.github.com/repos/aimeoscom/ai-payments/pulls/comments/181691012","pull_request_review_id":112361277,"id":181691012,"diff_hunk":"@@ -33,20 +111,225 @@ protected function getConfigPrefix()\n \n \n \t/**\n-\t * Returns the value for the given configuration key\n+\t * Returns the Omnipay gateway provider object.\n \t *\n-\t * @param string $key Configuration key name\n-\t * @param mixed $default Default value if no configuration is found\n-\t * @return mixed Configuration value\n+\t * @return \\Omnipay\\Common\\GatewayInterface Gateway provider object\n \t */\n-\tprotected function getValue( $key, $default = null )\n+\tprotected function getProvider()\n \t{\n-\t\tswitch( $key )\n+\t\t$config = $this->getServiceItem()->getConfig();\n+\t\t$config['apiKey'] = $config['stripe.apiKey'];\n+\n+\t\tif( !isset( $this->provider ) )\n \t\t{\n-\t\t\tcase 'type': return 'Stripe';\n-\t\t\tcase 'onsite': return true;\n+\t\t\t$this->provider = OPay::create( 'Stripe' );\n+\t\t\t$this->provider->setTestMode( (bool) $this->getValue( 'testmode', false ) );\n+\t\t\t$this->provider->initialize( $config );\n+\t\t}\n+\n+\t\treturn $this->provider;\n+\t}\n+\n+\n+\n+\t/**\n+\t * Tries to get an authorization or captures the money immediately for the given order if capturing the money\n+\t * separately isn't supported or not configured by the shop owner.\n+\t *\n+\t * @param \\Aimeos\\MShop\\Order\\Item\\Iface $order Order invoice object\n+\t * @param array $params Request parameter if available\n+\t * @return \\Aimeos\\MShop\\Common\\Item\\Helper\\Form\\Standard Form object with URL, action and parameters to redirect to\n+\t *    (e.g. to an external server of the payment provider or to a local success page)\n+\t */\n+\tpublic function process(\\Aimeos\\MShop\\Order\\Item\\Iface $order, array $params = [])\n+\t{\n+\t\tif( !isset( $params['paymenttoken'] ) ) {\n+\t\t\treturn $this->getPaymentForm( $order, $params );\n+\t\t}\n+\t\treturn $this->processOrder($order, $params);\n+\t}\n+\n+\n+\t/**\n+\t * Returns the payment form for entering payment details at the shop site.\n+\t *\n+\t * @param \\Aimeos\\MShop\\Order\\Item\\Iface $order Order object\n+\t * @param array $params Request parameter if available\n+\t * @return \\Aimeos\\MShop\\Common\\Item\\Helper\\Form\\Iface Form helper object\n+\t */\n+\tprotected function getPaymentForm(\\Aimeos\\MShop\\Order\\Item\\Iface $order, array $params)\n+\t{\n+\t\t$list = [];\n+\t\t$feConfig = $this->feConfig;\n+\n+\t\tforeach ($feConfig as $key => $config) {\n+\t\t\t$list[$key] = new \\Aimeos\\MW\\Criteria\\Attribute\\Standard($config);\n+\t\t}\n+\t\t$url = $this->getConfigValue(array('payment.url-self'));\n+\t\treturn new \\Aimeos\\MShop\\Common\\Item\\Helper\\Form\\Standard($url, 'POST', $list, false, $this->getHtmlForm());\n+\t}\n+\n+\n+\n+\n+\t/**\n+\t * Returns the configuration attribute definitions of the provider to generate a list of available fields and\n+\t * rules for the value of each field in the frontend.\n+\t *\n+\t * @param \\Aimeos\\MShop\\Order\\Item\\Base\\Iface $basket Basket object\n+\t * @return array List of attribute definitions implementing \\Aimeos\\MW\\Common\\Critera\\Attribute\\Iface\n+\t */\n+\tpublic function getConfigFE(\\Aimeos\\MShop\\Order\\Item\\Base\\Iface $basket)\n+\t{\n+\t\treturn [];\n+\t}\n+\n+\t/**\n+\t * Returns the data passed to the Omnipay library\n+\t *\n+\t * @param \\Aimeos\\MShop\\Order\\Item\\Base\\Iface $base Basket object\n+\t * @param $orderid Unique order ID\n+\t * @param array $params Request parameter if available\n+\t */\n+\tprotected function getData( \\Aimeos\\MShop\\Order\\Item\\Base\\Iface $base, $orderid, array $params )\n+\t{\n+\t\t$data = parent::getData($base,$orderid,$params);\n+\t\tif( isset($params['paymenttoken']) ){\n+\t\t\t$data['token'] = $params['paymenttoken'];\n \t\t}\n+\t\treturn $data;\n+\t}\n+\n+\t/**\n+\t * Checks the frontend configuration attributes for validity.\n+\t *\n+\t * @param array $attributes Attributes entered by the customer during the checkout process\n+\t * @return array An array with the attribute keys as key and an error message as values for all attributes that are\n+\t *    known by the provider but aren't valid resp. null for attributes whose values are OK\n+\t */\n+\tpublic function checkConfigFE(array $attributes)\n+\t{\n+\t\treturn [];\n+\t\t//return $this->checkConfig($this->feConfig, $attributes);\n+\t}\n+\n+\tpublic function getHtmlForm()\n+\t{\n+\t\treturn '<script src=\"https://js.stripe.com/v3/\"></script>\n+\t\t<script type=\"text/javascript\">\n+    \t$(document).ready(function () {\n+        var stripe = Stripe(\"'.$this->getConfigValue( array( $this->getConfigPrefix() . '.publishableKey' ), '' ).'\");","path":"lib/custom/src/MShop/Service/Provider/Payment/Stripe.php","position":211,"original_position":211,"commit_id":"32e47c8982e047588edb6585425901f672313adf","original_commit_id":"32e47c8982e047588edb6585425901f672313adf","user":{"login":"aimeoscom","id":17964525,"avatar_url":"https://avatars2.githubusercontent.com/u/17964525?v=4","gravatar_id":"","url":"https://api.github.com/users/aimeoscom","html_url":"https://github.com/aimeoscom","followers_url":"https://api.github.com/users/aimeoscom/followers","following_url":"https://api.github.com/users/aimeoscom/following{/other_user}","gists_url":"https://api.github.com/users/aimeoscom/gists{/gist_id}","starred_url":"https://api.github.com/users/aimeoscom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aimeoscom/subscriptions","organizations_url":"https://api.github.com/users/aimeoscom/orgs","repos_url":"https://api.github.com/users/aimeoscom/repos","events_url":"https://api.github.com/users/aimeoscom/events{/privacy}","received_events_url":"https://api.github.com/users/aimeoscom/received_events","type":"User","site_admin":false},"body":"You can use `getConfigValue( 'stripe.publishableKey' )` instead","created_at":"2018-04-16T10:38:10Z","updated_at":"2018-04-16T10:38:10Z","html_url":"https://github.com/aimeoscom/ai-payments/pull/12#discussion_r181691012","pull_request_url":"https://api.github.com/repos/aimeoscom/ai-payments/pulls/12","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/aimeoscom/ai-payments/pulls/comments/181691012"},"html":{"href":"https://github.com/aimeoscom/ai-payments/pull/12#discussion_r181691012"},"pull_request":{"href":"https://api.github.com/repos/aimeoscom/ai-payments/pulls/12"}}},"pull_request":{"url":"https://api.github.com/repos/aimeoscom/ai-payments/pulls/12","id":181161516,"html_url":"https://github.com/aimeoscom/ai-payments/pull/12","diff_url":"https://github.com/aimeoscom/ai-payments/pull/12.diff","patch_url":"https://github.com/aimeoscom/ai-payments/pull/12.patch","issue_url":"https://api.github.com/repos/aimeoscom/ai-payments/issues/12","number":12,"state":"open","locked":false,"title":"Stripe implementation","user":{"login":"alextravin","id":8221400,"avatar_url":"https://avatars0.githubusercontent.com/u/8221400?v=4","gravatar_id":"","url":"https://api.github.com/users/alextravin","html_url":"https://github.com/alextravin","followers_url":"https://api.github.com/users/alextravin/followers","following_url":"https://api.github.com/users/alextravin/following{/other_user}","gists_url":"https://api.github.com/users/alextravin/gists{/gist_id}","starred_url":"https://api.github.com/users/alextravin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alextravin/subscriptions","organizations_url":"https://api.github.com/users/alextravin/orgs","repos_url":"https://api.github.com/users/alextravin/repos","events_url":"https://api.github.com/users/alextravin/events{/privacy}","received_events_url":"https://api.github.com/users/alextravin/received_events","type":"User","site_admin":false},"body":"Stripe implementation. We also need to change ai-client-html. Will create pull request now","created_at":"2018-04-12T10:44:55Z","updated_at":"2018-04-16T10:38:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b22676e4b5600b58ddd2944e551873ae6721b59d","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/aimeoscom/ai-payments/pulls/12/commits","review_comments_url":"https://api.github.com/repos/aimeoscom/ai-payments/pulls/12/comments","review_comment_url":"https://api.github.com/repos/aimeoscom/ai-payments/pulls/comments{/number}","comments_url":"https://api.github.com/repos/aimeoscom/ai-payments/issues/12/comments","statuses_url":"https://api.github.com/repos/aimeoscom/ai-payments/statuses/32e47c8982e047588edb6585425901f672313adf","head":{"label":"alextravin:master","ref":"master","sha":"32e47c8982e047588edb6585425901f672313adf","user":{"login":"alextravin","id":8221400,"avatar_url":"https://avatars0.githubusercontent.com/u/8221400?v=4","gravatar_id":"","url":"https://api.github.com/users/alextravin","html_url":"https://github.com/alextravin","followers_url":"https://api.github.com/users/alextravin/followers","following_url":"https://api.github.com/users/alextravin/following{/other_user}","gists_url":"https://api.github.com/users/alextravin/gists{/gist_id}","starred_url":"https://api.github.com/users/alextravin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alextravin/subscriptions","organizations_url":"https://api.github.com/users/alextravin/orgs","repos_url":"https://api.github.com/users/alextravin/repos","events_url":"https://api.github.com/users/alextravin/events{/privacy}","received_events_url":"https://api.github.com/users/alextravin/received_events","type":"User","site_admin":false},"repo":{"id":128877271,"name":"ai-payments","full_name":"alextravin/ai-payments","owner":{"login":"alextravin","id":8221400,"avatar_url":"https://avatars0.githubusercontent.com/u/8221400?v=4","gravatar_id":"","url":"https://api.github.com/users/alextravin","html_url":"https://github.com/alextravin","followers_url":"https://api.github.com/users/alextravin/followers","following_url":"https://api.github.com/users/alextravin/following{/other_user}","gists_url":"https://api.github.com/users/alextravin/gists{/gist_id}","starred_url":"https://api.github.com/users/alextravin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alextravin/subscriptions","organizations_url":"https://api.github.com/users/alextravin/orgs","repos_url":"https://api.github.com/users/alextravin/repos","events_url":"https://api.github.com/users/alextravin/events{/privacy}","received_events_url":"https://api.github.com/users/alextravin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/alextravin/ai-payments","description":"Payment provider extension for Aimeos web shops and e-commerce solutions","fork":true,"url":"https://api.github.com/repos/alextravin/ai-payments","forks_url":"https://api.github.com/repos/alextravin/ai-payments/forks","keys_url":"https://api.github.com/repos/alextravin/ai-payments/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alextravin/ai-payments/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alextravin/ai-payments/teams","hooks_url":"https://api.github.com/repos/alextravin/ai-payments/hooks","issue_events_url":"https://api.github.com/repos/alextravin/ai-payments/issues/events{/number}","events_url":"https://api.github.com/repos/alextravin/ai-payments/events","assignees_url":"https://api.github.com/repos/alextravin/ai-payments/assignees{/user}","branches_url":"https://api.github.com/repos/alextravin/ai-payments/branches{/branch}","tags_url":"https://api.github.com/repos/alextravin/ai-payments/tags","blobs_url":"https://api.github.com/repos/alextravin/ai-payments/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alextravin/ai-payments/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alextravin/ai-payments/git/refs{/sha}","trees_url":"https://api.github.com/repos/alextravin/ai-payments/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alextravin/ai-payments/statuses/{sha}","languages_url":"https://api.github.com/repos/alextravin/ai-payments/languages","stargazers_url":"https://api.github.com/repos/alextravin/ai-payments/stargazers","contributors_url":"https://api.github.com/repos/alextravin/ai-payments/contributors","subscribers_url":"https://api.github.com/repos/alextravin/ai-payments/subscribers","subscription_url":"https://api.github.com/repos/alextravin/ai-payments/subscription","commits_url":"https://api.github.com/repos/alextravin/ai-payments/commits{/sha}","git_commits_url":"https://api.github.com/repos/alextravin/ai-payments/git/commits{/sha}","comments_url":"https://api.github.com/repos/alextravin/ai-payments/comments{/number}","issue_comment_url":"https://api.github.com/repos/alextravin/ai-payments/issues/comments{/number}","contents_url":"https://api.github.com/repos/alextravin/ai-payments/contents/{+path}","compare_url":"https://api.github.com/repos/alextravin/ai-payments/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alextravin/ai-payments/merges","archive_url":"https://api.github.com/repos/alextravin/ai-payments/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alextravin/ai-payments/downloads","issues_url":"https://api.github.com/repos/alextravin/ai-payments/issues{/number}","pulls_url":"https://api.github.com/repos/alextravin/ai-payments/pulls{/number}","milestones_url":"https://api.github.com/repos/alextravin/ai-payments/milestones{/number}","notifications_url":"https://api.github.com/repos/alextravin/ai-payments/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alextravin/ai-payments/labels{/name}","releases_url":"https://api.github.com/repos/alextravin/ai-payments/releases{/id}","deployments_url":"https://api.github.com/repos/alextravin/ai-payments/deployments","created_at":"2018-04-10T05:15:17Z","updated_at":"2018-04-16T10:34:24Z","pushed_at":"2018-04-16T10:34:22Z","git_url":"git://github.com/alextravin/ai-payments.git","ssh_url":"git@github.com:alextravin/ai-payments.git","clone_url":"https://github.com/alextravin/ai-payments.git","svn_url":"https://github.com/alextravin/ai-payments","homepage":"https://aimeos.org/","size":218,"stargazers_count":0,"watchers_count":0,"language":"PHP","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":{"key":"lgpl-3.0","name":"GNU Lesser General Public License v3.0","spdx_id":"LGPL-3.0","url":"https://api.github.com/licenses/lgpl-3.0"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"aimeoscom:master","ref":"master","sha":"ba8f6a6d7b631c003a56b819ec03143029c97483","user":{"login":"aimeoscom","id":17964525,"avatar_url":"https://avatars2.githubusercontent.com/u/17964525?v=4","gravatar_id":"","url":"https://api.github.com/users/aimeoscom","html_url":"https://github.com/aimeoscom","followers_url":"https://api.github.com/users/aimeoscom/followers","following_url":"https://api.github.com/users/aimeoscom/following{/other_user}","gists_url":"https://api.github.com/users/aimeoscom/gists{/gist_id}","starred_url":"https://api.github.com/users/aimeoscom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aimeoscom/subscriptions","organizations_url":"https://api.github.com/users/aimeoscom/orgs","repos_url":"https://api.github.com/users/aimeoscom/repos","events_url":"https://api.github.com/users/aimeoscom/events{/privacy}","received_events_url":"https://api.github.com/users/aimeoscom/received_events","type":"User","site_admin":false},"repo":{"id":38568121,"name":"ai-payments","full_name":"aimeoscom/ai-payments","owner":{"login":"aimeoscom","id":17964525,"avatar_url":"https://avatars2.githubusercontent.com/u/17964525?v=4","gravatar_id":"","url":"https://api.github.com/users/aimeoscom","html_url":"https://github.com/aimeoscom","followers_url":"https://api.github.com/users/aimeoscom/followers","following_url":"https://api.github.com/users/aimeoscom/following{/other_user}","gists_url":"https://api.github.com/users/aimeoscom/gists{/gist_id}","starred_url":"https://api.github.com/users/aimeoscom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aimeoscom/subscriptions","organizations_url":"https://api.github.com/users/aimeoscom/orgs","repos_url":"https://api.github.com/users/aimeoscom/repos","events_url":"https://api.github.com/users/aimeoscom/events{/privacy}","received_events_url":"https://api.github.com/users/aimeoscom/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/aimeoscom/ai-payments","description":"Payment provider extension for Aimeos web shops and e-commerce solutions","fork":false,"url":"https://api.github.com/repos/aimeoscom/ai-payments","forks_url":"https://api.github.com/repos/aimeoscom/ai-payments/forks","keys_url":"https://api.github.com/repos/aimeoscom/ai-payments/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aimeoscom/ai-payments/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aimeoscom/ai-payments/teams","hooks_url":"https://api.github.com/repos/aimeoscom/ai-payments/hooks","issue_events_url":"https://api.github.com/repos/aimeoscom/ai-payments/issues/events{/number}","events_url":"https://api.github.com/repos/aimeoscom/ai-payments/events","assignees_url":"https://api.github.com/repos/aimeoscom/ai-payments/assignees{/user}","branches_url":"https://api.github.com/repos/aimeoscom/ai-payments/branches{/branch}","tags_url":"https://api.github.com/repos/aimeoscom/ai-payments/tags","blobs_url":"https://api.github.com/repos/aimeoscom/ai-payments/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aimeoscom/ai-payments/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aimeoscom/ai-payments/git/refs{/sha}","trees_url":"https://api.github.com/repos/aimeoscom/ai-payments/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aimeoscom/ai-payments/statuses/{sha}","languages_url":"https://api.github.com/repos/aimeoscom/ai-payments/languages","stargazers_url":"https://api.github.com/repos/aimeoscom/ai-payments/stargazers","contributors_url":"https://api.github.com/repos/aimeoscom/ai-payments/contributors","subscribers_url":"https://api.github.com/repos/aimeoscom/ai-payments/subscribers","subscription_url":"https://api.github.com/repos/aimeoscom/ai-payments/subscription","commits_url":"https://api.github.com/repos/aimeoscom/ai-payments/commits{/sha}","git_commits_url":"https://api.github.com/repos/aimeoscom/ai-payments/git/commits{/sha}","comments_url":"https://api.github.com/repos/aimeoscom/ai-payments/comments{/number}","issue_comment_url":"https://api.github.com/repos/aimeoscom/ai-payments/issues/comments{/number}","contents_url":"https://api.github.com/repos/aimeoscom/ai-payments/contents/{+path}","compare_url":"https://api.github.com/repos/aimeoscom/ai-payments/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aimeoscom/ai-payments/merges","archive_url":"https://api.github.com/repos/aimeoscom/ai-payments/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aimeoscom/ai-payments/downloads","issues_url":"https://api.github.com/repos/aimeoscom/ai-payments/issues{/number}","pulls_url":"https://api.github.com/repos/aimeoscom/ai-payments/pulls{/number}","milestones_url":"https://api.github.com/repos/aimeoscom/ai-payments/milestones{/number}","notifications_url":"https://api.github.com/repos/aimeoscom/ai-payments/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aimeoscom/ai-payments/labels{/name}","releases_url":"https://api.github.com/repos/aimeoscom/ai-payments/releases{/id}","deployments_url":"https://api.github.com/repos/aimeoscom/ai-payments/deployments","created_at":"2015-07-05T12:24:13Z","updated_at":"2018-04-04T10:08:09Z","pushed_at":"2018-04-16T10:34:23Z","git_url":"git://github.com/aimeoscom/ai-payments.git","ssh_url":"git@github.com:aimeoscom/ai-payments.git","clone_url":"https://github.com/aimeoscom/ai-payments.git","svn_url":"https://github.com/aimeoscom/ai-payments","homepage":"https://aimeos.org/","size":211,"stargazers_count":6,"watchers_count":6,"language":"PHP","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"lgpl-3.0","name":"GNU Lesser General Public License v3.0","spdx_id":"LGPL-3.0","url":"https://api.github.com/licenses/lgpl-3.0"},"forks":6,"open_issues":1,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/aimeoscom/ai-payments/pulls/12"},"html":{"href":"https://github.com/aimeoscom/ai-payments/pull/12"},"issue":{"href":"https://api.github.com/repos/aimeoscom/ai-payments/issues/12"},"comments":{"href":"https://api.github.com/repos/aimeoscom/ai-payments/issues/12/comments"},"review_comments":{"href":"https://api.github.com/repos/aimeoscom/ai-payments/pulls/12/comments"},"review_comment":{"href":"https://api.github.com/repos/aimeoscom/ai-payments/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/aimeoscom/ai-payments/pulls/12/commits"},"statuses":{"href":"https://api.github.com/repos/aimeoscom/ai-payments/statuses/32e47c8982e047588edb6585425901f672313adf"}},"author_association":"NONE"}}
{"actor":{"display_login":"aimeoscom"}}