mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
Fix PHPcs errors
This commit is contained in:
parent
cd75b08e9e
commit
a4cb280fe3
2 changed files with 293 additions and 290 deletions
|
@ -15,65 +15,65 @@ use WooCommerce\PayPalCommerce\OrderTracking\Endpoint\OrderTrackingEndpoint;
|
||||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
|
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'order-tracking.assets' => function( ContainerInterface $container ) : OrderEditPageAssets {
|
'order-tracking.assets' => function( ContainerInterface $container ) : OrderEditPageAssets {
|
||||||
return new OrderEditPageAssets(
|
return new OrderEditPageAssets(
|
||||||
$container->get( 'order-tracking.module.url' ),
|
$container->get( 'order-tracking.module.url' ),
|
||||||
$container->get( 'ppcp.asset-version' )
|
$container->get( 'ppcp.asset-version' )
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
'order-tracking.endpoint.controller' => static function ( ContainerInterface $container ) : OrderTrackingEndpoint {
|
'order-tracking.endpoint.controller' => static function ( ContainerInterface $container ) : OrderTrackingEndpoint {
|
||||||
return new OrderTrackingEndpoint(
|
return new OrderTrackingEndpoint(
|
||||||
$container->get( 'api.host' ),
|
$container->get( 'api.host' ),
|
||||||
$container->get( 'api.bearer' ),
|
$container->get( 'api.bearer' ),
|
||||||
$container->get( 'woocommerce.logger.woocommerce' ),
|
$container->get( 'woocommerce.logger.woocommerce' ),
|
||||||
$container->get( 'button.request-data' )
|
$container->get( 'button.request-data' )
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
'order-tracking.module.url' => static function ( ContainerInterface $container ): string {
|
'order-tracking.module.url' => static function ( ContainerInterface $container ): string {
|
||||||
return plugins_url(
|
return plugins_url(
|
||||||
'/modules/ppcp-order-tracking/',
|
'/modules/ppcp-order-tracking/',
|
||||||
dirname( realpath( __FILE__ ), 3 ) . '/woocommerce-paypal-payments.php'
|
dirname( realpath( __FILE__ ), 3 ) . '/woocommerce-paypal-payments.php'
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
'order-tracking.meta-box.renderer' => static function ( ContainerInterface $container ): MetaBoxRenderer {
|
'order-tracking.meta-box.renderer' => static function ( ContainerInterface $container ): MetaBoxRenderer {
|
||||||
return new MetaBoxRenderer(
|
return new MetaBoxRenderer(
|
||||||
$container->get( 'order-tracking.endpoint.controller' ),
|
$container->get( 'order-tracking.endpoint.controller' ),
|
||||||
$container->get( 'order-tracking.allowed-shipping-statuses' ),
|
$container->get( 'order-tracking.allowed-shipping-statuses' ),
|
||||||
$container->get( 'order-tracking.available-carriers' ),
|
$container->get( 'order-tracking.available-carriers' )
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
'order-tracking.allowed-shipping-statuses' => static function ( ContainerInterface $container ): array {
|
'order-tracking.allowed-shipping-statuses' => static function ( ContainerInterface $container ): array {
|
||||||
return array('SHIPPED', 'ON_HOLD', 'DELIVERED', 'CANCELLED');
|
return array( 'SHIPPED', 'ON_HOLD', 'DELIVERED', 'CANCELLED' );
|
||||||
},
|
},
|
||||||
'order-tracking.allowed-carriers' => static function ( ContainerInterface $container ): array {
|
'order-tracking.allowed-carriers' => static function ( ContainerInterface $container ): array {
|
||||||
return require __DIR__ . '/carriers.php';
|
return require __DIR__ . '/carriers.php';
|
||||||
},
|
},
|
||||||
'order-tracking.available-carriers' => static function ( ContainerInterface $container ): array {
|
'order-tracking.available-carriers' => static function ( ContainerInterface $container ): array {
|
||||||
$wc_default_country = get_option( 'woocommerce_default_country' );
|
$wc_default_country = get_option( 'woocommerce_default_country' );
|
||||||
$has_state = strpos($wc_default_country, ':');
|
$has_state = strpos( $wc_default_country, ':' );
|
||||||
$selected_address = $has_state ? substr($wc_default_country, 0, $has_state) : $wc_default_country;
|
$selected_address = $has_state ? substr( $wc_default_country, 0, $has_state ) : $wc_default_country;
|
||||||
$allowed_carriers = $container->get('order-tracking.allowed-carriers');
|
$allowed_carriers = $container->get( 'order-tracking.allowed-carriers' );
|
||||||
$selected_country_carriers = $allowed_carriers[$selected_address] ?? [];
|
$selected_country_carriers = $allowed_carriers[ $selected_address ] ?? array();
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
$selected_country_carriers,
|
$selected_country_carriers,
|
||||||
$allowed_carriers['global'],
|
$allowed_carriers['global'],
|
||||||
array(
|
array(
|
||||||
'name' => 'Other',
|
'name' => 'Other',
|
||||||
'items' => array(
|
'items' => array(
|
||||||
'OTHER' => _x( 'Other', 'Name of carrier', 'woocommerce-paypal-payments' ),
|
'OTHER' => _x( 'Other', 'Name of carrier', 'woocommerce-paypal-payments' ),
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
'order-tracking.is-paypal-order-edit-page' => static function ( ContainerInterface $container ): bool {
|
'order-tracking.is-paypal-order-edit-page' => static function ( ContainerInterface $container ): bool {
|
||||||
$orderId = isset( $_GET['post'] ) ? (int)$_GET['post'] : '';
|
$order_id = isset( $_GET['post'] ) ? (int) $_GET['post'] : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||||
if (empty($orderId)) {
|
if ( empty( $order_id ) ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$meta = get_post_meta($orderId, PayPalGateway::ORDER_ID_META_KEY, true);
|
$meta = get_post_meta( $order_id, PayPalGateway::ORDER_ID_META_KEY, true );
|
||||||
|
|
||||||
return !empty($meta);
|
return ! empty( $meta );
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
@ -31,13 +31,13 @@ class OrderTrackingEndpoint {
|
||||||
|
|
||||||
use RequestTrait, TransactionIdHandlingTrait;
|
use RequestTrait, TransactionIdHandlingTrait;
|
||||||
|
|
||||||
const ENDPOINT = 'ppc-tracking-info';
|
const ENDPOINT = 'ppc-tracking-info';
|
||||||
/**
|
/**
|
||||||
* @var RequestData
|
* @var RequestData
|
||||||
*/
|
*/
|
||||||
protected $request_data;
|
protected $request_data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Host URL.
|
* The Host URL.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
|
@ -79,266 +79,269 @@ class OrderTrackingEndpoint {
|
||||||
*/
|
*/
|
||||||
private $merchant_id;
|
private $merchant_id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PartnersEndpoint constructor.
|
* PartnersEndpoint constructor.
|
||||||
*
|
*
|
||||||
* @param string $host The host.
|
* @param string $host The host.
|
||||||
* @param Bearer $bearer The bearer.
|
* @param Bearer $bearer The bearer.
|
||||||
* @param LoggerInterface $logger The logger.
|
* @param LoggerInterface $logger The logger.
|
||||||
* @param RequestData $request_data
|
* @param RequestData $request_data
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
string $host,
|
string $host,
|
||||||
Bearer $bearer,
|
Bearer $bearer,
|
||||||
LoggerInterface $logger,
|
LoggerInterface $logger,
|
||||||
RequestData $request_data
|
RequestData $request_data
|
||||||
) {
|
) {
|
||||||
$this->host = $host;
|
$this->host = $host;
|
||||||
$this->bearer = $bearer;
|
$this->bearer = $bearer;
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
$this->request_data = $request_data;
|
$this->request_data = $request_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the request.
|
* Handles the request.
|
||||||
*/
|
*/
|
||||||
public function handle_request() {
|
public function handle_request() {
|
||||||
try {
|
try {
|
||||||
$data = $this->request_data->read_request( $this->nonce() );
|
$data = $this->request_data->read_request( $this->nonce() );
|
||||||
$action = $data['action'];
|
$action = $data['action'];
|
||||||
$request_body = $this->extract_tracking_information($data);
|
$request_body = $this->extract_tracking_information( $data );
|
||||||
$order_id = (int)$data['order_id'];
|
$order_id = (int) $data['order_id'];
|
||||||
$action === 'create' ? $this->add_tracking_information($request_body, $order_id) : $this->update_tracking_information($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';
|
$action_message = $action === 'create' ? 'created' : 'updated';
|
||||||
$message = __("successfully {$action_message}",'woocommerce-paypal-payments');
|
$message = sprintf(
|
||||||
wp_send_json_success(array('message' => $message));
|
// translators: %1$s is the action message (created or updated).
|
||||||
return true;
|
_x( 'successfully %1$s', 'tracking inof success message', 'woocommerce-paypal-payments' ),
|
||||||
} catch ( Exception $error ) {
|
esc_html( $action_message )
|
||||||
wp_send_json_error( $error->getMessage(), 500 );
|
);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
wp_send_json_success( array( 'message' => $message ) );
|
||||||
* Creates the tracking information of a given order with the given data.
|
} catch ( Exception $error ) {
|
||||||
*
|
wp_send_json_error( $error->getMessage(), 500 );
|
||||||
* @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)
|
* 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';
|
||||||
|
|
||||||
$args = array(
|
$body = array(
|
||||||
|
'trackers' => array( $data ),
|
||||||
|
);
|
||||||
|
|
||||||
|
$args = array(
|
||||||
'method' => 'POST',
|
'method' => 'POST',
|
||||||
'headers' => $this->request_headers(),
|
'headers' => $this->request_headers(),
|
||||||
'body' => wp_json_encode( $body ),
|
'body' => wp_json_encode( $body ),
|
||||||
);
|
);
|
||||||
|
|
||||||
$response = $this->request( $url, $args );
|
$response = $this->request( $url, $args );
|
||||||
|
|
||||||
if ( is_wp_error( $response ) ) {
|
if ( is_wp_error( $response ) ) {
|
||||||
$error = new RuntimeException(
|
$error = new RuntimeException(
|
||||||
'Could not create order tracking information.'
|
'Could not create order tracking information.'
|
||||||
);
|
);
|
||||||
$this->logger->log(
|
$this->logger->log(
|
||||||
'warning',
|
'warning',
|
||||||
$error->getMessage(),
|
$error->getMessage(),
|
||||||
array(
|
array(
|
||||||
'args' => $args,
|
'args' => $args,
|
||||||
'response' => $response,
|
'response' => $response,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
throw $error;
|
throw $error;
|
||||||
}
|
}
|
||||||
|
|
||||||
$json = json_decode( $response['body'] );
|
$json = json_decode( $response['body'] );
|
||||||
$status_code = (int) wp_remote_retrieve_response_code( $response );
|
$status_code = (int) wp_remote_retrieve_response_code( $response );
|
||||||
if ( 200 !== $status_code ) {
|
if ( 200 !== $status_code ) {
|
||||||
$error = new PayPalApiException(
|
$error = new PayPalApiException(
|
||||||
$json,
|
$json,
|
||||||
$status_code
|
$status_code
|
||||||
);
|
);
|
||||||
$this->logger->log(
|
$this->logger->log(
|
||||||
'warning',
|
'warning',
|
||||||
sprintf(
|
sprintf(
|
||||||
'Failed to create order tracking information. PayPal API response: %1$s',
|
'Failed to create order tracking information. PayPal API response: %1$s',
|
||||||
$error->getMessage()
|
$error->getMessage()
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'args' => $args,
|
'args' => $args,
|
||||||
'response' => $response,
|
'response' => $response,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
throw $error;
|
throw $error;
|
||||||
}
|
}
|
||||||
|
|
||||||
update_post_meta($order_id, '_ppcp_paypal_tracking_number', $data['tracking_number']);
|
update_post_meta( $order_id, '_ppcp_paypal_tracking_number', $data['tracking_number'] );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the tracking information of a given order.
|
* Gets the tracking information of a given order.
|
||||||
*
|
*
|
||||||
* @param int $wc_order_id The order ID.
|
* @param int $wc_order_id The order ID.
|
||||||
* @return array The tracking information.
|
* @return array The tracking information.
|
||||||
* @psalm-return TrackingInfo
|
* @psalm-return TrackingInfo
|
||||||
*/
|
*/
|
||||||
public function get_tracking_information(int $wc_order_id) : array {
|
public function get_tracking_information( int $wc_order_id ) : array {
|
||||||
$wc_order = wc_get_order( $wc_order_id );
|
$wc_order = wc_get_order( $wc_order_id );
|
||||||
$transaction_id = $wc_order->get_transaction_id();
|
$transaction_id = $wc_order->get_transaction_id();
|
||||||
$tracking_number = get_post_meta($wc_order_id, '_ppcp_paypal_tracking_number', true);
|
$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);
|
$url = trailingslashit( $this->host ) . 'v1/shipping/trackers/' . $this->find_tracker_id( $transaction_id, $tracking_number );
|
||||||
|
|
||||||
$args = array(
|
$args = array(
|
||||||
'method' => 'GET',
|
'method' => 'GET',
|
||||||
'headers' => $this->request_headers(),
|
'headers' => $this->request_headers(),
|
||||||
);
|
);
|
||||||
|
|
||||||
$response = $this->request( $url, $args );
|
$response = $this->request( $url, $args );
|
||||||
|
|
||||||
if ( is_wp_error( $response ) ) {
|
if ( is_wp_error( $response ) ) {
|
||||||
$error = new RuntimeException(
|
$error = new RuntimeException(
|
||||||
'Could not fetch the tracking information.'
|
'Could not fetch the tracking information.'
|
||||||
);
|
);
|
||||||
$this->logger->log(
|
$this->logger->log(
|
||||||
'warning',
|
'warning',
|
||||||
$error->getMessage(),
|
$error->getMessage(),
|
||||||
array(
|
array(
|
||||||
'args' => $args,
|
'args' => $args,
|
||||||
'response' => $response,
|
'response' => $response,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
throw $error;
|
throw $error;
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = json_decode( $response['body'] );
|
$data = json_decode( $response['body'] );
|
||||||
$status_code = (int) wp_remote_retrieve_response_code( $response );
|
$status_code = (int) wp_remote_retrieve_response_code( $response );
|
||||||
|
|
||||||
if ( 200 !== $status_code ) {
|
if ( 200 !== $status_code ) {
|
||||||
return [];
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'transaction_id' => $data->transaction_id ?? '',
|
'transaction_id' => $data->transaction_id ?? '',
|
||||||
'status' => $data->status ?? '',
|
'status' => $data->status ?? '',
|
||||||
'tracking_number' => $data->tracking_number ?? '',
|
'tracking_number' => $data->tracking_number ?? '',
|
||||||
'carrier' => $data->carrier ?? '',
|
'carrier' => $data->carrier ?? '',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the tracking information of a given order with the given data.
|
* Updates the tracking information of a given order with the given data.
|
||||||
*
|
*
|
||||||
* @param array $data The tracking information to update.
|
* @param array $data The tracking information to update.
|
||||||
* @psalm-param TrackingInfo $data
|
* @psalm-param TrackingInfo $data
|
||||||
* @param int $order_id The order ID.
|
* @param int $order_id The order ID.
|
||||||
* @throws RuntimeException If problem updating.
|
* @throws RuntimeException If problem updating.
|
||||||
*/
|
*/
|
||||||
public function update_tracking_information(array $data, int $order_id) : void {
|
public function update_tracking_information( array $data, int $order_id ) : void {
|
||||||
$tracking_info = $this->get_tracking_information($order_id);
|
$tracking_info = $this->get_tracking_information( $order_id );
|
||||||
$transaction_id = $tracking_info['transaction_id'] ?? '';
|
$transaction_id = $tracking_info['transaction_id'] ?? '';
|
||||||
$tracking_number = $tracking_info['tracking_number'] ?? '';
|
$tracking_number = $tracking_info['tracking_number'] ?? '';
|
||||||
$url = trailingslashit( $this->host ) . 'v1/shipping/trackers/'. $this->find_tracker_id($transaction_id, $tracking_number);
|
$url = trailingslashit( $this->host ) . 'v1/shipping/trackers/' . $this->find_tracker_id( $transaction_id, $tracking_number );
|
||||||
|
|
||||||
$args = array(
|
$args = array(
|
||||||
'method' => 'PUT',
|
'method' => 'PUT',
|
||||||
'headers' => $this->request_headers(),
|
'headers' => $this->request_headers(),
|
||||||
'body' => wp_json_encode( $data ),
|
'body' => wp_json_encode( $data ),
|
||||||
);
|
);
|
||||||
|
|
||||||
$response = $this->request( $url, $args );
|
$response = $this->request( $url, $args );
|
||||||
|
|
||||||
if ( is_wp_error( $response ) ) {
|
if ( is_wp_error( $response ) ) {
|
||||||
$error = new RuntimeException(
|
$error = new RuntimeException(
|
||||||
'Could not update order tracking information.'
|
'Could not update order tracking information.'
|
||||||
);
|
);
|
||||||
$this->logger->log(
|
$this->logger->log(
|
||||||
'warning',
|
'warning',
|
||||||
$error->getMessage(),
|
$error->getMessage(),
|
||||||
array(
|
array(
|
||||||
'args' => $args,
|
'args' => $args,
|
||||||
'response' => $response,
|
'response' => $response,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
throw $error;
|
throw $error;
|
||||||
}
|
}
|
||||||
|
|
||||||
$json = json_decode( $response['body'] );
|
$json = json_decode( $response['body'] );
|
||||||
$status_code = (int) wp_remote_retrieve_response_code( $response );
|
$status_code = (int) wp_remote_retrieve_response_code( $response );
|
||||||
if ( 204 !== $status_code ) {
|
if ( 204 !== $status_code ) {
|
||||||
$error = new PayPalApiException(
|
$error = new PayPalApiException(
|
||||||
$json,
|
$json,
|
||||||
$status_code
|
$status_code
|
||||||
);
|
);
|
||||||
$this->logger->log(
|
$this->logger->log(
|
||||||
'warning',
|
'warning',
|
||||||
sprintf(
|
sprintf(
|
||||||
'Failed to update the order tracking information. PayPal API response: %1$s',
|
'Failed to update the order tracking information. PayPal API response: %1$s',
|
||||||
$error->getMessage()
|
$error->getMessage()
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'args' => $args,
|
'args' => $args,
|
||||||
'response' => $response,
|
'response' => $response,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
throw $error;
|
throw $error;
|
||||||
}
|
}
|
||||||
|
|
||||||
update_post_meta($order_id, '_ppcp_paypal_tracking_number', $data['tracking_number']);
|
update_post_meta( $order_id, '_ppcp_paypal_tracking_number', $data['tracking_number'] );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The nonce.
|
* The nonce.
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function nonce(): string {
|
public static function nonce(): string {
|
||||||
return self::ENDPOINT;
|
return self::ENDPOINT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extracts the needed tracking information from given request data.
|
* Extracts the needed tracking information from given request data.
|
||||||
*
|
*
|
||||||
* @param array $data The request data map.
|
* @param array $data The request data map.
|
||||||
* @psalm-param RequestValues $data
|
* @psalm-param RequestValues $data
|
||||||
* @return array A map of tracking information keys to values.
|
* @return array A map of tracking information keys to values.
|
||||||
* @psalm-return TrackingInfo
|
* @psalm-return TrackingInfo
|
||||||
*/
|
*/
|
||||||
protected function extract_tracking_information(array $data): array {
|
protected function extract_tracking_information( array $data ): array {
|
||||||
return array(
|
return array(
|
||||||
'transaction_id' => $data['transaction_id'] ?? '',
|
'transaction_id' => $data['transaction_id'] ?? '',
|
||||||
'tracking_number' => $data['tracking_number'] ?? '',
|
'tracking_number' => $data['tracking_number'] ?? '',
|
||||||
'status' => $data['status'] ?? '',
|
'status' => $data['status'] ?? '',
|
||||||
'carrier' => $data['carrier'] ?? '',
|
'carrier' => $data['carrier'] ?? '',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the request headers.
|
* Creates the request headers.
|
||||||
*
|
*
|
||||||
* @return array The request headers.
|
* @return array The request headers.
|
||||||
*/
|
*/
|
||||||
protected function request_headers(): array {
|
protected function request_headers(): array {
|
||||||
return array(
|
return array(
|
||||||
'Authorization' => 'Bearer ' . $this->bearer->bearer()->token(),
|
'Authorization' => 'Bearer ' . $this->bearer->bearer()->token(),
|
||||||
'Content-Type' => 'application/json',
|
'Content-Type' => 'application/json',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds the tracker ID from given transaction ID and tracking number.
|
* Finds the tracker ID from given transaction ID and tracking number.
|
||||||
*
|
*
|
||||||
* @param string $transaction_id The transaction ID.
|
* @param string $transaction_id The transaction ID.
|
||||||
* @param string $tracking_number The tracking number.
|
* @param string $tracking_number The tracking number.
|
||||||
* @return string The tracker ID.
|
* @return string The tracker ID.
|
||||||
*/
|
*/
|
||||||
protected function find_tracker_id(string $transaction_id, string $tracking_number): string {
|
protected function find_tracker_id( string $transaction_id, string $tracking_number ): string {
|
||||||
return !empty($tracking_number) ? "{$transaction_id}-{$tracking_number}" : "{$transaction_id}-NOTRACKER";
|
return ! empty( $tracking_number ) ? "{$transaction_id}-{$tracking_number}" : "{$transaction_id}-NOTRACKER";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue