本文整理汇总了C#中Braintree.CreditCardRequest类的典型用法代码示例。如果您正苦于以下问题:C# CreditCardRequest类的具体用法?C# CreditCardRequest怎么用?C# CreditCardRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CreditCardRequest类属于Braintree命名空间,在下文中一共展示了CreditCardRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToXml_Includes_DeviceSessionId
public void ToXml_Includes_DeviceSessionId()
{
CreditCardRequest request = new CreditCardRequest();
request.DeviceSessionId = "my_dsid";
Assert.IsTrue(request.ToXml().Contains("my_dsid"));
}
示例2: ToXml_Includes_FraudMerchantId
public void ToXml_Includes_FraudMerchantId()
{
CreditCardRequest request = new CreditCardRequest();
request.FraudMerchantId = "my_fmid";
Assert.IsTrue(request.ToXml().Contains("my_fmid"));
}
示例3: ToXml_Includes_PaymentMethodNonce
public void ToXml_Includes_PaymentMethodNonce()
{
CreditCardRequest request = new CreditCardRequest();
request.PaymentMethodNonce = "my-payment-method-nonce";
Assert.IsTrue(request.ToXml().Contains("my-payment-method-nonce"));
}
示例4: ToXml_Includes_DeviceData
public void ToXml_Includes_DeviceData()
{
CreditCardRequest request = new CreditCardRequest();
request.DeviceData = "{\"device_session_id\":\"my_dsid\", \"fraud_merchant_id\":\"my_fmid\"}";
Assert.IsTrue(request.ToXml().Contains("device-data"));
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: AppendWithRequest
public void AppendWithRequest()
{
Request request = new CreditCardRequest
{
CVV = "123",
CardholderName = "Drew"
};
string actual = new QueryString().Append("[credit_card]", request).ToString();
Assert.AreEqual("%5bcredit_card%5d%5bcardholder_name%5d=Drew&%5bcredit_card%5d%5bcvv%5d=123", actual);
}
示例6: AppendWithNestedRequest
public void AppendWithNestedRequest()
{
Request request = new CreditCardRequest
{
CVV = "123",
CardholderName = "Drew",
Options = new CreditCardOptionsRequest
{
VerifyCard = true,
MakeDefault = true
}
};
string actual = new QueryString().Append("[credit_card]", request).ToString();
Assert.AreEqual("%5bcredit_card%5d%5bcardholder_name%5d=Drew&%5bcredit_card%5d%5bcvv%5d=123&%5bcredit_card%5d%5boptions%5d%5bmake_default%5d=true&%5bcredit_card%5d%5boptions%5d%5bverify_card%5d=true", actual);
}
示例7: Create_CreatesCreditCardForGivenCustomerId
public void Create_CreatesCreditCardForGivenCustomerId()
{
Customer customer = gateway.Customer.Create(new CustomerRequest()).Target;
var creditCardRequest = new CreditCardRequest
{
CustomerId = customer.Id,
Number = "5105105105105100",
ExpirationDate = "05/12",
CVV = "123",
CardholderName = "Michael Angelo",
BillingAddress = new CreditCardAddressRequest
{
FirstName = "John",
CountryName = "Chad",
CountryCodeAlpha2 = "TD",
CountryCodeAlpha3 = "TCD",
CountryCodeNumeric = "148"
}
};
CreditCard creditCard = gateway.CreditCard.Create(creditCardRequest).Target;
Assert.AreEqual("510510", creditCard.Bin);
Assert.AreEqual("5100", creditCard.LastFour);
Assert.AreEqual("510510******5100", creditCard.MaskedNumber);
Assert.AreEqual("05", creditCard.ExpirationMonth);
Assert.AreEqual("2012", creditCard.ExpirationYear);
Assert.AreEqual("Michael Angelo", creditCard.CardholderName);
Assert.IsTrue(creditCard.IsDefault.Value);
Assert.IsFalse(creditCard.IsVenmoSdk.Value);
Assert.AreEqual(DateTime.Now.Year, creditCard.CreatedAt.Value.Year);
Assert.AreEqual(DateTime.Now.Year, creditCard.UpdatedAt.Value.Year);
Assert.IsNotNull(creditCard.ImageUrl);
Address billingAddress = creditCard.BillingAddress;
Assert.AreEqual("Chad", billingAddress.CountryName);
Assert.AreEqual("TD", billingAddress.CountryCodeAlpha2);
Assert.AreEqual("TCD", billingAddress.CountryCodeAlpha3);
Assert.AreEqual("148", billingAddress.CountryCodeNumeric);
Assert.IsTrue(Regex.IsMatch(creditCard.UniqueNumberIdentifier, "\\A\\w{32}\\z"));
}
示例8: Find_FindsAssociatedSubscriptions
public void Find_FindsAssociatedSubscriptions()
{
Customer customer = gateway.Customer.Create(new CustomerRequest()).Target;
var creditCardRequest = new CreditCardRequest
{
CustomerId = customer.Id,
Number = "5105105105105100",
ExpirationDate = "05/12",
CVV = "123"
};
CreditCard originalCreditCard = gateway.CreditCard.Create(creditCardRequest).Target;
string id = Guid.NewGuid().ToString();
var subscriptionRequest = new SubscriptionRequest
{
Id = id,
PlanId = "integration_trialless_plan",
PaymentMethodToken = originalCreditCard.Token,
Price = 1.00M
};
gateway.Subscription.Create(subscriptionRequest);
CreditCard creditCard = gateway.CreditCard.Find(originalCreditCard.Token);
Subscription subscription = creditCard.Subscriptions[0];
Assert.AreEqual(id, subscription.Id);
Assert.AreEqual("integration_trialless_plan", subscription.PlanId);
Assert.AreEqual(1.00M, subscription.Price);
}
示例9: Update_UpdatesCreditCardByToken
public void Update_UpdatesCreditCardByToken()
{
Customer customer = gateway.Customer.Create(new CustomerRequest()).Target;
var creditCardCreateRequest = new CreditCardRequest
{
CustomerId = customer.Id,
Number = "5105105105105100",
ExpirationDate = "05/12",
CVV = "123",
CardholderName = "Michael Angelo"
};
CreditCard originalCreditCard = gateway.CreditCard.Create(creditCardCreateRequest).Target;
var creditCardUpdateRequest = new CreditCardRequest
{
CustomerId = customer.Id,
Number = "4111111111111111",
ExpirationDate = "12/05",
CVV = "321",
CardholderName = "Dave Inchy"
};
CreditCard creditCard = gateway.CreditCard.Update(originalCreditCard.Token, creditCardUpdateRequest).Target;
Assert.AreEqual("411111", creditCard.Bin);
Assert.AreEqual("1111", creditCard.LastFour);
Assert.AreEqual("12", creditCard.ExpirationMonth);
Assert.AreEqual("2005", creditCard.ExpirationYear);
Assert.AreEqual("Dave Inchy", creditCard.CardholderName);
Assert.AreEqual(DateTime.Now.Year, creditCard.CreatedAt.Value.Year);
Assert.AreEqual(DateTime.Now.Year, creditCard.UpdatedAt.Value.Year);
}
示例10: Create
public virtual Result<CreditCard> Create(CreditCardRequest request)
{
XmlNode creditCardXML = service.Post(service.MerchantPath() + "/payment_methods", request);
return new ResultImpl<CreditCard>(new NodeWrapper(creditCardXML), gateway);
}
示例11: Update
public virtual Result<CreditCard> Update(string token, CreditCardRequest request)
{
XmlNode creditCardXML = service.Put(service.MerchantPath() + "/payment_methods/credit_card/" + token, request);
return new ResultImpl<CreditCard>(new NodeWrapper(creditCardXML), gateway);
}
示例12: GatewayRejectionReason_ExposedOnVerification
public void GatewayRejectionReason_ExposedOnVerification()
{
BraintreeGateway processingRulesGateway = new BraintreeGateway
{
Environment = Environment.DEVELOPMENT,
MerchantId = "processing_rules_merchant_id",
PublicKey = "processing_rules_public_key",
PrivateKey = "processing_rules_private_key"
};
Customer customer = processingRulesGateway.Customer.Create(new CustomerRequest()).Target;
CreditCardRequest request = new CreditCardRequest
{
CustomerId = customer.Id,
CardholderName = "John Doe",
CVV = "200",
Number = "4111111111111111",
ExpirationDate = "05/12",
Options = new CreditCardOptionsRequest
{
VerifyCard = true
}
};
Result<CreditCard> result = processingRulesGateway.CreditCard.Create(request);
Assert.IsFalse(result.IsSuccess());
CreditCardVerification verification = result.CreditCardVerification;
Assert.AreEqual(TransactionGatewayRejectionReason.CVV, verification.GatewayRejectionReason);
}
示例13: VerifyInvalidCreditCard
public void VerifyInvalidCreditCard()
{
Customer customer = gateway.Customer.Create(new CustomerRequest()).Target;
CreditCardRequest request = new CreditCardRequest
{
CustomerId = customer.Id,
CardholderName = "John Doe",
CVV = "123",
Number = "5105105105105100",
ExpirationDate = "05/12",
Options = new CreditCardOptionsRequest
{
VerifyCard = true
}
};
Result<CreditCard> result = gateway.CreditCard.Create(request);
Assert.IsFalse(result.IsSuccess());
CreditCardVerification verification = result.CreditCardVerification;
Assert.AreEqual(VerificationStatus.PROCESSOR_DECLINED, verification.Status);
Assert.IsNull(verification.GatewayRejectionReason);
}
示例14: Update_CreatesNewBillingAddressByDefault
public void Update_CreatesNewBillingAddressByDefault()
{
Customer customer = gateway.Customer.Create(new CustomerRequest()).Target;
var request = new CreditCardRequest
{
CustomerId = customer.Id,
Number = "5105105105105100",
ExpirationDate = "05/12",
BillingAddress = new CreditCardAddressRequest
{
FirstName = "John"
}
};
CreditCard creditCard = gateway.CreditCard.Create(request).Target;
var updateRequest = new CreditCardRequest
{
BillingAddress = new CreditCardAddressRequest
{
LastName = "Jones",
CountryName = "El Salvador",
CountryCodeAlpha2 = "SV",
CountryCodeAlpha3 = "SLV",
CountryCodeNumeric = "222"
}
};
CreditCard updatedCreditCard = gateway.CreditCard.Update(creditCard.Token, updateRequest).Target;
Assert.IsNull(updatedCreditCard.BillingAddress.FirstName);
Assert.AreEqual("Jones", updatedCreditCard.BillingAddress.LastName);
Assert.AreNotEqual(creditCard.BillingAddress.Id, updatedCreditCard.BillingAddress.Id);
Address billingAddress = updatedCreditCard.BillingAddress;
Assert.AreEqual("El Salvador", billingAddress.CountryName);
Assert.AreEqual("SV", billingAddress.CountryCodeAlpha2);
Assert.AreEqual("SLV", billingAddress.CountryCodeAlpha3);
Assert.AreEqual("222", billingAddress.CountryCodeNumeric);
}
示例15: Update_UpdatesDefaultIfSpecified
public void Update_UpdatesDefaultIfSpecified()
{
Customer customer = gateway.Customer.Create(new CustomerRequest()).Target;
var creditCardCreateRequest = new CreditCardRequest
{
CustomerId = customer.Id,
Number = "5105105105105100",
ExpirationDate = "05/12",
CVV = "123",
CardholderName = "Michael Angelo"
};
CreditCard card1 = gateway.CreditCard.Create(creditCardCreateRequest).Target;
CreditCard card2 = gateway.CreditCard.Create(creditCardCreateRequest).Target;
Assert.IsTrue(card1.IsDefault.Value);
Assert.IsFalse(card2.IsDefault.Value);
var creditCardUpdateRequest = new CreditCardRequest
{
Options = new CreditCardOptionsRequest
{
MakeDefault = true
}
};
gateway.CreditCard.Update(card2.Token, creditCardUpdateRequest);
Assert.IsFalse(gateway.CreditCard.Find(card1.Token).IsDefault.Value);
Assert.IsTrue(gateway.CreditCard.Find(card2.Token).IsDefault.Value);
}