Skip to content

Commit

Permalink
Purchases: Disable cancel for pending_transfer domains (#8859)
Browse files Browse the repository at this point in the history
Disable cancel in `/purchases` for domains
that are pending transfer.
  • Loading branch information
aidvu authored Oct 25, 2016
1 parent 5011cba commit fec71da
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 2 deletions.
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 purchase.pendingTransfer;
}

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 not be cancelable if domain is pending transfer', () => {
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

0 comments on commit fec71da

Please sign in to comment.