You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

iPhone钱包应用未调用PassKit的webServiceURL问题求助

问题:Apple Wallet未调用Pass的webServiceURL

我正在开发一个多店铺项目,支持店铺创建「买X送Y」类型的优惠活动(例如买6杯咖啡送2杯),并生成对应优惠的二维码。用户无需下载APP,扫描二维码即可生成storeCard类型的Pass,添加到iPhone钱包应用中。

项目基于Laravel框架开发,使用thenextweb/passgenerator包实现Pass生成功能。按照Apple PassKit文档要求,我已在代码中定义了webServiceURL,但iPhone钱包应用始终未调用该URL。我已添加日志中间件监控请求,未发现相关调用记录,且该URL已配置合法的SSL证书。

<?php

namespace App\Services;

use App\Models\Offer;
use Illuminate\Support\Str;
use Thenextweb\Definitions\Coupon;
use Thenextweb\PassGenerator;

class PassService
{
    public function generate(
        int          $offer_id,
        string       $description,
        string|array $assets = NULL
    ) {
        // dd(url("item.png"));
        $offer = Offer::findOrFail($offer_id);
        $facility = $offer->facility;

        $pass = new PassGenerator();
        $serial = Str::uuid();

        // $auxiliaryFields = [];

        // for ($i = 0; $i < $offer->info->purchased_items_count; $i++) {
        //     $temp = [
        //         "key" => "item",
        //         "label" => "Offer Item",
        //         "value" => "Test",
        //         // "icon" => url("item.png")
        //         "icon" => [
        //             "data" => base64_encode(file_get_contents(public_path("item.png"))),
        //             "mime" => "image/png",
        //             "filename" => "item.png"
        //         ]
        //     ];
        //     $auxiliaryFields[] = $temp;
        // }

        $pass_definition = [
            "organizationName" => $facility->name,
            "backgroundColor" => "rgb(212, 212, 212)",
            "foregroundColor" => "rgb(99, 99, 99)",
            "logoText" => $description,
            "locations" => [
                (object)[
                    "altitude" => 50,
                    "latitude" => 37.33211150000000344562067766673862934112548828125,
                    "longitude" => -122.0307624000000004116373020224273204803466796875,
                    "relevantText" => "This is a test"
                ]
            ],
            "barcode" => [

                "message" => $description,
                "format" => "PKBarcodeFormatQR",
                "messageEncoding" => "utf-8",
            ],
            "storeCard" => [
                "headerFields" => [
                    [
                        "key" => "offer_name",
                        "label" => "Offer Name",
                        "value" => $offer->name
                    ]
                ],
                "primaryFields" => [
                    [
                        "key" => "offer_type",
                        "label" => "Offer Type",
                        "value" => Str::replace("_", " ", $offer->offer_type),
                    ],
                ],
                "backFields" => [
                    [
                        "key" => "purchased_items_count",
                        "label" => "Purchased Items Count",
                        "value" => $offer->info->purchased_items_count,
                    ],
                    [
                        "key" => "offer_items_count",
                        "label" => "Offer Items Count",
                        "value" => $offer->info->offer_items_count,
                    ],
                ],
                // "auxiliaryFields" => $auxiliaryFields,
            ],
            "authenticationToken" => "0123456789ABCDEF",
            "webServiceURL" => url("offers/verify") . "/", //route('offers.verify'),
            "serialNumber" => $serial,
            "formatVersion" => 1,
            "description" => $description,
            "passTypeIdentifier" => "pass.ixcoders.alwalaa",
            "teamIdentifier" => "J2UMUTGYQC",
        ];

        // dd($pass_definition);
        $pass->setPassDefinition($pass_definition);

        if (!is_null($assets)) {
            if (is_array($assets)) {
                for ($i = 0; $i < count($assets); $i++) {
                    $asset = $assets[$i];
                    $pass->addAsset($asset);
                }
            } else {
                $pass->addAsset($assets);
            }
        }

        return $pass->create();
    }
}

恳请协助排查该问题,找出钱包应用未调用webServiceURL的原因。

内容的提问来源于stack exchange,提问作者Eyad Bereh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.22 13:05:02