Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Purchases: Disable cancel for pending_transfer domains #8859

Merged
merged 2 commits into from
Oct 25, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions client/lib/purchases/assembler.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ function createPurchaseObject( purchase ) {
countryCode: purchase.payment_country_code,
countryName: purchase.payment_country_name
},
pendingTransfer: Boolean( purchase.pending_transfer ),
productId: Number( purchase.product_id ),
productName: purchase.product_name,
productSlug: purchase.product_slug,
Expand Down
10 changes: 9 additions & 1 deletion client/lib/purchases/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ function isCancelable( purchase ) {
return false;
}

if ( isPendingTransfer( purchase ) ) {
return false;
}

if ( isExpired( purchase ) ) {
return false;
}
Expand Down Expand Up @@ -127,6 +131,10 @@ function isPaidWithPaypal( purchase ) {
return 'paypal' === purchase.payment.type;
}

function isPendingTransfer( purchase ) {
return true === purchase.pendingTransfer;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for an equality check here.

}

function isRedeemable( purchase ) {
return purchase.isRedeemable;
}
Expand Down Expand Up @@ -261,4 +269,4 @@ export {
paymentLogoType,
purchaseType,
showCreditCardExpiringWarning,
}
};
13 changes: 12 additions & 1 deletion client/lib/purchases/test/data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ const DOMAIN_PURCHASE = {
isCancelable: true
};

const DOMAIN_PURCHASE_PENDING_TRANSFER = {
expiryStatus: 'active',
id: 10001,
isDomainRegistration: true,
meta: 'foo.com',
productName: 'Domain Registration',
productSlug: 'domain_reg',
pendingTransfer: true
};

const DOMAIN_PURCHASE_EXPIRED = Object.assign( {}, DOMAIN_PURCHASE, {
expiryStatus: 'expired',
id: 10002,
Expand Down Expand Up @@ -65,11 +75,12 @@ const PLAN_PURCHASE = {

export default {
DOMAIN_PURCHASE,
DOMAIN_PURCHASE_PENDING_TRANSFER,
DOMAIN_PURCHASE_EXPIRED,
DOMAIN_PURCHASE_INCLUDED_IN_PLAN,
DOMAIN_MAPPING_PURCHASE,
DOMAIN_MAPPING_PURCHASE_EXPIRED,
PLAN_PURCHASE,
SITE_REDIRECT_PURCHASE,
SITE_REDIRECT_PURCHASE_EXPIRED
}
};
5 changes: 5 additions & 0 deletions client/lib/purchases/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { expect } from 'chai';
*/
import {
DOMAIN_PURCHASE,
DOMAIN_PURCHASE_PENDING_TRANSFER,
DOMAIN_PURCHASE_EXPIRED,
DOMAIN_PURCHASE_INCLUDED_IN_PLAN,
DOMAIN_MAPPING_PURCHASE,
Expand Down Expand Up @@ -60,5 +61,9 @@ describe( 'index', () => {
it( 'should be cancelable when the purchase can have auto-renew disabled', () => {
expect( isCancelable( PLAN_PURCHASE ) ).to.be.true;
} );

it( 'should be cancelable when the purchase can have auto-renew disabled', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CP mistake :) The test name needs a change

expect( isCancelable( DOMAIN_PURCHASE_PENDING_TRANSFER ) ).to.be.false;
} );
} );
} );
1 change: 1 addition & 0 deletions client/state/purchases/test/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ describe( 'selectors', () => {
priceText: 'undefinedundefined',
productId: NaN,
productSlug: undefined,
pendingTransfer: false,
refundPeriodInDays: undefined,
refundText: 'undefinedundefined',
renewDate: undefined,
Expand Down