#azharwaheed

1 messages ยท Page 1 of 1 (latest)

pearl bladeBOT
blissful hornet
#

๐Ÿ‘‹ happy to help

#

would you mind elaborating please?

waxen bear
#

yes

#

i want to avoid creating a new customer if a customer already exist with the same email and name already exists

blissful hornet
waxen bear
#

var service = new CustomerService();
var customers = service.List();

string lastId = null;

// Enumerate the first page of the list
foreach (Customer customer in customers)
{
lastId = customer.Id;
Console.WriteLine(customer.Email);
}

customers = service.List(new CustomerListOptions()
{
StartingAfter = lastId,
});

// Enumerate the subsequent page
foreach (Customer customer in customers)
{
lastId = customer.Id;
Console.WriteLine(customer.Email);
}

blissful hornet
#
var options = new CustomerListOptions
{
  Email = "abc@example.com",
  Limit = 1,
};
var service = new CustomerService();
StripeList<Customer> customers = service.List(
  options);
waxen bear
#

private void Start()
{
StripeConfiguration.ApiKey = "sk_test_51NYQkEDJMBBSt3MK6za7LiV4vXCpVkRBLOoNqtQgTEbWuyLPFfHHR57tVJ0iMEdZqtG4aV0iemPKN7ik0ZkySPqo00uuxF2d4e";
Successful_panel.gameObject.SetActive(false);
//var service = new CustomerService();
//Customer customer = service.Get("customer@example.com");
var options = new CustomerListOptions
{
Email = "customer@example.com",
Limit = 1,
};
var service = new CustomerService();
StripeList<Customer> customers = service.List(options);

    var options1 = new CustomerCreateOptions
    {
      
        Email = "customer@example.com"

    };
    var service1 = new CustomerService();
    Customer customer = service.Create(options1);

    Debug.Log(customer.Email);

}
#

add these code in script but create new customer . customer already exist in dashborad

blissful hornet
#

yes because you didn't add an "if" statement to prevent that from happening if you already have a customer that has that email address

waxen bear
#

can you share me any example

blissful hornet
#

actually we can't really write code for you, this is a matter of a simple if statement. if you're not really technical I highly recommend hiring someone to help you write your code