Skip to content

Commit

Permalink
2.32.0
Browse files Browse the repository at this point in the history
  • Loading branch information
braintreeps committed Aug 6, 2014
1 parent 38740ef commit 2e4e453
Show file tree
Hide file tree
Showing 25 changed files with 1,124 additions and 30 deletions.
14 changes: 7 additions & 7 deletions Braintree.Tests/ClientTokenTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public void Generate_GeneratedFingerprintIsAcceptedByGateway()
var authorizationFingerprint = TestHelper.extractParamFromJson("authorizationFingerprint", clientToken);

var encodedFingerprint = HttpUtility.UrlEncode(authorizationFingerprint, Encoding.UTF8);
var url = "nonces.json";
var url = "v1/payment_methods.json";
url += "?authorizationFingerprint=" + encodedFingerprint;
url += "&sharedCustomerIdentifierType=testing";
url += "&sharedCustomerIdentifier=test-identifier";
Expand Down Expand Up @@ -151,8 +151,8 @@ public void Generate_DefaultsToVersionTwo()
};
var encodedClientToken = gateway.ClientToken.generate();
var decodedClientToken = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(encodedClientToken));
String version = TestHelper.extractParamFromJson("version", decodedClientToken);
Assert.AreEqual("2", version);
int version = TestHelper.extractIntParamFromJson("version", decodedClientToken);
Assert.AreEqual(2, version);
}

[Test]
Expand Down Expand Up @@ -189,7 +189,7 @@ public void Generate_GatewayRespectsVerifyCard()
AddTopLevelElement("credit_card[expiration_month]", "11").
AddTopLevelElement("credit_card[expiration_year]", "2099");

HttpWebResponse Response = new BraintreeTestHttpService().Post(gateway.MerchantId, "nonces.json", builder.ToQueryString());
HttpWebResponse Response = new BraintreeTestHttpService().Post(gateway.MerchantId, "v1/payment_methods/credit_cards.json", builder.ToQueryString());
Assert.AreEqual(422, (int)Response.StatusCode);

Customer customer = gateway.Customer.Find(customerId);
Expand Down Expand Up @@ -240,8 +240,8 @@ public void Generate_GatewayRespectsFailOnDuplicatePaymentMethod()
AddTopLevelElement("credit_card[expiration_month]", "11").
AddTopLevelElement("credit_card[expiration_year]", "2099");

HttpWebResponse Response = new BraintreeTestHttpService().Post(gateway.MerchantId, "nonces.json", builder.ToQueryString());
Response = new BraintreeTestHttpService().Post(gateway.MerchantId, "nonces.json", builder.ToQueryString());
HttpWebResponse Response = new BraintreeTestHttpService().Post(gateway.MerchantId, "v1/payment_methods/credit_cards.json", builder.ToQueryString());
Response = new BraintreeTestHttpService().Post(gateway.MerchantId, "v1/payment_methods/credit_cards.json", builder.ToQueryString());

Assert.AreEqual(422, (int)Response.StatusCode);

Expand Down Expand Up @@ -292,7 +292,7 @@ public void Generate_GatewayRespectsMakeDefault()
AddTopLevelElement("credit_card[expiration_month]", "11").
AddTopLevelElement("credit_card[expiration_year]", "2099");

HttpWebResponse Response = new BraintreeTestHttpService().Post(gateway.MerchantId, "nonces.json", builder.ToQueryString());
HttpWebResponse Response = new BraintreeTestHttpService().Post(gateway.MerchantId, "v1/payment_methods/credit_cards.json", builder.ToQueryString());
Assert.AreEqual(HttpStatusCode.Created, Response.StatusCode);

Customer customer = gateway.Customer.Find(customerId);
Expand Down
4 changes: 2 additions & 2 deletions Braintree.Tests/CreditCardTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -524,14 +524,14 @@ public void FromNonce_ReturnsErrorWhenProvidedLockedNonce()
AddTopLevelElement("credit_card[expiration_month]", "11").
AddTopLevelElement("credit_card[expiration_year]", "2099");

httpService.Post(gateway.MerchantId, "nonces.json", builder.ToQueryString());
httpService.Post(gateway.MerchantId, "v1/payment_methods/credit_cards.json", builder.ToQueryString());

builder = new RequestBuilder("");
builder.AddTopLevelElement("authorization_fingerprint", authorizationFingerprint).
AddTopLevelElement("shared_customer_identifier_type", "testing").
AddTopLevelElement("shared_customer_identifier", "test-identifier");

HttpWebResponse response = httpService.Get(gateway.MerchantId, "nonces.json?" + builder.ToQueryString());
HttpWebResponse response = httpService.Get(gateway.MerchantId, "v1/payment_methods.json?" + builder.ToQueryString());
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
String responseBody = reader.ReadToEnd();

Expand Down
43 changes: 43 additions & 0 deletions Braintree.Tests/PayPalAccountTest.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
using System;
using System.Linq;
using NUnit.Framework;
using Braintree;
using Braintree.Exceptions;
using Braintree.Test;

using Params = System.Collections.Generic.Dictionary<string, object>;

namespace Braintree.Tests
{
[TestFixture]
Expand Down Expand Up @@ -167,5 +170,45 @@ public void Update_CanMakeDefault()
Assert.IsTrue(updateResult.IsSuccess());
Assert.IsTrue(updateResult.Target.IsDefault.Value);
}

[Test]
public void ReturnsSubscriptionsAssociatedWithPayPalAccount()
{
var customer = gateway.Customer.Create().Target;
var paymentMethodToken = string.Format("paypal-account-{0}", DateTime.Now.Ticks);
var nonce = TestHelper.GetNonceForPayPalAccount(
gateway,
new Params
{
{ "consent_code", "consent-code" },
{ "token", paymentMethodToken }
});

var result = gateway.PaymentMethod.Create(new PaymentMethodRequest
{
PaymentMethodNonce = nonce,
CustomerId = customer.Id
});

Assert.IsTrue(result.IsSuccess());
var token = result.Target.Token;
var subscription1 = gateway.Subscription.Create(new SubscriptionRequest
{
PaymentMethodToken = token,
PlanId = PlanFixture.PLAN_WITHOUT_TRIAL.Id
}).Target;

var subscription2 = gateway.Subscription.Create(new SubscriptionRequest
{
PaymentMethodToken = token,
PlanId = PlanFixture.PLAN_WITHOUT_TRIAL.Id
}).Target;

var paypalAccount = gateway.PayPalAccount.Find(token);
Assert.IsNotNull(paypalAccount);
var ids = from s in new Subscription[] { subscription1, subscription2 } orderby s.Id select s.Id;
var accountSubscriptionIds = from s in paypalAccount.Subscriptions orderby s.Id select s.Id;
Assert.IsTrue(ids.SequenceEqual(accountSubscriptionIds));
}
}
}
Loading

0 comments on commit 2e4e453

Please sign in to comment.