Skip to main content
Published: December 04 2014, 7:48:00 AMUpdated: November 28 2020, 12:59:36 PM

The code sample was created by giving a WSDL web reference to Business Policies Management WSDL
http://developer.ebay.com/webservices/business-policies/latest/SellerProfilesManagementService.wsdl

1.      Add a web service reference to the eBay Business Policies Management WSDL (Please use the latest version of the WSDL)
http://developer.ebay.com/webservices/business-policies/latest/SellerProfilesManagementService.wsdl


2.       Create a custom service by overriding the GetWebRequest method

CustomBusinessPoliciesManagement.cs

using System;

using System.Collections.Generic;

using System.Text;

using System.Net;

using BusinessPoliciesManagement_API_Sample.com.ebay.developer;

 

namespace BusinessPoliciesManagement_API_Sample

{

    public class CustomBusinessPoliciesManagement: SellerProfilesManagementService

    {

        protected override WebRequest GetWebRequest(Uri uri)

        {

            try

            {

                HttpWebRequest request = (HttpWebRequest)base.GetWebRequest(uri);

                request.Headers.Add("X-EBAY-SOA-OPERATION-NAME", "getSellerProfiles");

                request.Headers.Add("X-EBAY-SOA-SECURITY-TOKEN", "YOUR-TOKEN-HERE");

                request.Headers.Add("X-EBAY-SOA-GLOBAL-ID", "EBAY-US");

                return request;

            }

            catch (Exception ex)

            {

                throw ex;

            }

        }

    }

}

 

 

 

3.       Call the custom service and make the addSellerProfile API as follows to create Shipping Profile

Program.cs

using System;

using System.Collections.Generic;

using System.Text;

using BusinessPoliciesManagement_API_Sample.com.ebay.developer;

 

namespace BusinessPoliciesManagement_API_Sample

{

    class Program

    {

        static void Main(string[] args)

        {

            try

            {

                CustomBusinessPoliciesManagement service = new CustomBusinessPoliciesManagement();

                service.Url = @"http://svcs.sandbox.ebay.com/services/selling/v1/SellerProfilesManagementService";

 

                AddSellerProfileRequest request = new AddSellerProfileRequest();

                PaymentProfile payProfile = new PaymentProfile();

                payProfile.profileName = "Only PayPal As Payment Method";

                payProfile.profileTypeSpecified = true;

                payProfile.profileType = ProfileType.PAYMENT;

 

                CategoryGroup category = new CategoryGroup();

                category.@default = true;

                category.name = "ALL";

                CategoryGroup[] categoryArray = { category };

                payProfile.categoryGroups = categoryArray;

 

                PaymentInfo payInfo = new PaymentInfo();

                string[] payMethods = { "PayPal" };

                payInfo.acceptedPaymentMethod = payMethods;

                payInfo.paypalEmailAddress = "yourmail@mail.com";

 

                payProfile.paymentInfo = payInfo;

                request.paymentProfile = payProfile;

 

                AddSellerProfileResponse response = new AddSellerProfileResponse();

                response = service.addSellerProfile(request);

 

                if (response.ack == AckValue.Success)

                {

                    Console.WriteLine("Ack: " + response.ack.ToString());

                    Console.WriteLine("Payment Profile Details:");

                    Console.WriteLine("Profile Name: " + response.paymentProfile.profileId);

                    Console.WriteLine("Profile ID: " + response.paymentProfile.profileName);

                }

                else

                {

                    foreach (ErrorData error in response.errorMessage)

                    {

                        Console.WriteLine("Error ID: " + error.errorId);

                        Console.WriteLine("Error Message: " + error.message);

                    }

                }

            }

            catch (Exception ex)

            {

                throw ex;

            }

            Console.ReadLine();

        } 

    }

}

 

 

How well did this answer your question?
Answers others found helpful