Merge pull request #793 from woocommerce/PCP-155-tracking-api

Tracking API
This commit is contained in:
Emili Castells 2022-08-19 09:30:57 +02:00 committed by GitHub
commit 8d6ce555fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 3994 additions and 12 deletions

View file

@ -140,4 +140,24 @@ class Token {
}
return true;
}
/**
* Checks if tracking is available in access token scope.
*
* @return bool Whether tracking features are enabled or not.
*/
public function is_tracking_available(): bool {
if ( ! isset( $this->json->scope ) ) {
return false;
}
if ( strpos(
$this->json->scope,
'https://uri.paypal.com/services/shipping/trackers/readwrite'
) !== false ) {
return true;
}
return false;
}
}

View file

@ -0,0 +1,2 @@
node_modules
/assets

View file

@ -0,0 +1,612 @@
<?php
/**
* The order tracking carriers.
*
* @package WooCommerce\PayPalCommerce\OrderTracking
*/
declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\OrderTracking;
use Psr\Container\ContainerInterface;
return array(
'global' => array(
'name' => 'Global',
'items' => array(
'B_TWO_C_EUROPE' => _x( 'B2C Europe', 'Name of carrier', 'woocommerce-paypal-payments' ),
'CJ_LOGISTICS' => _x( 'CJ Logistics', 'Name of carrier', 'woocommerce-paypal-payments' ),
'CORREOS_EXPRESS' => _x( 'Correos Express', 'Name of carrier', 'woocommerce-paypal-payments' ),
'DHL_ACTIVE_TRACING' => _x( 'DHL Active Tracing', 'Name of carrier', 'woocommerce-paypal-payments' ),
'DHL_BENELUX' => _x( 'DHL Benelux', 'Name of carrier', 'woocommerce-paypal-payments' ),
'DHL_GLOBAL_MAIL' => _x( 'DHL ecCommerce US', 'Name of carrier', 'woocommerce-paypal-payments' ),
'DHL_GLOBAL_MAIL_ASIA' => _x( 'DHL eCommerce Asia', 'Name of carrier', 'woocommerce-paypal-payments' ),
'DHL' => _x( 'DHL Express', 'Name of carrier', 'woocommerce-paypal-payments' ),
'DHL_GLOBAL_ECOMMERCE' => _x( 'DHL Global eCommerce', 'Name of carrier', 'woocommerce-paypal-payments' ),
'DHL_PACKET' => _x( 'DHL Packet', 'Name of carrier', 'woocommerce-paypal-payments' ),
'DPD' => _x( 'DPD Global', 'Name of carrier', 'woocommerce-paypal-payments' ),
'DPD_LOCAL' => _x( 'DPD Local', 'Name of carrier', 'woocommerce-paypal-payments' ),
'DPD_LOCAL_REF' => _x( 'DPD Local Reference', 'Name of carrier', 'woocommerce-paypal-payments' ),
'DPE_EXPRESS' => _x( 'DPE Express', 'Name of carrier', 'woocommerce-paypal-payments' ),
'DPEX' => _x( 'DPEX Hong Kong', 'Name of carrier', 'woocommerce-paypal-payments' ),
'DTDC_EXPRESS' => _x( 'DTDC Express Global', 'Name of carrier', 'woocommerce-paypal-payments' ),
'ESHOPWORLD' => _x( 'EShopWorld', 'Name of carrier', 'woocommerce-paypal-payments' ),
'FEDEX' => _x( 'FedEx', 'Name of carrier', 'woocommerce-paypal-payments' ),
'FLYT_EXPRESS' => _x( 'FLYT Express', 'Name of carrier', 'woocommerce-paypal-payments' ),
'GLS' => _x( 'GLS', 'Name of carrier', 'woocommerce-paypal-payments' ),
'IMX' => _x( 'IMX France', 'Name of carrier', 'woocommerce-paypal-payments' ),
'INT_SUER' => _x( 'International SEUR', 'Name of carrier', 'woocommerce-paypal-payments' ),
'LANDMARK_GLOBAL' => _x( 'Landmark Global', 'Name of carrier', 'woocommerce-paypal-payments' ),
'MATKAHUOLTO' => _x( 'Matkahuoloto', 'Name of carrier', 'woocommerce-paypal-payments' ),
'OMNIPARCEL' => _x( 'Omni Parcel', 'Name of carrier', 'woocommerce-paypal-payments' ),
'ONE_WORLD' => _x( 'One World', 'Name of carrier', 'woocommerce-paypal-payments' ),
'POSTI' => _x( 'Posti', 'Name of carrier', 'woocommerce-paypal-payments' ),
'RABEN_GROUP' => _x( 'Raben Group', 'Name of carrier', 'woocommerce-paypal-payments' ),
'SF_EXPRESS' => _x( 'SF EXPRESS', 'Name of carrier', 'woocommerce-paypal-payments' ),
'SKYNET_Worldwide' => _x( 'SkyNet Worldwide Express', 'Name of carrier', 'woocommerce-paypal-payments' ),
'SPREADEL' => _x( 'Spreadel', 'Name of carrier', 'woocommerce-paypal-payments' ),
'TNT' => _x( 'TNT Global', 'Name of carrier', 'woocommerce-paypal-payments' ),
'UPS' => _x( 'UPS', 'Name of carrier', 'woocommerce-paypal-payments' ),
'UPS_MI' => _x( 'UPS Mail Innovations', 'Name of carrier', 'woocommerce-paypal-payments' ),
'WEBINTERPRET' => _x( 'WebInterpret', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'AG' => array(
'name' => _x( 'Antigua and Barbuda', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'CORREOS_AG' => _x( 'Correos Antigua and Barbuda', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'AR' => array(
'name' => _x( 'Argentina', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'EMIRATES_POST' => _x( 'Emirates Post', 'Name of carrier', 'woocommerce-paypal-payments' ),
'OCA_AR ' => _x( 'OCA Argentina', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'AU' => array(
'name' => _x( 'Australia', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'ADSONE' => _x( 'Adsone', 'Name of carrier', 'woocommerce-paypal-payments' ),
'AUSTRALIA_POST' => _x( 'Australia Post', 'Name of carrier', 'woocommerce-paypal-payments' ),
'TOLL_AU' => _x( 'Australia Toll', 'Name of carrier', 'woocommerce-paypal-payments' ),
'BONDS_COURIERS' => _x( 'Bonds Couriers', 'Name of carrier', 'woocommerce-paypal-payments' ),
'COURIERS_PLEASE' => _x( 'Couriers Please', 'Name of carrier', 'woocommerce-paypal-payments' ),
'DHL_AU' => _x( 'DHL Australia', 'Name of carrier', 'woocommerce-paypal-payments' ),
'DTDC_AU' => _x( 'DTDC Australia', 'Name of carrier', 'woocommerce-paypal-payments' ),
'FASTWAY_AU' => _x( 'Fastway Australia', 'Name of carrier', 'woocommerce-paypal-payments' ),
'HUNTER_EXPRESS ' => _x( 'Hunter Express', 'Name of carrier', 'woocommerce-paypal-payments' ),
'SENDLE' => _x( 'Sendle', 'Name of carrier', 'woocommerce-paypal-payments' ),
'STARTRACK' => _x( 'Star Track', 'Name of carrier', 'woocommerce-paypal-payments' ),
'STARTRACK_EXPRESS' => _x( 'Star Track Express', 'Name of carrier', 'woocommerce-paypal-payments' ),
'TNT_AU ' => _x( 'TNT Australia', 'Name of carrier', 'woocommerce-paypal-payments' ),
'TOLL' => _x( 'Toll', 'Name of carrier', 'woocommerce-paypal-payments' ),
'UBI_LOGISTICS' => _x( 'UBI Logistics', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'AT' => array(
'name' => _x( 'Austria', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'AUSTRIAN_POST_EXPRESS' => _x( 'Austrian Post Express', 'Name of carrier', 'woocommerce-paypal-payments' ),
'AUSTRIAN_POST' => _x( 'Austrian Post Registered', 'Name of carrier', 'woocommerce-paypal-payments' ),
'DHL_AT' => _x( 'DHL Austria', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'BE' => array(
'name' => _x( 'Belgium', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'BPOST' => _x( 'bpost', 'Name of carrier', 'woocommerce-paypal-payments' ),
'BPOST_INT' => _x( 'bpost International', 'Name of carrier', 'woocommerce-paypal-payments' ),
'MONDIAL_BE' => _x( 'Mondial Belgium', 'Name of carrier', 'woocommerce-paypal-payments' ),
'TAXIPOST' => _x( 'TaxiPost', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'BR' => array(
'name' => _x( 'Brazil', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'CORREOS_BR' => _x( 'Correos Brazil', 'Name of carrier', 'woocommerce-paypal-payments' ),
'DIRECTLOG_BR' => _x( 'Directlog', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'BG' => array(
'name' => _x( 'Bulgaria', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'BULGARIAN_POST' => _x( 'Bulgarian Post', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'CA' => array(
'name' => _x( 'Canada', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'CANADA_POST' => _x( 'Canada Post', 'Name of carrier', 'woocommerce-paypal-payments' ),
'CANPAR' => _x( 'Canpar', 'Name of carrier', 'woocommerce-paypal-payments' ),
'GREYHOUND' => _x( 'Greyhound', 'Name of carrier', 'woocommerce-paypal-payments' ),
'LOOMIS' => _x( 'Loomis', 'Name of carrier', 'woocommerce-paypal-payments' ),
'PUROLATOR' => _x( 'Purolator', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'CL' => array(
'name' => _x( 'Chile', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'CORREOS_CL' => _x( 'Correos Chile', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'CN' => array(
'name' => _x( 'China', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'FOUR_PX_EXPRESS' => _x( 'Correos', 'Name of carrier', 'woocommerce-paypal-payments' ),
'AUPOST_CN' => _x( 'AUPOST CHINA', 'Name of carrier', 'woocommerce-paypal-payments' ),
'BQC_EXPRESS' => _x( 'BQC Express', 'Name of carrier', 'woocommerce-paypal-payments' ),
'BUYLOGIC' => _x( 'Buylogic', 'Name of carrier', 'woocommerce-paypal-payments' ),
'CHINA_POST' => _x( 'China Post', 'Name of carrier', 'woocommerce-paypal-payments' ),
'CNEXPS' => _x( 'CN Exps', 'Name of carrier', 'woocommerce-paypal-payments' ),
'EC_CN' => _x( 'EC China', 'Name of carrier', 'woocommerce-paypal-payments' ),
'EFS' => _x( 'EFS', 'Name of carrier', 'woocommerce-paypal-payments' ),
'EMPS_CN' => _x( 'EMPS China', 'Name of carrier', 'woocommerce-paypal-payments' ),
'EMS_CN' => _x( 'EMS China', 'Name of carrier', 'woocommerce-paypal-payments' ),
'HUAHAN_EXPRESS' => _x( 'Huahan Express', 'Name of carrier', 'woocommerce-paypal-payments' ),
'SFC_EXPRESS' => _x( 'SFC Express', 'Name of carrier', 'woocommerce-paypal-payments' ),
'TNT_CN' => _x( 'TNT China', 'Name of carrier', 'woocommerce-paypal-payments' ),
'WINIT' => _x( 'WinIt', 'Name of carrier', 'woocommerce-paypal-payments' ),
'YANWEN_CN' => _x( 'Yanwen', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'CR' => array(
'name' => _x( 'Costa Rica', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'CORREOS_CR' => _x( 'Correos De Costa Rica', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'HR' => array(
'name' => _x( 'Croatia', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'HRVATSKA_HR' => _x( 'Hrvatska', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'CY' => array(
'name' => _x( 'Cyprus', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'CYPRUS_POST_CYP' => _x( 'Cyprus Post', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'CZ' => array(
'name' => _x( 'Czech Republic', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'CESKA_CZ' => _x( 'Ceska', 'Name of carrier', 'woocommerce-paypal-payments' ),
'GLS_CZ' => _x( 'GLS Czech Republic', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'FR' => array(
'name' => _x( 'France', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'BERT' => _x( 'BERT TRANSPORT', 'Name of carrier', 'woocommerce-paypal-payments' ),
'CHRONOPOST_FR' => _x( 'Chronopost France', 'Name of carrier', 'woocommerce-paypal-payments' ),
'COLIPOSTE' => _x( 'Coliposte', 'Name of carrier', 'woocommerce-paypal-payments' ),
'COLIS' => _x( 'Colis France', 'Name of carrier', 'woocommerce-paypal-payments' ),
'DHL_FR' => _x( 'DHL France', 'Name of carrier', 'woocommerce-paypal-payments' ),
'DPD_FR' => _x( 'DPD France', 'Name of carrier', 'woocommerce-paypal-payments' ),
'GEODIS' => _x( 'GEODIS - Distribution & Express', 'Name of carrier', 'woocommerce-paypal-payments' ),
'GLS_FR' => _x( 'GLS France', 'Name of carrier', 'woocommerce-paypal-payments' ),
'LAPOSTE' => _x( 'LA Poste', 'Name of carrier', 'woocommerce-paypal-payments' ),
'MONDIAL' => _x( 'Mondial Relay', 'Name of carrier', 'woocommerce-paypal-payments' ),
'RELAIS_COLIS_FR' => _x( 'Relais Colis', 'Name of carrier', 'woocommerce-paypal-payments' ),
'TELIWAY' => _x( 'Teliway', 'Name of carrier', 'woocommerce-paypal-payments' ),
'TNT_FR' => _x( 'TNT France', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'DE' => array(
'name' => _x( 'Germany', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'ASENDIA_DE' => _x( 'Asendia Germany', 'Name of carrier', 'woocommerce-paypal-payments' ),
'DELTEC_DE' => _x( 'Deltec Germany', 'Name of carrier', 'woocommerce-paypal-payments' ),
'DEUTSCHE_DE' => _x( 'Deutsche', 'Name of carrier', 'woocommerce-paypal-payments' ),
'DHL_DEUTSCHE_POST' => _x( 'DHL Deutsche Post', 'Name of carrier', 'woocommerce-paypal-payments' ),
'DPD_DE' => _x( 'DPD Germany', 'Name of carrier', 'woocommerce-paypal-payments' ),
'GLS_DE' => _x( 'GLS Germany', 'Name of carrier', 'woocommerce-paypal-payments' ),
'HERMES_DE' => _x( 'Hermes Germany', 'Name of carrier', 'woocommerce-paypal-payments' ),
'TNT_DE' => _x( 'TNT Germany', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'GR' => array(
'name' => _x( 'Greece', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'ELTA_GR' => _x( 'ELTA Greece', 'Name of carrier', 'woocommerce-paypal-payments' ),
'GENIKI_GR' => _x( 'Geniki Greece', 'Name of carrier', 'woocommerce-paypal-payments' ),
'ACS_GR' => _x( 'GRC Greece', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'HK' => array(
'name' => _x( 'Hong Kong', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'ASENDIA_HK' => _x( 'Asendia Hong Kong', 'Name of carrier', 'woocommerce-paypal-payments' ),
'DHL_HK' => _x( 'DHL Hong Kong', 'Name of carrier', 'woocommerce-paypal-payments' ),
'DPD_HK' => _x( 'DPD Hong Kong', 'Name of carrier', 'woocommerce-paypal-payments' ),
'HK_POST' => _x( 'Hong Kong Post', 'Name of carrier', 'woocommerce-paypal-payments' ),
'KERRY_EXPRESS_HK' => _x( 'Kerry Express Hong Kong', 'Name of carrier', 'woocommerce-paypal-payments' ),
'LOGISTICSWORLDWIDE_HK' => _x( 'Logistics Worldwide Hong Kong', 'Name of carrier', 'woocommerce-paypal-payments' ),
'QUANTIUM' => _x( 'Quantium', 'Name of carrier', 'woocommerce-paypal-payments' ),
'SEKOLOGISTICS' => _x( 'Seko Logistics', 'Name of carrier', 'woocommerce-paypal-payments' ),
'TAQBIN_HK' => _x( 'TA-Q-BIN Parcel Hong Kong', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'HU' => array(
'name' => _x( 'Hungary', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'MAGYAR_HU' => _x( 'Magyar', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'IS' => array(
'name' => _x( 'Iceland', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'POSTUR_IS' => _x( 'Postur', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'IN' => array(
'name' => _x( 'India', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'BLUEDART' => _x( 'Bluedart', 'Name of carrier', 'woocommerce-paypal-payments' ),
'DELHIVERY_IN' => _x( 'Delhivery', 'Name of carrier', 'woocommerce-paypal-payments' ),
'DOTZOT' => _x( 'DotZot', 'Name of carrier', 'woocommerce-paypal-payments' ),
'DTDC_IN' => _x( 'DTDC India', 'Name of carrier', 'woocommerce-paypal-payments' ),
'EKART' => _x( 'Ekart', 'Name of carrier', 'woocommerce-paypal-payments' ),
'INDIA_POST' => _x( 'India Post', 'Name of carrier', 'woocommerce-paypal-payments' ),
'PROFESSIONAL_COURIERS' => _x( 'Professional Couriers', 'Name of carrier', 'woocommerce-paypal-payments' ),
'REDEXPRESS' => _x( 'Red Express', 'Name of carrier', 'woocommerce-paypal-payments' ),
'SWIFTAIR' => _x( 'Swift Air', 'Name of carrier', 'woocommerce-paypal-payments' ),
'XPRESSBEES' => _x( 'Xpress Bees', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'ID' => array(
'name' => _x( 'Indonesia', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'FIRST_LOGISITCS' => _x( 'First Logistics', 'Name of carrier', 'woocommerce-paypal-payments' ),
'JNE_IDN' => _x( 'JNE Indonesia', 'Name of carrier', 'woocommerce-paypal-payments' ),
'LION_PARCEL' => _x( 'Lion Parcel', 'Name of carrier', 'woocommerce-paypal-payments' ),
'NINJAVAN_ID' => _x( 'Ninjavan Indonesia', 'Name of carrier', 'woocommerce-paypal-payments' ),
'PANDU' => _x( 'Pandu Logistics', 'Name of carrier', 'woocommerce-paypal-payments' ),
'POS_ID' => _x( 'Pos Indonesia Domestic', 'Name of carrier', 'woocommerce-paypal-payments' ),
'POS_INT' => _x( 'Pos Indonesia International', 'Name of carrier', 'woocommerce-paypal-payments' ),
'RPX_ID' => _x( 'RPX Indonesia', 'Name of carrier', 'woocommerce-paypal-payments' ),
'RPX' => _x( 'RPX International', 'Name of carrier', 'woocommerce-paypal-payments' ),
'TIKI_ID' => _x( 'Tiki', 'Name of carrier', 'woocommerce-paypal-payments' ),
'WAHANA_ID' => _x( 'Wahana', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'IE' => array(
'name' => _x( 'Ireland', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'AN_POST' => _x( 'AN POST Ireland', 'Name of carrier', 'woocommerce-paypal-payments' ),
'DPD_IR' => _x( 'DPD Ireland', 'Name of carrier', 'woocommerce-paypal-payments' ),
'MASTERLINK' => _x( 'Masterlink', 'Name of carrier', 'woocommerce-paypal-payments' ),
'TPG' => _x( 'TPG', 'Name of carrier', 'woocommerce-paypal-payments' ),
'WISELOADS' => _x( 'Wiseloads', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'IL' => array(
'name' => _x( 'Israel', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'ISRAEL_POST' => _x( 'Israel Post', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'IT' => array(
'name' => _x( 'Italy', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'BRT_IT' => _x( 'BRT Bartolini', 'Name of carrier', 'woocommerce-paypal-payments' ),
'DHL_IT' => _x( 'DHL Italy', 'Name of carrier', 'woocommerce-paypal-payments' ),
'DMM_NETWORK' => _x( 'DMM Network', 'Name of carrier', 'woocommerce-paypal-payments' ),
'FERCAM_IT' => _x( 'FERCAM Logistics & Transport', 'Name of carrier', 'woocommerce-paypal-payments' ),
'GLS_IT' => _x( 'GLS Italy', 'Name of carrier', 'woocommerce-paypal-payments' ),
'HERMES_IT' => _x( 'Hermes Italy', 'Name of carrier', 'woocommerce-paypal-payments' ),
'POSTE_ITALIANE' => _x( 'Poste Italiane', 'Name of carrier', 'woocommerce-paypal-payments' ),
'REGISTER_MAIL_IT' => _x( 'Register Mail IT', 'Name of carrier', 'woocommerce-paypal-payments' ),
'SDA_IT' => _x( 'SDA Italy', 'Name of carrier', 'woocommerce-paypal-payments' ),
'SGT_IT' => _x( 'SGT Corriere Espresso', 'Name of carrier', 'woocommerce-paypal-payments' ),
'TNT_CLICK_IT' => _x( 'TNT Click Italy', 'Name of carrier', 'woocommerce-paypal-payments' ),
'TNT_IT' => _x( 'TNT Italy', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'JP' => array(
'name' => _x( 'Japan', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'DHL_JP' => _x( 'DHL Japan', 'Name of carrier', 'woocommerce-paypal-payments' ),
'JP_POST' => _x( 'JP Post', 'Name of carrier', 'woocommerce-paypal-payments' ),
'JAPAN_POST' => _x( 'Japan Post', 'Name of carrier', 'woocommerce-paypal-payments' ),
'POCZTEX' => _x( 'Pocztex', 'Name of carrier', 'woocommerce-paypal-payments' ),
'SAGAWA' => _x( 'Sagawa', 'Name of carrier', 'woocommerce-paypal-payments' ),
'SAGAWA_JP' => _x( 'Sagawa JP', 'Name of carrier', 'woocommerce-paypal-payments' ),
'TNT_JP' => _x( 'TNT Japan', 'Name of carrier', 'woocommerce-paypal-payments' ),
'YAMATO' => _x( 'Yamato Japan', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'KR' => array(
'name' => _x( 'Korea', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'ECARGO' => _x( 'Ecargo', 'Name of carrier', 'woocommerce-paypal-payments' ),
'EPARCEL_KR' => _x( 'eParcel Korea', 'Name of carrier', 'woocommerce-paypal-payments' ),
'KOREA_POST' => _x( 'Korea Post', 'Name of carrier', 'woocommerce-paypal-payments' ),
'KOR_KOREA_POST' => _x( 'KOR Korea Post', 'Name of carrier', 'woocommerce-paypal-payments' ),
'CJ_KR' => _x( 'Korea Thai CJ', 'Name of carrier', 'woocommerce-paypal-payments' ),
'LOGISTICSWORLDWIDE_KR' => _x( 'Logistics Worldwide Korea', 'Name of carrier', 'woocommerce-paypal-payments' ),
'PANTOS' => _x( 'Pantos', 'Name of carrier', 'woocommerce-paypal-payments' ),
'RINCOS' => _x( 'Rincos', 'Name of carrier', 'woocommerce-paypal-payments' ),
'ROCKET_PARCEL' => _x( 'Rocket Parcel International', 'Name of carrier', 'woocommerce-paypal-payments' ),
'SRE_KOREA' => _x( 'SRE Korea', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'LT' => array(
'name' => _x( 'Lithuania', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'LIETUVOS_LT' => _x( 'Lietuvos Pastas', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'MY' => array(
'name' => _x( 'Malaysia', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'AIRPAK_MY' => _x( 'Airpak', 'Name of carrier', 'woocommerce-paypal-payments' ),
'CITYLINK_MY' => _x( 'CityLink Malaysia', 'Name of carrier', 'woocommerce-paypal-payments' ),
'CJ_MY' => _x( 'CJ Malaysia', 'Name of carrier', 'woocommerce-paypal-payments' ),
'CJ_INT_MY' => _x( 'CJ Malaysia International', 'Name of carrier', 'woocommerce-paypal-payments' ),
'CUCKOOEXPRESS' => _x( 'Cuckoo Express', 'Name of carrier', 'woocommerce-paypal-payments' ),
'JETSHIP_MY' => _x( 'Jet Ship Malaysia', 'Name of carrier', 'woocommerce-paypal-payments' ),
'KANGAROO_MY' => _x( 'Kangaroo Express', 'Name of carrier', 'woocommerce-paypal-payments' ),
'LOGISTICSWORLDWIDE_MY' => _x( 'Logistics Worldwide Malaysia', 'Name of carrier', 'woocommerce-paypal-payments' ),
'MALAYSIA_POST' => _x( 'Malaysia Post EMS / Pos Laju', 'Name of carrier', 'woocommerce-paypal-payments' ),
'NATIONWIDE' => _x( 'Nationwide', 'Name of carrier', 'woocommerce-paypal-payments' ),
'NINJAVAN_MY' => _x( 'Ninjavan Malaysia', 'Name of carrier', 'woocommerce-paypal-payments' ),
'SKYNET_MY' => _x( 'Skynet Malaysia', 'Name of carrier', 'woocommerce-paypal-payments' ),
'TAQBIN_MY' => _x( 'TA-Q-BIN Parcel Malaysia', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'MX' => array(
'name' => _x( 'Mexico', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'CORREOS_MX' => _x( 'Correos De Mexico', 'Name of carrier', 'woocommerce-paypal-payments' ),
'ESTAFETA' => _x( 'Estafeta', 'Name of carrier', 'woocommerce-paypal-payments' ),
'AEROFLASH' => _x( 'Mexico Aeroflash', 'Name of carrier', 'woocommerce-paypal-payments' ),
'REDPACK' => _x( 'Mexico Redpack', 'Name of carrier', 'woocommerce-paypal-payments' ),
'SENDA_MX' => _x( 'Mexico Senda Express', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'NL' => array(
'name' => _x( 'Netherlands', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'DHL_NL' => _x( 'DHL Netherlands', 'Name of carrier', 'woocommerce-paypal-payments' ),
'DHL_PARCEL_NL' => _x( 'DHL Parcel Netherlands', 'Name of carrier', 'woocommerce-paypal-payments' ),
'GLS_NL' => _x( 'GLS Netherlands', 'Name of carrier', 'woocommerce-paypal-payments' ),
'KIALA' => _x( 'Kiala', 'Name of carrier', 'woocommerce-paypal-payments' ),
'POSTNL' => _x( 'PostNL', 'Name of carrier', 'woocommerce-paypal-payments' ),
'POSTNL_INT' => _x( 'PostNl International', 'Name of carrier', 'woocommerce-paypal-payments' ),
'POSTNL_INT_3_S' => _x( 'PostNL International 3S', 'Name of carrier', 'woocommerce-paypal-payments' ),
'TNT_NL' => _x( 'TNT Netherlands', 'Name of carrier', 'woocommerce-paypal-payments' ),
'TRANSMISSION' => _x( 'Transmission Netherlands', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'NZ' => array(
'name' => _x( 'New Zealand', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'COURIER_POST' => _x( 'Courier Post', 'Name of carrier', 'woocommerce-paypal-payments' ),
'FASTWAY_NZ' => _x( 'Fastway New Zealand', 'Name of carrier', 'woocommerce-paypal-payments' ),
'NZ_POST' => _x( 'New Zealand Post', 'Name of carrier', 'woocommerce-paypal-payments' ),
'TOLL_IPEC' => _x( 'Toll IPEC', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'NG' => array(
'name' => _x( 'Nigeria', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'COURIERPLUS' => _x( 'Courier Plus', 'Name of carrier', 'woocommerce-paypal-payments' ),
'NIPOST_NG' => _x( 'NiPost', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'NO' => array(
'name' => _x( 'Norway', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'POSTEN_NORGE' => _x( 'Posten Norge', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'PH' => array(
'name' => _x( 'Philippines', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'TWO_GO' => _x( '2GO', 'Name of carrier', 'woocommerce-paypal-payments' ),
'AIR_21' => _x( 'Air 21', 'Name of carrier', 'woocommerce-paypal-payments' ),
'AIRSPEED' => _x( 'Airspeed', 'Name of carrier', 'woocommerce-paypal-payments' ),
'JAMEXPRESS_PH' => _x( 'Jam Express', 'Name of carrier', 'woocommerce-paypal-payments' ),
'LBC_PH' => _x( 'LBC Express', 'Name of carrier', 'woocommerce-paypal-payments' ),
'NINJAVAN_PH' => _x( 'Ninjavan Philippines', 'Name of carrier', 'woocommerce-paypal-payments' ),
'RAF_PH' => _x( 'RAF Philippines', 'Name of carrier', 'woocommerce-paypal-payments' ),
'XEND_EXPRESS_PH' => _x( 'Xend Express', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'PL' => array(
'name' => _x( 'Poland', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'DHL_PL' => _x( 'DHL Poland', 'Name of carrier', 'woocommerce-paypal-payments' ),
'DPD_PL' => _x( 'DPD Poland', 'Name of carrier', 'woocommerce-paypal-payments' ),
'INPOST_PACZKOMATY' => _x( 'InPost Paczkomaty', 'Name of carrier', 'woocommerce-paypal-payments' ),
'POCZTA_POLSKA' => _x( 'Poczta Polska', 'Name of carrier', 'woocommerce-paypal-payments' ),
'SIODEMKA' => _x( 'Siodemka', 'Name of carrier', 'woocommerce-paypal-payments' ),
'TNT_PL' => _x( 'TNT Poland', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'PT' => array(
'name' => _x( 'Portugal', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'ADICIONAL_PT' => _x( 'Adicional Logistics', 'Name of carrier', 'woocommerce-paypal-payments' ),
'CHRONOPOST_PT' => _x( 'Chronopost Portugal', 'Name of carrier', 'woocommerce-paypal-payments' ),
'CTT_PT' => _x( 'Portugal PTT', 'Name of carrier', 'woocommerce-paypal-payments' ),
'SEUR_PT' => _x( 'Portugal Seur', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'RO' => array(
'name' => _x( 'Romania', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'DPD_RO' => _x( 'DPD Romania', 'Name of carrier', 'woocommerce-paypal-payments' ),
'POSTA_RO' => _x( 'Postaromana', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'RU' => array(
'name' => _x( 'Russia', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'DPD_RU' => _x( 'DPD Russia', 'Name of carrier', 'woocommerce-paypal-payments' ),
'RUSSIAN_POST' => _x( 'Russian Post', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'SA' => array(
'name' => _x( 'Saudi Arabia', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'DAWN_WING' => _x( 'Dawn Wing', 'Name of carrier', 'woocommerce-paypal-payments' ),
'RAM' => _x( 'Ram', 'Name of carrier', 'woocommerce-paypal-payments' ),
'THE_COURIER_GUY' => _x( 'The Courier Guy', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'CS' => array(
'name' => _x( 'Serbia', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'POST_SERBIA_CS' => _x( 'Serbia Post', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'SG' => array(
'name' => _x( 'Singapore', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'DHL_SG' => _x( 'DHL Singapore', 'Name of carrier', 'woocommerce-paypal-payments' ),
'JETSHIP_SG' => _x( 'JetShip Singapore', 'Name of carrier', 'woocommerce-paypal-payments' ),
'NINJAVAN_SG' => _x( 'Ninjavan Singapore', 'Name of carrier', 'woocommerce-paypal-payments' ),
'PARCELPOST_SG' => _x( 'Parcel Post', 'Name of carrier', 'woocommerce-paypal-payments' ),
'SINGPOST' => _x( 'Singapore Post', 'Name of carrier', 'woocommerce-paypal-payments' ),
'TAQBIN_SG' => _x( 'TA-Q-BIN Parcel Singapore', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'ZA' => array(
'name' => _x( 'South Africa', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'FASTWAY_ZA' => _x( 'Fastway South Africa', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'ES' => array(
'name' => _x( 'Spain', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'ASM_ES' => _x( 'ASM', 'Name of carrier', 'woocommerce-paypal-payments' ),
'CBL_LOGISTICA' => _x( 'CBL Logistics', 'Name of carrier', 'woocommerce-paypal-payments' ),
'CORREOS_ES' => _x( 'Correos De Spain', 'Name of carrier', 'woocommerce-paypal-payments' ),
'DHL_ES ' => _x( 'DHL Spain', 'Name of carrier', 'woocommerce-paypal-payments' ),
'DHL_PARCEL_ES' => _x( 'DHL Parcel Spain', 'Name of carrier', 'woocommerce-paypal-payments' ),
'GLS_ES' => _x( 'GLS Spain', 'Name of carrier', 'woocommerce-paypal-payments' ),
'INT_SEUR' => _x( 'International Suer', 'Name of carrier', 'woocommerce-paypal-payments' ),
'ITIS' => _x( 'ITIS', 'Name of carrier', 'woocommerce-paypal-payments' ),
'NACEX_ES' => _x( 'Nacex Spain', 'Name of carrier', 'woocommerce-paypal-payments' ),
'REDUR_ES' => _x( 'Redur Spain', 'Name of carrier', 'woocommerce-paypal-payments' ),
'SEUR_ES' => _x( 'Spanish Seur', 'Name of carrier', 'woocommerce-paypal-payments' ),
'TNT_ES' => _x( 'TNT Spain', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'SE' => array(
'name' => _x( 'Sweden', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'DBSCHENKER_SE' => _x( 'DB Schenker Sweden', 'Name of carrier', 'woocommerce-paypal-payments' ),
'DIRECTLINK_SE' => _x( 'DirectLink Sweden', 'Name of carrier', 'woocommerce-paypal-payments' ),
'POSTNORD_LOGISTICS_GLOBAL' => _x( 'PostNord Logistics', 'Name of carrier', 'woocommerce-paypal-payments' ),
'POSTNORD_LOGISTICS_DK' => _x( 'PostNord Logistics Denmark', 'Name of carrier', 'woocommerce-paypal-payments' ),
'POSTNORD_LOGISTICS_SE' => _x( 'PostNord Logistics Sweden', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'CH' => array(
'name' => _x( 'Switzerland', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'SWISS_POST' => _x( 'Swiss Post', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'TW' => array(
'name' => _x( 'Taiwan', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'CHUNGHWA_POST' => _x( 'Chunghwa Post', 'Name of carrier', 'woocommerce-paypal-payments' ),
'TAIWAN_POST_TW' => _x( 'Taiwan Post', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'TH' => array(
'name' => _x( 'Thailand', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'ACOMMMERCE' => _x( 'Acommerce', 'Name of carrier', 'woocommerce-paypal-payments' ),
'ALPHAFAST' => _x( 'Alphafast', 'Name of carrier', 'woocommerce-paypal-payments' ),
'CJ_TH' => _x( 'CJ Thailand', 'Name of carrier', 'woocommerce-paypal-payments' ),
'FASTRACK' => _x( 'FastTrack Thailand', 'Name of carrier', 'woocommerce-paypal-payments' ),
'KERRY_EXPRESS_TH' => _x( 'Kerry Express Thailand', 'Name of carrier', 'woocommerce-paypal-payments' ),
'NIM_EXPRESS' => _x( 'NIM Express', 'Name of carrier', 'woocommerce-paypal-payments' ),
'NINJAVAN_THAI' => _x( 'Ninjavan Thailand', 'Name of carrier', 'woocommerce-paypal-payments' ),
'SENDIT' => _x( 'SendIt', 'Name of carrier', 'woocommerce-paypal-payments' ),
'THAILAND_POST' => _x( 'Thailand Post', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'TR' => array(
'name' => _x( 'Turkey', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'PTT_POST' => _x( 'PTT Posta', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'UA' => array(
'name' => _x( 'Ukraine', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'NOVA_POSHTA' => _x( 'Nova Poshta', 'Name of carrier', 'woocommerce-paypal-payments' ),
'NOVA_POSHTA_INT' => _x( 'Nova Poshta International', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'AE' => array(
'name' => _x( 'United Arab Emirates', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'AXL' => _x( 'AXL Express & Logistics', 'Name of carrier', 'woocommerce-paypal-payments' ),
'CONTINENTAL' => _x( 'Continental', 'Name of carrier', 'woocommerce-paypal-payments' ),
'SKYNET_UAE' => _x( 'Skynet Worldwide Express UAE', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'GB' => array(
'name' => _x( 'United Kingdom', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'AIRBORNE_EXPRESS_UK' => _x( 'Airborne Express UK', 'Name of carrier', 'woocommerce-paypal-payments' ),
'AIRSURE' => _x( 'Airsure', 'Name of carrier', 'woocommerce-paypal-payments' ),
'APC_OVERNIGHT' => _x( 'APC Overnight', 'Name of carrier', 'woocommerce-paypal-payments' ),
'ASENDIA_UK' => _x( 'Asendia UK', 'Name of carrier', 'woocommerce-paypal-payments' ),
'COLLECTPLUS' => _x( 'CollectPlus', 'Name of carrier', 'woocommerce-paypal-payments' ),
'DELTEC_UK' => _x( 'Deltec UK', 'Name of carrier', 'woocommerce-paypal-payments' ),
'DHL_UK' => _x( 'DHL UK', 'Name of carrier', 'woocommerce-paypal-payments' ),
'DPD_DELISTRACK' => _x( 'DPD Delistrack', 'Name of carrier', 'woocommerce-paypal-payments' ),
'DPD_UK' => _x( 'DPD UK', 'Name of carrier', 'woocommerce-paypal-payments' ),
'FASTWAY_UK' => _x( 'Fastway UK', 'Name of carrier', 'woocommerce-paypal-payments' ),
'HERMESWORLD_UK' => _x( 'HermesWorld', 'Name of carrier', 'woocommerce-paypal-payments' ),
'INTERLINK' => _x( 'Interlink Express', 'Name of carrier', 'woocommerce-paypal-payments' ),
'MYHERMES' => _x( 'MyHermes UK', 'Name of carrier', 'woocommerce-paypal-payments' ),
'NIGHTLINE_UK' => _x( 'Nightline UK', 'Name of carrier', 'woocommerce-paypal-payments' ),
'PARCELFORCE' => _x( 'Parcel Force', 'Name of carrier', 'woocommerce-paypal-payments' ),
'ROYAL_MAIL' => _x( 'Royal Mail', 'Name of carrier', 'woocommerce-paypal-payments' ),
'RPD_2_MAN' => _x( 'RPD2man Deliveries', 'Name of carrier', 'woocommerce-paypal-payments' ),
'SKYNET_UK' => _x( 'Skynet Worldwide Express UK', 'Name of carrier', 'woocommerce-paypal-payments' ),
'TNT_UK' => _x( 'TNT UK', 'Name of carrier', 'woocommerce-paypal-payments' ),
'UK_MAIL' => _x( 'UK Mail', 'Name of carrier', 'woocommerce-paypal-payments' ),
'YODEL' => _x( 'Yodel', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'US' => array(
'name' => _x( 'United States', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'ABC_PACKAGE' => _x( 'ABC Package Express', 'Name of carrier', 'woocommerce-paypal-payments' ),
'AIRBORNE_EXPRESS' => _x( 'Airborne Express', 'Name of carrier', 'woocommerce-paypal-payments' ),
'ASENDIA_US' => _x( 'Asendia USA', 'Name of carrier', 'woocommerce-paypal-payments' ),
'CPACKET' => _x( 'Cpacket', 'Name of carrier', 'woocommerce-paypal-payments' ),
'ENSENDA' => _x( 'Ensenda USA', 'Name of carrier', 'woocommerce-paypal-payments' ),
'ESTES' => _x( 'Estes', 'Name of carrier', 'woocommerce-paypal-payments' ),
'FASTWAY_US' => _x( 'Fastway USA', 'Name of carrier', 'woocommerce-paypal-payments' ),
'GLOBEGISTICS' => _x( 'Globegistics USA', 'Name of carrier', 'woocommerce-paypal-payments' ),
'INTERNATIONAL_BRIDGE' => _x( 'International Bridge', 'Name of carrier', 'woocommerce-paypal-payments' ),
'ONTRAC' => _x( 'OnTrac', 'Name of carrier', 'woocommerce-paypal-payments' ),
'RL_US' => _x( 'RL Carriers', 'Name of carrier', 'woocommerce-paypal-payments' ),
'RRDONNELLEY' => _x( 'RR Donnelley', 'Name of carrier', 'woocommerce-paypal-payments' ),
'USPS' => _x( 'USPS', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
'VN' => array(
'name' => _x( 'Vietnam', 'Name of carrier country', 'woocommerce-paypal-payments' ),
'items' => array(
'KERRY_EXPRESS_VN' => _x( 'Kerry Express Vietnam', 'Name of carrier', 'woocommerce-paypal-payments' ),
'VIETNAM_POST' => _x( 'Vietnam Post', 'Name of carrier', 'woocommerce-paypal-payments' ),
'VNPOST_EMS' => _x( 'Vietnam Post EMS', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
);

View file

@ -0,0 +1,17 @@
{
"name": "woocommerce/ppcp-order-tracking",
"type": "dhii-mod",
"description": "Order tracking module for PPCP",
"license": "GPL-2.0",
"require": {
"php": "^7.1 | ^8.0",
"dhii/module-interface": "^0.3.0-alpha1"
},
"autoload": {
"psr-4": {
"WooCommerce\\PayPalCommerce\\OrderTracking\\": "src"
}
},
"minimum-stability": "dev",
"prefer-stable": true
}

View file

@ -0,0 +1,12 @@
<?php
/**
* The order tracking module extensions.
*
* @package WooCommerce\PayPalCommerce\OrderTracking
*/
declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\OrderTracking;
return array();

View file

@ -0,0 +1,16 @@
<?php
/**
* The order tracking module.
*
* @package WooCommerce\PayPalCommerce\OrderTracking
*/
declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\OrderTracking;
use Dhii\Modular\Module\ModuleInterface;
return static function (): ModuleInterface {
return new OrderTrackingModule();
};

View file

@ -0,0 +1,23 @@
{
"name": "ppcp-order-tracking",
"version": "1.0.0",
"license": "GPL-3.0-or-later",
"main": "resources/js/order-edit-page.js",
"devDependencies": {
"@babel/core": "^7.9.0",
"@babel/preset-env": "^7.9.5",
"babel-loader": "^8.1.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"cross-env": "^7.0.3",
"file-loader": "^6.2.0",
"sass": "^1.42.1",
"sass-loader": "^12.1.0",
"webpack": "^5.55.0",
"webpack-cli": "^4.8.0"
},
"scripts": {
"build": "cross-env BABEL_ENV=default NODE_ENV=production webpack",
"watch": "cross-env BABEL_ENV=default NODE_ENV=production webpack --watch",
"dev": "cross-env BABEL_ENV=default webpack --watch"
}
}

View file

@ -0,0 +1,20 @@
#ppcp_order-tracking {
.tracking-info-message {
padding-left: 20px;
}
.error {
color: red;
font-weight: bold;
}
.success {
color: green;
font-weight: bold;
}
input,select {
width: 100%;
}
}

View file

@ -0,0 +1,49 @@
import {PaymentMethods} from "../../../ppcp-button/resources/js/modules/Helper/CheckoutMethodState";
document.addEventListener(
'DOMContentLoaded',
() => {
const config = PayPalCommerceGatewayOrderTrackingInfo;
if (!typeof (PayPalCommerceGatewayOrderTrackingInfo)) {
console.error('trackign cannot be set.');
return;
}
const transactionId = document.querySelector('.ppcp-tracking-transaction_id');
const trackingNumber = document.querySelector('.ppcp-tracking-tracking_number');
const status = document.querySelector('.ppcp-tracking-status');
const carrier = document.querySelector('.ppcp-tracking-carrier');
const orderId = document.querySelector('.ppcp-order_id');
const submitButton = document.querySelector('.submit_tracking_info');
submitButton.addEventListener('click', function (event) {
submitButton.setAttribute('disabled', 'disabled');
fetch(config.ajax.tracking_info.endpoint, {
method: 'POST',
body: JSON.stringify({
nonce: config.ajax.tracking_info.nonce,
transaction_id: transactionId ? transactionId.value : null,
tracking_number: trackingNumber ? trackingNumber.value : null,
status: status ? status.value : null,
carrier: carrier ? carrier.value : null,
order_id: orderId ? orderId.value : null,
action: submitButton ? submitButton.dataset.action : null,
})
}).then(function (res) {
return res.json();
}).then(function (data) {
if (!data.success) {
console.error(data);
throw Error(data.data.message);
}
jQuery( "<span class='success tracking-info-message'>" + data.data.message + "</span>" ).insertAfter(submitButton);
setTimeout(()=> jQuery('.tracking-info-message').remove(),3000);
submitButton.dataset.action = 'update';
submitButton.textContent = 'update';
submitButton.removeAttribute('disabled');
});
})
},
);

View file

@ -0,0 +1,82 @@
<?php
/**
* The order tracking module services.
*
* @package WooCommerce\PayPalCommerce\OrderTracking
*/
declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\OrderTracking;
use Psr\Container\ContainerInterface;
use WooCommerce\PayPalCommerce\OrderTracking\Assets\OrderEditPageAssets;
use WooCommerce\PayPalCommerce\OrderTracking\Endpoint\OrderTrackingEndpoint;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
return array(
'order-tracking.assets' => function( ContainerInterface $container ) : OrderEditPageAssets {
return new OrderEditPageAssets(
$container->get( 'order-tracking.module.url' ),
$container->get( 'ppcp.asset-version' )
);
},
'order-tracking.endpoint.controller' => static function ( ContainerInterface $container ) : OrderTrackingEndpoint {
return new OrderTrackingEndpoint(
$container->get( 'api.host' ),
$container->get( 'api.bearer' ),
$container->get( 'woocommerce.logger.woocommerce' ),
$container->get( 'button.request-data' )
);
},
'order-tracking.module.url' => static function ( ContainerInterface $container ): string {
/**
* The path cannot be false.
*
* @psalm-suppress PossiblyFalseArgument
*/
return plugins_url(
'/modules/ppcp-order-tracking/',
dirname( realpath( __FILE__ ), 3 ) . '/woocommerce-paypal-payments.php'
);
},
'order-tracking.meta-box.renderer' => static function ( ContainerInterface $container ): MetaBoxRenderer {
return new MetaBoxRenderer(
$container->get( 'order-tracking.endpoint.controller' ),
$container->get( 'order-tracking.allowed-shipping-statuses' ),
$container->get( 'order-tracking.available-carriers' )
);
},
'order-tracking.allowed-shipping-statuses' => static function ( ContainerInterface $container ): array {
return array( 'SHIPPED', 'ON_HOLD', 'DELIVERED', 'CANCELLED' );
},
'order-tracking.allowed-carriers' => static function ( ContainerInterface $container ): array {
return require __DIR__ . '/carriers.php';
},
'order-tracking.available-carriers' => static function ( ContainerInterface $container ): array {
$api_shop_country = $container->get( 'api.shop.country' );
$allowed_carriers = $container->get( 'order-tracking.allowed-carriers' );
$selected_country_carriers = $allowed_carriers[ $api_shop_country ] ?? array();
return array(
$api_shop_country => $selected_country_carriers ?? array(),
'global' => $allowed_carriers['global'] ?? array(),
'other' => array(
'name' => 'Other',
'items' => array(
'OTHER' => _x( 'Other', 'Name of carrier', 'woocommerce-paypal-payments' ),
),
),
);
},
'order-tracking.is-paypal-order-edit-page' => static function ( ContainerInterface $container ): bool {
$order_id = isset( $_GET['post'] ) ? (int) $_GET['post'] : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
if ( empty( $order_id ) ) {
return false;
}
$meta = get_post_meta( $order_id, PayPalGateway::ORDER_ID_META_KEY, true );
return ! empty( $meta );
},
);

View file

@ -0,0 +1,100 @@
<?php
/**
* Register and configure assets for order edit page.
*
* @package WooCommerce\PayPalCommerce\OrderTracking\Assets
*/
declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\OrderTracking\Assets;
use WooCommerce\PayPalCommerce\OrderTracking\Endpoint\OrderTrackingEndpoint;
/**
* Class OrderEditPageAssets
*/
class OrderEditPageAssets {
/**
* The URL to the module.
*
* @var string
*/
private $module_url;
/**
* The assets version.
*
* @var string
*/
private $version;
/**
* WebhooksStatusPageAssets constructor.
*
* @param string $module_url The URL to the module.
* @param string $version The assets version.
*/
public function __construct(
string $module_url,
string $version
) {
$this->module_url = $module_url;
$this->version = $version;
}
/**
* Registers the scripts and styles.
*
* @return void
*/
public function register(): void {
wp_register_style(
'ppcp-webhooks-order-edit-page-style',
untrailingslashit( $this->module_url ) . '/assets/css/order-edit-page.css',
array(),
$this->version
);
wp_register_script(
'ppcp-tracking',
untrailingslashit( $this->module_url ) . '/assets/js/order-edit-page.js',
array( 'jquery' ),
$this->version,
true
);
wp_localize_script(
'ppcp-tracking',
'PayPalCommerceGatewayOrderTrackingInfo',
$this->get_script_data()
);
}
/**
* Returns the data for the script.
*
* @return array a map of script data.
*/
public function get_script_data(): array {
return array(
'ajax' => array(
'tracking_info' => array(
'endpoint' => \WC_AJAX::get_endpoint( OrderTrackingEndpoint::ENDPOINT ),
'nonce' => wp_create_nonce( OrderTrackingEndpoint::nonce() ),
),
),
);
}
/**
* Enqueues the necessary scripts.
*
* @return void
*/
public function enqueue(): void {
wp_enqueue_style( 'ppcp-webhooks-order-edit-page-style' );
wp_enqueue_script( 'ppcp-tracking' );
}
}

View file

@ -0,0 +1,356 @@
<?php
/**
* The order tracking Endpoint.
*
* @package WooCommerce\PayPalCommerce\OrderTracking\Endpoint
*/
declare( strict_types=1 );
namespace WooCommerce\PayPalCommerce\OrderTracking\Endpoint;
use Exception;
use Psr\Log\LoggerInterface;
use WC_Order;
use WooCommerce\PayPalCommerce\ApiClient\Authentication\Bearer;
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\RequestTrait;
use WooCommerce\PayPalCommerce\ApiClient\Exception\PayPalApiException;
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
use WooCommerce\PayPalCommerce\Button\Endpoint\RequestData;
use WooCommerce\PayPalCommerce\WcGateway\Processor\TransactionIdHandlingTrait;
/**
* The OrderTrackingEndpoint.
*
* @psalm-type SupportedStatuses = 'SHIPPED'|'ON_HOLD'|'DELIVERED'|'CANCELLED'
* @psalm-type TrackingInfo = array{transaction_id: string, status: SupportedStatuses, tracking_number?: string, carrier?: string}
* @psalm-type RequestValues = array{transaction_id: string, status: SupportedStatuses, order_id: int, action: 'create'|'update', tracking_number?: string, carrier?: string}
* Class OrderTrackingEndpoint
*/
class OrderTrackingEndpoint {
use RequestTrait, TransactionIdHandlingTrait;
const ENDPOINT = 'ppc-tracking-info';
/**
* The RequestData.
*
* @var RequestData
*/
protected $request_data;
/**
* The Host URL.
*
* @var string
*/
private $host;
/**
* The bearer.
*
* @var Bearer
*/
private $bearer;
/**
* The logger.
*
* @var LoggerInterface
*/
private $logger;
/**
* PartnersEndpoint constructor.
*
* @param string $host The host.
* @param Bearer $bearer The bearer.
* @param LoggerInterface $logger The logger.
* @param RequestData $request_data The Request data.
*/
public function __construct(
string $host,
Bearer $bearer,
LoggerInterface $logger,
RequestData $request_data
) {
$this->host = $host;
$this->bearer = $bearer;
$this->logger = $logger;
$this->request_data = $request_data;
}
/**
* Handles the request.
*/
public function handle_request(): void {
try {
$data = $this->request_data->read_request( $this->nonce() );
$action = $data['action'];
$request_body = $this->extract_tracking_information( $data );
$order_id = (int) $data['order_id'];
$action === 'create' ? $this->add_tracking_information( $request_body, $order_id ) : $this->update_tracking_information( $data, $order_id );
$action_message = $action === 'create' ? 'created' : 'updated';
$message = sprintf(
// translators: %1$s is the action message (created or updated).
_x( 'successfully %1$s', 'tracking info success message', 'woocommerce-paypal-payments' ),
esc_html( $action_message )
);
wp_send_json_success( array( 'message' => $message ) );
} catch ( Exception $error ) {
wp_send_json_error( $error->getMessage(), 500 );
}
}
/**
* Creates the tracking information of a given order with the given data.
*
* @param array $data The tracking information to add.
* @psalm-param TrackingInfo $data
* @param int $order_id The order ID.
* @throws RuntimeException If problem creating.
*/
public function add_tracking_information( array $data, int $order_id ) : void {
$url = trailingslashit( $this->host ) . 'v1/shipping/trackers-batch';
$body = array(
'trackers' => array( $data ),
);
$args = array(
'method' => 'POST',
'headers' => $this->request_headers(),
'body' => wp_json_encode( $body ),
);
$response = $this->request( $url, $args );
if ( is_wp_error( $response ) ) {
$error = new RuntimeException(
'Could not create order tracking information.'
);
$this->logger->log(
'warning',
$error->getMessage(),
array(
'args' => $args,
'response' => $response,
)
);
throw $error;
}
/**
* Need to ignore Method WP_Error::offsetGet does not exist
*
* @psalm-suppress UndefinedMethod
*/
$json = json_decode( $response['body'] );
$status_code = (int) wp_remote_retrieve_response_code( $response );
if ( 200 !== $status_code ) {
$error = new PayPalApiException(
$json,
$status_code
);
$this->logger->log(
'warning',
sprintf(
'Failed to create order tracking information. PayPal API response: %1$s',
$error->getMessage()
),
array(
'args' => $args,
'response' => $response,
)
);
throw $error;
}
update_post_meta( $order_id, '_ppcp_paypal_tracking_number', $data['tracking_number'] ?? '' );
}
/**
* Gets the tracking information of a given order.
*
* @param int $wc_order_id The order ID.
* @return array|null The tracking information.
* @psalm-return TrackingInfo|null
* @throws RuntimeException If problem getting.
*/
public function get_tracking_information( int $wc_order_id ) : ?array {
$wc_order = wc_get_order( $wc_order_id );
if ( ! is_a( $wc_order, WC_Order::class ) ) {
throw new RuntimeException( 'wrong order ID' );
}
$transaction_id = $wc_order->get_transaction_id();
$tracking_number = get_post_meta( $wc_order_id, '_ppcp_paypal_tracking_number', true );
$url = trailingslashit( $this->host ) . 'v1/shipping/trackers/' . $this->find_tracker_id( $transaction_id, $tracking_number );
$args = array(
'method' => 'GET',
'headers' => $this->request_headers(),
);
$response = $this->request( $url, $args );
if ( is_wp_error( $response ) ) {
$error = new RuntimeException(
'Could not fetch the tracking information.'
);
$this->logger->log(
'warning',
$error->getMessage(),
array(
'args' => $args,
'response' => $response,
)
);
throw $error;
}
/**
* Need to ignore Method WP_Error::offsetGet does not exist
*
* @psalm-suppress UndefinedMethod
*/
$data = json_decode( $response['body'] );
$status_code = (int) wp_remote_retrieve_response_code( $response );
if ( 200 !== $status_code ) {
return null;
}
return $this->extract_tracking_information( (array) $data );
}
/**
* Updates the tracking information of a given order with the given data.
*
* @param array $data The tracking information to update.
* @psalm-param TrackingInfo $data
* @param int $order_id The order ID.
* @throws RuntimeException If problem updating.
*/
public function update_tracking_information( array $data, int $order_id ) : void {
$tracking_info = $this->get_tracking_information( $order_id );
$transaction_id = $tracking_info['transaction_id'] ?? '';
$tracking_number = $tracking_info['tracking_number'] ?? '';
$url = trailingslashit( $this->host ) . 'v1/shipping/trackers/' . $this->find_tracker_id( $transaction_id, $tracking_number );
$args = array(
'method' => 'PUT',
'headers' => $this->request_headers(),
'body' => wp_json_encode( $data ),
);
$response = $this->request( $url, $args );
if ( is_wp_error( $response ) ) {
$error = new RuntimeException(
'Could not update order tracking information.'
);
$this->logger->log(
'warning',
$error->getMessage(),
array(
'args' => $args,
'response' => $response,
)
);
throw $error;
}
/**
* Need to ignore Method WP_Error::offsetGet does not exist
*
* @psalm-suppress UndefinedMethod
*/
$json = json_decode( $response['body'] );
$status_code = (int) wp_remote_retrieve_response_code( $response );
if ( 204 !== $status_code ) {
$error = new PayPalApiException(
$json,
$status_code
);
$this->logger->log(
'warning',
sprintf(
'Failed to update the order tracking information. PayPal API response: %1$s',
$error->getMessage()
),
array(
'args' => $args,
'response' => $response,
)
);
throw $error;
}
update_post_meta( $order_id, '_ppcp_paypal_tracking_number', $data['tracking_number'] ?? '' );
}
/**
* The nonce.
*
* @return string
*/
public static function nonce(): string {
return self::ENDPOINT;
}
/**
* Extracts the needed tracking information from given data.
*
* @param array $data The request data map.
* @psalm-param RequestValues $data
* @return array A map of tracking information keys to values.
* @psalm-return TrackingInfo
* @throws RuntimeException If problem extracting.
*/
protected function extract_tracking_information( array $data ): array {
if ( empty( $data['transaction_id'] ) || empty( $data['status'] ) ) {
$this->logger->log( 'warning', 'Missing transaction_id or status.' );
throw new RuntimeException( 'Missing transaction_id or status.' );
}
$tracking_info = array(
'transaction_id' => $data['transaction_id'],
'status' => $data['status'],
);
if ( ! empty( $data['tracking_number'] ) ) {
$tracking_info['tracking_number'] = $data['tracking_number'];
}
if ( ! empty( $data['carrier'] ) ) {
$tracking_info['carrier'] = $data['carrier'];
}
return $tracking_info;
}
/**
* Creates the request headers.
*
* @return array The request headers.
*/
protected function request_headers(): array {
return array(
'Authorization' => 'Bearer ' . $this->bearer->bearer()->token(),
'Content-Type' => 'application/json',
);
}
/**
* Finds the tracker ID from given transaction ID and tracking number.
*
* @param string $transaction_id The transaction ID.
* @param string $tracking_number The tracking number.
* @return string The tracker ID.
*/
protected function find_tracker_id( string $transaction_id, string $tracking_number ): string {
return ! empty( $tracking_number ) ? "{$transaction_id}-{$tracking_number}" : "{$transaction_id}-NOTRACKER";
}
}

View file

@ -0,0 +1,131 @@
<?php
/**
* The order tracking MetaBox renderer.
*
* @package WooCommerce\PayPalCommerce\OrderTracking
*/
declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\OrderTracking;
use WC_Order;
use WooCommerce\PayPalCommerce\OrderTracking\Endpoint\OrderTrackingEndpoint;
use WP_Post;
/**
* Class MetaBoxRenderer
*
* @psalm-type CarrierType = string
* @psalm-type CarrierItemCode = string
* @psalm-type CarrierItemName = string
* @psalm-type Carrier = array{name: string, items: array<CarrierItemCode, CarrierItemName>}
* @psalm-type Carriers = array<CarrierType, Carrier>
*/
class MetaBoxRenderer {
public const NAME_PREFIX = 'ppcp-tracking';
/**
* The OrderTrackingEndpoint.
*
* @var OrderTrackingEndpoint
*/
protected $order_tracking_endpoint;
/**
* Allowed shipping statuses.
*
* @var string[]
*/
protected $allowed_statuses;
/**
* Available shipping carriers.
*
* @var array
* @psalm-var Carriers
*/
protected $carriers;
/**
* MetaBoxRenderer constructor.
*
* @param OrderTrackingEndpoint $order_tracking_endpoint The OrderTrackingEndpoint.
* @param string[] $allowed_statuses Allowed shipping statuses.
* @param array $carriers Available shipping carriers.
* @psalm-param Carriers $carriers
*/
public function __construct(
OrderTrackingEndpoint $order_tracking_endpoint,
array $allowed_statuses,
array $carriers
) {
$this->order_tracking_endpoint = $order_tracking_endpoint;
$this->allowed_statuses = $allowed_statuses;
$this->carriers = $carriers;
}
/**
* Renders the order tracking MetaBox.
*
* @param WP_Post $post The post object.
*/
public function render( WP_Post $post ): void {
$wc_order = wc_get_order( $post->ID );
if ( ! is_a( $wc_order, WC_Order::class ) ) {
return;
}
$tracking_info = $this->order_tracking_endpoint->get_tracking_information( $post->ID );
$tracking_is_not_added = empty( $tracking_info );
$transaction_id = $tracking_info['transaction_id'] ?? $wc_order->get_transaction_id() ?: '';
$tracking_number = $tracking_info['tracking_number'] ?? '';
$status_value = $tracking_info['status'] ?? 'SHIPPED';
$carrier_value = $tracking_info['carrier'] ?? '';
$carriers = (array) apply_filters( 'ppcp_tracking_carriers', $this->carriers );
$statuses = (array) apply_filters( 'ppcp_tracking_statuses', $this->allowed_statuses );
$action = $tracking_is_not_added ? 'create' : 'update';
?>
<p>
<label for="<?php echo esc_attr( self::NAME_PREFIX ); ?>-transaction_id"><?php echo esc_html__( 'Transaction ID', 'woocommerce-paypal-payments' ); ?></label>
<input type="text" disabled class="<?php echo esc_attr( self::NAME_PREFIX ); ?>-transaction_id" id="<?php echo esc_attr( self::NAME_PREFIX ); ?>-transaction_id" name="<?php echo esc_attr( self::NAME_PREFIX ); ?>[transaction_id]" value="<?php echo esc_html( $transaction_id ); ?>"/></p>
<p>
<label for="<?php echo esc_attr( self::NAME_PREFIX ); ?>-tracking_number"><?php echo esc_html__( 'Tracking Number', 'woocommerce-paypal-payments' ); ?></label>
<input type="text" class="<?php echo esc_attr( self::NAME_PREFIX ); ?>-tracking_number" id="<?php echo esc_attr( self::NAME_PREFIX ); ?>-tracking_number" name="<?php echo esc_attr( self::NAME_PREFIX ); ?>[tracking_number]" value="<?php echo esc_html( $tracking_number ); ?>"/></p>
<p>
<label for="<?php echo esc_attr( self::NAME_PREFIX ); ?>-status"><?php echo esc_html__( 'Status', 'woocommerce-paypal-payments' ); ?></label>
<select class="<?php echo esc_attr( self::NAME_PREFIX ); ?>-status" id="<?php echo esc_attr( self::NAME_PREFIX ); ?>-status" name="<?php echo esc_attr( self::NAME_PREFIX ); ?>[status]">
<?php foreach ( $statuses as $status ) : ?>
<option value="<?php echo esc_attr( $status ); ?>" <?php selected( $status_value, $status ); ?>><?php echo esc_html( $status ); ?></option>
<?php endforeach; ?>
</select>
</p>
<p>
<label for="ppcp-tracking-carrier"><?php echo esc_html__( 'Carrier', 'woocommerce-paypal-payments' ); ?></label>
<select class="ppcp-tracking-carrier" id="ppcp-tracking-carrier" name="ppcp-tracking[carrier]">
<option value=""><?php echo esc_html__( 'Select Carrier', 'woocommerce-paypal-payments' ); ?></option>
<?php
foreach ( $carriers as $carrier ) :
$country = $carrier['name'] ?? '';
$carrier_items = $carrier['items'] ?? array();
?>
<optgroup label="<?php echo esc_attr( $country ); ?>">
<?php foreach ( $carrier_items as $carrier_code => $carrier_name ) : ?>
<option value="<?php echo esc_attr( $carrier_code ); ?>" <?php selected( $carrier_value, $carrier_code ); ?>><?php echo esc_html( $carrier_name ); ?></option>
<?php endforeach; ?>
</optgroup>
<?php endforeach; ?>
</select>
</p>
<input type="hidden" class="ppcp-order_id" name="<?php echo esc_attr( self::NAME_PREFIX ); ?>[order_id]" value="<?php echo intval( $post->ID ); ?>"/>
<p>
<button type="button" class="button submit_tracking_info" data-action="<?php echo esc_attr( $action ); ?>"><?php echo esc_html( ucfirst( $action ) ); ?></button></p>
<?php
}
}

View file

@ -0,0 +1,149 @@
<?php
/**
* The order tracking module.
*
* @package WooCommerce\PayPalCommerce\OrderTracking
*/
declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\OrderTracking;
use Dhii\Container\ServiceProvider;
use Dhii\Modular\Module\ModuleInterface;
use Exception;
use Interop\Container\ServiceProviderInterface;
use Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface;
use WC_Order;
use WooCommerce\PayPalCommerce\OrderTracking\Assets\OrderEditPageAssets;
use WooCommerce\PayPalCommerce\OrderTracking\Endpoint\OrderTrackingEndpoint;
use WooCommerce\PayPalCommerce\WcGateway\Exception\NotFoundException;
use WooCommerce\PayPalCommerce\WcGateway\Helper\PayUponInvoiceHelper;
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
use WooCommerce\PayPalCommerce\WcGateway\Settings\SettingsListener;
/**
* Class OrderTrackingModule
*/
class OrderTrackingModule implements ModuleInterface {
/**
* {@inheritDoc}
*/
public function setup(): ServiceProviderInterface {
return new ServiceProvider(
require __DIR__ . '/../services.php',
require __DIR__ . '/../extensions.php'
);
}
/**
* {@inheritDoc}
*
* @param ContainerInterface $c A services container instance.
* @throws NotFoundException
*/
public function run( ContainerInterface $c ): void {
$settings = $c->get( 'wcgateway.settings' );
assert( $settings instanceof Settings );
$pui_helper = $c->get( 'wcgateway.pay-upon-invoice-helper' );
assert( $pui_helper instanceof PayUponInvoiceHelper );
if ( $pui_helper->is_pui_ready_in_admin() ) {
$settings->set( 'tracking_enabled', true );
$settings->persist();
}
$tracking_enabled = $settings->has( 'tracking_enabled' ) && $settings->get( 'tracking_enabled' );
if ( ! $tracking_enabled ) {
return;
}
$asset_loader = $c->get( 'order-tracking.assets' );
assert( $asset_loader instanceof OrderEditPageAssets );
$is_paypal_order_edit_page = $c->get( 'order-tracking.is-paypal-order-edit-page' );
$endpoint = $c->get( 'order-tracking.endpoint.controller' );
assert( $endpoint instanceof OrderTrackingEndpoint );
$logger = $c->get( 'woocommerce.logger.woocommerce' );
assert( $logger instanceof LoggerInterface );
add_action(
'init',
static function () use ( $asset_loader, $is_paypal_order_edit_page ) {
if ( ! $is_paypal_order_edit_page ) {
return;
}
$asset_loader->register();
}
);
add_action(
'admin_enqueue_scripts',
static function () use ( $asset_loader, $is_paypal_order_edit_page ) {
if ( ! $is_paypal_order_edit_page ) {
return;
}
$asset_loader->enqueue();
}
);
add_action(
'wc_ajax_' . OrderTrackingEndpoint::ENDPOINT,
array( $endpoint, 'handle_request' )
);
$meta_box_renderer = $c->get( 'order-tracking.meta-box.renderer' );
add_action(
'add_meta_boxes',
static function() use ( $meta_box_renderer, $is_paypal_order_edit_page ) {
if ( ! $is_paypal_order_edit_page ) {
return;
}
add_meta_box( 'ppcp_order-tracking', __( 'Tracking Information', 'woocommerce-paypal-payments' ), array( $meta_box_renderer, 'render' ), 'shop_order', 'side' );
},
10,
2
);
add_action(
'woocommerce_order_status_completed',
static function( int $order_id ) use ( $endpoint, $logger ) {
$tracking_information = $endpoint->get_tracking_information( $order_id );
if ( $tracking_information ) {
return;
}
$wc_order = wc_get_order( $order_id );
if ( ! is_a( $wc_order, WC_Order::class ) ) {
return;
}
$transaction_id = $wc_order->get_transaction_id();
if ( empty( $transaction_id ) ) {
return;
}
$tracking_data = array(
'transaction_id' => $transaction_id,
'status' => 'SHIPPED',
);
try {
$endpoint->add_tracking_information( $tracking_data, $order_id );
} catch ( Exception $exception ) {
$logger->error( "Couldn't create tracking information: " . $exception->getMessage() );
throw $exception;
}
}
);
}
}

View file

@ -0,0 +1,36 @@
const path = require('path');
const isProduction = process.env.NODE_ENV === 'production';
module.exports = {
devtool: 'eval-source-map',
mode: isProduction ? 'production' : 'development',
target: 'web',
entry: {
'order-edit-page': path.resolve('./resources/js/order-edit-page.js'),
'order-edit-page-style': path.resolve('./resources/css/order-edit-page.scss'),
},
output: {
path: path.resolve(__dirname, 'assets/'),
filename: 'js/[name].js',
},
module: {
rules: [{
test: /\.js?$/,
exclude: /node_modules/,
loader: 'babel-loader',
},
{
test: /\.scss$/,
exclude: /node_modules/,
use: [
{
loader: 'file-loader',
options: {
name: 'css/[name].css',
}
},
{loader:'sass-loader'}
]
}]
}
};

File diff suppressed because it is too large Load diff

View file

@ -72,6 +72,8 @@ class StatusReportModule implements ModuleInterface {
$had_ppec_plugin = PPECHelper::is_plugin_configured();
$is_tracking_available = $c->get( 'order-tracking.is-tracking-available' );
$items = array(
array(
'label' => esc_html__( 'Onboarded', 'woocommerce-paypal-payments' ),
@ -149,6 +151,12 @@ class StatusReportModule implements ModuleInterface {
$had_ppec_plugin
),
),
array(
'label' => esc_html__( 'Tracking enabled', 'woocommerce-paypal-payments' ),
'exported_label' => 'Tracking enabled',
'description' => esc_html__( 'Whether tracking is enabled on PayPal account or not.', 'woocommerce-paypal-payments' ),
'value' => $this->bool_to_html( $is_tracking_available ),
),
);
echo wp_kses_post(

View file

@ -12,6 +12,7 @@ declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\WcGateway;
use Psr\Container\ContainerInterface;
use WooCommerce\PayPalCommerce\ApiClient\Authentication\Bearer;
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\PayUponInvoiceOrderEndpoint;
use WooCommerce\PayPalCommerce\ApiClient\Entity\ApplicationContext;
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
@ -944,6 +945,20 @@ return array(
'requirements' => array(),
'gateway' => 'paypal',
),
'tracking_enabled' => array(
'title' => __( 'Tracking', 'woocommerce-paypal-payments' ),
'type' => 'checkbox',
'desc_tip' => true,
'label' => __( 'Enable tracking', 'woocommerce-paypal-payments' ),
'description' => __( 'Enable tracking', 'woocommerce-paypal-payments' ),
'default' => false,
'screens' => array(
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => array( 'paypal' ),
'input_class' => $container->get( 'wcgateway.settings.should-disable-tracking-checkbox' ) ? array( 'ppcp-disabled-checkbox' ) : array(),
),
// General button styles.
'button_style_heading' => array(
@ -2287,7 +2302,9 @@ return array(
},
'wcgateway.pay-upon-invoice-helper' => static function( ContainerInterface $container ): PayUponInvoiceHelper {
return new PayUponInvoiceHelper(
$container->get( 'wcgateway.checkout-helper' )
$container->get( 'wcgateway.checkout-helper' ),
$container->get( 'api.shop.country' ),
$container->get( 'wcgateway.pay-upon-invoice-product-status' )
);
},
'wcgateway.pay-upon-invoice-product-status' => static function( ContainerInterface $container ): PayUponInvoiceProductStatus {
@ -2418,4 +2435,31 @@ return array(
(bool) $settings->get( 'allow_card_button_gateway' ) :
$container->get( 'wcgateway.settings.allow_card_button_gateway.default' );
},
'order-tracking.is-tracking-available' => static function ( ContainerInterface $container ): bool {
try {
$bearer = $container->get( 'api.bearer' );
assert( $bearer instanceof Bearer );
$token = $bearer->bearer();
return $token->is_tracking_available();
} catch ( RuntimeException $exception ) {
return false;
}
},
'wcgateway.settings.should-disable-tracking-checkbox' => static function ( ContainerInterface $container ): bool {
$pui_helper = $container->get( 'wcgateway.pay-upon-invoice-helper' );
assert( $pui_helper instanceof PayUponInvoiceHelper );
$is_tracking_available = $container->get( 'order-tracking.is-tracking-available' );
if ( ! $is_tracking_available ) {
return true;
}
if ( $pui_helper->is_pui_ready_in_admin() ) {
return true;
}
return false;
},
);

View file

@ -23,13 +23,32 @@ class PayUponInvoiceHelper {
*/
protected $checkout_helper;
/**
* The selected shop country.
*
* @var string
*/
protected $shop_country;
/**
* The PUI seller product status.
*
* @var PayUponInvoiceProductStatus
*/
protected $pui_product_status;
/**
* PayUponInvoiceHelper constructor.
*
* @param CheckoutHelper $checkout_helper The checkout helper.
* @param CheckoutHelper $checkout_helper The checkout helper.
* @param string $shop_country The selected shop country.
* @param PayUponInvoiceProductStatus $pui_product_status The PUI seller product status.
*/
public function __construct( CheckoutHelper $checkout_helper ) {
$this->checkout_helper = $checkout_helper;
public function __construct( CheckoutHelper $checkout_helper, string $shop_country, PayUponInvoiceProductStatus $pui_product_status ) {
$this->checkout_helper = $checkout_helper;
$this->shop_country = $shop_country;
$this->pui_product_status = $pui_product_status;
}
/**
@ -78,4 +97,17 @@ class PayUponInvoiceHelper {
return false;
}
/**
* Checks whether PUI is ready in admin screen.
*
* @return bool
*/
public function is_pui_ready_in_admin(): bool {
if ( $this->shop_country === 'DE' && $this->pui_product_status->pui_is_active() ) {
return true;
}
return false;
}
}

View file

@ -235,7 +235,7 @@ class SettingsListener {
*
* @throws \WooCommerce\PayPalCommerce\WcGateway\Exception\NotFoundException When a setting was not found.
*/
public function listen() {
public function listen(): void {
if ( ! $this->is_valid_update_request() ) {
return;
@ -473,4 +473,36 @@ class SettingsListener {
}
return true;
}
/**
* Prevent enabling tracking if it is not enabled for merchant account.
*/
public function listen_for_tracking_enabled(): void {
if ( State::STATE_ONBOARDED !== $this->state->current_state() ) {
return;
}
try {
$token = $this->bearer->bearer();
if ( ! $token->is_tracking_available() ) {
$this->settings->set( 'tracking_enabled', false );
$this->settings->persist();
return;
}
} catch ( RuntimeException $exception ) {
$this->settings->set( 'tracking_enabled', false );
$this->settings->persist();
add_action(
'admin_notices',
function () use ( $exception ) {
printf(
'<div class="notice notice-error"><p>%1$s</p><p>%2$s</p></div>',
esc_html__( 'Authentication with PayPal failed: ', 'woocommerce-paypal-payments' ) . esc_attr( $exception->getMessage() ),
wp_kses_post( __( 'Please verify your API Credentials and try again to connect your PayPal business account. Visit the <a href="https://docs.woocommerce.com/document/woocommerce-paypal-payments/" target="_blank">plugin documentation</a> for more information about the setup.', 'woocommerce-paypal-payments' ) )
);
}
);
}
}
}

View file

@ -386,6 +386,7 @@ class WCGatewayModule implements ModuleInterface {
*/
$listener->listen_for_merchant_id();
$listener->listen_for_vaulting_enabled();
$listener->listen_for_tracking_enabled();
}
);