Skip to content

Commit 467b26b

Browse files
committed
Change the onboarding process to "without return URL & return button"
1 parent 1b768dc commit 467b26b

File tree

9 files changed

+27
-64
lines changed

9 files changed

+27
-64
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

7-
## [1.3.12] - 2024-??-??
7+
## [1.3.12] - 2025-??-??
88

99
- add possibility to ignore cached tokens. It helps e.g. for webhook registration
1010
- Update Client Version v1.0.12
11+
- Change the onboarding process to "without return URL & return button"
1112

1213
## [1.3.11] - 2024-09-12
1314

metadata.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
'en' => 'Use of the online payment service from PayPal. Documentation: <a href="https://docs.oxid-esales.com/modules/paypal-checkout/en/latest/" target="_blank">PayPal Checkout</a>'
5959
],
6060
'thumbnail' => 'out/img/paypal.png',
61-
'version' => '1.3.12-rc.1',
61+
'version' => '1.3.12-rc.2',
6262
'author' => 'OXID eSales AG',
6363
'url' => 'https://www.oxid-esales.com',
6464
'email' => 'info@oxid-esales.com',

out/src/js/paypal-admin.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/build/js/paypal-admin.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ function onboardedCallbackSandbox(authCode, sharedId)
4444

4545
function callConfigControllerAutoConfigurationFromCallback(authCode, sharedId, isSandBox)
4646
{
47-
fetch(window.selfLink + 'cl=oscpaypalconfig&fnc=autoConfigurationFromCallback', {
47+
const sandboxSnippet = isSandBox ? '&XDEBUG_SESSION_START=1' : '';
48+
fetch(window.selfLink + 'cl=oscpaypalconfig&fnc=autoConfigurationFromCallback' + sandboxSnippet, {
4849
method: 'POST',
4950
headers: {
5051
'content-type': 'application/json'
@@ -57,8 +58,8 @@ function callConfigControllerAutoConfigurationFromCallback(authCode, sharedId, i
5758
})
5859
.then(
5960
function (response) {
60-
if (response.status !== 200) {
61-
return;
61+
if (response.status === 200) {
62+
window.location.reload();
6263
}
6364
}
6465
)

resources/grunt/jshint.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ module.exports = {
77
browser: true,
88
globals: {
99
jQuery: true
10-
}
10+
},
11+
esversion: 9
1112
},
1213
moduleproduction: {
1314
src: [

src/Controller/Admin/PayPalConfigController.php

+8-34
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ class PayPalConfigController extends AdminController
3434
/**
3535
* @var string Current class template name.
3636
*/
37-
protected $_sThisTemplate = 'oscpaypalconfig.tpl'; // phpcs:ignore PSR2.Classes.PropertyDeclaration
37+
// phpcs:ignore PSR2.Classes.PropertyDeclaration
38+
protected $_sThisTemplate = 'oscpaypalconfig.tpl';
3839

3940
/**
4041
* @return string
@@ -110,17 +111,12 @@ private function buildSignUpLink(
110111
$localeCode = $lang->getLanguageAbbr() . '-' . $countryCode;
111112

112113
$partnerLogoUrl = Registry::getConfig()->getOutUrl(null, true) . 'admin/img/loginlogo.png';
113-
$returnToPartnerUrl = $config->getAdminUrlForJSCalls() .
114-
'cl=oscpaypalconfig&fnc=returnFromSignup' .
115-
'&isSandbox=' . ($isSandbox ? '1' : '0')
116-
;
117114

118115
$params = [
119116
'partnerClientId' => $partnerClientId,
120117
'partnerId' => $partnerId,
121118
'partnerLogoUrl' => $partnerLogoUrl,
122-
'returnToPartnerUrl' => $returnToPartnerUrl,
123-
'product' => 'ppcp',
119+
'product' => 'PPCP',
124120
'secondaryProducts' => 'payment_methods',
125121
'capabilities' => 'PAY_UPON_INVOICE',
126122
'integrationType' => 'FO',
@@ -163,10 +159,9 @@ public function createNonce(): string
163159
public function save()
164160
{
165161
$confArr = Registry::getRequest()->getRequestEscapedParameter('conf');
166-
$shopId = Registry::getConfig()->getShopId();
167162

168163
$confArr = $this->handleSpecialFields($confArr);
169-
$this->saveConfig($confArr, $shopId);
164+
$this->saveConfig($confArr);
170165
$this->checkEligibility();
171166
parent::save();
172167
}
@@ -175,9 +170,8 @@ public function save()
175170
* Saves configuration values
176171
*
177172
* @param array $conf
178-
* @param int $shopId
179173
*/
180-
protected function saveConfig(array $conf, int $shopId)
174+
protected function saveConfig(array $conf)
181175
{
182176
foreach ($conf as $confName => $value) {
183177
$this->getServiceFromContainer(ModuleSettings::class)->save($confName, $value);
@@ -347,32 +341,12 @@ public function autoConfigurationFromCallback()
347341
$logger->error($exception->getMessage(), [$exception]);
348342
}
349343

350-
$result = [];
351-
header('Content-Type: application/json; charset=UTF-8');
352-
Registry::getUtils()->showMessageAndExit(json_encode($result));
353-
}
354-
355-
public function returnFromSignup()
356-
{
357-
$config = new Config();
358-
$request = Registry::getRequest();
359-
if (
360-
('true' === (string)$request->getRequestParameter('permissionsGranted')) &&
361-
('true' === (string)$request->getRequestParameter('consentStatus'))
362-
) {
363-
/** @var ModuleSettings $moduleSettings */
364-
$moduleSettings = $this->getServiceFromContainer(ModuleSettings::class);
365-
$isSandbox = (string)$request->getRequestParameter('isSandbox');
366-
$isSandbox = $isSandbox === '1';
367-
$moduleSettings->saveMerchantId($request->getRequestParameter('merchantIdInPayPal'), $isSandbox);
368-
}
369-
370344
$this->autoConfiguration();
371345
$this->registerWebhooks();
372346

373-
$url = $config->getAdminUrlForJSCalls() . 'cl=oscpaypalconfig';
374-
375-
Registry::getUtils()->redirect($url, false, 302);
347+
$result = [];
348+
header('Content-Type: application/json; charset=UTF-8');
349+
Registry::getUtils()->showMessageAndExit(json_encode($result));
376350
}
377351

378352
/**

src/Core/Onboarding/Onboarding.php

+3-11
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ class Onboarding
2424

2525
public function autoConfigurationFromCallback(): array
2626
{
27-
$credentials = [];
2827
try {
2928
$paypalConfig = oxNew(PayPalConfig::class);
3029
//fetch and save credentials
@@ -90,23 +89,16 @@ public function saveSandboxMode(bool $isSandbox)
9089
$moduleSettings->saveSandboxMode($isSandbox);
9190
}
9291

93-
public function saveCredentials(array $credentials): array
92+
public function saveCredentials(array $credentials)
9493
{
95-
if (
96-
!isset($credentials['client_id']) ||
97-
!isset($credentials['client_secret'])
98-
) {
94+
if (!isset($credentials['client_id'], $credentials['client_secret'], $credentials['payer_id'])) {
9995
throw OnboardingException::mandatoryDataNotFound();
10096
}
10197

10298
$moduleSettings = $this->getServiceFromContainer(ModuleSettings::class);
10399
$moduleSettings->saveClientId($credentials['client_id']);
104100
$moduleSettings->saveClientSecret($credentials['client_secret']);
105-
106-
return [
107-
'client_id' => $moduleSettings->getClientId(),
108-
'client_secret' => $moduleSettings->getClientSecret()
109-
];
101+
$moduleSettings->saveMerchantId($credentials['payer_id']);
110102
}
111103

112104
public function getOnboardingClient(bool $isSandbox, bool $withCredentials = false): ApiOnboardingClient

src/Service/ModuleSettings.php

+6-9
Original file line numberDiff line numberDiff line change
@@ -389,19 +389,16 @@ public function saveClientSecret(string $clientSecret)
389389
}
390390
}
391391

392-
public function saveMerchantId($merchantId, $isSandbox = null)
392+
public function saveMerchantId($merchantId)
393393
{
394-
$logger = new PayPalLogger();
395-
$isSandbox = !is_null($isSandbox) ? $isSandbox : $this->isSandbox();
396-
if ($isSandbox) {
394+
if ($this->isSandbox()) {
397395
$this->save('oscPayPalSandboxClientMerchantId', $merchantId);
398-
$logger->info(sprintf('Saving Sandbox Merchant ID %s from onboarding', $merchantId));
399-
}
400-
401-
if (!$isSandbox) {
396+
} else {
402397
$this->save('oscPayPalClientMerchantId', $merchantId);
403-
$logger->info(sprintf('Saving Live Merchant ID %s from onboarding', $merchantId));
404398
}
399+
400+
$logger = new PayPalLogger();
401+
$logger->debug(sprintf('Saving Merchant ID %s from onboarding', $merchantId));
405402
}
406403

407404
public function saveAcdcEligibility(bool $eligibility)

tests/Codeception/Acceptance/AdminOnboardingCest.php

-3
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,6 @@ public function testOnboardingSandboxMode(AcceptanceTester $I): void
9292
$I->waitForElement("//a[contains(@href, 'cl=oscpaypalonboarding')]", 20);
9393
$I->waitForElementClickable("//a[contains(@href, 'cl=oscpaypalonboarding')]");
9494
$href = $I->grabAttributeFrom("//a[contains(@href, 'cl=oscpaypalonboarding')]", 'href');
95-
$I->assertStringContainsString('returnFromSignup', $href);
96-
$I->amOnUrl($href);
97-
$I->see('You can now close the window');
9895

9996
//NOTE: in case of non ssl url, the webhook cannot be created, so webhook part depends on test environment
10097
//locally we will still see a note, that the module is inactive

0 commit comments

Comments
 (0)