钱包应用程序未调用或调用 webServiceURL

问题描述 投票:0回答:1

让我提供一些背景信息: 我正在做一个项目,有几个商店,每个商店根据(买X - 送Y)模型定义自己的报价,例如:买6个咖啡杯免费送2个,并生成一个二维码这个优惠

用户无需下载任何应用程序,只需扫描二维码,即可为他生成 storeCard 类型的通行证,然后他将使用 iPhone 设备上的钱包应用程序添加此通行证

整个实现是使用 Laravel 框架并使用此包https://github.com/thenextweb/passgenerator

thenextweb/passgenerator
)来实现生成通行证的功能

如此处所述:https://developer.apple.com/library/archive/documentation/PassKit/Reference/PassKit_WebService/WebService.html 我们需要定义一个

webServiceURL
,我在我的代码中定义了它,看起来像这样

<?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
,它也不会被调用。

我什至创建了一个记录所有请求的中间件,并尝试查看是否正在调用此 URL,但似乎没有。

该 URL 已安装 SSL。

php laravel apple-wallet
1个回答
0
投票

你好,我也有同样的问题,你解决这个问题了吗?

© www.soinside.com 2019 - 2024. All rights reserved.