@@ -108,6 +108,26 @@ public function index(): void {
108108 $ webhook_id = $ result ['id ' ];
109109 }
110110
111+ $ merchant_id = $ this ->request ->get ['merchantIdInPayPal ' ];
112+
113+ $ result = $ paypal ->getSellerStatus ($ config_setting ['partner ' ][$ environment ]['partner_id ' ], $ merchant_id );
114+
115+ $ fastlane_status = false ;
116+
117+ if (!empty ($ result ['capabilities ' ])) {
118+ foreach ($ result ['capabilities ' ] as $ capability ) {
119+ if (($ capability ['name ' ] == 'FASTLANE_CHECKOUT ' ) && ($ capability ['status ' ] == 'ACTIVE ' )) {
120+ $ fastlane_status = true ;
121+ }
122+ }
123+ }
124+
125+ $ country_code = '' ;
126+
127+ if (!empty ($ result ['country ' ])) {
128+ $ country_code = $ result ['country ' ];
129+ }
130+
111131 if ($ paypal ->hasErrors ()) {
112132 $ error_messages = [];
113133
@@ -129,9 +149,7 @@ public function index(): void {
129149
130150 $ this ->error ['warning ' ] = implode (' ' , $ error_messages );
131151 }
132-
133- $ merchant_id = $ this ->request ->get ['merchantIdInPayPal ' ];
134-
152+
135153 $ setting = $ this ->model_setting_setting ->getSetting ('payment_paypal ' );
136154
137155 $ setting ['payment_paypal_environment ' ] = $ environment ;
@@ -147,13 +165,18 @@ public function index(): void {
147165 $ setting ['payment_paypal_setting ' ]['general ' ]['callback_token ' ] = $ callback_token ;
148166 $ setting ['payment_paypal_setting ' ]['general ' ]['webhook_token ' ] = $ webhook_token ;
149167 $ setting ['payment_paypal_setting ' ]['general ' ]['cron_token ' ] = $ cron_token ;
150-
151- $ this ->load ->model ('localisation/country ' );
168+ $ setting ['payment_paypal_setting ' ]['fastlane ' ]['status ' ] = $ fastlane_status ;
169+
170+ if (!empty ($ country_code )) {
171+ $ setting ['payment_paypal_setting ' ]['general ' ]['country_code ' ] = $ country_code ;
172+ } else {
173+ $ this ->load ->model ('localisation/country ' );
152174
153- $ country = $ this ->model_localisation_country ->getCountry ($ this ->config ->get ('config_country_id ' ));
175+ $ country = $ this ->model_localisation_country ->getCountry ($ this ->config ->get ('config_country_id ' ));
154176
155- $ setting ['payment_paypal_setting ' ]['general ' ]['country_code ' ] = $ country ['iso_code_2 ' ];
156-
177+ $ setting ['payment_paypal_setting ' ]['general ' ]['country_code ' ] = $ country ['iso_code_2 ' ];
178+ }
179+
157180 $ currency_code = $ this ->config ->get ('config_currency ' );
158181 $ currency_value = $ this ->currency ->getValue ($ this ->config ->get ('config_currency ' ));
159182
@@ -1811,6 +1834,24 @@ public function connect(): void {
18111834 if (isset ($ result ['id ' ])) {
18121835 $ webhook_id = $ result ['id ' ];
18131836 }
1837+
1838+ $ result = $ paypal ->getSellerStatus ($ config_setting ['partner ' ][$ environment ]['partner_id ' ], $ merchant_id );
1839+
1840+ $ fastlane_status = false ;
1841+
1842+ if (!empty ($ result ['capabilities ' ])) {
1843+ foreach ($ result ['capabilities ' ] as $ capability ) {
1844+ if (($ capability ['name ' ] == 'FASTLANE_CHECKOUT ' ) && ($ capability ['status ' ] == 'ACTIVE ' )) {
1845+ $ fastlane_status = true ;
1846+ }
1847+ }
1848+ }
1849+
1850+ $ country_code = '' ;
1851+
1852+ if (!empty ($ result ['country ' ])) {
1853+ $ country_code = $ result ['country ' ];
1854+ }
18141855
18151856 if ($ paypal ->hasErrors ()) {
18161857 $ error_messages = [];
@@ -1852,13 +1893,18 @@ public function connect(): void {
18521893 $ setting ['payment_paypal_setting ' ]['general ' ]['callback_token ' ] = $ callback_token ;
18531894 $ setting ['payment_paypal_setting ' ]['general ' ]['webhook_token ' ] = $ webhook_token ;
18541895 $ setting ['payment_paypal_setting ' ]['general ' ]['cron_token ' ] = $ cron_token ;
1855-
1856- $ this ->load ->model ('localisation/country ' );
1896+ $ setting ['payment_paypal_setting ' ]['fastlane ' ]['status ' ] = $ fastlane_status ;
1897+
1898+ if (!empty ($ country_code )) {
1899+ $ setting ['payment_paypal_setting ' ]['general ' ]['country_code ' ] = $ country_code ;
1900+ } else {
1901+ $ this ->load ->model ('localisation/country ' );
18571902
1858- $ country = $ this ->model_localisation_country ->getCountry ($ this ->config ->get ('config_country_id ' ));
1903+ $ country = $ this ->model_localisation_country ->getCountry ($ this ->config ->get ('config_country_id ' ));
18591904
1860- $ setting ['payment_paypal_setting ' ]['general ' ]['country_code ' ] = $ country ['iso_code_2 ' ];
1861-
1905+ $ setting ['payment_paypal_setting ' ]['general ' ]['country_code ' ] = $ country ['iso_code_2 ' ];
1906+ }
1907+
18621908 $ currency_code = $ this ->config ->get ('config_currency ' );
18631909 $ currency_value = $ this ->currency ->getValue ($ this ->config ->get ('config_currency ' ));
18641910
0 commit comments