spec/integration/braintree/subscription_spec.rb in braintree-2.78.0 vs spec/integration/braintree/subscription_spec.rb in braintree-2.79.0
- old
+ new
@@ -111,10 +111,35 @@
result.should be_success
transaction = result.subscription.transactions[0]
transaction.paypal_details.payer_email.should == "payer@example.com"
end
+ it "creates a subscription when given a paypal description" do
+ customer = Braintree::Customer.create!
+ payment_method_result = Braintree::PaymentMethod.create(
+ :payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment,
+ :customer_id => customer.id
+ )
+
+ result = Braintree::Subscription.create(
+ :payment_method_token => payment_method_result.payment_method.token,
+ :plan_id => SpecHelper::TriallessPlan[:id],
+ :options => {
+ :paypal => {
+ :description => "A great product",
+ },
+ },
+ )
+
+ result.should be_success
+ subscription = result.subscription
+ subscription.description.should == "A great product"
+ transaction = subscription.transactions[0]
+ transaction.paypal_details.payer_email.should == "payer@example.com"
+ transaction.paypal_details.description.should == "A great product"
+ end
+
it "returns an error if the payment_method_nonce hasn't been vaulted" do
customer = Braintree::Customer.create!
result = Braintree::Subscription.create(
:payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment,
:plan_id => SpecHelper::TriallessPlan[:id]
@@ -745,11 +770,11 @@
result = Braintree::Subscription.update(@subscription.id, :payment_method_nonce => nonce)
result.subscription.transactions[0].credit_card_details.token.should == @credit_card.token
result.subscription.payment_method_token.should_not == @credit_card.token
end
- it "allows chaning the descriptors" do
+ it "allows changing the descriptors" do
result = Braintree::Subscription.update(@subscription.id,
:descriptor => {
:name => 'aaa*1234',
:phone => '3334443333',
:url => "ebay.com"
@@ -760,10 +785,35 @@
result.subscription.descriptor.name.should == 'aaa*1234'
result.subscription.descriptor.phone.should == '3334443333'
result.subscription.descriptor.url.should == 'ebay.com'
end
+ it "allows changing the paypal description" do
+ customer = Braintree::Customer.create!
+ payment_method = Braintree::PaymentMethod.create(
+ :payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment,
+ :customer_id => customer.id
+ ).payment_method
+
+ subscription = Braintree::Subscription.create(
+ :payment_method_token => payment_method.token,
+ :plan_id => SpecHelper::TriallessPlan[:id]
+ ).subscription
+
+ result = Braintree::Subscription.update(
+ subscription.id,
+ :options => {
+ :paypal => {
+ :description => 'A great product',
+ },
+ },
+ )
+
+ result.success?.should == true
+ result.subscription.description.should == 'A great product'
+ end
+
context "when successful" do
it "returns a success response with the updated subscription if valid" do
new_id = rand(36**9).to_s(36)
result = Braintree::Subscription.update(@subscription.id,
:id => new_id,
@@ -1650,8 +1700,44 @@
transaction.amount.should == BigDecimal.new(Braintree::Test::TransactionAmounts::Authorize)
transaction.processor_authorization_code.should_not be_nil
transaction.type.should == Braintree::Transaction::Type::Sale
transaction.status.should == Braintree::Transaction::Status::Authorized
+ end
+
+ it "is successful with subscription id and submit_for_settlement" do
+ subscription = Braintree::Subscription.create(
+ :payment_method_token => @credit_card.token,
+ :plan_id => SpecHelper::TriallessPlan[:id]
+ ).subscription
+ SpecHelper.make_past_due(subscription)
+
+ result = Braintree::Subscription.retry_charge(subscription.id, Braintree::Test::TransactionAmounts::Authorize, true)
+
+ result.success?.should == true
+ transaction = result.transaction
+
+ transaction.amount.should == BigDecimal.new(Braintree::Test::TransactionAmounts::Authorize)
+ transaction.processor_authorization_code.should_not be_nil
+ transaction.type.should == Braintree::Transaction::Type::Sale
+ transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
+ end
+
+ it "is successful with subscription id, amount and submit_for_settlement" do
+ subscription = Braintree::Subscription.create(
+ :payment_method_token => @credit_card.token,
+ :plan_id => SpecHelper::TriallessPlan[:id]
+ ).subscription
+ SpecHelper.make_past_due(subscription)
+
+ result = Braintree::Subscription.retry_charge(subscription.id, Braintree::Test::TransactionAmounts::Authorize, true)
+
+ result.success?.should == true
+ transaction = result.transaction
+
+ transaction.amount.should == BigDecimal.new(Braintree::Test::TransactionAmounts::Authorize)
+ transaction.processor_authorization_code.should_not be_nil
+ transaction.type.should == Braintree::Transaction::Type::Sale
+ transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
end
end
end