অ্যাকাউন্ট তৈরি করা

আপনি Merchant Center অ্যাকাউন্ট তৈরি করতে Merchant API ব্যবহার করতে পারেন, যা accountAggregation, accountManagement বা comparisonShopping ব্যবহার করে উন্নত অ্যাকাউন্টের সাথে লিঙ্ক করা যেতে পারে। এই accounts.createAndConfigure পদ্ধতি আপনাকে অ্যাকাউন্ট তৈরি করতে এবং ঐচ্ছিকভাবে ব্যবহারকারীদের সাথে এটি কনফিগার করতে এবং পরিষেবার মাধ্যমে অন্যান্য অ্যাকাউন্টের সাথে লিঙ্ক করতে দেয়।

এই নির্দেশিকায়, accountManagement, comparisonShopping বা accountAggregation-এর মতো পরিষেবা ব্যবহার করে অ্যাকাউন্ট তৈরি করতে Merchant API কীভাবে ব্যবহার করতে হয় তা ব্যাখ্যা করা হয়েছে। accounts.createAndConfigure ব্যবহার করার সময়, আপনাকে অবশ্যই service ফিল্ডে অন্তত একটি accountAggregation, accountManagement বা comparisonShopping উল্লেখ করে নতুন অ্যাকাউন্টটি কোনও পরিষেবা প্রদানকারীর সাথে লিঙ্ক করতে হবে। আপনি একই অনুরোধে accountAggregation ও comparisonShopping উল্লেখ করতে পারবেন, কিন্তু accountManagement-এর সাথে accountAggregation বা comparisonShopping একসাথে ব্যবহার করা যাবে না। আপনি accountManagement উল্লেখ করলে, আপনাকে অবশ্যই user বা users ফিল্ড ব্যবহার করে নতুন অ্যাকাউন্টে কমপক্ষে একজন ব্যবহারকারীকে যোগ করতে হবে।

পূর্বশর্ত

Merchant API ব্যবহার করে অ্যাকাউন্ট তৈরি করার আগে, আপনি যে পরিষেবা ব্যবহার করেন তার উপর নির্ভর করে নিম্নলিখিত প্রয়োজনীয়তা পূরণ করেছেন কিনা তা নিশ্চিত করুন:

  • অ্যাডমিনিস্ট্রেটর অ্যাক্সেস: accountManagement, comparisonShopping বা accountAggregation ব্যবহার করে নতুন অ্যাকাউন্ট লিঙ্ক করার সময় প্রোভাইডার অ্যাকাউন্টে আপনার অ্যাডমিনিস্ট্রেটর অ্যাক্সেস থাকতে হবে।
  • উন্নত অ্যাকাউন্ট: আপনি accountAggregation ব্যবহার করলে, আপনার প্রদানকারীর অ্যাকাউন্ট অবশ্যই অ্যাকাউন্ট এগ্রিগেশনের জন্য কনফিগার করা একটি উন্নত অ্যাকাউন্ট হতে হবে। আপনি পরিষেবা প্রদানকারী হলে এবং উন্নত অ্যাকাউন্ট সেট-আপ করার প্রয়োজন হলে, কনফিগারেশন সংক্রান্ত সহায়তার জন্য সহায়তা টিমের সাথে যোগাযোগ করুন।

অ্যাকাউন্ট তৈরি করা (অ্যাকাউন্ট ম্যানেজমেন্ট বা তুলনা করে কেনাকাটা ব্যবহার করে)

নতুন অ্যাকাউন্ট তৈরি করতে, accounts.createAndConfigure নম্বরে কল করুন। যেসব পার্টনার মার্চেন্টদের তাদের অ্যাকাউন্ট ম্যানেজ করতে সাহায্য করে তাদের জন্য এটি সাজেস্ট করা পদ্ধতি, কারণ এটি মার্চেন্টদের তাদের অ্যাকাউন্টের সম্পূর্ণ কন্ট্রোল ও মালিকানা ধরে রাখতে দেয় এবং একই সাথে পার্টনারদের নির্দিষ্ট অনুমতি দেয়।

অনুরোধের বডিতে:

  1. আপনি যে অ্যাকাউন্ট তৈরি করতে চান সেটির বিবরণ account ফিল্ডে লিখুন।
  2. accountName ফিল্ডে, বারবার ব্যবহার করা হয়েছে এবং অপ্রয়োজনীয় যতিচিহ্ন, বড় হাতের অক্ষর, আন্ডারস্কোর, সব বড় হাতের অক্ষর, ইমোজি বা / বা _-এর মতো অ-বর্ণানুক্রমিক প্রতীক ব্যবহার করবেন না। ব্যবসায়িক সাফিক্স (যেমন, "Inc." বা "GmbH"), প্রচারমূলক টেক্সট, ব্যক্তিগত তথ্য বা অনুপযুক্ত ভাষা ব্যবহার করবেন না। ছোট, স্পষ্ট ও পেশাদার নাম ব্যবহার করুন। আরও তথ্যের জন্য, ব্যবসার নাম যোগ করা দেখুন।
  3. আপনি accountManagement ব্যবহার করলে, অ্যাকাউন্টে অ্যাক্সেস থাকবে এমন কমপক্ষে একজন ব্যবহারকারীকে user ফিল্ডে নির্দিষ্ট করুন।
  4. আপনি এই অ্যাকাউন্টে যেসব পরিষেবা দিতে চান, সেগুলি service ফিল্ডে উল্লেখ করুন, যেমন accountManagement এবং আপনার অ্যাকাউন্টের রিসোর্স নাম provider হিসেবে সেট করুন (যেমন, providers/{YOUR_ACCOUNT_ID})। productsManagement বা campaignsManagement-এর মতো উপলভ্য পরিষেবার তালিকা দেখতে, অ্যাকাউন্ট সম্পর্কের ম্যানেজ করুন লিঙ্কে যান।

"merchantStore" নামের একটি অ্যাকাউন্ট তৈরি করার অনুরোধের উদাহরণ এবং অ্যাকাউন্ট ও প্রোডাক্ট ম্যানেজমেন্টের জন্য সেটিকে অ্যাকাউন্ট {YOUR_ACCOUNT_ID}-এর সাথে লিঙ্ক করা:

POST https://merchantapi.googleapis.com/accounts/v1/accounts:createAndConfigure
{
  "account": {
    "accountName": "merchantStore",
    "adultContent": false,
    "timeZone": {
      "id": "America/New_York"
    },
    "languageCode": "en-US"
  },
  "user": [
    {
      "userId": "test@example.com",
      "user": {
        "accessRights": ["ADMIN"]
      }
    }
  ],
  "service": [
    {
      "accountManagement": {},
      "provider": "providers/{YOUR_ACCOUNT_ID}"
    },
    {
      "productsManagement": {},
      "provider": "providers/{YOUR_ACCOUNT_ID}"
    }
  ]
}

কল সফল হলে, নতুন অ্যাকাউন্ট তৈরি হয় এবং সেটি নির্দিষ্ট পরিষেবার জন্য আপনার অ্যাকাউন্টের সাথে লিঙ্ক করা হয়। তৈরি করার সময় আপনি accountManagement, accountAggregation, বা comparisonShopping পরিষেবা উল্লেখ করলে, সেগুলি অটোমেটিক অনুমোদিত হয়ে যায় এবং লিঙ্ক স্ট্যাটাস ESTABLISHED হয়। তৈরি করা অ্যাকাউন্টটি গ্রহণ না করা পর্যন্ত অন্যান্য পরিষেবার লিঙ্ক PENDING অবস্থায় থাকতে পারে। উত্তরের বডিতে নতুন তৈরি করা Account রিসোর্স রয়েছে।

অ্যাকাউন্ট তৈরি ও কনফিগার করতে accounts.createAndConfigure কীভাবে ব্যবহার করতে হয় তা নিম্নলিখিত নমুনা থেকে দেখুন:

Java

import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.accounts.v1.AccessRight;
import com.google.shopping.merchant.accounts.v1.Account;
import com.google.shopping.merchant.accounts.v1.AccountManagement;
import com.google.shopping.merchant.accounts.v1.AccountsServiceClient;
import com.google.shopping.merchant.accounts.v1.AccountsServiceSettings;
import com.google.shopping.merchant.accounts.v1.CreateAndConfigureAccountRequest;
import com.google.shopping.merchant.accounts.v1.CreateAndConfigureAccountRequest.AddAccountService;
import com.google.shopping.merchant.accounts.v1.CreateAndConfigureAccountRequest.AddUser;
import com.google.shopping.merchant.accounts.v1.ProductsManagement;
import com.google.shopping.merchant.accounts.v1.User;
import com.google.type.TimeZone;
import java.util.List;
import shopping.merchant.samples.utils.Authenticator;

/**
 * This class demonstrates how to create a new Merchant Center account and configure it with various
 * services.
 */
public class CreateAndConfigureAccountSample {

  public static void createAndConfigureAccount(
      long providerId, String newAccountName, String userEmail) throws Exception {

    // Obtains OAuth token based on the user's configuration.
    GoogleCredentials credential = new Authenticator().authenticate();

    // Creates service settings using the credentials retrieved above.
    AccountsServiceSettings accountsServiceSettings =
        AccountsServiceSettings.newBuilder()
            .setCredentialsProvider(FixedCredentialsProvider.create(credential))
            .build();

    // Calls the API and catches and prints any network failures/errors.
    try (AccountsServiceClient accountsServiceClient =
        AccountsServiceClient.create(accountsServiceSettings)) {

      // The account to be created.
      Account account =
          Account.newBuilder()
              .setAccountName(newAccountName)
              .setTimeZone(TimeZone.newBuilder().setId("Europe/Zurich").build())
              .setLanguageCode("en-US")
              .build();

      // The services to be added to the new account.
      // This sample shows how to configure a new account with account management and
      // product management.
      // For more information about the different services, see:
      // https://developers.google.com/merchant/api/guides/accounts/services
      AddAccountService accountManagementService =
          AddAccountService.newBuilder()
              .setProvider("accounts/" + providerId)
              .setExternalAccountId("external_account_id")
              .setAccountManagement(AccountManagement.newBuilder().build())
              .build();
      // This part is optional. You can also omit this and link the account later.
      AddAccountService productsManagementService =
          AddAccountService.newBuilder()
              .setProvider("accounts/" + providerId)
              .setExternalAccountId("external_account_id")
              .setProductsManagement(ProductsManagement.newBuilder().build())
              .build();

      // For sub-account creation, use the AccountAggregation service. For an example on how to do
      // this, see the `CreateSubAccount` sample.

      // The user to be added to the new account.
      // This part is optional.
      AddUser user =
          AddUser.newBuilder()
              .setUserId(userEmail)
              .setUser(User.newBuilder().addAccessRights(AccessRight.STANDARD).build())
              .build();

      CreateAndConfigureAccountRequest request =
          CreateAndConfigureAccountRequest.newBuilder()
              .setAccount(account)
              .addAllService(List.of(accountManagementService, productsManagementService))
              .addUser(user)
              .build();

      System.out.println("Sending Create and Configure Account request:");
      Account response = accountsServiceClient.createAndConfigureAccount(request);

      System.out.println("Created Account below");
      System.out.println(response);
    } catch (Exception e) {
      System.out.println(e);
    }
  }

  public static void main(String[] args) throws Exception {
    // This is the provider ID of the e-commerce platform.
    long providerId = 123L;
    // This is the name of the new account to be created.
    String newAccountName = "MyNewShop";
    // This is the email of a user to be added to the new account.
    String userEmail = "test-user@gmail.com";
    createAndConfigureAccount(providerId, newAccountName, userEmail);
  }
}

এই ধরনের অ্যাকাউন্ট তৈরি করার পরে, আপনাকে এগুলি করে সেটি অনবোর্ড করতে হবে যেমন পরিষেবার শর্তাবলীতে সম্মতি দেওয়া , ব্যবসা সম্পর্কিত তথ্য সেট-আপ করা, এবং ওয়েবসাইট যাচাই করা।

অ্যাকাউন্ট তৈরি করার সময় ইমেল যাচাইকরণ প্রসেস বন্ধ রাখা

accounts.createAndConfigure-এর মাধ্যমে অ্যাকাউন্ট তৈরি করার সময়, আপনি ঐচ্ছিকভাবে user ফিল্ড ব্যবহার করে যোগ করা নতুন ব্যবহারকারীদের জন্য যাচাইকরণ ইমেল বন্ধ করতে পারেন। এটি করার জন্য, সেই ব্যবহারকারীর জন্য করা অনুরোধে verificationMailSettings.verificationMailMode-এর মান SUPPRESS_VERIFICATION_MAIL হিসেবে সেট করুন। আপনি যদি তৈরি করার সাথে সাথেই মার্চেন্টের হয়ে ব্যবহারকারীদের যাচাই করতে চান তাহলে এটি কাজে লাগবে। এর জন্য users.verifySelf পদ্ধতি ব্যবহার করুন। ডিফল্ট হিসেবে, verificationMailMode SEND_VERIFICATION_MAIL হিসেবে সেট করা থাকে এবং অ্যাকাউন্ট তৈরি করার সময় যোগ করা নতুন ব্যবহারকারীদের ইমেল আইডিতে যাচাইকরণ ইমেল পাঠানো হয়।

POST https://merchantapi.googleapis.com/accounts/v1/accounts:createAndConfigure
{
  "account": {
    "accountName": "merchantStore",
    "adultContent": false,
    "timeZone": {
      "id": "America/New_York"
    },
    "languageCode": "en-US"
  },
  "user": [
    {
      "userId": "test@example.com",
      "user": {
        "accessRights": ["ADMIN"]
      },
      "verificationMailSettings": {
        "verificationMailMode": "SUPPRESS_VERIFICATION_MAIL"
      }
    }
  ],
  "service": [
    {
      "accountManagement": {},
      "provider": "providers/{YOUR_ACCOUNT_ID}"
    }
  ]
}

আপনি verificationMailMode-এর মান SUPPRESS_VERIFICATION_MAIL হিসেবে সেট করলে, যাচাইকরণ সম্পূর্ণ করতে, তৈরি করার সময় যোগ করা প্রতিটি ব্যবহারকারীর জন্য আপনাকে users.verifySelf কল করতে হবে। এই কলটি অবশ্যই যাচাই করা ব্যবহারকারী হিসেবে যাচাই করতে হবে (userId-এ উল্লেখ করা ব্যবহারকারী), যেমন ব্যবহারকারীর থেকে OAuth টোকেন ব্যবহার করে।

অ্যাকাউন্ট তৈরি করার সময় একটি ছদ্মনাম উল্লেখ করা

আপনি setAlias ফিল্ড ব্যবহার করে CreateAndConfigureAccountRequest কোনও প্রদানকারীর প্রসঙ্গে অ্যাকাউন্টের জন্য একটি ছদ্মনাম নির্দিষ্ট করতে পারবেন। আপনার সিস্টেমে অ্যাকাউন্ট শনাক্ত করতে উপনাম ব্যবহার করা যেতে পারে। আপনি পরিষেবা প্রদানকারী হলে, আপনি GET /accounts/v1/accounts/{provider}~{alias} ব্যবহার করে অ্যাকাউন্ট ফিরিয়ে আনতে অ্যালিয়াস ব্যবহার করতে পারবেন। প্রদত্ত পরিষেবা প্রদানকারীর জন্য উপনাম অনন্য হতে হবে এবং আপনাকে অনুরোধের service ফিল্ডে একই পরিষেবা প্রদানকারীর একটি পরিষেবা উল্লেখ করতে হবে। ছদ্মনাম সংক্রান্ত প্রয়োজনীয়তা সম্পর্কে আরও জানতে, অ্যাকাউন্ট সম্পর্ক ম্যানেজ করুন দেখুন।

POST https://merchantapi.googleapis.com/accounts/v1/accounts:createAndConfigure
{
  "account": {
    "accountName": "merchantStore",
    "adultContent": false,
    "timeZone": {
      "id": "America/New_York"
    },
    "languageCode": "en-US"
  },
  "service": [
    {
      "accountManagement": {},
      "provider": "providers/{YOUR_ACCOUNT_ID}"
    }
  ],
  "setAlias": [
    {
      "provider": "providers/{YOUR_ACCOUNT_ID}",
      "accountIdAlias": "my-merchant-alias"
    }
  ]
}

আপনি যদি কোনও মার্চেন্টের হয়ে অ্যাকাউন্ট তৈরি করা পার্টনার হন, তাহলে আমরা নিচে উল্লেখ করা ফ্লো অনুসরণ করার সাজেশন দিই:

  1. অ্যাকাউন্ট তৈরি করা: নতুন অ্যাকাউন্ট তৈরি করতে আপনার পার্টনার ক্রেডেনশিয়াল সহ accounts.createAndConfigure-এ কল করুন।
    • আপনার প্রদানকারীর আইডি লিঙ্ক করার জন্য serviceaccountManagement সেট করুন।
    • user ফিল্ড ব্যবহার করে মার্চেন্টকে ব্যবহারকারী হিসেবে যোগ করুন এবং verificationMailSettings.verificationMailMode-এর মান SUPPRESS_VERIFICATION_MAIL হিসেবে সেট করুন।
  2. ব্যবহারকারীকে যাচাই করা: মার্চেন্টের ক্রেডেনশিয়াল (যেমন, OAuth টোকেন ব্যবহার করে) সহ, ব্যবহারকারীর স্ট্যাটাস PENDING থেকে VERIFIED-এ পরিবর্তন করতে users.verifySelf কল করুন।
  3. ব্যবসার দেশ সেট করুন: মার্চেন্ট ক্রেডেনশিয়াল দিয়ে, accounts.updateBusinessInfo ব্যবহার করে address.regionCode আপডেট করার মাধ্যমে ব্যবসার দেশ সেট করুন। পরিষেবার শর্তাবলীতে সম্মতি জানানোর আগে এটি প্রয়োজন।
  4. পরিষেবার শর্তাবলীতে সম্মতি দিন : মার্চেন্ট ক্রেডেনশিয়াল ব্যবহার করে, পরিষেবার শর্তাবলীতে সম্মতি দিন ।

এই ফ্লো, Google-এর থেকে আমন্ত্রণমূলক ইমেল না পেয়েও, আপনার প্ল্যাটফর্মের মধ্যে কোনও মার্চেন্টকে নির্বিঘ্নে অনবোর্ড করতে দেয়।

ক্লায়েন্ট অ্যাকাউন্ট তৈরি করা (অ্যাকাউন্ট এগ্রিগেশন ব্যবহার করে)

ক্লায়েন্ট অ্যাকাউন্ট হল আলাদা Merchant Center অ্যাকাউন্ট যা accountAggregation পরিষেবা ব্যবহার করে আপনার উন্নত অ্যাকাউন্টের সাথে লিঙ্ক করা হয়। এর ফলে আলাদা সেটিংস, ওয়েবসাইট ও ডেটা ফিড বজায় রেখেও কেন্দ্রীয়ভাবে ম্যানেজ করা যায়। নতুন ক্লায়েন্ট অ্যাকাউন্ট তৈরি করতে আপনি Merchant Accounts সাব-API ব্যবহার করতে পারবেন।

ক্লায়েন্ট অ্যাকাউন্ট তৈরি করতে, আপনার কাছে অবশ্যই উন্নত অ্যাকাউন্ট সেট-আপ থাকতে হবে। আপনার Merchant Center অ্যাকাউন্টকে উন্নত অ্যাকাউন্টে পরিবর্তন করতে হলে আপনাকে অ্যাকাউন্ট অ্যাডমিনিস্ট্রেটর হতে হবে এবং আপনার অ্যাকাউন্টে কোনও অমীমাংসিত সমস্যা থাকলে চলবে না।

নতুন ক্লায়েন্ট অ্যাকাউন্ট তৈরি করতে, accounts.createAndConfigure নম্বরে কল করুন। অনুরোধের বডিতে:

  1. আপনি যে অ্যাকাউন্ট তৈরি করতে চান সেটির বিবরণ account ফিল্ডে লিখুন।
  2. accountName ফিল্ডে, বারবার ব্যবহার করা হয়েছে এবং অপ্রয়োজনীয় যতিচিহ্ন, বড় হাতের অক্ষর, আন্ডারস্কোর বা বর্ণসাংখ্যিক নয় এমন প্রতীক (যেমন "/" বা "_") ব্যবহার করবেন না। ব্যবসায়িক সাফিক্স (যেমন, "Inc." বা "GmbH"), প্রচারমূলক টেক্সট, ব্যক্তিগত তথ্য বা অনুপযুক্ত ভাষা ব্যবহার করবেন না। ছোট, স্পষ্ট ও পেশাদার নাম ব্যবহার করুন। আরও তথ্যের জন্য, ব্যবসার নাম যোগ করা দেখুন।
  3. ঐচ্ছিকভাবে, user ফিল্ডে কোনও নতুন অনুমোদিত ব্যবহারকারীর নাম লিখুন। এছাড়াও, অ্যাকাউন্ট অ্যাক্সেস, পেরেন্ট অ্যাডভান্সড অ্যাকাউন্ট থেকে উত্তরাধিকার সূত্রে পাওয়া যায়।
  4. service ফিল্ডে, accountAggregation নির্দিষ্ট করুন এবং provider-কে আপনার উন্নত অ্যাকাউন্টের রিসোর্স নাম হিসেবে সেট করুন (যেমন, providers/{ADVANCED_ACCOUNT_ID})। এটি আপনার উন্নত অ্যাকাউন্টকে নতুন অ্যাকাউন্টের জন্য অ্যাগ্রিগেটর হিসেবে প্রতিষ্ঠা করে।

এখানে "merchantStore" নামের একটি ক্লায়েন্ট অ্যাকাউন্ট তৈরি করার অনুরোধের উদাহরণ দেওয়া হল যা উন্নত অ্যাকাউন্টের সাথে লিঙ্ক করা আছে {ADVANCED_ACCOUNT_ID}:

POST https://merchantapi.googleapis.com/accounts/v1/accounts:createAndConfigure
{
  "account": {
    "accountName": "merchantStore",
    "adultContent": false,
    "timeZone": {
      "id": "America/New_York"
    },
    "languageCode": "en-US"
  },
  "service": [
    {
      "accountAggregation": {},
      "provider": "providers/{ADVANCED_ACCOUNT_ID}"
    }
  ]
}

কলটি সফল হলে, নতুন ক্লায়েন্ট অ্যাকাউন্ট তৈরি হয় এবং সেটি আপনার উল্লেখ করা উন্নত অ্যাকাউন্টের সাথে লিঙ্ক করা হয়। উত্তর বডিতে নতুন তৈরি করা Account রিসোর্স থাকবে।

নতুন ক্লায়েন্ট অ্যাকাউন্ট তৈরি করতে accounts.createAndConfigure কীভাবে ব্যবহার করতে হয় তা নিম্নলিখিত নমুনা থেকে বোঝা যায়।

Java

import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.accounts.v1.Account;
import com.google.shopping.merchant.accounts.v1.AccountAggregation;
import com.google.shopping.merchant.accounts.v1.AccountsServiceClient;
import com.google.shopping.merchant.accounts.v1.AccountsServiceSettings;
import com.google.shopping.merchant.accounts.v1.CreateAndConfigureAccountRequest;
import com.google.shopping.merchant.accounts.v1.CreateAndConfigureAccountRequest.AddAccountService;
import com.google.type.TimeZone;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;

/** This class demonstrates how to create a sub-account under an advanced account. */
public class CreateSubAccountSample {

  private static String getParent(String accountId) {
    return String.format("accounts/%s", accountId);
  }

  public static Account createSubAccount(Config config) throws Exception {

    // Obtains OAuth token based on the user's configuration.
    GoogleCredentials credential = new Authenticator().authenticate();

    // Creates service settings using the credentials retrieved above.
    AccountsServiceSettings accountsServiceSettings =
        AccountsServiceSettings.newBuilder()
            .setCredentialsProvider(FixedCredentialsProvider.create(credential))
            .build();

    // Creates parent/provider to identify the advanced account into which to insert the subaccount.
    String parent = getParent(config.getAccountId().toString());

    // Calls the API and catches and prints any network failures/errors.
    try (AccountsServiceClient accountsServiceClient =
        AccountsServiceClient.create(accountsServiceSettings)) {

      CreateAndConfigureAccountRequest request =
          CreateAndConfigureAccountRequest.newBuilder()
              .setAccount(
                  Account.newBuilder()
                      .setAccountName("Demo Business")
                      .setAdultContent(false)
                      .setTimeZone(TimeZone.newBuilder().setId("America/New_York").build())
                      .setLanguageCode("en-US")
                      .build())
              .addService(
                  AddAccountService.newBuilder()
                      .setProvider(parent)
                      .setAccountAggregation(AccountAggregation.getDefaultInstance())
                      .build())
              .build();

      System.out.println("Sending Create SubAccount request");
      Account response = accountsServiceClient.createAndConfigureAccount(request);
      System.out.println("Inserted Account Name below");
      // Format: `accounts/{account}`
      System.out.println(response.getName());
      return response;
    }
  }

  public static void main(String[] args) throws Exception {
    Config config = Config.load();

    createSubAccount(config);
  }
}

PHP

use Google\ApiCore\ApiException;
use Google\Shopping\Merchant\Accounts\V1\Account;
use Google\Shopping\Merchant\Accounts\V1\AccountAggregation;
use Google\Shopping\Merchant\Accounts\V1\Client\AccountsServiceClient;
use Google\Shopping\Merchant\Accounts\V1\CreateAndConfigureAccountRequest;
use Google\Shopping\Merchant\Accounts\V1\CreateAndConfigureAccountRequest\AddAccountService;
use Google\Type\TimeZone;

/**
 * This class demonstrates how to create a sub-account under an MCA account.
 */
class CreateSubAccount
{

    private static function getParent(string $accountId): string
    {
        return sprintf("accounts/%s", $accountId);
    }


    public static function createSubAccount(array $config): void
    {
        // Gets the OAuth credentials to make the request.
        $credentials = Authentication::useServiceAccountOrTokenFile();

        // Creates options config containing credentials for the client to use.
        $options = ['credentials' => $credentials];

        // Creates a client.
        $accountsServiceClient = new AccountsServiceClient($options);

        // Creates parent/provider to identify the MCA account into which to insert the subaccount.
        $parent = self::getParent($config['accountId']);

        // Calls the API and catches and prints any network failures/errors.
        try {
            $request = new CreateAndConfigureAccountRequest([
                'account' => (new Account([
                    'account_name' => 'Demo Business',
                    'adult_content' => false,
                    'time_zone' => (new TimeZone(['id' => 'America/New_York'])),
                    'language_code' => 'en-US',
                ])),
                'service' => [
                    (new AddAccountService([
                        'provider' => $parent,
                        'account_aggregation' => new AccountAggregation,
                    ])),
                ],
            ]);

            print "Sending Create SubAccount request\n";
            $response = $accountsServiceClient->createAndConfigureAccount($request);
            print "Inserted Account Name below\n";
            // Format: `accounts/{account}
            print $response->getName() . PHP_EOL;
        } catch (ApiException $e) {
            print $e->getMessage();
        }
    }
    public function callSample(): void
    {
        $config = Config::generateConfig();
        self::createSubAccount($config);
    }
}

$sample = new CreateSubAccount();
$sample->callSample();

Python

from examples.authentication import configuration
from examples.authentication import generate_user_credentials
from google.shopping.merchant_accounts_v1 import Account
from google.shopping.merchant_accounts_v1 import AccountAggregation
from google.shopping.merchant_accounts_v1 import AccountsServiceClient
from google.shopping.merchant_accounts_v1 import CreateAndConfigureAccountRequest

_ACCOUNT = configuration.Configuration().read_merchant_info()


def get_parent(account_id):
  return f"accounts/{account_id}"


def create_sub_account():
  """Creates a sub-account under an advanced account."""

  # Get OAuth credentials.
  credentials = generate_user_credentials.main()

  # Create a client.
  client = AccountsServiceClient(credentials=credentials)

  # Get the parent advanced account ID.
  parent = get_parent(_ACCOUNT)

  # Create the request.
  request = CreateAndConfigureAccountRequest(
      account=Account(
          account_name="Demo Business",
          adult_content=False,
          time_zone={"id": "America/New_York"},
          language_code="en-US",
      ),
      service=[
          CreateAndConfigureAccountRequest.AddAccountService(
              provider=parent,
              account_aggregation=AccountAggregation(),
          )
      ],
  )

  # Make the request and print the response.
  try:
    print("Sending Create SubAccount request")
    response = client.create_and_configure_account(request=request)
    print("Inserted Account Name below")
    print(response.name)
  except RuntimeError as e:
    print(e)


if __name__ == "__main__":
  create_sub_account()

cURL

curl -X POST \
"https://merchantapi.googleapis.com/accounts/v1/accounts:createAndConfigure" \
-H "Authorization: Bearer {YOUR_ACCESS_TOKEN}" \
-H "Content-Type: application/json" \
-d '{
  "account": {
    "accountName": "Demo Business",
    "adultContent": false,
    "timeZone": {
      "id": "America/New_York"
    },
    "languageCode": "en-US"
  },
  "service": [
    {
      "accountAggregation": {},
      "provider": "providers/{ADVANCED_ACCOUNT_ID}"
    }
  ]
}'

ক্লায়েন্ট অ্যাকাউন্ট ফিরিয়ে আনা

কোনও উন্নত অ্যাকাউন্টের সব ক্লায়েন্ট অ্যাকাউন্টের তালিকা পেতে, এই accounts.listSubaccounts পদ্ধতি ব্যবহার করুন। অনুরোধ URL-এর provider ফিল্ডে আপনার উন্নত অ্যাকাউন্টের আইডি দিন।

এখানে অনুরোধের একটি নমুনা দেওয়া হল:

GET https://merchantapi.googleapis.com/accounts/v1/accounts/{ADVANCED_ACCOUNT_ID}:listSubaccounts

সফল কলের একটি নমুনা উত্তর এখানে দেওয়া হল:

{
"accounts": [
    {
      "name": "accounts/<var class=\"readonly\">{SUB_ACCOUNT_ID_1}</var>",
      "accountId": "<var class=\"readonly\">{SUB_ACCOUNT_ID_1}</var>",
      "accountName": "<var class=\"readonly\">{SUB_ACCOUNT_NAME_1}</var>",
      "timeZone": {
        "id": "America/Los_Angeles"
      },
      "languageCode": "en-US"
    },
    {
      "name": "accounts/<var class=\"readonly\">{SUB_ACCOUNT_ID_2}</var>",
      "accountId": "<var class=\"readonly\">{SUB_ACCOUNT_ID_2}</var>",
      "accountName": "<var class=\"readonly\">{SUB_ACCOUNT_NAME_2}</var>",
      "timeZone": {
        "id": "America/Los_Angeles"
      },
      "languageCode": "en-US"
    }
  ]
}

আপনার অ্যাডভান্সড অ্যাকাউন্টের সব ক্লায়েন্ট অ্যাকাউন্ট কীভাবে তালিকাভুক্ত করতে হয় তা নিম্নলিখিত নমুনা থেকে বুঝতে পারবেন।

Java

import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.accounts.v1.Account;
import com.google.shopping.merchant.accounts.v1.AccountsServiceClient;
import com.google.shopping.merchant.accounts.v1.AccountsServiceClient.ListSubAccountsPagedResponse;
import com.google.shopping.merchant.accounts.v1.AccountsServiceSettings;
import com.google.shopping.merchant.accounts.v1.ListSubAccountsRequest;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;

/** This class demonstrates how to list all the subaccounts of an advanced account. */
public class ListSubAccountsSample {

  private static String getParent(String accountId) {
    return String.format("accounts/%s", accountId);
  }

  public static ListSubAccountsPagedResponse listSubAccounts(Config config) throws Exception {

    // Obtains OAuth token based on the user's configuration.
    GoogleCredentials credential = new Authenticator().authenticate();

    // Creates service settings using the credentials retrieved above.
    AccountsServiceSettings accountsServiceSettings =
        AccountsServiceSettings.newBuilder()
            .setCredentialsProvider(FixedCredentialsProvider.create(credential))
            .build();

    // Creates parent/provider to identify the advanced account from which to list all sub-accounts.
    String parent = getParent(config.getAccountId().toString());

    // Calls the API and catches and prints any network failures/errors.
    try (AccountsServiceClient accountsServiceClient =
        AccountsServiceClient.create(accountsServiceSettings)) {

      // The parent has the format: accounts/{account}
      ListSubAccountsRequest request =
          ListSubAccountsRequest.newBuilder().setProvider(parent).build();
      System.out.println("Sending list subaccounts request:");

      ListSubAccountsPagedResponse response = accountsServiceClient.listSubAccounts(request);

      int count = 0;

      // Iterates over all rows in all pages and prints the datasource in each row.
      // Automatically uses the `nextPageToken` if returned to fetch all pages of data.
      for (Account account : response.iterateAll()) {
        System.out.println(account);
        count++;
      }
      System.out.print("The following count of accounts were returned: ");
      System.out.println(count);
      return response;
    }
  }

  public static void main(String[] args) throws Exception {
    Config config = Config.load();
    listSubAccounts(config);
  }
}

PHP

use Google\ApiCore\ApiException;
use Google\Shopping\Merchant\Accounts\V1\Client\AccountsServiceClient;
use Google\Shopping\Merchant\Accounts\V1\ListSubAccountsRequest;

/**
 * This class demonstrates how to list all the subaccounts of an advanced account.
 */
class ListSubAccounts
{
    private static function getParent(string $accountId): string
    {
        return sprintf("accounts/%s", $accountId);
    }


    public static function listSubAccounts(array $config): void
    {
        // Gets the OAuth credentials to make the request.
        $credentials = Authentication::useServiceAccountOrTokenFile();

        // Creates options config containing credentials for the client to use.
        $options = ['credentials' => $credentials];

        // Creates a client.
        $accountsServiceClient = new AccountsServiceClient($options);

        // Creates parent/provider to identify the advanced account from which
        //to list all accounts.
        $parent = self::getParent($config['accountId']);

        // Calls the API and catches and prints any network failures/errors.
        try {

            // The parent has the format: accounts/{account}
            $request = new ListSubAccountsRequest(['provider' => $parent]);
            print "Sending list subaccounts request:\n";

            $response = $accountsServiceClient->listSubAccounts($request);

            $count = 0;

            // Iterates over all rows in all pages and prints the datasource in each row.
            // Automatically uses the `nextPageToken` if returned to fetch all pages of data.
            foreach ($response->iterateAllElements() as $account) {
                print_r($account);
                $count++;
            }
            print "The following count of accounts were returned: ";
            print $count . PHP_EOL;
        } catch (ApiException $e) {
            print "An error has occured: \n";
            print $e->getMessage();
        }
    }

    public function callSample(): void
    {
        $config = Config::generateConfig();
        self::listSubAccounts($config);
    }
}

$sample = new ListSubAccounts();
$sample->callSample();

Python

from examples.authentication import configuration
from examples.authentication import generate_user_credentials
from google.shopping.merchant_accounts_v1 import AccountsServiceClient
from google.shopping.merchant_accounts_v1 import ListSubAccountsRequest

_ACCOUNT = configuration.Configuration().read_merchant_info()


def get_parent(account_id):
  return f"accounts/{account_id}"


def list_sub_accounts():
  """Lists all the subaccounts of an advanced account."""

  # Get OAuth credentials.
  credentials = generate_user_credentials.main()

  # Create a client.
  client = AccountsServiceClient(credentials=credentials)

  # Get the parent advanced account ID.
  parent = get_parent(_ACCOUNT)

  # Create the request.
  request = ListSubAccountsRequest(provider=parent)

  # Make the request and print the response.
  try:
    print("Sending list subaccounts request:")
    response = client.list_sub_accounts(request=request)

    count = 0
    for account in response:
      print(account)
      count += 1

    print(f"The following count of accounts were returned: {count}")

  except RuntimeError as e:
    print("An error has occured: ")
    print(e)


if __name__ == "__main__":
  list_sub_accounts()

cURL

curl -X GET \
"https://merchantapi.googleapis.com/accounts/v1/accounts/{ADVANCED_ACCOUNT_ID}:listSubaccounts" \
-H "Authorization: Bearer {YOUR_ACCESS_TOKEN}" \

ক্লায়েন্ট অ্যাকাউন্ট মুছে দেওয়া

আপনি যদি আর কোনও ক্লায়েন্ট অ্যাকাউন্ট ম্যানেজ করতে না চান, তাহলে accounts.delete পদ্ধতি ব্যবহার করে এটি মুছে দিতে পারবেন।

এই পদ্ধতি প্রয়োগ করতে, যে অ্যাকাউন্টটি মুছে দেওয়া হচ্ছে সেটির অ্যাডমিনিস্ট্রেটর অ্যাক্সেস থাকতে হবে।

এখানে অনুরোধের একটি নমুনা দেওয়া হল:

DELETE https://merchantapi.googleapis.com/accounts/v1/accounts/{SUB_ACCOUNT_ID}

সফল হলে, রেসপন্স বডি হল একটি খালি JSON অবজেক্ট, যা থেকে বোঝা যায় যে অ্যাকাউন্টটি মুছে দেওয়া হয়েছে।

ক্লায়েন্ট অ্যাকাউন্ট কীভাবে মুছতে হয় তা নিম্নলিখিত নমুনা থেকে বোঝা যায়।

Java

import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.accounts.v1.AccountName;
import com.google.shopping.merchant.accounts.v1.AccountsServiceClient;
import com.google.shopping.merchant.accounts.v1.AccountsServiceSettings;
import com.google.shopping.merchant.accounts.v1.DeleteAccountRequest;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;

/** This class demonstrates how to delete a given Merchant Center account. */
public class DeleteAccountSample {

  // This method can delete a standalone, advanced account or sub-account. If you delete an advanced
  // account,
  // all sub-accounts will also be deleted.
  // Admin user access is required to execute this method.

  public static void deleteAccount(Config config, String accountId) throws Exception {

    // Obtains OAuth token based on the user's configuration.
    GoogleCredentials credential = new Authenticator().authenticate();

    // Creates service settings using the credentials retrieved above.
    AccountsServiceSettings accountsServiceSettings =
        AccountsServiceSettings.newBuilder()
            .setCredentialsProvider(FixedCredentialsProvider.create(credential))
            .build();

    // Creates account name to identify the account.
    String name =
        AccountName.newBuilder()
            .setAccount(accountId)
            .build()
            .toString();

    // Calls the API.
    try (AccountsServiceClient accountsServiceClient =
        AccountsServiceClient.create(accountsServiceSettings)) {
      DeleteAccountRequest request =
          DeleteAccountRequest.newBuilder()
              .setName(name)
              // Optional. If set to true, the account will be deleted even if it has offers or
              // provides services to other accounts. Defaults to 'false'.
              .setForce(true)
              .build();

      System.out.println("Sending Delete Account request");
      accountsServiceClient.deleteAccount(request); // No response returned on success.
      System.out.println("Delete successful.");
    }
  }

  public static void deleteAccount(Config config) throws Exception {
    deleteAccount(config, config.getAccountId().toString());
  }

  public static void main(String[] args) throws Exception {
    Config config = Config.load();
    deleteAccount(config);
  }
}

PHP

use Google\ApiCore\ApiException;
use Google\Shopping\Merchant\Accounts\V1\Client\AccountsServiceClient;
use Google\Shopping\Merchant\Accounts\V1\DeleteAccountRequest;


/**
 * This class demonstrates how to delete a given Merchant Center account.
 */
class DeleteAccount
{
    private static function getParent(string $accountId): string
    {
        return sprintf("accounts/%s", $accountId);
    }

    // This method can delete a standalone, advanced account or sub-account.
    // If you delete an advanced account, all sub-accounts will also be deleted.
    // Admin user access is required to execute this method.
    public static function deleteAccount(array $config): void
    {
        // Gets the OAuth credentials to make the request.
        $credentials = Authentication::useServiceAccountOrTokenFile();

        // Creates options config containing credentials for the client to use.
        $options = ['credentials' => $credentials];

        // Creates a client.
        $accountsServiceClient = new AccountsServiceClient($options);


        // Gets the account ID from the config file.
        $accountId = $config['accountId'];

        // Creates account name to identify the account.
        $name = self::getParent($accountId);

        // Calls the API and catches and prints any network failures/errors.
        try {
            $request = new DeleteAccountRequest([
                'name' => $name,
                // Optional. If set to true, the account will be deleted even if it has offers or
                // provides services to other accounts. Defaults to 'false'.
                'force' => true,
            ]);

            print "Sending Delete Account request\n";
            $accountsServiceClient->deleteAccount($request); // No response returned on success.
            print "Delete successful.\n";
        } catch (ApiException $e) {
            print $e->getMessage();
        }
    }

    public function callSample(): void
    {
        $config = Config::generateConfig();
        self::deleteAccount($config);
    }
}

$sample = new DeleteAccount();
$sample->callSample();

Python

from examples.authentication import configuration
from examples.authentication import generate_user_credentials
from google.shopping.merchant_accounts_v1 import AccountsServiceClient
from google.shopping.merchant_accounts_v1 import DeleteAccountRequest

_ACCOUNT = configuration.Configuration().read_merchant_info()


def get_parent(account_id):
  return f"accounts/{account_id}"


def delete_account():
  """Deletes a given Merchant Center account."""

  # Get OAuth credentials.
  credentials = generate_user_credentials.main()

  # Create a client.
  client = AccountsServiceClient(credentials=credentials)

  # Create the account name.
  name = get_parent(_ACCOUNT)

  # Create the request.
  request = DeleteAccountRequest(name=name, force=True)

  # Make the request and print the response.
  try:
    print("Sending Delete Account request")
    client.delete_account(request=request)
    print("Delete successful.")
  except RuntimeError as e:
    print(e)


if __name__ == "__main__":
  delete_account()

cURL

curl -X DELETE \
"https://merchantapi.googleapis.com/accounts/v1/accounts/{SUB_ACCOUNT_ID}?force=true" \
-H "Authorization: Bearer {YOUR_ACCESS_TOKEN}" \

পরিষেবার শর্তাবলীতে সম্মতি দিন

অভিভাবক অ্যাডভান্সড অ্যাকাউন্ট যে Merchant Center পরিষেবার শর্তাবলীতে (TOS) সম্মতি দিয়েছে, ক্লায়েন্ট অ্যাকাউন্ট সেটিই মেনে চলে।

আপনার ব্যবসার তথ্য আপডেট করা

আপনার ক্লায়েন্ট অ্যাকাউন্টের জন্য ব্যবসা সংক্রান্ত তথ্য এডিট করতে আপনি Merchant Accounts API ব্যবহার করতে পারবেন।

  • কোনও অ্যাকাউন্টের ব্যবসার তথ্য দেখতে, accounts.getBusinessInfo নম্বরে কল করুন।
  • অ্যাকাউন্টের ব্যবসার তথ্য এডিট করতে, accounts.updateBusinessInfo নম্বরে কল করুন।