googleapis / googleapis/google-api-php-client

Merchant API: CarrierService is never accepted

Open
#2,675 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
9.8k
Forks
3.5k
PR merge metrics
No merged PRs in 30d

Description

#### Environment details

- OS: macOS Sequoia
- PHP version: 8.3
- Package name and version: "google/apiclient": "^2.15",

#### Objective

1. Target is to sync shipping rates together with "warehouseBasedDeliveryTimes" to the Merchant Center.

```php
$shoppingContentService = new ShoppingContent($client);
$shoppingContentService->shippingsettings->update(
merchantId: $merchantId,
accountId: $merchantId,
postBody: $payload
);
```

#### Example Payload
```json
{
"accountId": null,
"services": [
{
"active": true,
"currency": "EUR",
"deliveryCountry": "DE",
"eligibility": null,
"name": "Express Shipping DE",
"shipmentType": null,
"rateGroups": [
{
"applicableShippingLabels": null,
"name": null,
"mainTable": {
"name": null,
"rowHeaders": {
"numberOfItems": null,
"postalCodeGroupNames": null,
"weights": [
{ "unit": "kg", "value": "1" },
{ "unit": "kg", "value": "infinity" }
]
},
"rows": [
{
"cells": [
{
"flatRate": {
"currency": "EUR",
"value": "12.4"
}
}
]
},
{
"cells": [
{
"flatRate": {
"currency": "EUR",
"value": "12.4"
}
}
]
}
]
}
}
],
"deliveryTime": {
"maxHandlingTimeInDays": null,
"maxTransitTimeInDays": null,
"minHandlingTimeInDays": null,
"minTransitTimeInDays": null,
"warehouseBasedDeliveryTimes": [
{
"carrier": "DHL",
"carrierService": "ExpressEasy",
"originAdministrativeArea": "Berlin",
"originCity": "Berlin",
"originCountry": "DE",
"originPostalCode": "12345",
"originStreetAddress": "Street 1",
"warehouseName": "Warehouse 1"
}
]
}
}
]
}
```

#### Issue
No matter what you insert as `deliveryTime.warehouseBasedDeliveryTimes.carrierService`, it will always be rejected. Setting the value via Merchant Center UI works.

```shell
❌ An error occurred:
Message: {
"error": {
"code": 400,
"message": "[services[0].deliveryTime.warehouseBasedDeliveryTimes[0].carrierService] Unknown carrier service: ExpressEasy for carrier: DHL",
"errors": [
{
"message": "[services[0].deliveryTime.warehouseBasedDeliveryTimes[0].carrierService] Unknown carrier service: ExpressEasy for carrier: DHL",
"domain": "global",
"reason": "invalid"
}
]
}
}

File: /app/vendor/google/apiclient/src/Http/REST.php on line 134
```

#### How to find valid options?
```php
$shoppingContentService = new ShoppingContent($client);
$response = $shoppingContentService->shippingsettings->getsupportedcarriers($merchantId);
$carriers = $response->getCarriers();
```

**Output:**
```shell
...

{
"country": "DE",
"eddServices": [
"Paket Domestic",
"P\u00e4ckchen Domestic",
"ExpressEasy",
"Express 9am",
"Express Domestic",
"Express Envelope",
"Express 12pm"
],
"name": "DHL",
"services": [
"Paket",
"P\u00e4ckchen"
]
}

...
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.