Skip to content

Commit 8482059

Browse files
committed
Remove unnecessary gateway methods
1 parent a879ff2 commit 8482059

File tree

4 files changed

+110
-50
lines changed

4 files changed

+110
-50
lines changed

modules/ppcp-onboarding/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"@wordpress/element": "^2.20.3",
3333
"@wordpress/i18n": "^4.1.0",
3434
"@wordpress/plugins": "^2.25.3",
35-
"@wordpress/url": "^3.1.0"
35+
"@wordpress/url": "^3.1.0",
36+
"interpolate-components": "^1.1.1"
3637
}
3738
}

modules/ppcp-onboarding/resources/js/task-list/connection-form.js

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,56 @@
44
import { __ } from '@wordpress/i18n';
55
import apiFetch from '@wordpress/api-fetch';
66
import { Button } from '@wordpress/components';
7-
import { Form, TextControl } from '@woocommerce/components';
7+
import { Form, Link, TextControl } from '@woocommerce/components';
8+
import interpolateComponents from 'interpolate-components';
89
import { isEmail } from '@wordpress/url';
910
import { OPTIONS_STORE_NAME } from '@woocommerce/data';
1011
import { useDispatch, useSelect } from '@wordpress/data';
1112

1213
const WC_PAYPAL_NAMESPACE = '/wc-paypal/v1';
1314

14-
export const ConnectionForm = ( { markConfigured, paymentGateway } ) => {
15+
const ConnectionHelpText = () => {
16+
return (
17+
<p>
18+
{ interpolateComponents( {
19+
mixedString: __(
20+
'Your API details can be obtained from your {{docsLink}}PayPal developer account{{/docsLink}}, and your Merchant Id from your {{merchantLink}}PayPal Business account{{/merchantLink}}. Don’t have a PayPal account? {{registerLink}}Create one.{{/registerLink}}',
21+
'woocommerce-admin'
22+
),
23+
components: {
24+
docsLink: (
25+
<Link
26+
href="https://developer.paypal.com/docs/api-basics/manage-apps/#create-or-edit-sandbox-and-live-apps"
27+
target="_blank"
28+
type="external"
29+
/>
30+
),
31+
merchantLink: (
32+
<Link
33+
href="https://www.paypal.com/us/smarthelp/article/FAQ3850"
34+
target="_blank"
35+
type="external"
36+
/>
37+
),
38+
registerLink: (
39+
<Link
40+
href="https://www.paypal.com/us/business"
41+
target="_blank"
42+
type="external"
43+
/>
44+
),
45+
},
46+
} ) }
47+
</p>
48+
);
49+
};
50+
51+
export const ConnectionForm = ( { markConfigured } ) => {
1552
const { createNotice } = useDispatch( 'core/notices' );
1653
const { updateOptions } = useDispatch( OPTIONS_STORE_NAME );
1754
const isOptionsUpdating = useSelect( ( select ) => {
1855
return select( OPTIONS_STORE_NAME ).isOptionsUpdating();
1956
} );
20-
const { setup_help_text: setupHelpText } = paymentGateway;
2157

2258
const updateSettingsManually = ( values ) => {
2359
const productionValues = Object.keys( values ).reduce(
@@ -191,13 +227,14 @@ export const ConnectionForm = ( { markConfigured, paymentGateway } ) => {
191227
/>
192228
<Button
193229
isPrimary
230+
disabled={ isOptionsUpdating }
194231
isBusy={ isOptionsUpdating }
195232
onClick={ handleSubmit }
196233
>
197234
{ __( 'Proceed', 'woocommerce-paypal-payments' ) }
198235
</Button>
199236

200-
<p>{ setupHelpText }</p>
237+
<ConnectionHelpText />
201238
</>
202239
);
203240
} }

modules/ppcp-onboarding/yarn.lock

Lines changed: 63 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3070,6 +3070,11 @@ ajv@^8.0.1:
30703070
require-from-string "^2.0.2"
30713071
uri-js "^4.2.2"
30723072

3073+
ansi-colors@^3.0.0:
3074+
version "3.2.4"
3075+
resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-3.2.4.tgz#e3a3da4bfbae6c86a9c285625de124a234026fbf"
3076+
integrity sha512-hHUXGagefjN2iRrID63xckIvotOXOojhQKWIPUZ4mNUZ9nLZW+7FMNoE1lOkEhNWYsx/7ysGIuJYCiMAA9FnrA==
3077+
30733078
ansi-colors@^4.1.1:
30743079
version "4.1.1"
30753080
resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.1.tgz#cbb9ae256bf750af1eab344f229aa27fe94ba348"
@@ -3821,7 +3826,7 @@ [email protected]:
38213826
resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.1.0.tgz#f6cf7933a360e0588fa9fde85651cdc7f805d1f6"
38223827
integrity sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==
38233828

3824-
cacache@^12.0.2:
3829+
cacache@^12.0.2, cacache@^12.0.3:
38253830
version "12.0.4"
38263831
resolved "https://registry.yarnpkg.com/cacache/-/cacache-12.0.4.tgz#668bcbd105aeb5f1d92fe25570ec9525c8faa40c"
38273832
integrity sha512-a0tMB40oefvuInr4Cwb3GerbL9xTj1D5yg0T5xrjGCGyfvbxseIXX7BAO/u/hIXdafzOI5JC3wDwHyf24buOAQ==
@@ -4388,6 +4393,24 @@ copy-descriptor@^0.1.0:
43884393
resolved "https://registry.yarnpkg.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d"
43894394
integrity sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=
43904395

4396+
4397+
version "5.1.2"
4398+
resolved "https://registry.yarnpkg.com/copy-webpack-plugin/-/copy-webpack-plugin-5.1.2.tgz#8a889e1dcafa6c91c6cd4be1ad158f1d3823bae2"
4399+
integrity sha512-Uh7crJAco3AjBvgAy9Z75CjK8IG+gxaErro71THQ+vv/bl4HaQcpkexAY8KVW/T6D2W2IRr+couF/knIRkZMIQ==
4400+
dependencies:
4401+
cacache "^12.0.3"
4402+
find-cache-dir "^2.1.0"
4403+
glob-parent "^3.1.0"
4404+
globby "^7.1.1"
4405+
is-glob "^4.0.1"
4406+
loader-utils "^1.2.3"
4407+
minimatch "^3.0.4"
4408+
normalize-path "^3.0.0"
4409+
p-limit "^2.2.1"
4410+
schema-utils "^1.0.0"
4411+
serialize-javascript "^4.0.0"
4412+
webpack-log "^2.0.0"
4413+
43914414
core-js-compat@^3.9.0, core-js-compat@^3.9.1:
43924415
version "3.13.0"
43934416
resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.13.0.tgz#a88f5fa81d8e9b15d7f98abc4447a4dfca2a358f"
@@ -4954,6 +4977,13 @@ diffie-hellman@^5.0.0:
49544977
miller-rabin "^4.0.0"
49554978
randombytes "^2.0.0"
49564979

4980+
dir-glob@^2.0.0:
4981+
version "2.2.2"
4982+
resolved "https://registry.yarnpkg.com/dir-glob/-/dir-glob-2.2.2.tgz#fa09f0694153c8918b18ba0deafae94769fc50c4"
4983+
integrity sha512-f9LBi5QWzIW3I6e//uxZoLBlUt9kcp66qo0sSCxL6YZKc75R1c4MFCoe/LaZiBGmgujvQdxc5Bn3QhfyvK5Hsw==
4984+
dependencies:
4985+
path-type "^3.0.0"
4986+
49574987
dir-glob@^3.0.1:
49584988
version "3.0.1"
49594989
resolved "https://registry.yarnpkg.com/dir-glob/-/dir-glob-3.0.1.tgz#56dbf73d992a4a93ba1584f4534063fd2e41717f"
@@ -6451,6 +6481,18 @@ globby@^6.1.0:
64516481
pify "^2.0.0"
64526482
pinkie-promise "^2.0.0"
64536483

6484+
globby@^7.1.1:
6485+
version "7.1.1"
6486+
resolved "https://registry.yarnpkg.com/globby/-/globby-7.1.1.tgz#fb2ccff9401f8600945dfada97440cca972b8680"
6487+
integrity sha1-+yzP+UAfhgCUXfral0QMypcrhoA=
6488+
dependencies:
6489+
array-union "^1.0.1"
6490+
dir-glob "^2.0.0"
6491+
glob "^7.1.2"
6492+
ignore "^3.3.5"
6493+
pify "^3.0.0"
6494+
slash "^1.0.0"
6495+
64546496
globjoin@^0.1.4:
64556497
version "0.1.4"
64566498
resolved "https://registry.yarnpkg.com/globjoin/-/globjoin-0.1.4.tgz#2f4494ac8919e3767c5cbb691e9f463324285d43"
@@ -6792,6 +6834,11 @@ ignore-emit-webpack-plugin@^2.0.6:
67926834
resolved "https://registry.yarnpkg.com/ignore-emit-webpack-plugin/-/ignore-emit-webpack-plugin-2.0.6.tgz#570c30a08ee4c2ce6060f80d4bc4c5c5fec4d606"
67936835
integrity sha512-/zC18RWCC2wz4ZwnS4UoujGWzvSKy28DLjtE+jrGBOXej6YdmityhBDzE8E0NlktEqi4tgdNbydX8B6G4haHSQ==
67946836

6837+
ignore@^3.3.5:
6838+
version "3.3.10"
6839+
resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.3.10.tgz#0a97fb876986e8081c631160f8f9f389157f0043"
6840+
integrity sha512-Pgs951kaMm5GXP7MOvxERINe3gsaVjUWFm+UZPSq9xYriQAksyhg0csnS0KXSNRD5NmNdapXEpjxG49+AKh/ug==
6841+
67956842
ignore@^4.0.6:
67966843
version "4.0.6"
67976844
resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc"
@@ -6905,7 +6952,7 @@ internal-slot@^1.0.3:
69056952
has "^1.0.3"
69066953
side-channel "^1.0.4"
69076954

6908-
6955+
[email protected], interpolate-components@^1.1.1:
69096956
version "1.1.1"
69106957
resolved "https://registry.yarnpkg.com/interpolate-components/-/interpolate-components-1.1.1.tgz#699fff45d1525e98c7ce7b7159591d992b5dd6df"
69116958
integrity sha1-aZ//RdFSXpjHzntxWVkdmStd1t8=
@@ -9223,7 +9270,7 @@ p-limit@^1.1.0:
92239270
dependencies:
92249271
p-try "^1.0.0"
92259272

9226-
p-limit@^2.0.0, p-limit@^2.2.0:
9273+
p-limit@^2.0.0, p-limit@^2.2.0, p-limit@^2.2.1:
92279274
version "2.3.0"
92289275
resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1"
92299276
integrity sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==
@@ -11023,6 +11070,11 @@ sisteransi@^1.0.5:
1102311070
resolved "https://registry.yarnpkg.com/sisteransi/-/sisteransi-1.0.5.tgz#134d681297756437cc05ca01370d3a7a571075ed"
1102411071
integrity sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==
1102511072

11073+
slash@^1.0.0:
11074+
version "1.0.0"
11075+
resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55"
11076+
integrity sha1-xB8vbDn8FtHNF61LXYlhFK5HDVU=
11077+
1102611078
slash@^3.0.0:
1102711079
version "3.0.0"
1102811080
resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634"
@@ -12485,6 +12537,14 @@ webpack-livereload-plugin@^2.3.0:
1248512537
portfinder "^1.0.17"
1248612538
tiny-lr "^1.1.1"
1248712539

12540+
webpack-log@^2.0.0:
12541+
version "2.0.0"
12542+
resolved "https://registry.yarnpkg.com/webpack-log/-/webpack-log-2.0.0.tgz#5b7928e0637593f119d32f6227c1e0ac31e1b47f"
12543+
integrity sha512-cX8G2vR/85UYG59FgkoMamwHUIkSSlV3bBMRsbxVXVUk2j6NleCKjQ/WE9eYg9WY4w25O9w8wKP4rzNZFmUcUg==
12544+
dependencies:
12545+
ansi-colors "^3.0.0"
12546+
uuid "^3.3.2"
12547+
1248812548
webpack-sources@^1.1.0, webpack-sources@^1.3.0, webpack-sources@^1.4.0, webpack-sources@^1.4.1, webpack-sources@^1.4.3:
1248912549
version "1.4.3"
1249012550
resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-1.4.3.tgz#eedd8ec0b928fbf1cbfe994e22d2d890f330a933"

modules/ppcp-wc-gateway/src/Gateway/class-paypalgateway.php

Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,10 @@ public function __construct(
173173
* @return bool
174174
*/
175175
public function needs_setup(): bool {
176-
return ! $this->get_option( 'merchant_email' ) ||
177-
! $this->get_option( 'merchant_id' ) ||
178-
! get_option( 'client_id' ) ||
179-
! get_option( 'client_secret' );
176+
return ! $this->config->has( 'merchant_email' ) ||
177+
! $this->config->has( 'merchant_id' ) ||
178+
! $this->config->has( 'client_id' ) ||
179+
! $this->config->has( 'client_secret' );
180180
}
181181

182182
/**
@@ -365,31 +365,6 @@ public function get_transaction_url( $order ): string {
365365
return parent::get_transaction_url( $order );
366366
}
367367

368-
/**
369-
* Get required setting keys for setup.
370-
*
371-
* @return array Array of setting keys used for setup.
372-
*/
373-
public function get_required_settings_keys() {
374-
return array(
375-
'merchant_email',
376-
'merchant_id',
377-
'client_id',
378-
'client_secret',
379-
);
380-
}
381-
382-
/**
383-
* Get the oAuth connection URL.
384-
*
385-
* @param string $return_url The URL to return to after the oAuth connection has been established.
386-
* @return string Connection URL.
387-
*/
388-
public function get_oauth_connection_url( $return_url = '' ) {
389-
// @todo This will need to load a new script or two that handles the onboarding script and window data.
390-
return null;
391-
}
392-
393368
/**
394369
* Get a list of scripts to enqueue after plugin install.
395370
*
@@ -399,17 +374,4 @@ public function get_post_install_script_handles() {
399374
return array( 'ppcp-task-list-fill' );
400375
}
401376

402-
/**
403-
* Get help text to display during quick setup.
404-
*/
405-
public function get_setup_help_text() {
406-
return sprintf(
407-
// translators: %1$s is the URL on info to create API credentials, %2$s is the URL on info find the secure Merchant ID, %3$s is the URL to create a new PayPal business account.
408-
__( 'Your API details can be obtained from your <a href="%1$s">PayPal developer account</a>, and your Merchant ID from your <a href="%2$s">PayPal Business account</a>. Don’t have a PayPal account? <a href="%3$s">Create one.</a>', 'woocommerce-paypal-payments' ),
409-
'https://developer.paypal.com/docs/api-basics/manage-apps/#create-or-edit-sandbox-and-live-apps',
410-
'https://www.paypal.com/us/smarthelp/article/FAQ3850',
411-
'https://www.paypal.com/us/business'
412-
);
413-
}
414-
415377
}

0 commit comments

Comments
 (0)