本文整理汇总了C#中CustomerRequest类的典型用法代码示例。如果您正苦于以下问题:C# CustomerRequest类的具体用法?C# CustomerRequest怎么用?C# CustomerRequest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CustomerRequest类属于命名空间,在下文中一共展示了CustomerRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddCustomer
/// <summary>
/// Adds a new customer to the database.
/// </summary>
/// <param name="customer">Customer.</param>
/// <returns>Number of records affected. If all worked well, then should be 1.</returns>
public int AddCustomer(CustomerModel customer)
{
CustomerRequest request = new CustomerRequest();
request.RequestId = NewRequestId;
request.AccessToken = AccessToken;
request.ClientTag = ClientTag;
request.Action = "Create";
request.Customer = Mapper.ToDataTransferObject(customer);
CustomerResponse response = null;
SafeProxy.DoAction<ActionServiceClient>(Service, client =>
{ response = client.SetCustomers(request); });
if (request.RequestId != response.CorrelationId)
throw new ApplicationException("AddCustomer: RequestId and CorrelationId do not match.");
if (response.Acknowledge != AcknowledgeType.Success)
throw new ApplicationException(response.Message);
// Update version & new customerId
customer.Version = response.Customer.Version;
customer.CustomerId = response.Customer.CustomerId;
return response.RowsAffected;
}
示例2: Customer
public void Customer()
{
CustomerRequest request = new CustomerRequest
{
PaymentMethodNonce = Nonce.Coinbase
};
Result<Customer> customerResult = gateway.Customer.Create(request);
Assert.IsTrue(customerResult.IsSuccess());
var customer = gateway.Customer.Find(customerResult.Target.Id);
Assert.AreEqual(1, customer.CoinbaseAccounts.Length);
CoinbaseAccount account = customer.CoinbaseAccounts[0];
Assert.AreNotEqual("", account.UserEmail);
Assert.IsNotNull(account.UserEmail);
Assert.AreNotEqual("", account.UserName);
Assert.IsNotNull(account.UserName);
Assert.AreNotEqual("", account.UserId);
Assert.IsNotNull(account.UserId);
Assert.AreEqual(1, customer.PaymentMethods.Length);
Assert.AreEqual(customer.PaymentMethods[0], customer.CoinbaseAccounts[0]);
}
示例3: ToXml_Includes_DeviceSessionId
public void ToXml_Includes_DeviceSessionId()
{
var request = new CustomerRequest()
{
CreditCard = new CreditCardRequest()
{
DeviceSessionId = "my_dsid",
FraudMerchantId = "my_fmid"
}
};
Assert.IsTrue(request.ToXml().Contains("my_dsid"));
Assert.IsTrue(request.ToXml().Contains("my_fmid"));
}
示例4: ToXml_Includes_DeviceData
public void ToXml_Includes_DeviceData()
{
var request = new CustomerRequest()
{
CreditCard = new CreditCardRequest()
{
DeviceData = "{\"device_session_id\":\"my_dsid\", \"fraud_merchant_id\":\"my_fmid\"}"
}
};
Assert.IsTrue(request.ToXml().Contains("device_session_id"));
Assert.IsTrue(request.ToXml().Contains("my_dsid"));
Assert.IsTrue(request.ToXml().Contains("fraud_merchant_id"));
Assert.IsTrue(request.ToXml().Contains("my_fmid"));
}
示例5: GetCustomer
public Customer GetCustomer(int customerId)
{
CustomerRequest request = new CustomerRequest();
request.RequestId = NewRequestId;
request.AccessToken = AccessToken;
request.ClientTag = ClientTag;
request.LoadOptions = new string[] { "Customer" };
request.Criteria = new CustomerCriteria { CustomerId = customerId };
CustomerResponse response = ActionServiceClient.GetCustomers(request);
if (request.RequestId != response.CorrelationId)
throw new ApplicationException("GetCustomers: RequestId and CorrelationId do not match.");
return response.Customer;
}
示例6: AddCustomer
public void AddCustomer(Customer customer)
{
CustomerRequest request = new CustomerRequest();
request.RequestId = NewRequestId;
request.AccessToken = AccessToken;
request.ClientTag = ClientTag;
request.Action = "Create";
request.Customer = customer;
CustomerResponse response = ActionServiceClient.SetCustomers(request);
if (request.RequestId != response.CorrelationId)
throw new ApplicationException("AddCustomer: RequestId and CorrelationId do not match.");
// These messages are for public consumption. Includes validation errors.
if (response.Acknowledge == AcknowledgeType.Failure)
throw new ApplicationException(response.Message);
}
示例7: DeleteCustomer
public int DeleteCustomer(int customerId)
{
CustomerRequest request = new CustomerRequest();
request.RequestId = NewRequestId;
request.AccessToken = AccessToken;
request.ClientTag = ClientTag;
request.Action = "Delete";
request.Criteria = new CustomerCriteria { CustomerId = customerId };
CustomerResponse response = ActionServiceClient.SetCustomers(request);
if (request.RequestId != response.CorrelationId)
throw new ApplicationException("DeleteCustomer: RequestId and CorrelationId do not match.");
if (response.Acknowledge == AcknowledgeType.Failure)
throw new ApplicationException(response.Message);
return response.RowsAffected;
}
示例8: CreateCustomerFromTransparentRedirect
public void CreateCustomerFromTransparentRedirect()
{
CustomerRequest trParams = new CustomerRequest
{
FirstName = "John"
};
CustomerRequest request = new CustomerRequest
{
LastName = "Doe"
};
string queryString = TestHelper.QueryStringForTR(trParams, request, gateway.TransparentRedirect.Url, service);
Result<Customer> result = gateway.TransparentRedirect.ConfirmCustomer(queryString);
Assert.IsTrue(result.IsSuccess());
Customer customer = result.Target;
Assert.AreEqual("John", customer.FirstName);
Assert.AreEqual("Doe", customer.LastName);
}
示例9: Can_Create_A_Customer
public void Can_Create_A_Customer()
{
//// Arrange
var gateway = this.BraintreeProviderSettings.AsBraintreeGateway();
var customerRequest = new CustomerRequest()
{
CustomerId = this.CustomerKey.ToString(),
FirstName = "Rusty",
LastName = "Swayne",
Company = "Mindfly",
Email = "[email protected]",
Website = "http://www.mindfly.com"
};
//// Act
var result = gateway.Customer.Create(customerRequest);
//// Assert
Assert.IsTrue(result.IsSuccess());
}
示例10: Find_RaisesNotFoundErrorForCreditCardToken
public void Find_RaisesNotFoundErrorForCreditCardToken()
{
var createRequest = new CustomerRequest
{
CreditCard = new CreditCardRequest
{
Number = "5555555555554444",
ExpirationDate = "05/12",
CVV = "123",
}
};
var resp = gateway.Customer.Create(createRequest);
Assert.IsNotNull(resp);
Customer customer = resp.Target;
Assert.IsNotNull(customer, resp.Message);
try {
gateway.PayPalAccount.Find(customer.CreditCards[0].Token);
Assert.Fail("Should throw NotFoundException");
} catch (NotFoundException) {}
}
示例11: Setup
public void Setup()
{
gateway = new BraintreeGateway
{
//Environment = Environment.DEVELOPMENT,
//MerchantId = "integration_merchant_id",
//PublicKey = "integration_public_key",
//PrivateKey = "integration_private_key"
};
CustomerRequest request = new CustomerRequest
{
CreditCard = new CreditCardRequest
{
CardholderName = "Fred Jones",
Number = "5555555555554444",
ExpirationDate = "05/12"
}
};
customer = gateway.Customer.Create(request).Target;
creditCard = customer.CreditCards[0];
}
示例12: Search_FindDuplicateCardsGivenPaymentMethodToken
public void Search_FindDuplicateCardsGivenPaymentMethodToken()
{
CreditCardRequest creditCard = new CreditCardRequest
{
Number = "4111111111111111",
ExpirationDate = "05/2012"
};
CustomerRequest jimRequest = new CustomerRequest
{
FirstName = "Jim",
CreditCard = creditCard
};
CustomerRequest joeRequest = new CustomerRequest
{
FirstName = "Jim",
CreditCard = creditCard
};
Customer jim = gateway.Customer.Create(jimRequest).Target;
Customer joe = gateway.Customer.Create(joeRequest).Target;
CustomerSearchRequest searchRequest = new CustomerSearchRequest().
PaymentMethodTokenWithDuplicates.Is(jim.CreditCards[0].Token);
ResourceCollection<Customer> collection = gateway.Customer.Search(searchRequest);
List<string> customerIds = new List<string>();
foreach (Customer customer in collection) {
customerIds.Add(customer.Id);
}
Assert.IsTrue(customerIds.Contains(jim.Id));
Assert.IsTrue(customerIds.Contains(joe.Id));
}
示例13: Update_AcceptsPaymentMethodNonce
public void Update_AcceptsPaymentMethodNonce()
{
var create = new CustomerRequest
{
CreditCard = new CreditCardRequest
{
Number = "4111111111111111",
ExpirationDate = "10/18",
}
};
var customer = gateway.Customer.Create(create).Target;
var update = new CustomerRequest
{
PaymentMethodNonce = Nonce.PayPalFuturePayment
};
var updatedCustomer = gateway.Customer.Update(customer.Id, update).Target;
Assert.AreEqual(1, updatedCustomer.PayPalAccounts.Length);
Assert.AreEqual(1, updatedCustomer.CreditCards.Length);
Assert.AreEqual(2, updatedCustomer.PaymentMethods.Length);
}
示例14: Update_AcceptsNestedBillingAddressId
public void Update_AcceptsNestedBillingAddressId()
{
Customer customer = gateway.Customer.Create(new CustomerRequest()).Target;
AddressRequest addressRequest = new AddressRequest
{
FirstName = "John",
LastName = "Doe"
};
Address address = gateway.Address.Create(customer.Id, addressRequest).Target;
var updateRequest = new CustomerRequest
{
CreditCard = new CreditCardRequest
{
Number = "4111111111111111",
ExpirationDate = "10/10",
BillingAddressId = address.Id
}
};
Customer updatedCustomer = gateway.Customer.Update(customer.Id, updateRequest).Target;
Address billingAddress = updatedCustomer.CreditCards[0].BillingAddress;
Assert.AreEqual(address.Id, billingAddress.Id);
Assert.AreEqual("John", billingAddress.FirstName);
Assert.AreEqual("Doe", billingAddress.LastName);
}
示例15: Update_UpdatesCustomerAndNestedValues
public void Update_UpdatesCustomerAndNestedValues()
{
var createRequest = new CustomerRequest()
{
FirstName = "Old First",
LastName = "Old Last",
CreditCard = new CreditCardRequest()
{
Number = "4111111111111111",
ExpirationDate = "10/10",
BillingAddress = new CreditCardAddressRequest()
{
PostalCode = "11111"
}
}
};
Customer customer = gateway.Customer.Create(createRequest).Target;
CreditCard creditCard = customer.CreditCards[0];
Address address = creditCard.BillingAddress;
var updateRequest = new CustomerRequest()
{
FirstName = "New First",
LastName = "New Last",
CreditCard = new CreditCardRequest()
{
ExpirationDate = "12/12",
Options = new CreditCardOptionsRequest()
{
UpdateExistingToken = creditCard.Token
},
BillingAddress = new CreditCardAddressRequest()
{
PostalCode = "44444",
CountryName = "Chad",
CountryCodeAlpha2 = "TD",
CountryCodeAlpha3 = "TCD",
CountryCodeNumeric = "148",
Options = new CreditCardAddressOptionsRequest()
{
UpdateExisting = true
}
}
}
};
Customer updatedCustomer = gateway.Customer.Update(customer.Id, updateRequest).Target;
CreditCard updatedCreditCard = gateway.CreditCard.Find(creditCard.Token);
Address updatedAddress = gateway.Address.Find(customer.Id, address.Id);
Assert.AreEqual("New First", updatedCustomer.FirstName);
Assert.AreEqual("New Last", updatedCustomer.LastName);
Assert.AreEqual("12/2012", updatedCreditCard.ExpirationDate);
Assert.AreEqual("44444", updatedAddress.PostalCode);
Assert.AreEqual("Chad", updatedAddress.CountryName);
Assert.AreEqual("TD", updatedAddress.CountryCodeAlpha2);
Assert.AreEqual("TCD", updatedAddress.CountryCodeAlpha3);
Assert.AreEqual("148", updatedAddress.CountryCodeNumeric);
}