Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

2.4.0

  • Loading branch information...
commit c007571e89b22b7826e81413ea9914384f15596e 1 parent b927284
Braintree Open Source braintreeps authored

Showing 30 changed files with 664 additions and 65 deletions. Show diff stats Hide diff stats

  1. +1 0  Braintree.Tests/Braintree.Tests.csproj
  2. +52 14 Braintree.Tests/CreditCardTest.cs
  3. +2 2 Braintree.Tests/CryptoTest.cs
  4. +112 1 Braintree.Tests/CustomerTest.cs
  5. +36 18 Braintree.Tests/SubscriptionTest.cs
  6. +7 0 Braintree.Tests/TrUtilTest.cs
  7. +30 2 Braintree.Tests/TransactionTest.cs
  8. +1 0  Braintree.Tests/TransparentRedirectRequestTest.cs
  9. +192 0 Braintree.Tests/TransparentRedirectTest.cs
  10. +6 4 Braintree/Braintree.csproj
  11. +5 0 Braintree/BraintreeGateway.cs
  12. +4 2 Braintree/CreditCard.cs
  13. +43 0 Braintree/CreditCardGateway.cs
  14. +3 0  Braintree/CreditCardOptionsRequest.cs
  15. +12 0 Braintree/CreditCardRequest.cs
  16. +4 1 Braintree/CustomerGateway.cs
  17. +12 0 Braintree/CustomerRequest.cs
  18. +3 3 Braintree/{CustomerSearchRequest.cs → IdsSearchRequest.cs}
  19. +2 2 Braintree/Properties/AssemblyInfo.cs
  20. +5 0 Braintree/Request.cs
  21. +26 0 Braintree/StatusEvent.cs
  22. +1 0  Braintree/TrUtil.cs
  23. +21 5 Braintree/Transaction.cs
  24. +2 0  Braintree/TransactionGateway.cs
  25. +5 0 Braintree/TransactionRequest.cs
  26. +49 0 Braintree/TransparentRedirectGateway.cs
  27. +2 1  Braintree/TransparentRedirectRequest.cs
  28. +14 7 Braintree/ValidationErrorCode.cs
  29. +9 0 CHANGELOG.md
  30. +3 3 braintree.shfbproj
1  Braintree.Tests/Braintree.Tests.csproj
@@ -75,6 +75,7 @@
75 75 <Compile Include="RequestTest.cs" />
76 76 <Compile Include="ResourceCollectionTest.cs" />
77 77 <Compile Include="MultipleValueNodeTest.cs" />
  78 + <Compile Include="TransparentRedirectTest.cs" />
78 79 </ItemGroup>
79 80 <ItemGroup>
80 81 <ProjectReference Include="..\Braintree\Braintree.csproj">
66 Braintree.Tests/CreditCardTest.cs
... ... @@ -1,4 +1,5 @@
1 1 using System;
  2 +using System.Collections.Generic;
2 3 using NUnit.Framework;
3 4 using Braintree;
4 5 using Braintree.Exceptions;
@@ -66,7 +67,7 @@ public void Create_CreatesCreditCardForGivenCustomerId()
66 67 Assert.AreEqual("05", creditCard.ExpirationMonth);
67 68 Assert.AreEqual("2012", creditCard.ExpirationYear);
68 69 Assert.AreEqual("Michael Angelo", creditCard.CardholderName);
69   - Assert.IsTrue(creditCard.Default.Value);
  70 + Assert.IsTrue(creditCard.IsDefault.Value);
70 71 Assert.AreEqual(DateTime.Now.Year, creditCard.CreatedAt.Value.Year);
71 72 Assert.AreEqual(DateTime.Now.Year, creditCard.UpdatedAt.Value.Year);
72 73 }
@@ -111,7 +112,7 @@ public void ConfirmTransparentRedirectCreate_CreatesTheCreditCardObservingMakeDe
111 112 };
112 113
113 114 CreditCard creditCard = gateway.CreditCard.Create(request).Target;
114   - Assert.IsTrue(creditCard.Default.Value);
  115 + Assert.IsTrue(creditCard.IsDefault.Value);
115 116
116 117 CreditCardRequest trParams = new CreditCardRequest
117 118 {
@@ -125,7 +126,7 @@ public void ConfirmTransparentRedirectCreate_CreatesTheCreditCardObservingMakeDe
125 126 String queryString = TestHelper.QueryStringForTR(trParams, request, gateway.CreditCard.TransparentRedirectURLForCreate());
126 127
127 128 CreditCard card = gateway.CreditCard.ConfirmTransparentRedirect(queryString).Target;
128   - Assert.IsTrue(card.Default.Value);
  129 + Assert.IsTrue(card.IsDefault.Value);
129 130 }
130 131
131 132 [Test]
@@ -145,7 +146,7 @@ public void ConfirmTransparentRedirectCreate_CreatesTheCreditCardObservingMakeDe
145 146 };
146 147
147 148 CreditCard creditCard = gateway.CreditCard.Create(request).Target;
148   - Assert.IsTrue(creditCard.Default.Value);
  149 + Assert.IsTrue(creditCard.IsDefault.Value);
149 150
150 151 CreditCardRequest trParams = new CreditCardRequest
151 152 {
@@ -155,7 +156,7 @@ public void ConfirmTransparentRedirectCreate_CreatesTheCreditCardObservingMakeDe
155 156 String queryString = TestHelper.QueryStringForTR(trParams, request, gateway.CreditCard.TransparentRedirectURLForCreate());
156 157
157 158 CreditCard card = gateway.CreditCard.ConfirmTransparentRedirect(queryString).Target;
158   - Assert.IsTrue(card.Default.Value);
  159 + Assert.IsTrue(card.IsDefault.Value);
159 160 }
160 161
161 162 [Test]
@@ -281,8 +282,8 @@ public void Create_SetsDefaultIfSpecified()
281 282 CreditCard card1 = gateway.CreditCard.Create(request1).Target;
282 283 CreditCard card2 = gateway.CreditCard.Create(request2).Target;
283 284
284   - Assert.IsFalse(gateway.CreditCard.Find(card1.Token).Default.Value);
285   - Assert.IsTrue(gateway.CreditCard.Find(card2.Token).Default.Value);
  285 + Assert.IsFalse(gateway.CreditCard.Find(card1.Token).IsDefault.Value);
  286 + Assert.IsTrue(gateway.CreditCard.Find(card2.Token).IsDefault.Value);
286 287 }
287 288
288 289 [Test]
@@ -302,8 +303,8 @@ public void Update_UpdatesDefaultIfSpecified()
302 303 CreditCard card1 = gateway.CreditCard.Create(creditCardCreateRequest).Target;
303 304 CreditCard card2 = gateway.CreditCard.Create(creditCardCreateRequest).Target;
304 305
305   - Assert.IsTrue(card1.Default.Value);
306   - Assert.IsFalse(card2.Default.Value);
  306 + Assert.IsTrue(card1.IsDefault.Value);
  307 + Assert.IsFalse(card2.IsDefault.Value);
307 308
308 309
309 310 var creditCardUpdateRequest = new CreditCardRequest
@@ -316,8 +317,8 @@ public void Update_UpdatesDefaultIfSpecified()
316 317
317 318 gateway.CreditCard.Update(card2.Token, creditCardUpdateRequest);
318 319
319   - Assert.IsFalse(gateway.CreditCard.Find(card1.Token).Default.Value);
320   - Assert.IsTrue(gateway.CreditCard.Find(card2.Token).Default.Value);
  320 + Assert.IsFalse(gateway.CreditCard.Find(card1.Token).IsDefault.Value);
  321 + Assert.IsTrue(gateway.CreditCard.Find(card2.Token).IsDefault.Value);
321 322 }
322 323
323 324 [Test]
@@ -502,7 +503,7 @@ public void Delete_DeletesTheCreditCard()
502 503 }
503 504
504 505 [Test]
505   - public void verifyValidCreditCard()
  506 + public void VerifyValidCreditCard()
506 507 {
507 508 Customer customer = gateway.Customer.Create(new CustomerRequest()).Target;
508 509 CreditCardRequest request = new CreditCardRequest
@@ -523,7 +524,7 @@ public void verifyValidCreditCard()
523 524 }
524 525
525 526 [Test]
526   - public void verifyValidCreditCardSpecifyingMerhantAccount()
  527 + public void VerifyValidCreditCardSpecifyingMerhantAccount()
527 528 {
528 529 Customer customer = gateway.Customer.Create(new CustomerRequest()).Target;
529 530 CreditCardRequest request = new CreditCardRequest
@@ -546,7 +547,7 @@ public void verifyValidCreditCardSpecifyingMerhantAccount()
546 547 }
547 548
548 549 [Test]
549   - public void verifyInvalidCreditCard()
  550 + public void VerifyInvalidCreditCard()
550 551 {
551 552 Customer customer = gateway.Customer.Create(new CustomerRequest()).Target;
552 553 CreditCardRequest request = new CreditCardRequest
@@ -567,5 +568,42 @@ public void verifyInvalidCreditCard()
567 568 CreditCardVerification verification = result.CreditCardVerification;
568 569 Assert.AreEqual("processor_declined", verification.Status);
569 570 }
  571 +
  572 + [Test]
  573 + public void Expired()
  574 + {
  575 + ResourceCollection<CreditCard> collection = gateway.CreditCard.Expired();
  576 +
  577 + Assert.IsTrue(collection.MaximumCount > 1);
  578 +
  579 + List<String> cards = new List<String>();
  580 + foreach (CreditCard card in collection) {
  581 + Assert.IsTrue(card.IsExpired.Value);
  582 + cards.Add(card.Token);
  583 + }
  584 +
  585 + HashSet<String> uniqueCards = new HashSet<String>(cards);
  586 + Assert.AreEqual(uniqueCards.Count, collection.MaximumCount);
  587 + }
  588 +
  589 + [Test]
  590 + public void ExpiringBetween()
  591 + {
  592 + DateTime beginning = new DateTime(2010, 1, 1);
  593 + DateTime end = new DateTime(2010, 12, 31);
  594 +
  595 + ResourceCollection<CreditCard> collection = gateway.CreditCard.ExpiringBetween(beginning, end);
  596 +
  597 + Assert.IsTrue(collection.MaximumCount > 1);
  598 +
  599 + List<String> cards = new List<String>();
  600 + foreach (CreditCard card in collection) {
  601 + Assert.AreEqual("2010", card.ExpirationYear);
  602 + cards.Add(card.Token);
  603 + }
  604 +
  605 + HashSet<String> uniqueCards = new HashSet<String>(cards);
  606 + Assert.AreEqual(uniqueCards.Count, collection.MaximumCount);
  607 + }
570 608 }
571 609 }
4 Braintree.Tests/CryptoTest.cs
... ... @@ -1,4 +1,4 @@
1   -using System;
  1 +using System;
2 2 using System.Collections.Generic;
3 3 using System.Text;
4 4 using NUnit.Framework;
@@ -10,7 +10,7 @@ namespace Braintree.Tests
10 10 public class CryptoTest
11 11 {
12 12 [Test]
13   - public void hmacHash_ReturnsCorrectHash()
  13 + public void HmacHash_ReturnsCorrectHash()
14 14 {
15 15 String actual = new Crypto().HmacHash("secretKey", "hello world");
16 16 Assert.AreEqual("D503D7A1A6ADBA1E6474E9FF2C4167F9DFDF4247", actual);
113 Braintree.Tests/CustomerTest.cs
@@ -326,6 +326,62 @@ public void ConfirmTransparentRedirect_UpdatesTheCustomer()
326 326 }
327 327
328 328 [Test]
  329 + public void Update_UpdatesCustomerAndNestedValuesViaTr()
  330 + {
  331 + var createRequest = new CustomerRequest()
  332 + {
  333 + FirstName = "Old First",
  334 + LastName = "Old Last",
  335 + CreditCard = new CreditCardRequest()
  336 + {
  337 + Number = "4111111111111111",
  338 + ExpirationDate = "10/10",
  339 + BillingAddress = new CreditCardAddressRequest()
  340 + {
  341 + PostalCode = "11111"
  342 + }
  343 + }
  344 + };
  345 +
  346 + Customer customer = gateway.Customer.Create(createRequest).Target;
  347 + CreditCard creditCard = customer.CreditCards[0];
  348 + Address address = creditCard.BillingAddress;
  349 +
  350 + var trParams = new CustomerRequest()
  351 + {
  352 + CustomerId = customer.Id,
  353 + FirstName = "New First",
  354 + LastName = "New Last",
  355 + CreditCard = new CreditCardRequest()
  356 + {
  357 + ExpirationDate = "12/12",
  358 + Options = new CreditCardOptionsRequest()
  359 + {
  360 + UpdateExistingToken = creditCard.Token
  361 + },
  362 + BillingAddress = new CreditCardAddressRequest()
  363 + {
  364 + PostalCode = "44444",
  365 + Options = new CreditCardAddressOptionsRequest()
  366 + {
  367 + UpdateExisting = true
  368 + }
  369 + }
  370 + }
  371 + };
  372 +
  373 + String queryString = TestHelper.QueryStringForTR(trParams, new CustomerRequest(), gateway.Customer.TransparentRedirectURLForUpdate());
  374 + Customer updatedCustomer = gateway.Customer.ConfirmTransparentRedirect(queryString).Target;
  375 + CreditCard updatedCreditCard = gateway.CreditCard.Find(creditCard.Token);
  376 + Address updatedAddress = gateway.Address.Find(customer.Id, address.Id);
  377 +
  378 + Assert.AreEqual("New First", updatedCustomer.FirstName);
  379 + Assert.AreEqual("New Last", updatedCustomer.LastName);
  380 + Assert.AreEqual("12/2012", updatedCreditCard.ExpirationDate);
  381 + Assert.AreEqual("44444", updatedAddress.PostalCode);
  382 + }
  383 +
  384 + [Test]
329 385 public void Update_UpdatesCustomerWithNewValues()
330 386 {
331 387 string oldId = Guid.NewGuid().ToString();
@@ -370,6 +426,60 @@ public void Update_UpdatesCustomerWithNewValues()
370 426 }
371 427
372 428 [Test]
  429 + public void Update_UpdatesCustomerAndNestedValues()
  430 + {
  431 + var createRequest = new CustomerRequest()
  432 + {
  433 + FirstName = "Old First",
  434 + LastName = "Old Last",
  435 + CreditCard = new CreditCardRequest()
  436 + {
  437 + Number = "4111111111111111",
  438 + ExpirationDate = "10/10",
  439 + BillingAddress = new CreditCardAddressRequest()
  440 + {
  441 + PostalCode = "11111"
  442 + }
  443 + }
  444 + };
  445 +
  446 + Customer customer = gateway.Customer.Create(createRequest).Target;
  447 + CreditCard creditCard = customer.CreditCards[0];
  448 + Address address = creditCard.BillingAddress;
  449 +
  450 + var updateRequest = new CustomerRequest()
  451 + {
  452 + FirstName = "New First",
  453 + LastName = "New Last",
  454 + CreditCard = new CreditCardRequest()
  455 + {
  456 + ExpirationDate = "12/12",
  457 + Options = new CreditCardOptionsRequest()
  458 + {
  459 + UpdateExistingToken = creditCard.Token
  460 + },
  461 + BillingAddress = new CreditCardAddressRequest()
  462 + {
  463 + PostalCode = "44444",
  464 + Options = new CreditCardAddressOptionsRequest()
  465 + {
  466 + UpdateExisting = true
  467 + }
  468 + }
  469 + }
  470 + };
  471 +
  472 + Customer updatedCustomer = gateway.Customer.Update(customer.Id, updateRequest).Target;
  473 + CreditCard updatedCreditCard = gateway.CreditCard.Find(creditCard.Token);
  474 + Address updatedAddress = gateway.Address.Find(customer.Id, address.Id);
  475 +
  476 + Assert.AreEqual("New First", updatedCustomer.FirstName);
  477 + Assert.AreEqual("New Last", updatedCustomer.LastName);
  478 + Assert.AreEqual("12/2012", updatedCreditCard.ExpirationDate);
  479 + Assert.AreEqual("44444", updatedAddress.PostalCode);
  480 + }
  481 +
  482 + [Test]
373 483 public void Delete_DeletesTheCustomer()
374 484 {
375 485 String id = Guid.NewGuid().ToString();
@@ -398,8 +508,9 @@ public void Delete_DeletesTheCustomer()
398 508 foreach (Customer item in collection) {
399 509 items.Add(item.Id);
400 510 }
  511 + HashSet<String> uniqueItems = new HashSet<String>(items);
401 512
402   - Assert.AreEqual(items.Count, collection.MaximumCount);
  513 + Assert.AreEqual(uniqueItems.Count, collection.MaximumCount);
403 514 }
404 515 }
405 516 }
54 Braintree.Tests/SubscriptionTest.cs
@@ -536,6 +536,34 @@ public void UpdatePlan()
536 536 }
537 537
538 538 [Test]
  539 + public void Update_PaymentMethodToken()
  540 + {
  541 + Subscription subscription = gateway.Subscription.Create(new SubscriptionRequest
  542 + {
  543 + PaymentMethodToken = creditCard.Token,
  544 + PlanId = Plan.PLAN_WITHOUT_TRIAL.Id,
  545 + }).Target;
  546 +
  547 + CreditCard newCreditCard = gateway.CreditCard.Create(new CreditCardRequest
  548 + {
  549 + CustomerId = creditCard.CustomerId,
  550 + Number = "5105105105105100",
  551 + ExpirationDate = "05/12",
  552 + CVV = "123",
  553 + CardholderName = creditCard.CardholderName
  554 +
  555 + }).Target;
  556 +
  557 + SubscriptionRequest updateRequest = new SubscriptionRequest { PaymentMethodToken = newCreditCard.Token };
  558 + Result<Subscription> result = gateway.Subscription.Update(subscription.Id, updateRequest);
  559 +
  560 + Assert.IsTrue(result.IsSuccess());
  561 + subscription = result.Target;
  562 +
  563 + Assert.AreEqual(newCreditCard.Token, subscription.PaymentMethodToken);
  564 + }
  565 +
  566 + [Test]
539 567 public void UpdateMerchantAccountId()
540 568 {
541 569 Plan originalPlan = Plan.PLAN_WITHOUT_TRIAL;
@@ -613,15 +641,10 @@ public void Create_WithBadPlanId()
613 641 PlanId = "noSuchPlanId"
614 642 };
615 643
616   - try
617   - {
618   - gateway.Subscription.Create(createRequest);
619   - Assert.Fail("Expected NotFoundException.");
620   - }
621   - catch (NotFoundException)
622   - {
623   - // expected
624   - }
  644 + Result<Subscription> result = gateway.Subscription.Create(createRequest);
  645 +
  646 + Assert.IsFalse(result.IsSuccess());
  647 + Assert.AreEqual(ValidationErrorCode.SUBSCRIPTION_PLAN_ID_IS_INVALID, result.Errors.ForObject("subscription").OnField("plan_id")[0].Code);
625 648 }
626 649
627 650 [Test]
@@ -633,15 +656,10 @@ public void Create_WithBadPaymentMethod()
633 656 PlanId = Plan.PLAN_WITHOUT_TRIAL.Id
634 657 };
635 658
636   - try
637   - {
638   - gateway.Subscription.Create(createRequest);
639   - Assert.Fail("Expected NotFoundException.");
640   - }
641   - catch (NotFoundException)
642   - {
643   - // expected
644   - }
  659 + Result<Subscription> result = gateway.Subscription.Create(createRequest);
  660 +
  661 + Assert.IsFalse(result.IsSuccess());
  662 + Assert.AreEqual(ValidationErrorCode.SUBSCRIPTION_PAYMENT_METHOD_TOKEN_IS_INVALID, result.Errors.ForObject("subscription").OnField("payment_method_token")[0].Code);
645 663 }
646 664
647 665 [Test]
7 Braintree.Tests/TrUtilTest.cs
@@ -27,6 +27,13 @@ public void IncludesApiVersion()
27 27 }
28 28
29 29 [Test]
  30 + public void IncludesKind()
  31 + {
  32 + String tr_data = TrUtil.BuildTrData(new TransactionRequest(), "example.com");
  33 + TestHelper.AssertIncludes("kind=create_transaction", tr_data);
  34 + }
  35 +
  36 + [Test]
30 37 public void IsValidTrQueryString_ForValidString()
31 38 {
32 39 String queryString = "http_status=200&id=6kdj469tw7yck32j&hash=99c9ff20cd7910a1c1e793ff9e3b2d15586dc6b9";
32 Braintree.Tests/TransactionTest.cs
@@ -1415,6 +1415,27 @@ public void SubmitForSettlement_WithAmount()
1415 1415 }
1416 1416
1417 1417 [Test]
  1418 + public void StatusHistory_HasCorrectValues()
  1419 + {
  1420 + TransactionRequest request = new TransactionRequest
  1421 + {
  1422 + Amount = SandboxValues.TransactionAmount.AUTHORIZE,
  1423 + CreditCard = new CreditCardRequest
  1424 + {
  1425 + Number = SandboxValues.CreditCardNumber.VISA,
  1426 + ExpirationDate = "05/2008"
  1427 + }
  1428 + };
  1429 +
  1430 + String transactionId = gateway.Transaction.Sale(request).Target.Id;
  1431 + Transaction transaction = gateway.Transaction.SubmitForSettlement(transactionId, Decimal.Parse("50.00")).Target;
  1432 +
  1433 + Assert.AreEqual(2, transaction.StatusHistory.Length);
  1434 + Assert.AreEqual(TransactionStatus.AUTHORIZED, transaction.StatusHistory[0].Status);
  1435 + Assert.AreEqual(TransactionStatus.SUBMITTED_FOR_SETTLEMENT, transaction.StatusHistory[1].Status);
  1436 + }
  1437 +
  1438 + [Test]
1418 1439 public void SubmitForSettlement_WithValidationError()
1419 1440 {
1420 1441 TransactionRequest request = new TransactionRequest
@@ -1480,9 +1501,16 @@ public void Refund_WithABasicTransaction()
1480 1501 System.Console.WriteLine("Got exception! " + e.Source);
1481 1502 throw e;
1482 1503 }
  1504 +
1483 1505 Assert.IsTrue(result.IsSuccess());
1484   - Assert.AreEqual(TransactionType.CREDIT, result.Target.Type);
1485   - Assert.AreEqual(transaction.Amount, result.Target.Amount);
  1506 + var refund = result.Target;
  1507 +
  1508 + Assert.AreEqual(TransactionType.CREDIT, refund.Type);
  1509 + Assert.AreEqual(transaction.Amount, refund.Amount);
  1510 +
  1511 + Transaction firstTransaction = gateway.Transaction.Find(transaction.Id);
  1512 + Assert.AreEqual(refund.Id, firstTransaction.RefundId);
  1513 + Assert.AreEqual(firstTransaction.Id, refund.RefundedTransactionId);
1486 1514 }
1487 1515
1488 1516 [Test]
1  Braintree.Tests/TransparentRedirectRequestTest.cs
@@ -148,5 +148,6 @@ public void Constructor_AuthenticationExceptionIfBadCredentials()
148 148 // expected
149 149 }
150 150 }
  151 +
151 152 }
152 153 }
192 Braintree.Tests/TransparentRedirectTest.cs
... ... @@ -0,0 +1,192 @@
  1 +using System;
  2 +using NUnit.Framework;
  3 +using Braintree;
  4 +
  5 +namespace Braintree.Tests
  6 +{
  7 + [TestFixture]
  8 + public class TransparentRedirectTest
  9 + {
  10 + private BraintreeGateway gateway;
  11 +
  12 + [SetUp]
  13 + public void Setup()
  14 + {
  15 + gateway = new BraintreeGateway
  16 + {
  17 + Environment = Environment.DEVELOPMENT,
  18 + MerchantId = "integration_merchant_id",
  19 + PublicKey = "integration_public_key",
  20 + PrivateKey = "integration_private_key"
  21 + };
  22 + }
  23 +
  24 + [Test]
  25 + public void Url_ReturnsCorrectUrl()
  26 + {
  27 + var host = System.Environment.GetEnvironmentVariable("GATEWAY_HOST") ?? "localhost";
  28 + var port = System.Environment.GetEnvironmentVariable("GATEWAY_PORT") ?? "3000";
  29 +
  30 + var url = "http://" + host + ":" + port + "/merchants/integration_merchant_id/transparent_redirect_requests";
  31 + Assert.AreEqual(url, gateway.TransparentRedirect.Url);
  32 + }
  33 +
  34 + [Test]
  35 + public void CreateTransactionFromTransparentRedirect()
  36 + {
  37 + TransactionRequest trParams = new TransactionRequest
  38 + {
  39 + Type = TransactionType.SALE
  40 + };
  41 +
  42 + TransactionRequest request = new TransactionRequest
  43 + {
  44 + Amount = SandboxValues.TransactionAmount.AUTHORIZE,
  45 + CreditCard = new CreditCardRequest
  46 + {
  47 + Number = SandboxValues.CreditCardNumber.VISA,
  48 + ExpirationDate = "05/2009",
  49 + }
  50 + };
  51 +
  52 + String queryString = TestHelper.QueryStringForTR(trParams, request, gateway.TransparentRedirect.Url);
  53 + Result<Transaction> result = gateway.TransparentRedirect.ConfirmTransaction(queryString);
  54 + Assert.IsTrue(result.IsSuccess());
  55 + Transaction transaction = result.Target;
  56 +
  57 + Assert.AreEqual(1000.00, transaction.Amount);
  58 + Assert.AreEqual(TransactionType.SALE, transaction.Type);
  59 + Assert.AreEqual(TransactionStatus.AUTHORIZED, transaction.Status);
  60 + Assert.AreEqual(DateTime.Now.Year, transaction.CreatedAt.Value.Year);
  61 + Assert.AreEqual(DateTime.Now.Year, transaction.UpdatedAt.Value.Year);
  62 +
  63 + CreditCard creditCard = transaction.CreditCard;
  64 + Assert.AreEqual("411111", creditCard.Bin);
  65 + Assert.AreEqual("1111", creditCard.LastFour);
  66 + Assert.AreEqual("05", creditCard.ExpirationMonth);
  67 + Assert.AreEqual("2009", creditCard.ExpirationYear);
  68 + Assert.AreEqual("05/2009", creditCard.ExpirationDate);
  69 +
  70 + }
  71 +
  72 + [Test]
  73 + public void CreateCustomerFromTransparentRedirect()
  74 + {
  75 + CustomerRequest trParams = new CustomerRequest
  76 + {
  77 + FirstName = "John"
  78 + };
  79 +
  80 + CustomerRequest request = new CustomerRequest
  81 + {
  82 + LastName = "Doe"
  83 + };
  84 +
  85 + String queryString = TestHelper.QueryStringForTR(trParams, request, gateway.TransparentRedirect.Url);
  86 + Result<Customer> result = gateway.TransparentRedirect.ConfirmCustomer(queryString);
  87 + Assert.IsTrue(result.IsSuccess());
  88 + Customer customer = result.Target;
  89 +
  90 + Assert.AreEqual("John", customer.FirstName);
  91 + Assert.AreEqual("Doe", customer.LastName);
  92 + }
  93 +
  94 + [Test]
  95 + public void UpdateCustomerFromTransparentRedirect()
  96 + {
  97 + var createRequest = new CustomerRequest
  98 + {
  99 + FirstName = "Miranda",
  100 + LastName = "Higgenbottom"
  101 + };
  102 +
  103 + Customer createdCustomer = gateway.Customer.Create(createRequest).Target;
  104 +
  105 + CustomerRequest trParams = new CustomerRequest
  106 + {
  107 + CustomerId = createdCustomer.Id,
  108 + FirstName = "Penelope"
  109 + };
  110 +
  111 + CustomerRequest request = new CustomerRequest
  112 + {
  113 + LastName = "Lambert"
  114 + };
  115 +
  116 + String queryString = TestHelper.QueryStringForTR(trParams, request, gateway.TransparentRedirect.Url);
  117 + Result<Customer> result = gateway.TransparentRedirect.ConfirmCustomer(queryString);
  118 + Assert.IsTrue(result.IsSuccess());
  119 + Customer updatedCustomer = gateway.Customer.Find(createdCustomer.Id);
  120 +
  121 + Assert.AreEqual("Penelope", updatedCustomer.FirstName);
  122 + Assert.AreEqual("Lambert", updatedCustomer.LastName);
  123 + }
  124 +
  125 + [Test]
  126 + public void CreateCreditCardFromTransparentRedirect()
  127 + {
  128 + Customer customer = gateway.Customer.Create(new CustomerRequest()).Target;
  129 + CreditCardRequest trParams = new CreditCardRequest
  130 + {
  131 + CustomerId = customer.Id,
  132 + Number = "4111111111111111",
  133 + ExpirationDate = "10/10"
  134 + };
  135 +
  136 + CreditCardRequest request = new CreditCardRequest
  137 + {
  138 + CardholderName = "John Doe"
  139 + };
  140 +
  141 + String queryString = TestHelper.QueryStringForTR(trParams, request, gateway.TransparentRedirect.Url);
  142 + Result<CreditCard> result = gateway.TransparentRedirect.ConfirmCreditCard(queryString);
  143 + Assert.IsTrue(result.IsSuccess());
  144 + CreditCard creditCard = result.Target;
  145 +
  146 + Assert.AreEqual("John Doe", creditCard.CardholderName);
  147 + Assert.AreEqual("411111", creditCard.Bin);
  148 + Assert.AreEqual("1111", creditCard.LastFour);
  149 + Assert.AreEqual("10/2010", creditCard.ExpirationDate);
  150 + }
  151 +
  152 +
  153 + [Test]
  154 + public void UpdateCreditCardFromTransparentRedirect()
  155 + {
  156 + Customer customer = gateway.Customer.Create(new CustomerRequest()).Target;
  157 +
  158 + var creditCardRequest = new CreditCardRequest
  159 + {
  160 + CustomerId = customer.Id,
  161 + Number = "5105105105105100",
  162 + ExpirationDate = "05/12",
  163 + CardholderName = "Beverly D'angelo"
  164 + };
  165 +
  166 + CreditCard createdCreditCard = gateway.CreditCard.Create(creditCardRequest).Target;
  167 +
  168 +
  169 + CreditCardRequest trParams = new CreditCardRequest
  170 + {
  171 + PaymentMethodToken = createdCreditCard.Token,
  172 + Number = "4111111111111111",
  173 + ExpirationDate = "10/10"
  174 + };
  175 +
  176 + CreditCardRequest request = new CreditCardRequest
  177 + {
  178 + CardholderName = "Sampsonite"
  179 + };
  180 +
  181 + String queryString = TestHelper.QueryStringForTR(trParams, request, gateway.TransparentRedirect.Url);
  182 + Result<CreditCard> result = gateway.TransparentRedirect.ConfirmCreditCard(queryString);
  183 + Assert.IsTrue(result.IsSuccess());
  184 + CreditCard creditCard = gateway.CreditCard.Find(createdCreditCard.Token);
  185 +
  186 + Assert.AreEqual("Sampsonite", creditCard.CardholderName);
  187 + Assert.AreEqual("411111", creditCard.Bin);
  188 + Assert.AreEqual("1111", creditCard.LastFour);
  189 + Assert.AreEqual("10/2010", creditCard.ExpirationDate);
  190 + }
  191 + }
  192 +}
10 Braintree/Braintree.csproj
@@ -9,7 +9,7 @@
9 9 <OutputType>Library</OutputType>
10 10 <AppDesignerFolder>Properties</AppDesignerFolder>
11 11 <RootNamespace>Braintree</RootNamespace>
12   - <AssemblyName>Braintree-2.3.0</AssemblyName>
  12 + <AssemblyName>Braintree-2.4.0</AssemblyName>
13 13 <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
14 14 <FileAlignment>512</FileAlignment>
15 15 <TargetFrameworkSubset>
@@ -23,7 +23,7 @@
23 23 <DefineConstants>DEBUG;TRACE</DefineConstants>
24 24 <ErrorReport>prompt</ErrorReport>
25 25 <WarningLevel>4</WarningLevel>
26   - <DocumentationFile>bin\Debug\Braintree-2.3.0.xml</DocumentationFile>
  26 + <DocumentationFile>bin\Debug\Braintree-2.4.0.xml</DocumentationFile>
27 27 <NoWarn>1591</NoWarn>
28 28 </PropertyGroup>
29 29 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
@@ -33,7 +33,7 @@
33 33 <DefineConstants>TRACE</DefineConstants>
34 34 <ErrorReport>prompt</ErrorReport>
35 35 <WarningLevel>4</WarningLevel>
36   - <DocumentationFile>bin\Debug\Braintree-2.3.0.xml</DocumentationFile>
  36 + <DocumentationFile>bin\Debug\Braintree-2.4.0.xml</DocumentationFile>
37 37 <NoWarn>1591</NoWarn>
38 38 </PropertyGroup>
39 39 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
@@ -104,8 +104,10 @@
104 104 <Compile Include="DateRangeNode.cs" />
105 105 <Compile Include="CreditCardAddressRequest.cs" />
106 106 <Compile Include="CreditCardAddressOptionsRequest.cs" />
107   - <Compile Include="CustomerSearchRequest.cs" />
  107 + <Compile Include="IdsSearchRequest.cs" />
108 108 <Compile Include="Exceptions\UpgradeRequiredException.cs" />
  109 + <Compile Include="StatusEvent.cs" />
  110 + <Compile Include="TransparentRedirectGateway.cs" />
109 111 </ItemGroup>
110 112 <ItemGroup>
111 113 <Reference Include="System" />
5 Braintree/BraintreeGateway.cs
@@ -109,6 +109,11 @@ public virtual TransactionGateway Transaction
109 109 get { return new TransactionGateway(); }
110 110 }
111 111
  112 + public virtual TransparentRedirectGateway TransparentRedirect
  113 + {
  114 + get { return new TransparentRedirectGateway(); }
  115 + }
  116 +
112 117 public virtual String TrData(Request trData, String redirectURL)
113 118 {
114 119 return TrUtil.BuildTrData(trData, redirectURL);
6 Braintree/CreditCard.cs
@@ -63,7 +63,8 @@ public class CreditCard
63 63 public String CardType { get; protected set; }
64 64 public DateTime? CreatedAt { get; protected set; }
65 65 public String CustomerId { get; protected set; }
66   - public Boolean? Default { get; protected set; }
  66 + public Boolean? IsDefault { get; protected set; }
  67 + public Boolean? IsExpired { get; protected set; }
67 68 public String CustomerLocation { get; protected set; }
68 69 public String LastFour { get; protected set; }
69 70 public Subscription[] Subscriptions { get; protected set; }
@@ -101,9 +102,10 @@ internal CreditCard(NodeWrapper node)
101 102 CardholderName = node.GetString("cardholder-name");
102 103 CardType = node.GetString("card-type");
103 104 CustomerId = node.GetString("customer-id");
104   - Default = node.GetBoolean("default");
  105 + IsDefault = node.GetBoolean("default");
105 106 ExpirationMonth = node.GetString("expiration-month");
106 107 ExpirationYear = node.GetString("expiration-year");
  108 + IsExpired = node.GetBoolean("expired");
107 109 CustomerLocation = node.GetString("customer-location");
108 110 LastFour = node.GetString("last-4");
109 111 Token = node.GetString("token");
43 Braintree/CreditCardGateway.cs
@@ -12,11 +12,13 @@ namespace Braintree
12 12 /// </summary>
13 13 public class CreditCardGateway
14 14 {
  15 + [Obsolete("Use gateway.TransparentRedirect.Url")]
15 16 public virtual String TransparentRedirectURLForCreate()
16 17 {
17 18 return Configuration.BaseMerchantURL() + "/payment_methods/all/create_via_transparent_redirect_request";
18 19 }
19 20
  21 + [Obsolete("Use gateway.TransparentRedirect.Url")]
20 22 public virtual String TransparentRedirectURLForUpdate()
21 23 {
22 24 return Configuration.BaseMerchantURL() + "/payment_methods/all/update_via_transparent_redirect_request";
@@ -29,6 +31,7 @@ public virtual Result<CreditCard> Create(CreditCardRequest request)
29 31 return new Result<CreditCard>(new NodeWrapper(creditCardXML));
30 32 }
31 33
  34 + [Obsolete("Use gateway.TransparentRedirect.Confirm()")]
32 35 public virtual Result<CreditCard> ConfirmTransparentRedirect(String queryString)
33 36 {
34 37 TransparentRedirectRequest trRequest = new TransparentRedirectRequest(queryString);
@@ -37,6 +40,46 @@ public virtual Result<CreditCard> ConfirmTransparentRedirect(String queryString)
37 40 return new Result<CreditCard>(new NodeWrapper(creditCardXML));
38 41 }
39 42
  43 + public virtual ResourceCollection<CreditCard> Expired()
  44 + {
  45 + NodeWrapper response = new NodeWrapper(WebServiceGateway.Post("/payment_methods/all/expired_ids"));
  46 +
  47 + return new ResourceCollection<CreditCard>(response, delegate(String[] ids) {
  48 + IdsSearchRequest query = new IdsSearchRequest().
  49 + Ids.IncludedIn(ids);
  50 +
  51 + NodeWrapper fetchResponse = new NodeWrapper(WebServiceGateway.Post("/payment_methods/all/expired", query));
  52 +
  53 + List<CreditCard> creditCards = new List<CreditCard>();
  54 + foreach (NodeWrapper node in fetchResponse.GetList("credit-card"))
  55 + {
  56 + creditCards.Add(new CreditCard(node));
  57 + }
  58 + return creditCards;
  59 + });
  60 + }
  61 +
  62 + public virtual ResourceCollection<CreditCard> ExpiringBetween(DateTime start, DateTime end)
  63 + {
  64 + String queryString = String.Format("start={0:MMyyyy}&end={1:MMyyyy}", start, end);
  65 +
  66 + NodeWrapper response = new NodeWrapper(WebServiceGateway.Post("/payment_methods/all/expiring_ids?" + queryString));
  67 +
  68 + return new ResourceCollection<CreditCard>(response, delegate(String[] ids) {
  69 + IdsSearchRequest query = new IdsSearchRequest().
  70 + Ids.IncludedIn(ids);
  71 +
  72 + NodeWrapper fetchResponse = new NodeWrapper(WebServiceGateway.Post("/payment_methods/all/expiring?" + queryString, query));
  73 +
  74 + List<CreditCard> creditCards = new List<CreditCard>();
  75 + foreach (NodeWrapper node in fetchResponse.GetList("credit-card"))
  76 + {
  77 + creditCards.Add(new CreditCard(node));
  78 + }
  79 + return creditCards;
  80 + });
  81 + }
  82 +
40 83 public virtual CreditCard Find(String token)
41 84 {
42 85 XmlNode creditCardXML = WebServiceGateway.Get("/payment_methods/" + token);
3  Braintree/CreditCardOptionsRequest.cs
@@ -11,6 +11,7 @@ public class CreditCardOptionsRequest : Request
11 11 public Boolean VerifyCard { get; set; }
12 12 public Boolean MakeDefault { get; set; }
13 13 public String VerificationMerchantAccountId { get; set; }
  14 + public String UpdateExistingToken { get; set; }
14 15
15 16 public override String ToXml()
16 17 {
@@ -27,6 +28,7 @@ public override String ToXml(String rootElement)
27 28 }
28 29 builder.Append(BuildXMLElement("verification-merchant-account-id", VerificationMerchantAccountId));
29 30 builder.Append(BuildXMLElement("verify-card", VerifyCard));
  31 + builder.Append(BuildXMLElement("update-existing-token", UpdateExistingToken));
30 32 builder.Append(String.Format("</{0}>", rootElement));
31 33
32 34 return builder.ToString();
@@ -43,6 +45,7 @@ public override String ToQueryString(String root)
43 45 Append(ParentBracketChildString(root, "verification_merchant_account_id"), VerificationMerchantAccountId).
44 46 Append(ParentBracketChildString(root, "verify_card"), VerifyCard).
45 47 Append(ParentBracketChildString(root, "make_default"), MakeDefault).
  48 + Append(ParentBracketChildString(root, "update_existing_token"), UpdateExistingToken).
46 49 ToString();
47 50 }
48 51 }
12 Braintree/CreditCardRequest.cs
@@ -42,6 +42,18 @@ public class CreditCardRequest : Request
42 42 public String ExpirationDate { get; set; }
43 43 public String PaymentMethodToken { get; set; }
44 44
  45 + public override String Kind()
  46 + {
  47 + if (PaymentMethodToken == null)
  48 + {
  49 + return TransparentRedirectGateway.CREATE_PAYMENT_METHOD;
  50 + }
  51 + else
  52 + {
  53 + return TransparentRedirectGateway.UPDATE_PAYMENT_METHOD;
  54 + }
  55 + }
  56 +
45 57 public override String ToXml()
46 58 {
47 59 return ToXml("credit-card");
5 Braintree/CustomerGateway.cs
@@ -37,6 +37,7 @@ public virtual Result<Customer> Update(String Id, CustomerRequest request)
37 37 return new Result<Customer>(new NodeWrapper(customerXML));
38 38 }
39 39
  40 + [Obsolete("Use gateway.TransparentRedirect.Confirm()")]
40 41 public virtual Result<Customer> ConfirmTransparentRedirect(String queryString)
41 42 {
42 43 TransparentRedirectRequest trRequest = new TransparentRedirectRequest(queryString);
@@ -45,11 +46,13 @@ public virtual Result<Customer> ConfirmTransparentRedirect(String queryString)
45 46 return new Result<Customer>(new NodeWrapper(node));
46 47 }
47 48
  49 + [Obsolete("Use gateway.TransparentRedirect.Url")]
48 50 public virtual String TransparentRedirectURLForCreate()
49 51 {
50 52 return Configuration.BaseMerchantURL() + "/customers/all/create_via_transparent_redirect_request";
51 53 }
52 54
  55 + [Obsolete("Use gateway.TransparentRedirect.Url")]
53 56 public virtual String TransparentRedirectURLForUpdate()
54 57 {
55 58 return Configuration.BaseMerchantURL() + "/customers/all/update_via_transparent_redirect_request";
@@ -66,7 +69,7 @@ public virtual ResourceCollection<Customer> All()
66 69
67 70 private List<Customer> FetchCustomers(String[] ids)
68 71 {
69   - CustomerSearchRequest query = new CustomerSearchRequest().
  72 + IdsSearchRequest query = new IdsSearchRequest().
70 73 Ids.IncludedIn(ids);
71 74
72 75 NodeWrapper response = new NodeWrapper(WebServiceGateway.Post("/customers/advanced_search", query));
12 Braintree/CustomerRequest.cs
@@ -58,6 +58,18 @@ public class CustomerRequest : Request
58 58 public Dictionary<String, String> CustomFields { get; set; }
59 59 public CreditCardRequest CreditCard { get; set; }
60 60
  61 + public override String Kind()
  62 + {
  63 + if (CustomerId == null)
  64 + {
  65 + return TransparentRedirectGateway.CREATE_CUSTOMER;
  66 + }
  67 + else
  68 + {
  69 + return TransparentRedirectGateway.UPDATE_CUSTOMER;
  70 + }
  71 + }
  72 +
61 73 public override String ToXml()
62 74 {
63 75 return ToXml("customer");
6 Braintree/CustomerSearchRequest.cs → Braintree/IdsSearchRequest.cs
@@ -6,13 +6,13 @@
6 6
7 7 namespace Braintree
8 8 {
9   - public class CustomerSearchRequest : SearchRequest
  9 + public class IdsSearchRequest : SearchRequest
10 10 {
11   - public MultipleValueNode<CustomerSearchRequest> Ids
  11 + public MultipleValueNode<IdsSearchRequest> Ids
12 12 {
13 13 get
14 14 {
15   - return new MultipleValueNode<CustomerSearchRequest>("ids", this);
  15 + return new MultipleValueNode<IdsSearchRequest>("ids", this);
16 16 }
17 17 }
18 18 }
4 Braintree/Properties/AssemblyInfo.cs
@@ -29,5 +29,5 @@
29 29 // Build Number
30 30 // Revision
31 31 //
32   -[assembly: AssemblyVersion("2.2.0.0")]
33   -[assembly: AssemblyFileVersion("2.2.0.0")]
  32 +[assembly: AssemblyVersion("2.4.0.0")]
  33 +[assembly: AssemblyFileVersion("2.4.0.0")]
5 Braintree/Request.cs
@@ -62,6 +62,11 @@ internal virtual String BuildXMLElement(String tagName, String value)
62 62 return String.Format("<{0}>{1}</{0}>", SecurityElement.Escape(tagName), SecurityElement.Escape(value));
63 63 }
64 64
  65 + public virtual String Kind()
  66 + {
  67 + return null;
  68 + }
  69 +
65 70 protected virtual String ParentBracketChildString(String parent, String child)
66 71 {
67 72 return String.Format("{0}[{1}]", parent, child);
26 Braintree/StatusEvent.cs
... ... @@ -0,0 +1,26 @@
  1 +#pragma warning disable 1591
  2 +
  3 +using System;
  4 +
  5 +namespace Braintree
  6 +{
  7 + public class StatusEvent
  8 + {
  9 + public Decimal? Amount { get; protected set; }
  10 + public TransactionStatus Status { get; protected set; }
  11 + public DateTime? Timestamp { get; protected set; }
  12 + public TransactionSource Source { get; protected set; }
  13 + public String User { get; protected set; }
  14 +
  15 + public StatusEvent(NodeWrapper node)
  16 + {
  17 + if (node == null) return;
  18 +
  19 + Amount = node.GetDecimal("amount");
  20 + Status = (TransactionStatus)CollectionUtil.Find(TransactionStatus.ALL, node.GetString("status"), TransactionStatus.UNRECOGNIZED);
  21 + Timestamp = node.GetDateTime("timestamp");
  22 + Source = (TransactionSource)CollectionUtil.Find(TransactionSource.ALL, node.GetString("transaction-source"), TransactionSource.UNRECOGNIZED);
  23 + User = node.GetString("user");
  24 + }
  25 + }
  26 +}
1  Braintree/TrUtil.cs
@@ -17,6 +17,7 @@ public static String BuildTrData(Request request, String redirectURL)
17 17 Append("public_key", Configuration.PublicKey).
18 18 Append("redirect_url", redirectURL).
19 19 Append("time", dateString).
  20 + Append("kind", request.Kind()).
20 21 ToString();
21 22
22 23 String requestQueryString = request.ToQueryString();
26 Braintree/Transaction.cs
@@ -29,13 +29,16 @@ public class TransactionStatus : Enumeration
29 29 protected TransactionStatus(String name) : base(name) {}
30 30 }
31 31
32   - public abstract class TransactionSource
  32 + public class TransactionSource : Enumeration
33 33 {
34   - public const String API = "api";
35   - public const String CONTROL_PANEL = "control_panel";
36   - public const String RECURRING = "recurring";
  34 + public static readonly TransactionSource API = new TransactionSource("api");
  35 + public static readonly TransactionSource CONTROL_PANEL = new TransactionSource("control_panel");
  36 + public static readonly TransactionSource RECURRING = new TransactionSource("recurring");
  37 + public static readonly TransactionSource UNRECOGNIZED = new TransactionSource("unrecognized");
37 38
38   - public static readonly String[] ALL = { API, CONTROL_PANEL, RECURRING };
  39 + public static readonly TransactionSource[] ALL = { API, CONTROL_PANEL, RECURRING };
  40 +
  41 + protected TransactionSource(String name) : base(name) {}
39 42 }
40 43
41 44 public class TransactionType : Enumeration
@@ -85,8 +88,11 @@ public class Transaction
85 88 public String ProcessorAuthorizationCode { get; protected set; }
86 89 public String ProcessorResponseCode { get; protected set; }
87 90 public String ProcessorResponseText { get; protected set; }
  91 + public String RefundedTransactionId { get; protected set; }
  92 + public String RefundId { get; protected set; }
88 93 public Address ShippingAddress { get; protected set; }
89 94 public TransactionStatus Status { get; protected set; }
  95 + public StatusEvent[] StatusHistory { get; protected set; }
90 96 public String SubscriptionId { get; protected set; }
91 97 public TransactionType Type { get; protected set; }
92 98 public DateTime? UpdatedAt { get; protected set; }
@@ -103,11 +109,21 @@ internal Transaction(NodeWrapper node)
103 109 AvsStreetAddressResponseCode = node.GetString("avs-street-address-response-code");
104 110 OrderId = node.GetString("order-id");
105 111 Status = (TransactionStatus)CollectionUtil.Find(TransactionStatus.ALL, node.GetString("status"), TransactionStatus.UNRECOGNIZED);
  112 +
  113 + List<NodeWrapper> statusNodes = node.GetList("status-history/status-event");
  114 + StatusHistory = new StatusEvent[statusNodes.Count];
  115 + for (int i = 0; i < statusNodes.Count; i++)
  116 + {
  117 + StatusHistory[i] = new StatusEvent(statusNodes[i]);
  118 + }
  119 +
106 120 Type = (TransactionType)CollectionUtil.Find(TransactionType.ALL, node.GetString("type"), TransactionType.UNRECOGNIZED);
107 121 MerchantAccountId = node.GetString("merchant-account-id");
108 122 ProcessorAuthorizationCode = node.GetString("processor-authorization-code");
109 123 ProcessorResponseCode = node.GetString("processor-response-code");
110 124 ProcessorResponseText = node.GetString("processor-response-text");
  125 + RefundedTransactionId = node.GetString("refunded-transaction-id");
  126 + RefundId = node.GetString("refund-id");
111 127 SubscriptionId = node.GetString("subscription-id");
112 128 CustomFields = node.GetDictionary("custom-fields");
113 129 CreditCard = new CreditCard(node.GetNode("credit-card"));
2  Braintree/TransactionGateway.cs
@@ -11,11 +11,13 @@ namespace Braintree
11 11 /// </summary>
12 12 public class TransactionGateway
13 13 {
  14 + [Obsolete("Use gateway.TransparentRedirect.Url")]
14 15 public virtual String TransparentRedirectURLForCreate()
15 16 {
16 17 return Configuration.BaseMerchantURL() + "/transactions/all/create_via_transparent_redirect_request";
17 18 }
18 19
  20 + [Obsolete("Use gateway.TransparentRedirect.Confirm()")]
19 21 public virtual Result<Transaction> ConfirmTransparentRedirect(String queryString)
20 22 {
21 23 TransparentRedirectRequest trRequest = new TransparentRedirectRequest(queryString);
5 Braintree/TransactionRequest.cs
@@ -44,6 +44,11 @@ public TransactionRequest()
44 44 CustomFields = new Dictionary<String, String>();
45 45 }
46 46
  47 + public override String Kind()
  48 + {
  49 + return TransparentRedirectGateway.CREATE_TRANSACTION;
  50 + }
  51 +
47 52 public override String ToXml()
48 53 {
49 54 return ToXml("transaction");
49 Braintree/TransparentRedirectGateway.cs
... ... @@ -0,0 +1,49 @@
  1 +#pragma warning disable 1591
  2 +
  3 +using System;
  4 +using System.Xml;
  5 +
  6 +namespace Braintree
  7 +{
  8 + public class TransparentRedirectGateway
  9 + {
  10 + public const String CREATE_CUSTOMER = "create_customer";
  11 + public const String UPDATE_CUSTOMER = "update_customer";
  12 + public const String CREATE_PAYMENT_METHOD = "create_payment_method";
  13 + public const String UPDATE_PAYMENT_METHOD = "update_payment_method";
  14 + public const String CREATE_TRANSACTION = "create_transaction";
  15 +
  16 + public String Url
  17 + {
  18 + get { return Configuration.BaseMerchantURL() + "/transparent_redirect_requests"; }
  19 + }
  20 +
  21 + public TransparentRedirectGateway()
  22 + {
  23 + }
  24 +
  25 + public virtual Result<Transaction> ConfirmTransaction(String queryString)
  26 + {
  27 + TransparentRedirectRequest trRequest = new TransparentRedirectRequest(queryString);
  28 + XmlNode node = WebServiceGateway.Post("/transparent_redirect_requests/" + trRequest.Id + "/confirm", trRequest);
  29 +
  30 + return new Result<Transaction>(new NodeWrapper(node));
  31 + }
  32 +
  33 + public virtual Result<Customer> ConfirmCustomer(String queryString)
  34 + {
  35 + TransparentRedirectRequest trRequest = new TransparentRedirectRequest(queryString);