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

আপনি মার্চেন্ট এপিআই (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 ফিল্ড ব্যবহার করে নতুন অ্যাকাউন্টে অন্তত একজন ব্যবহারকারীকে যুক্ত করতে হবে।

পূর্বশর্ত

মার্চেন্ট এপিআই ব্যবহার করে অ্যাকাউন্ট তৈরি করার আগে, আপনার ব্যবহৃত পরিষেবাগুলোর ওপর নির্ভর করে নিম্নলিখিত শর্তগুলো পূরণ করা নিশ্চিত করুন:

  • অ্যাডমিনিস্ট্রেটর অ্যাক্সেস : 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 ব্যবহার করে অ্যাকাউন্ট তৈরি করার সময়, আপনি ঐচ্ছিকভাবে 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 টোকেন ব্যবহার করে।

অ্যাকাউন্ট তৈরির সময় একটি ছদ্মনাম নির্দিষ্ট করুন।

আপনি CreateAndConfigureAccountRequestsetAlias ​​ফিল্ড ব্যবহার করে একজন প্রোভাইডারের প্রেক্ষাপটে একটি অ্যাকাউন্টের জন্য একটি অ্যালিয়াস নির্দিষ্ট করতে পারেন। আপনার সিস্টেমে অ্যাকাউন্টটি শনাক্ত করতে অ্যালিয়াসটি ব্যবহার করা যেতে পারে। আপনি যদি একজন পরিষেবা প্রদানকারী হন, তাহলে আপনি 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 কল করুন।
    • আপনার প্রোভাইডার আইডির সাথে accountManagement লিঙ্ক করার জন্য service সেট করুন।
    • user ফিল্ড ব্যবহার করে মার্চেন্টকে একজন ইউজার হিসেবে যুক্ত করুন, এবং verificationMailSettings.verificationMailMode কে SUPPRESS_VERIFICATION_MAIL এ সেট করুন।
  2. ব্যবহারকারী যাচাই করুন : মার্চেন্টের দেওয়া ক্রেডেনশিয়াল (যেমন, একটি OAuth টোকেন ব্যবহার করে) দিয়ে, ব্যবহারকারীর স্টেট PENDING থেকে VERIFIED এ পরিবর্তন করতে users.verifySelf কল করুন।
  3. ব্যবসার দেশ নির্ধারণ করুন : মার্চেন্ট ক্রেডেনশিয়াল ব্যবহার করে, accounts.updateBusinessInfo মাধ্যমে address.regionCode আপডেট করে ব্যবসার দেশ নির্ধারণ করুন। পরিষেবার শর্তাবলী গ্রহণ করার আগে এটি আবশ্যক।
  4. পরিষেবার শর্তাবলী গ্রহণ করুন : মার্চেন্ট ক্রেডেনশিয়াল ব্যবহার করে পরিষেবার শর্তাবলী গ্রহণ করুন

এই প্রক্রিয়াটি একজন ব্যবসায়ীকে গুগল থেকে আমন্ত্রণ ইমেল না পেয়েই আপনার প্ল্যাটফর্মে নির্বিঘ্নে যুক্ত হওয়ার সুযোগ দেয়।

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

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

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

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

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

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

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 ব্যবহার করে একটি নতুন ক্লায়েন্ট অ্যাকাউন্ট তৈরি করতে পারেন।

জাভা

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 void 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());
    } catch (Exception e) {
      System.out.println(e);
    }
  }

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

    createSubAccount(config);
  }
}

পিএইচপি

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

পাইথন

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"
    }
  ]
}

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

জাভা

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 void 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);
    } catch (Exception e) {
      System.out.println("An error has occured: ");
      System.out.println(e);
    }
  }

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

পিএইচপি

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

পাইথন

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 অবজেক্ট হয়, যা নির্দেশ করে যে অ্যাকাউন্টটি মুছে ফেলা হয়েছে।

নিম্নলিখিত নমুনাগুলিতে দেখানো হয়েছে কীভাবে একটি ক্লায়েন্ট অ্যাকাউন্ট মুছে ফেলতে হয়।

জাভা

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

    // Gets the account ID from the config file.
    String accountId = config.getAccountId().toString();

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

    // Calls the API and catches and prints any network failures/errors.
    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.");
    } catch (Exception e) {
      System.out.println(e);
    }
  }

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

পিএইচপি

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

পাইথন

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}" \

পরিষেবার শর্তাবলী গ্রহণ করুন

ক্লায়েন্ট অ্যাকাউন্টগুলো প্যারেন্ট অ্যাডভান্সড অ্যাকাউন্টে স্বাক্ষরিত মার্চেন্ট সেন্টার টার্মস অফ সার্ভিস (TOS) উত্তরাধিকারসূত্রে পায়।

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

আপনি আপনার ক্লায়েন্ট অ্যাকাউন্টগুলোর ব্যবসায়িক তথ্য সম্পাদনা করতে অ্যাকাউন্টস সাব-এপিআই ব্যবহার করতে পারেন।

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