发卡机构账号配置

前提条件

请务必先完成以下步骤,然后再继续:

确定要启用智能触碰功能的账号

在继续操作之前,您需要确定哪个账号将指定为 兑换发卡机构账号。确定这一点的方法有两种:

创建新的发卡机构账号

新账号的账号联系信息中必须包含商家的 信息。有关如何在 Google Pay 和钱包 请参阅此 支持文章 以下代码示例演示了如何使用 Google Wallet API:

Java

/**
 * Create a new Google Wallet Issuer account.
 *
 * @param issuerName The Issuer's name.
 * @param issuerEmail The Issuer's email address.
 * @throws IOException
 */
public void CreateIssuerAccount(String issuerName, String issuerEmail) throws IOException {
  // New Issuer information
  Issuer issuer =
      new Issuer()
          .setName(issuerName)
          .setContactInfo(new IssuerContactInfo().setEmail(issuerEmail));

  Issuer response = service.issuer().insert(issuer).execute();

  System.out.println("Issuer insert response");
  System.out.println(response.toPrettyString());
}

PHP

/**
 * Create a new Google Wallet issuer account.
 *
 * @param string $issuerName The Issuer's name.
 * @param string $issuerEmail The Issuer's email address.
 */
public function createIssuerAccount(string $issuerName, string $issuerEmail)
{
  // New Issuer information
  $issuer = new Google_Service_Walletobjects_Issuer([
    'name' => $issuerName,
    'contactInfo' => new Google_Service_Walletobjects_IssuerContactInfo([
      'email' => $issuerEmail,
    ]),
  ]);

  $response = $this->service->issuer->insert($issuer);

  print "Issuer insert response\n";
  print_r($response);
}

Python

def create_issuer_account(self, issuer_name: str, issuer_email: str):
    """Create a new Google Wallet Issuer account.

    Args:
        issuer_name (str): The Issuer's name.
        issuer_email (str): The Issuer's email address.
    """
    # New Issuer information
    issuer = {'name': issuer_name, 'contactInfo': {'email': issuer_email}}

    # Make the POST request
    response = self.http_client.post(url=self.issuer_url, json=issuer)

    print('Issuer insert response')
    print(response.text)

C#

/// <summary>
/// Create a new Google Wallet Issuer account.
/// </summary>
/// <param name="issuerName">The Issuer's name.</param>
/// <param name="issuerEmail">The Issuer's email address.</param>
public void CreateIssuerAccount(string issuerName, string issuerEmail)
{
  // New issuer information
  Issuer issuer = new Issuer()
  {
    ContactInfo = new IssuerContactInfo()
    {
      Email = issuerEmail
    },
    Name = issuerName,
  };

  Stream responseStream = service.Issuer
      .Insert(issuer)
      .ExecuteAsStream();
  StreamReader responseReader = new StreamReader(responseStream);
  JObject jsonResponse = JObject.Parse(responseReader.ReadToEnd());

  Console.WriteLine("Issuer insert response");
  Console.WriteLine(jsonResponse.ToString());
}

Node.js

/**
 * Create a new Google Wallet Issuer account.
 *
 * @param {string} issuerName The Issuer's name.
 * @param {string} issuerEmail The Issuer's email address.
 */
async createIssuerAccount(issuerName, issuerEmail) {
  // New Issuer information
  let issuer = {
    name: issuerName,
    contactInfo: {
      email: issuerEmail
    }
  };

  let response = await this.httpClient.request({
    url: this.issuerUrl,
    method: 'POST',
    data: issuer
  });

  console.log('Issuer insert response');
  console.log(response);
}

最初,只有创建发卡机构的主账号(服务账号或用户) 账号拥有访问权限。您需要更新发卡机构的权限 添加应该能够 管理卡券。以下代码示例演示了如何更新发卡机构 账号权限。

Java

/**
 * Update permissions for an existing Google Wallet Issuer account.
 *
 * <p><strong>Warning:</strong> This operation overwrites all existing permissions!
 *
 * <p>Example permissions list argument below. Copy the add entry as needed for each email address
 * that will need access. Supported values for role are: 'READER', 'WRITER', and 'OWNER'
 *
 * <pre><code>
 * ArrayList<Permission> permissions = new ArrayList<Permission>();
 * permissions.add(new Permission().setEmailAddress("emailAddress").setRole("OWNER"));
 * </code></pre>
 *
 * @param issuerId The Issuer ID being used for this request.
 * @param permissions The list of email addresses and roles to assign.
 * @throws IOException
 */
public void UpdateIssuerAccountPermissions(String issuerId, ArrayList<Permission> permissions)
    throws IOException {

  Permissions response =
      service
          .permissions()
          .update(
              Long.parseLong(issuerId),
              new Permissions().setIssuerId(Long.parseLong(issuerId)).setPermissions(permissions))
          .execute();

  System.out.println("Issuer permissions update response");
  System.out.println(response.toPrettyString());
}

PHP

/**
 * Update permissions for an existing Google Wallet Issuer account.
 *
 * **Warning:** This operation overwrites all existing permissions!
 *
 * Example permissions list argument below. Copy the entry as
 * needed for each email address that will need access. Supported
 * values for role are: 'READER', 'WRITER', and 'OWNER'
 *
 * $permissions = array(
 *  new Google_Service_Walletobjects_Permission([
 *    'emailAddress' => 'email-address',
 *    'role' => 'OWNER',
 *  ]),
 * );
 *
 * @param string $issuerId The Issuer ID being used for this request.
 * @param array $permissions The list of email addresses and roles to assign.
 */
public function updateIssuerAccountPermissions(string $issuerId, array $permissions)
{
  // Make the PUT request
  $response = $this->service->permissions->update(
    $issuerId,
    new Google_Service_Walletobjects_Permissions([
      'issuerId' => $issuerId,
      'permissions' => $permissions,
    ])
  );

  print "Permissions update response\n";
  print_r($response);
}

Python

def update_issuer_account_permissions(self, issuer_id: str,
                                      permissions: List):
    """Update permissions for an existing Google Wallet Issuer account.

    **Warning:** This operation overwrites all existing permissions!

    Example permissions list argument below. Copy the dict entry as
    needed for each email address that will need access. Supported
    values for role are: 'READER', 'WRITER', and 'OWNER'

    permissions = [
        {
            'emailAddress': 'email-address',
            'role': 'OWNER'
        }
    ]

    Args:
        issuer_id (str): The Issuer ID being used for this request.
        permissions (List): The list of email addresses and roles to assign.
    """
    response = self.http_client.put(url=f'{self.permissions_url}/{issuer_id}',
                                    json={
                                        'issuerId': issuer_id,
                                        'permissions': permissions
                                    })

    print('Permissions update response')
    print(response.text)

C#

/// <summary>
/// Update permissions for an existing Google Wallet Issuer account.
/// <para />
/// <strong>Warning:</strong> This operation overwrites all existing permissions!
/// <para />
/// Example permissions list argument below. Copy the add entry as needed for each email
/// address that will need access.Supported values for role are: 'READER', 'WRITER', and 'OWNER'
/// <para />
/// <![CDATA[List&lt;Permission> permissions = new List&lt;Permission>();]]>
/// <para />
/// permissions.Add(new Permission { EmailAddress = "emailAddress", Role = "OWNER"});
/// </summary>
/// <param name="issuerId">The issuer ID being used for this request.</param>
/// <param name="permissions">The list of email addresses and roles to assign.</param>
public void UpdateIssuerAccountPermissions(string issuerId, List<Permission> permissions)
{
  Stream responseStream = service.Permissions
      .Update(new Permissions
      {
        IssuerId = long.Parse(issuerId),
        PermissionsValue = permissions
      },
      long.Parse(issuerId))
      .ExecuteAsStream();
  StreamReader responseReader = new StreamReader(responseStream);
  JObject jsonResponse = JObject.Parse(responseReader.ReadToEnd());

  Console.WriteLine("Issuer permissions update response");
  Console.WriteLine(jsonResponse.ToString());
}

Node.js

/**
 * Update permissions for an existing Google Wallet Issuer account.
 *
 * **Warning:** This operation overwrites all existing permissions!
 *
 * Example permissions list argument below. Copy the dict entry as
 * needed for each email address that will need access. Supported
 * values for role are: 'READER', 'WRITER', and 'OWNER'
 *
 * let permissions = [
 *  {
 *    'emailAddress': 'email-address',
 *    'role': 'OWNER',
 *  },
 * ];
 *
 * @param {string} issuerId The Issuer ID being used for this request.
 * @param {Array} permissions The list of email addresses and roles to assign.
 */
async updateIssuerPermissions(issuerId, permissions) {
  let response = await this.httpClient.request({
    url: `${this.permissionsUrl}/${issuerId}`,
    method: 'PUT',
    data: {
      issuerId: issuerId,
      permissions: permissions
    }
  });

  console.log('Permissions update response');
  console.log(response);
}

使用现有账号

应使用以下条件来确定您是否可以使用 Issuer 包含现有卡券类的账号。

  • 如果用于开发卡券的发卡机构账号包含 您必须代表 商家。
  • 如果用于开发卡券的发卡机构账号仅包含类 可以使用该标识符

如果账号满足这些条件,您必须更新联系信息 包含商家信息 name 标识商家。只有您才拥有此账号的 API 访问权限。 其他卡券开发者应创建自己的发卡机构账号。

兑换发卡机构账号配置

使用 Google Pay 和钱包控制台

在兑换发卡机构账号中,您需要按照以下步骤操作:

  1. 前往 Google Wallet API 部分
  2. 选择其他功能
  3. 选择添加身份验证密钥
  4. 上传公钥(.pem 文件)并指定密钥版本
  5. 选择创建身份验证密钥

身份验证密钥获取后,系统就会向您提供收款方 ID 已成功上传。

-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEchyXj869zfmKhRi9xP7f2AK07kEo
4lE7ZlWTN14jh4YBTny+hRGRXcUzevV9zSSPJlPHpqqu5pEwlv1xyFvE1w==
-----END PUBLIC KEY-----

使用 Google Wallet API

上传公钥

要使用 Google Wallet API 分配公钥和密钥版本,您需要: 需要向 Issuers 端点发出 PATCH 请求。

PATCH https://walletobjects.googleapis.com/walletobjects/v1/issuer/{issuerId}

PATCH 请求正文类似于以下内容:

{
    "smartTapMerchantData": {
        "authenticationKeys": [
            {
                "id": 1,
                "publicKeyPem": "-----BEGIN PUBLIC KEY-----\n...\n-----END PUBLIC KEY-----"
            },
            {
                "id": 2,
                "publicKeyPem": "-----BEGIN PUBLIC KEY-----\n...\n-----END PUBLIC KEY-----"
            }
        ]
    }
}

以下代码示例演示了如何更新发卡机构账号以包含 演示公钥:

Java

/**
 * Add a new public key to an Issuer account.
 *
 * @param issuerId The issuer ID being used for this request.
 * @throws IOException
 */
public void AddSmartTapKey(Long issuerId) throws IOException {
  // New smart tap key information
  Issuer patchBody =
      new Issuer()
          .setSmartTapMerchantData(
              new SmartTapMerchantData()
                  .setAuthenticationKeys(
                      Arrays.asList(
                          new AuthenticationKey()
                              .setId(1)
                              .setPublicKeyPem(
                                  "-----BEGIN PUBLIC KEY-----\n"
                                      + "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEchyXj869zfmKhRi9xP7f2AK07kEo\n"
                                      + "4lE7ZlWTN14jh4YBTny+hRGRXcUzevV9zSSPJlPHpqqu5pEwlv1xyFvE1w==\n"
                                      + "-----END PUBLIC KEY-----"))));

  Issuer response = service.issuer().patch(issuerId, patchBody).execute();

  System.out.println("Issuer patch response");
  System.out.println(response.toPrettyString());
}

PHP

/**
 * Add a new public key to an Issuer account.
 *
 * @param string $issuerId The issuer ID being used for this request.
 */
public function addSmartTapKey(string $issuerId)
{
  // New smart tap key information
  $patchBody = new Google_Service_Walletobjects_Issuer([
    'smartTapMerchantData' => new Google_Service_Walletobjects_SmartTapMerchantData([
      'authenticationKeys' => [
        new Google_Service_Walletobjects_AuthenticationKey([
          'id' => 1,
          'publicKeyPem' => "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEchyXj869zfmKhRi9xP7f2AK07kEo\n4lE7ZlWTN14jh4YBTny+hRGRXcUzevV9zSSPJlPHpqqu5pEwlv1xyFvE1w==\n-----END PUBLIC KEY-----"
        ])
      ]
    ])
  ]);

  $response = $this->service->issuer->patch($issuerId, $patchBody);

  print "Issuer patch response\n";
  print_r($response);
}

Python

def add_smart_tap_key(self, issuer_id: str) -> str:
    """Add a new public key to an Issuer account.

    Args:
        issuer_id (str): The issuer ID being used for this request.
    """
    # New smart tap key information
    patch_body = {
        'smartTapMerchantData': {
            'authenticationKeys': [{
                'id':
                    1,
                'publicKeyPem':
                    '-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEchyXj869zfmKhRi9xP7f2AK07kEo\n4lE7ZlWTN14jh4YBTny+hRGRXcUzevV9zSSPJlPHpqqu5pEwlv1xyFvE1w==\n-----END PUBLIC KEY-----'
            }]
        }
    }

    # Make the PATCH request
    response = self.http_client.patch(url=f'{self.issuer_url}/{issuer_id}', json=patch_body)

    print('Issuer patch response')
    print(response.text)

    return response.json()['smartTapMerchantData']['smartTapMerchantId']

C#

/// <summary>
/// Add a new public key to an Issuer account.
/// </summary>
/// <param name="issuerId">The issuer ID being used for this request.</param>
public void AddSmartTapKey(long issuerId)
{
  // New smart tap key information
  Issuer patchBody = new Issuer()
  {
    SmartTapMerchantData = new SmartTapMerchantData
    {
      AuthenticationKeys = new List<AuthenticationKey>
      {
        new AuthenticationKey
        {
          Id = 1,
          PublicKeyPem = "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEchyXj869zfmKhRi9xP7f2AK07kEo\n4lE7ZlWTN14jh4YBTny+hRGRXcUzevV9zSSPJlPHpqqu5pEwlv1xyFvE1w==\n-----END PUBLIC KEY-----"
        }
      }
    }
  };

  Stream responseStream = service.Issuer
      .Patch(patchBody, issuerId)
      .ExecuteAsStream();
  StreamReader responseReader = new StreamReader(responseStream);
  JObject jsonResponse = JObject.Parse(responseReader.ReadToEnd());

  Console.WriteLine("Issuer patch response");
  Console.WriteLine(jsonResponse.ToString());
}

Node.js

/**
 * Add a new public key to an Issuer account.
 *
 * @param {string} issuerId The issuer ID being used for this request.
 */
async addSmartTapKey(issuerId) {
  // New smart tap key information
  let patchBody = {
    smartTapMerchantData: {
      authenticationKeys: [
        {
          id: 1,
          publicKeyPem: '-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEchyXj869zfmKhRi9xP7f2AK07kEo\n4lE7ZlWTN14jh4YBTny+hRGRXcUzevV9zSSPJlPHpqqu5pEwlv1xyFvE1w==\n-----END PUBLIC KEY-----'
        }
      ]
    }
  };

  let response = await this.httpClient.request({
    url: `${this.issuerUrl}/${issuerId}`,
    method: 'PATCH',
    data: patchBody
  });

  console.log('Issuer patch response');
  console.log(response);
}

响应将包含您发送的正文和一个额外字段, smartTapMerchantData.smartTapMerchantId。此字段代表 兑换发卡机构账号。

获取核销方 ID

添加任何密钥和密钥版本后,您可以使用 Google Wallet API 获取 向 Issuers 端点发出 GET 请求,以输入您的收款方 ID。

GET https://walletobjects.googleapis.com/walletobjects/v1/issuer/{issuerId}

Java

/**
 * Get the Collector ID for an Issuer account.
 *
 * @param issuerId The issuer ID being used for this request.
 * @return The Collector ID
 * @throws IOException
 */
public Long GetCollectorId(Long issuerId) throws IOException {
  Issuer response = service.issuer().get(issuerId).execute();

  System.out.println("Issuer patch response");
  System.out.println(response.toPrettyString());

  return response.getSmartTapMerchantData().getSmartTapMerchantId();
}

PHP

/**
 * Get the Collector ID for an Issuer account.
 *
 * @param string $issuerId The issuer ID being used for this request.
 * @return string The Collector ID.
 */
public function getCollectorId(string $issuerId)
{
  $response = $this->service->issuer->get($issuerId);

  print "Issuer get response\n";
  print_r($response);

  return $response['smartTapMerchantData']['smartTapMerchantId'];
}

Python

def get_collector_id(self, issuer_id: str) -> str:
    """Get the Collector ID for an Issuer account.

    Args:
        issuer_id (str): The issuer ID being used for this request.
    """
    # Make the GET request
    response = self.http_client.get(url=f'{self.issuer_url}/{issuer_id}')

    print('Issuer get response')
    print(response.text)

    return response.json()['smartTapMerchantData']['smartTapMerchantId']

C#

/// <summary>
/// Get the Collector ID for an Issuer account.
/// </summary>
/// <param name="issuerId">The issuer ID being used for this request.</param>
/// <returns>The Collector ID</returns>
public string GetCollectorId(long issuerId)
{
  Stream responseStream = service.Issuer
      .Get(issuerId)
      .ExecuteAsStream();
  StreamReader responseReader = new StreamReader(responseStream);
  JObject jsonResponse = JObject.Parse(responseReader.ReadToEnd());

  Console.WriteLine("Issuer get response");
  Console.WriteLine(jsonResponse.ToString());

  return jsonResponse["smartTapMerchantData"]["smartTapMerchantId"].Value<string>();
}

Node.js

/**
 * Get the Collector ID for an Issuer account.
 *
 * @param {string} issuerId The issuer ID being used for this request.
 *
 * @returns {string} The Collector ID
 */
async getCollectorId(issuerId) {
  let response = await this.httpClient.request({
    url: `${this.issuerUrl}/${issuerId}`,
    method: 'GET'
  });

  console.log('Issuer patch response');
  console.log(response);

  return response.data.smartTapMerchantData.smartTapMerchantId;
}

响应将包含 smartTapMerchantData.smartTapMerchantId 字段。 这是兑换发卡机构账号的收款方 ID。

发卡机构账号管理

卡券组织

管理卡券类和对象的两种常用方法 多个商家:

  • 所有商家使用一个集中的发卡机构账号
  • 每个商家有一个新的发卡机构账号

例如,Foo-Loyalty 为两个商家分别管理不同的会员回馈活动: ILuvCoffee 和 TeaLuv。其卡券类可在以下任一位置进行管理: 方法:

做法 说明
单一发行方账号 在一个发卡机构下包含所有会员卡类 账号“Foo-Loyalty”建议使用此选项 如果您打算跟踪您的卡券在哪里 都是在类级别兑换的。它也是 如果您从不向商家授予 对该发卡机构账号的 API 访问权限。
单独的发卡机构账号 创建两个单独的发卡机构账号:“iLuvCoffee” 通过 Foo-Loyalty”以及“teaLuv via Foo-Loyalty”。 如果您希望 特定发卡机构账号下的所有类 可在商家级别兑换,或者 您计划向 merchants API 授予 发卡机构账号。

兑换发卡机构账号

确定正确的兑换时,需要考虑以下两种情况 要使用的发卡机构账号。

场景 1:商家已在使用智能触碰

如果商家确认他们已经使用自己的 终端(商家已设置为兑换发卡机构),请按照 具体步骤如下:

  1. 申请商家的兑换发卡机构 ID
  2. 将商家的兑换发卡机构 ID 添加到 redemptionIssuers 属性 (与卡券类相关联)

场景 2:商家初次使用智能触碰功能

在这种情况下,商家拥有支持智能触碰但还不支持的终端 是否使用了该功能商家、终端提供商或卡券开发者 需要执行一次性设置,才能在商家的终端上启用智能触碰功能。

如需了解详情,请参阅 商家配置