mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-10 12:00:32 +08:00
catch exception
This commit is contained in:
parent
85944d392a
commit
3a4b942663
1 changed files with 60 additions and 43 deletions
|
@ -5,6 +5,7 @@ namespace Inpsyde\PayPalCommerce\Onboarding\Render;
|
||||||
|
|
||||||
|
|
||||||
use Inpsyde\PayPalCommerce\ApiClient\Endpoint\PartnerReferrals;
|
use Inpsyde\PayPalCommerce\ApiClient\Endpoint\PartnerReferrals;
|
||||||
|
use Inpsyde\PayPalCommerce\ApiClient\Exception\RuntimeException;
|
||||||
|
|
||||||
class OnboardingRenderer
|
class OnboardingRenderer
|
||||||
{
|
{
|
||||||
|
@ -16,48 +17,64 @@ class OnboardingRenderer
|
||||||
}
|
}
|
||||||
|
|
||||||
public function render() {
|
public function render() {
|
||||||
$url = add_query_arg(
|
try {
|
||||||
[
|
$url = add_query_arg(
|
||||||
'displayMode'=>'minibrowser',
|
[
|
||||||
],
|
'displayMode' => 'minibrowser',
|
||||||
$this->partnerReferrals->signupLink()
|
],
|
||||||
);
|
$this->partnerReferrals->signupLink()
|
||||||
?>
|
);
|
||||||
<tr valign="top">
|
?>
|
||||||
<th scope="row" class="titledesc">
|
<tr valign="top">
|
||||||
<?php echo esc_html_e('Connect to PayPal', 'woocommerce-paypal-commerce-gateway'); ?>
|
<th scope="row" class="titledesc">
|
||||||
</th>
|
<?php echo esc_html_e('Connect to PayPal', 'woocommerce-paypal-commerce-gateway'); ?>
|
||||||
<td class="forminp">
|
</th>
|
||||||
<script>
|
<td class="forminp">
|
||||||
function onboardingCallback(authCode, sharedId) {
|
<script>
|
||||||
fetch(PayPalCommerceGatewayOnboarding.endpoint, {
|
function onboardingCallback(authCode, sharedId) {
|
||||||
method: 'POST',
|
fetch(PayPalCommerceGatewayOnboarding.endpoint, {
|
||||||
headers: {
|
method: 'POST',
|
||||||
'content-type': 'application/json'
|
headers: {
|
||||||
},
|
'content-type': 'application/json'
|
||||||
body: JSON.stringify({
|
},
|
||||||
authCode: authCode,
|
body: JSON.stringify({
|
||||||
sharedId: sharedId,
|
authCode: authCode,
|
||||||
nonce: PayPalCommerceGatewayOnboarding.nonce
|
sharedId: sharedId,
|
||||||
})
|
nonce: PayPalCommerceGatewayOnboarding.nonce
|
||||||
});
|
})
|
||||||
}
|
});
|
||||||
</script>
|
}
|
||||||
<a
|
</script>
|
||||||
target="_blank"
|
<a
|
||||||
class="button-primary"
|
target="_blank"
|
||||||
data-paypal-onboard-complete="onboardingCallback"
|
class="button-primary"
|
||||||
href="<?php echo esc_url($url); ?>"
|
data-paypal-onboard-complete="onboardingCallback"
|
||||||
data-paypal-button="true"
|
href="<?php echo esc_url($url); ?>"
|
||||||
><?php
|
data-paypal-button="true"
|
||||||
esc_html_e('Sign up for PayPal', 'woocommerce-paypal-commerce-gateway');
|
><?php
|
||||||
?></a>
|
esc_html_e('Sign up for PayPal', 'woocommerce-paypal-commerce-gateway');
|
||||||
<script
|
?></a>
|
||||||
id="paypal-js"
|
<script
|
||||||
src="https://www.sandbox.paypal.com/webapps/merchantboarding/js/lib/lightbox/partner.js"
|
id="paypal-js"
|
||||||
></script>
|
src="https://www.sandbox.paypal.com/webapps/merchantboarding/js/lib/lightbox/partner.js"
|
||||||
</td>
|
></script>
|
||||||
</tr>
|
</td>
|
||||||
<?php
|
</tr>
|
||||||
|
<?php
|
||||||
|
} catch(RuntimeException $exception) {
|
||||||
|
?>
|
||||||
|
<tr valign="top">
|
||||||
|
<th scope="row" class="titledesc">
|
||||||
|
<?php echo esc_html_e('Connect to PayPal', 'woocommerce-paypal-commerce-gateway'); ?>
|
||||||
|
</th>
|
||||||
|
<td>
|
||||||
|
<?php echo esc_html_e(
|
||||||
|
'We could not properly connect to PayPal. Please reload the page to continue',
|
||||||
|
'woocommerce-paypal-commerce-gateway'
|
||||||
|
); ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue