Konfigurasi akun penerbit

Prasyarat

Pastikan Anda menyelesaikan langkah-langkah berikut sebelum melanjutkan:

Menentukan akun yang akan diaktifkan untuk Smart Tap

Sebelum melanjutkan, Anda perlu mengidentifikasi akun mana yang akan ditetapkan sebagai akun Penerbit Penukaran. Ada dua cara untuk menentukannya:

Membuat Akun Penerbit baru

Informasi kontak akun untuk akun baru harus berisi informasi tidak akurat atau tidak sesuai. Untuk petunjuk tentang cara melakukannya di Google Pay & Dompet Konsol, lihat artikel dukungan Contoh kode berikut menunjukkan pembuatan Akun penerbit menggunakan API Google Wallet:

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);
}

Awalnya, hanya akun utama (akun layanan atau pengguna) yang membuat Penerbit akun Anda akan memiliki akses. Anda perlu memperbarui izin Penerbit akun untuk mencakup pengguna atau akun layanan tambahan yang seharusnya dapat untuk mengelola kartu. Contoh kode berikut menunjukkan cara memperbarui Penerbit izin akun.

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);
}

Gunakan akun yang sudah ada

Kriteria berikut harus digunakan untuk menentukan apakah Anda dapat menggunakan Penerbit yang berisi class kartu yang sudah ada.

  • Jika akun Penerbit untuk pengembangan kartu berisi class untuk penjual lain, Anda harus menyiapkan akun baru atas nama penjual.
  • Jika akun penerbit untuk pengembangan kartu hanya berisi class untuk penjual tertentu, akun tersebut dapat digunakan.

Jika akun memenuhi kriteria ini, Anda harus memperbarui informasi kontak di Profil Bisnis dengan informasi penjual untuk memastikan akun nama tersebut mengidentifikasi penjual. Hanya Anda yang boleh memiliki akses API ke akun ini. Developer kartu tambahan harus membuat akun Penerbit sendiri.

Konfigurasi akun Penerbit Penukaran

Gunakan Google Pay & Konsol Wallet

Di akun Penerbit Penukaran, Anda harus mengikuti langkah-langkah berikut:

  1. Buka bagian Google Wallet API
  2. Pilih Fitur tambahan
  3. Pilih Add an authentication key
  4. Upload kunci publik (file .pem) dan tentukan versi kunci
  5. Pilih Create authentication key

ID Kolektor akan diberikan kepada Anda setelah kunci autentikasi berhasil diunggah.

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

Menggunakan Google Wallet API

Mengupload kunci publik

Untuk menetapkan kunci publik dan versi kunci menggunakan Google Wallet API, Anda harus membuat permintaan PATCH ke endpoint Penerbit.

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

Isi permintaan PATCH akan terlihat seperti berikut:

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

Contoh kode berikut menunjukkan cara memperbarui akun Penerbit untuk menyertakan kunci publik demo yang disebutkan sebelumnya:

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);
}

Respons akan mencakup {i>body<i} yang Anda kirim dan isian tambahan, smartTapMerchantData.smartTapMerchantId. Ini adalah ID Kolektor Akun Penerbit Penukaran.

Mendapatkan ID Kolektor

Setelah menambahkan kunci dan versi kunci, Anda dapat menggunakan Google Wallet API untuk mendapatkan ID Kolektor Anda dengan membuat permintaan GET ke endpoint Penerbit.

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;
}

Responsnya akan menyertakan kolom, smartTapMerchantData.smartTapMerchantId. Ini adalah ID Kolektor akun Penerbit Penukaran.

Pengelolaan akun penerbit

Lulus organisasi

Ada dua pendekatan umum untuk mengelola class dan objek kartu untuk beberapa penjual:

  • Satu akun Penerbit pusat untuk semua penjual
  • Satu akun Penerbit baru untuk setiap penjual

Misalnya, Foo-Loyalty mengelola program loyalitas terpisah untuk dua penjual: ILuvCoffee dan TeaLuv. Kelas kartu mereka dapat dikelola di salah satu cara berikut:

Pendekatan Deskripsi
Rekening Penerbit Tunggal Berisi semua kelas loyalitas di bawah satu Penerbit akun "Foo-Loyalty". Opsi ini direkomendasikan jika berencana untuk melacak di mana kartu Anda dapat ditukarkan di tingkat kelas. Hal ini juga opsi yang bagus jika Anda tidak pernah memberikan izin kepada penjual Akses API ke akun Penerbit tersebut.
Akun Penerbit Terpisah Buat dua akun Penerbit yang berbeda: "iLuvCoffee melalui Foo-Loyalty" dan "teaLuv via Foo-Loyalty." Opsi ini direkomendasikan jika Anda ingin mengasumsikan bahwa semua kelas pada akun Penerbit tertentu dapat ditukarkan di tingkat penjual, atau jika Anda berencana untuk memberi penjual akses API ke Akun penerbit.

Akun Penerbit Penukaran

Ada dua skenario yang perlu dipertimbangkan saat menentukan Penukaran yang benar Akun penerbit yang akan digunakan.

Skenario 1: Penjual sudah menggunakan Smart Tap

Jika penjual mengonfirmasi bahwa mereka sudah dapat menukarkan penawaran dari Google Wallet dengan terminal (penjual sudah disiapkan sebagai Penerbit Penukaran), ikuti langkah-langkah di bawah ini:

  1. Minta ID Penerbit Penukaran penjual
  2. Tambahkan ID Penerbit Penukaran penjual ke properti redemptionIssuers dari class kartu Anda

Skenario 2: Penjual baru menggunakan Smart Tap

Dalam skenario ini, penjual memiliki terminal yang mendukung Smart Tap tetapi belum memanfaatkan fitur tersebut. Penjual, penyedia terminal, atau developer kartu akan perlu melakukan penyiapan satu kali untuk mengaktifkan Smart Tap di terminal penjual.

Untuk informasi selengkapnya, lihat Konfigurasi penjual.