Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Wechat Mini Program Insurance Freight Bundle Laravel Package

tourze/wechat-mini-program-insurance-freight-bundle

Integrates WeChat Mini Program freight insurance (运费险) into Tourze/Symfony PHP projects. Provides bundle configuration and service wiring for freight-insurance workflows, helping mini program commerce applications connect insurance features with minimal setup.

View on GitHub
Deep Wiki
Context7

Getting Started

This release (0.1.1) is a patch on top of 0.1.0 with no documented functional changes — the changelog only links the diff between 0.1.0...0.1.1, so treat it as a maintenance bump rather than a feature release. Since there is no prior assessment, start by verifying what you actually have installed before designing around it.

  1. Confirm the package type. tourze/*-bundle packages are Symfony-style bundles (a *Bundle class extending Symfony\Component\HttpKernel\Bundle\Bundle), not native Laravel service providers. Check composer.json for extra.laravel.providers / extra.laravel.aliases. If absent, you will need to register the provider (or the bundle's DI config) manually — see Gotchas.
  2. Read the source, not the changelog. Open src/ and look for the client/service class that talks to WeChat's freight-insurance (运费险) endpoints, plus any DependencyInjection/ configuration tree. The config keys there are your integration surface.
  3. Set up credentials first. WeChat mini-program freight insurance requires app_id, app_secret, and an access-token strategy. Get a sandbox/test mini-program before writing feature code — the API is not mockable in a meaningful way without one.
  4. First use case: quote/estimate freight insurance for an order, then bind a policy to an order. Those two calls cover the majority of real integrations; everything else (cancel, query policy, claim notices) is secondary.

Implementation Patterns

Wrap the client behind your own interface. Do not inject the vendor client directly into controllers or jobs. Define FreightInsuranceGateway with quote(), bind(), cancel(), query() and adapt the package to it. This is the single highest-value pattern here: the WeChat freight-insurance API surface is narrow but has churn, and 0.1.x is pre-1.0.

Token handling in a queued/cached context. Access tokens are per-app and short-lived. Resolve and cache them in a dedicated service (Cache::remember('wechat:token:'.$appId, ...)) and pass them in, rather than letting each call fetch. If the bundle owns token retrieval, decorate it so you can add a distributed lock — concurrent token refresh is the classic failure here.

Bind on order state transitions, not on checkout. Fire bind() from an event listener (OrderPaid, OrderShipped) inside a queued listener with $tries = 3 and exponential backoff. Insurance binding is an external side effect; it must not block the request that created it, and it must not be lost.

Idempotency keys from your own domain. Derive the outbound request identifier from order_id + operation, store it on the order (or a freight_insurance_policies table), and check it before every call. Retries after a timeout should reconcile via query() rather than re-bind().

Model the policy as a first-class record. A freight_insurance_policies table (order_id, policy_no, status, premium, raw_response json, timestamps) means you can retry, audit, and support finance without asking WeChat. Persist the raw response — the package's DTOs will change shape across 0.1.x.

Feature-flag it. Put a FREIGHT_INSURANCE_ENABLED config gate in front of the gateway so staging and local never hit the live API, and so you can disable it during a WeChat outage without a deploy.

Gotchas and Tips

  • Symfony bundle in a Laravel app. If there is no extra.laravel block, you must either register the bundle's services manually in a service provider (importing its services.xml/services.yaml) or use symfony/dependency-injection in parallel with the Laravel container — awkward and easy to get wrong. Test container resolution early with a single resolve() smoke test.
  • 0.1.x semantics. Pre-1.0 packages carry no BC guarantee. Pin an exact version ("0.1.1", not "^0.1") and read the diff before every bump. The 0.1.1 changelog gives you nothing to go on beyond the compare link — open that URL and read the actual commits before upgrading.
  • Signature and encoding. WeChat APIs are unforgiving about request body serialization (float vs. string amounts, empty-string vs. omitted fields, UTF-8). If you get signature mismatches, compare the raw outbound body byte-for-byte against the docs before blaming the package.
  • Silent config failures. Bundle config trees frequently have required nodes without validation; a missing app_id surfaces as an opaque HTTP error several layers down. Add a boot-time check in your own provider that throws on startup if required keys are unset.
  • Logging and debugging. Log the outbound request id, the response errcode/errmsg, and the HTTP status at info; log the full payload at debug with secrets scrubbed. WeChat's error codes are numeric and undocumented in the package — build a small map as you encounter them.
  • Timeouts and retries are not free. These endpoints are not all idempotent. Only retry query() automatically; gate bind() behind your own idempotency record.
  • Extension points to prefer. If the bundle exposes a configurable HTTP client or transport, inject a Laravel-configured client with your timeout/retry middleware. If it hard-codes one, decorate at the gateway layer instead of forking.
  • Watch for the Laravel sibling package. Tourze commonly publishes paired *-laravel packages; check Packagist before hand-rolling the service provider, and check again at 0.2.x — a provider appearing upstream is the natural moment to delete your glue code.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
mehedimi/laravel-amp-mail
happones/laravel-vue-i18n-generator
jwerd/inertia-table
siberfx/flysystem-wasabi
hollyit/token-replace
ippanelcom/laravel-sdk
adachsoft/changelog-linter
adachsoft/collection
payerurl/telegrambot-crypto-payment-instant-payout
dskripchenko/laravel-hybrid-search
riorizkyrainey/lara-ced
mehedimi/static-vel
zharp/zharp
nonsapiens/bigquery-model-sync
lgu-bayambang-ict-office/lgu-laravel-development-standards
andydefer/laravel-support
se7enxweb/flysystem
lampwick/laravel
jeslage/statamic-emojis
micahdshackelford/rmap-laravel