2018-06-18 12:40:25 +00:00
|
|
|
import { model as User } from '../../../../../../website/server/models/user';
|
|
|
|
|
import amzLib from '../../../../../../website/server/libs/payments/amazon';
|
|
|
|
|
import payments from '../../../../../../website/server/libs/payments/payments';
|
|
|
|
|
import common from '../../../../../../website/common';
|
2024-03-11 14:59:57 +00:00
|
|
|
import { apiError } from '../../../../../../website/server/libs/apiError';
|
2020-12-14 14:59:17 +00:00
|
|
|
import * as gems from '../../../../../../website/server/libs/payments/gems';
|
2017-12-14 15:59:45 +00:00
|
|
|
|
2019-10-08 18:45:38 +00:00
|
|
|
const { i18n } = common;
|
2017-12-14 15:59:45 +00:00
|
|
|
|
|
|
|
|
describe('Amazon Payments - Checkout', () => {
|
|
|
|
|
const subKey = 'basic_3mo';
|
2019-10-08 18:45:38 +00:00
|
|
|
let user; let orderReferenceId; let
|
Fall Festival Gem Promo (#138)
* content: add gems blocks
* gemsBlocks: include ios and android identifiers
* wip: promo code
* split common constants into multiple files
* add second promo part
* geCurrentEvent, refactor promo
* fix lint
* fix exports, use world state api
* start adding world state tests
* remove console.log
* use gems block for purchases
* remove comments
* fix most unit tests
* restore comment
* fix lint
* prevent apple/google gift tests from breaking other tests when stub is not reset
* fix unit tests, clarify tests names
* iap: use gift object when gifting gems
* allow gift object with less data
* fix iap tests, remove findById stubs
* iap: require less data from the mobile apps
* apply discounts
* add missing worldState file
* fix lint
* add test event
* start removing 20 gems option for web
* start adding support for all gems packages on web
* fix unit tests for apple, stripe and google
* amazon: support all gems blocks
* paypal: support all gems blocks
* fix payments unit tests, add tests for getGemsBlock
* web: add gems plans with discounts, update stripe
* fix amazon and paypal clients, payments success modals
* amazon pay: disabled state
* update icons, start abstracting payments buttons
* begin redesign
* redesign gems modal
* fix buttons
* fix hover color for gems modal close icon
* add key to world state current event
* extend test event length
* implement gems modals designs
* early test fall2020
* fix header banner position
* add missing files
* use iso 8601 for dates, minor ui fixes
* fix time zones
* events: fix ISO8601 format
* fix css indentation
* start abstracting banners
* refactor payments buttons
* test spooky, fix group plans box
* implement gems promo banners, refactor banners, fixes
* fix lint
* fix dates
* remove unused i18n strings
* fix stripe integration test
* fix world state integration tests
* the current active event
* add missing unit tests
* add storybook story for payments buttons component
* fix typo
* fix(stripe): correct label when gifting subscriptions
2020-09-21 14:22:13 +00:00
|
|
|
headers; const gemsBlockKey = '21gems'; const gemsBlock = common.content.gems[gemsBlockKey];
|
2017-12-14 15:59:45 +00:00
|
|
|
let setOrderReferenceDetailsSpy;
|
|
|
|
|
let confirmOrderReferenceSpy;
|
|
|
|
|
let authorizeSpy;
|
|
|
|
|
let closeOrderReferenceSpy;
|
|
|
|
|
|
|
|
|
|
let paymentBuyGemsStub;
|
2023-01-23 04:30:48 +00:00
|
|
|
let paymentCreateSubscriptionStub;
|
Fall Festival Gem Promo (#138)
* content: add gems blocks
* gemsBlocks: include ios and android identifiers
* wip: promo code
* split common constants into multiple files
* add second promo part
* geCurrentEvent, refactor promo
* fix lint
* fix exports, use world state api
* start adding world state tests
* remove console.log
* use gems block for purchases
* remove comments
* fix most unit tests
* restore comment
* fix lint
* prevent apple/google gift tests from breaking other tests when stub is not reset
* fix unit tests, clarify tests names
* iap: use gift object when gifting gems
* allow gift object with less data
* fix iap tests, remove findById stubs
* iap: require less data from the mobile apps
* apply discounts
* add missing worldState file
* fix lint
* add test event
* start removing 20 gems option for web
* start adding support for all gems packages on web
* fix unit tests for apple, stripe and google
* amazon: support all gems blocks
* paypal: support all gems blocks
* fix payments unit tests, add tests for getGemsBlock
* web: add gems plans with discounts, update stripe
* fix amazon and paypal clients, payments success modals
* amazon pay: disabled state
* update icons, start abstracting payments buttons
* begin redesign
* redesign gems modal
* fix buttons
* fix hover color for gems modal close icon
* add key to world state current event
* extend test event length
* implement gems modals designs
* early test fall2020
* fix header banner position
* add missing files
* use iso 8601 for dates, minor ui fixes
* fix time zones
* events: fix ISO8601 format
* fix css indentation
* start abstracting banners
* refactor payments buttons
* test spooky, fix group plans box
* implement gems promo banners, refactor banners, fixes
* fix lint
* fix dates
* remove unused i18n strings
* fix stripe integration test
* fix world state integration tests
* the current active event
* add missing unit tests
* add storybook story for payments buttons component
* fix typo
* fix(stripe): correct label when gifting subscriptions
2020-09-21 14:22:13 +00:00
|
|
|
let amount = gemsBlock.price / 100;
|
2017-12-14 15:59:45 +00:00
|
|
|
|
|
|
|
|
function expectOrderReferenceSpy () {
|
|
|
|
|
expect(setOrderReferenceDetailsSpy).to.be.calledOnce;
|
|
|
|
|
expect(setOrderReferenceDetailsSpy).to.be.calledWith({
|
|
|
|
|
AmazonOrderReferenceId: orderReferenceId,
|
|
|
|
|
OrderReferenceAttributes: {
|
|
|
|
|
OrderTotal: {
|
|
|
|
|
CurrencyCode: amzLib.constants.CURRENCY_CODE,
|
|
|
|
|
Amount: amount,
|
|
|
|
|
},
|
|
|
|
|
SellerNote: amzLib.constants.SELLER_NOTE,
|
|
|
|
|
SellerOrderAttributes: {
|
|
|
|
|
SellerOrderId: common.uuid(),
|
|
|
|
|
StoreName: amzLib.constants.STORE_NAME,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function expectAuthorizeSpy () {
|
|
|
|
|
expect(authorizeSpy).to.be.calledOnce;
|
|
|
|
|
expect(authorizeSpy).to.be.calledWith({
|
|
|
|
|
AmazonOrderReferenceId: orderReferenceId,
|
|
|
|
|
AuthorizationReferenceId: common.uuid().substring(0, 32),
|
|
|
|
|
AuthorizationAmount: {
|
|
|
|
|
CurrencyCode: amzLib.constants.CURRENCY_CODE,
|
|
|
|
|
Amount: amount,
|
|
|
|
|
},
|
|
|
|
|
SellerAuthorizationNote: amzLib.constants.SELLER_NOTE,
|
|
|
|
|
TransactionTimeout: 0,
|
|
|
|
|
CaptureNow: true,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function expectAmazonStubs () {
|
|
|
|
|
expectOrderReferenceSpy();
|
|
|
|
|
|
|
|
|
|
expect(confirmOrderReferenceSpy).to.be.calledOnce;
|
|
|
|
|
expect(confirmOrderReferenceSpy).to.be.calledWith({ AmazonOrderReferenceId: orderReferenceId });
|
|
|
|
|
|
|
|
|
|
expectAuthorizeSpy();
|
|
|
|
|
|
|
|
|
|
expect(closeOrderReferenceSpy).to.be.calledOnce;
|
|
|
|
|
expect(closeOrderReferenceSpy).to.be.calledWith({ AmazonOrderReferenceId: orderReferenceId });
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-08 18:45:38 +00:00
|
|
|
beforeEach(() => {
|
2017-12-14 15:59:45 +00:00
|
|
|
user = new User();
|
|
|
|
|
headers = {};
|
|
|
|
|
orderReferenceId = 'orderReferenceId';
|
|
|
|
|
|
|
|
|
|
setOrderReferenceDetailsSpy = sinon.stub(amzLib, 'setOrderReferenceDetails');
|
2018-10-26 16:15:28 +00:00
|
|
|
setOrderReferenceDetailsSpy.resolves({});
|
2017-12-14 15:59:45 +00:00
|
|
|
|
|
|
|
|
confirmOrderReferenceSpy = sinon.stub(amzLib, 'confirmOrderReference');
|
2018-10-26 16:15:28 +00:00
|
|
|
confirmOrderReferenceSpy.resolves({});
|
2017-12-14 15:59:45 +00:00
|
|
|
|
|
|
|
|
authorizeSpy = sinon.stub(amzLib, 'authorize');
|
2018-10-26 16:15:28 +00:00
|
|
|
authorizeSpy.resolves({});
|
2017-12-14 15:59:45 +00:00
|
|
|
|
|
|
|
|
closeOrderReferenceSpy = sinon.stub(amzLib, 'closeOrderReference');
|
2018-10-26 16:15:28 +00:00
|
|
|
closeOrderReferenceSpy.resolves({});
|
2017-12-14 15:59:45 +00:00
|
|
|
|
|
|
|
|
paymentBuyGemsStub = sinon.stub(payments, 'buyGems');
|
2018-10-26 16:15:28 +00:00
|
|
|
paymentBuyGemsStub.resolves({});
|
2017-12-14 15:59:45 +00:00
|
|
|
|
2023-01-23 04:30:48 +00:00
|
|
|
paymentCreateSubscriptionStub = sinon.stub(payments, 'createSubscription');
|
|
|
|
|
paymentCreateSubscriptionStub.resolves({});
|
2017-12-14 15:59:45 +00:00
|
|
|
|
|
|
|
|
sinon.stub(common, 'uuid').returns('uuid-generated');
|
2020-12-14 14:59:17 +00:00
|
|
|
sandbox.stub(gems, 'validateGiftMessage');
|
2017-12-14 15:59:45 +00:00
|
|
|
});
|
|
|
|
|
|
2019-10-08 18:45:38 +00:00
|
|
|
afterEach(() => {
|
2017-12-14 15:59:45 +00:00
|
|
|
amzLib.setOrderReferenceDetails.restore();
|
|
|
|
|
amzLib.confirmOrderReference.restore();
|
|
|
|
|
amzLib.authorize.restore();
|
|
|
|
|
amzLib.closeOrderReference.restore();
|
|
|
|
|
payments.buyGems.restore();
|
|
|
|
|
payments.createSubscription.restore();
|
|
|
|
|
common.uuid.restore();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
function expectBuyGemsStub (paymentMethod, gift) {
|
|
|
|
|
expect(paymentBuyGemsStub).to.be.calledOnce;
|
|
|
|
|
|
2019-10-08 18:45:38 +00:00
|
|
|
const expectedArgs = {
|
2017-12-14 15:59:45 +00:00
|
|
|
user,
|
|
|
|
|
paymentMethod,
|
|
|
|
|
headers,
|
2023-01-23 04:30:48 +00:00
|
|
|
sku: undefined,
|
2017-12-14 15:59:45 +00:00
|
|
|
};
|
Fall Festival Gem Promo (#138)
* content: add gems blocks
* gemsBlocks: include ios and android identifiers
* wip: promo code
* split common constants into multiple files
* add second promo part
* geCurrentEvent, refactor promo
* fix lint
* fix exports, use world state api
* start adding world state tests
* remove console.log
* use gems block for purchases
* remove comments
* fix most unit tests
* restore comment
* fix lint
* prevent apple/google gift tests from breaking other tests when stub is not reset
* fix unit tests, clarify tests names
* iap: use gift object when gifting gems
* allow gift object with less data
* fix iap tests, remove findById stubs
* iap: require less data from the mobile apps
* apply discounts
* add missing worldState file
* fix lint
* add test event
* start removing 20 gems option for web
* start adding support for all gems packages on web
* fix unit tests for apple, stripe and google
* amazon: support all gems blocks
* paypal: support all gems blocks
* fix payments unit tests, add tests for getGemsBlock
* web: add gems plans with discounts, update stripe
* fix amazon and paypal clients, payments success modals
* amazon pay: disabled state
* update icons, start abstracting payments buttons
* begin redesign
* redesign gems modal
* fix buttons
* fix hover color for gems modal close icon
* add key to world state current event
* extend test event length
* implement gems modals designs
* early test fall2020
* fix header banner position
* add missing files
* use iso 8601 for dates, minor ui fixes
* fix time zones
* events: fix ISO8601 format
* fix css indentation
* start abstracting banners
* refactor payments buttons
* test spooky, fix group plans box
* implement gems promo banners, refactor banners, fixes
* fix lint
* fix dates
* remove unused i18n strings
* fix stripe integration test
* fix world state integration tests
* the current active event
* add missing unit tests
* add storybook story for payments buttons component
* fix typo
* fix(stripe): correct label when gifting subscriptions
2020-09-21 14:22:13 +00:00
|
|
|
if (gift) {
|
|
|
|
|
expectedArgs.gift = gift;
|
|
|
|
|
expectedArgs.gemsBlock = undefined;
|
2020-12-14 14:59:17 +00:00
|
|
|
expect(gems.validateGiftMessage).to.be.calledOnce;
|
|
|
|
|
expect(gems.validateGiftMessage).to.be.calledWith(gift, user);
|
Fall Festival Gem Promo (#138)
* content: add gems blocks
* gemsBlocks: include ios and android identifiers
* wip: promo code
* split common constants into multiple files
* add second promo part
* geCurrentEvent, refactor promo
* fix lint
* fix exports, use world state api
* start adding world state tests
* remove console.log
* use gems block for purchases
* remove comments
* fix most unit tests
* restore comment
* fix lint
* prevent apple/google gift tests from breaking other tests when stub is not reset
* fix unit tests, clarify tests names
* iap: use gift object when gifting gems
* allow gift object with less data
* fix iap tests, remove findById stubs
* iap: require less data from the mobile apps
* apply discounts
* add missing worldState file
* fix lint
* add test event
* start removing 20 gems option for web
* start adding support for all gems packages on web
* fix unit tests for apple, stripe and google
* amazon: support all gems blocks
* paypal: support all gems blocks
* fix payments unit tests, add tests for getGemsBlock
* web: add gems plans with discounts, update stripe
* fix amazon and paypal clients, payments success modals
* amazon pay: disabled state
* update icons, start abstracting payments buttons
* begin redesign
* redesign gems modal
* fix buttons
* fix hover color for gems modal close icon
* add key to world state current event
* extend test event length
* implement gems modals designs
* early test fall2020
* fix header banner position
* add missing files
* use iso 8601 for dates, minor ui fixes
* fix time zones
* events: fix ISO8601 format
* fix css indentation
* start abstracting banners
* refactor payments buttons
* test spooky, fix group plans box
* implement gems promo banners, refactor banners, fixes
* fix lint
* fix dates
* remove unused i18n strings
* fix stripe integration test
* fix world state integration tests
* the current active event
* add missing unit tests
* add storybook story for payments buttons component
* fix typo
* fix(stripe): correct label when gifting subscriptions
2020-09-21 14:22:13 +00:00
|
|
|
} else {
|
2020-12-14 14:59:17 +00:00
|
|
|
expect(gems.validateGiftMessage).to.not.be.called;
|
Fall Festival Gem Promo (#138)
* content: add gems blocks
* gemsBlocks: include ios and android identifiers
* wip: promo code
* split common constants into multiple files
* add second promo part
* geCurrentEvent, refactor promo
* fix lint
* fix exports, use world state api
* start adding world state tests
* remove console.log
* use gems block for purchases
* remove comments
* fix most unit tests
* restore comment
* fix lint
* prevent apple/google gift tests from breaking other tests when stub is not reset
* fix unit tests, clarify tests names
* iap: use gift object when gifting gems
* allow gift object with less data
* fix iap tests, remove findById stubs
* iap: require less data from the mobile apps
* apply discounts
* add missing worldState file
* fix lint
* add test event
* start removing 20 gems option for web
* start adding support for all gems packages on web
* fix unit tests for apple, stripe and google
* amazon: support all gems blocks
* paypal: support all gems blocks
* fix payments unit tests, add tests for getGemsBlock
* web: add gems plans with discounts, update stripe
* fix amazon and paypal clients, payments success modals
* amazon pay: disabled state
* update icons, start abstracting payments buttons
* begin redesign
* redesign gems modal
* fix buttons
* fix hover color for gems modal close icon
* add key to world state current event
* extend test event length
* implement gems modals designs
* early test fall2020
* fix header banner position
* add missing files
* use iso 8601 for dates, minor ui fixes
* fix time zones
* events: fix ISO8601 format
* fix css indentation
* start abstracting banners
* refactor payments buttons
* test spooky, fix group plans box
* implement gems promo banners, refactor banners, fixes
* fix lint
* fix dates
* remove unused i18n strings
* fix stripe integration test
* fix world state integration tests
* the current active event
* add missing unit tests
* add storybook story for payments buttons component
* fix typo
* fix(stripe): correct label when gifting subscriptions
2020-09-21 14:22:13 +00:00
|
|
|
expectedArgs.gemsBlock = gemsBlock;
|
|
|
|
|
}
|
2017-12-14 15:59:45 +00:00
|
|
|
expect(paymentBuyGemsStub).to.be.calledWith(expectedArgs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
it('should purchase gems', async () => {
|
2018-10-26 16:15:28 +00:00
|
|
|
sinon.stub(user, 'canGetGems').resolves(true);
|
Fall Festival Gem Promo (#138)
* content: add gems blocks
* gemsBlocks: include ios and android identifiers
* wip: promo code
* split common constants into multiple files
* add second promo part
* geCurrentEvent, refactor promo
* fix lint
* fix exports, use world state api
* start adding world state tests
* remove console.log
* use gems block for purchases
* remove comments
* fix most unit tests
* restore comment
* fix lint
* prevent apple/google gift tests from breaking other tests when stub is not reset
* fix unit tests, clarify tests names
* iap: use gift object when gifting gems
* allow gift object with less data
* fix iap tests, remove findById stubs
* iap: require less data from the mobile apps
* apply discounts
* add missing worldState file
* fix lint
* add test event
* start removing 20 gems option for web
* start adding support for all gems packages on web
* fix unit tests for apple, stripe and google
* amazon: support all gems blocks
* paypal: support all gems blocks
* fix payments unit tests, add tests for getGemsBlock
* web: add gems plans with discounts, update stripe
* fix amazon and paypal clients, payments success modals
* amazon pay: disabled state
* update icons, start abstracting payments buttons
* begin redesign
* redesign gems modal
* fix buttons
* fix hover color for gems modal close icon
* add key to world state current event
* extend test event length
* implement gems modals designs
* early test fall2020
* fix header banner position
* add missing files
* use iso 8601 for dates, minor ui fixes
* fix time zones
* events: fix ISO8601 format
* fix css indentation
* start abstracting banners
* refactor payments buttons
* test spooky, fix group plans box
* implement gems promo banners, refactor banners, fixes
* fix lint
* fix dates
* remove unused i18n strings
* fix stripe integration test
* fix world state integration tests
* the current active event
* add missing unit tests
* add storybook story for payments buttons component
* fix typo
* fix(stripe): correct label when gifting subscriptions
2020-09-21 14:22:13 +00:00
|
|
|
await amzLib.checkout({
|
|
|
|
|
user, orderReferenceId, headers, gemsBlock: gemsBlockKey,
|
|
|
|
|
});
|
2017-12-14 15:59:45 +00:00
|
|
|
|
|
|
|
|
expectBuyGemsStub(amzLib.constants.PAYMENT_METHOD);
|
|
|
|
|
expectAmazonStubs();
|
|
|
|
|
expect(user.canGetGems).to.be.calledOnce;
|
|
|
|
|
user.canGetGems.restore();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should error if gem amount is too low', async () => {
|
2019-10-08 18:45:38 +00:00
|
|
|
const receivingUser = new User();
|
2017-12-14 15:59:45 +00:00
|
|
|
receivingUser.save();
|
2019-10-08 18:45:38 +00:00
|
|
|
const gift = {
|
2017-12-14 15:59:45 +00:00
|
|
|
type: 'gems',
|
|
|
|
|
gems: {
|
|
|
|
|
amount: 0,
|
|
|
|
|
uuid: receivingUser._id,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
2019-10-08 18:45:38 +00:00
|
|
|
await expect(amzLib.checkout({
|
|
|
|
|
gift, user, orderReferenceId, headers,
|
|
|
|
|
}))
|
2018-02-17 17:11:24 +00:00
|
|
|
.to.eventually.be.rejected.and.to.eql({
|
|
|
|
|
httpCode: 400,
|
|
|
|
|
message: 'Amount must be at least 1.',
|
|
|
|
|
name: 'BadRequest',
|
|
|
|
|
});
|
2017-12-14 15:59:45 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should error if user cannot get gems gems', async () => {
|
2018-10-26 16:15:28 +00:00
|
|
|
sinon.stub(user, 'canGetGems').resolves(false);
|
Fall Festival Gem Promo (#138)
* content: add gems blocks
* gemsBlocks: include ios and android identifiers
* wip: promo code
* split common constants into multiple files
* add second promo part
* geCurrentEvent, refactor promo
* fix lint
* fix exports, use world state api
* start adding world state tests
* remove console.log
* use gems block for purchases
* remove comments
* fix most unit tests
* restore comment
* fix lint
* prevent apple/google gift tests from breaking other tests when stub is not reset
* fix unit tests, clarify tests names
* iap: use gift object when gifting gems
* allow gift object with less data
* fix iap tests, remove findById stubs
* iap: require less data from the mobile apps
* apply discounts
* add missing worldState file
* fix lint
* add test event
* start removing 20 gems option for web
* start adding support for all gems packages on web
* fix unit tests for apple, stripe and google
* amazon: support all gems blocks
* paypal: support all gems blocks
* fix payments unit tests, add tests for getGemsBlock
* web: add gems plans with discounts, update stripe
* fix amazon and paypal clients, payments success modals
* amazon pay: disabled state
* update icons, start abstracting payments buttons
* begin redesign
* redesign gems modal
* fix buttons
* fix hover color for gems modal close icon
* add key to world state current event
* extend test event length
* implement gems modals designs
* early test fall2020
* fix header banner position
* add missing files
* use iso 8601 for dates, minor ui fixes
* fix time zones
* events: fix ISO8601 format
* fix css indentation
* start abstracting banners
* refactor payments buttons
* test spooky, fix group plans box
* implement gems promo banners, refactor banners, fixes
* fix lint
* fix dates
* remove unused i18n strings
* fix stripe integration test
* fix world state integration tests
* the current active event
* add missing unit tests
* add storybook story for payments buttons component
* fix typo
* fix(stripe): correct label when gifting subscriptions
2020-09-21 14:22:13 +00:00
|
|
|
await expect(amzLib.checkout({
|
|
|
|
|
user, orderReferenceId, headers, gemsBlock: gemsBlockKey,
|
|
|
|
|
}))
|
2019-10-08 18:45:38 +00:00
|
|
|
.to.eventually.be.rejected.and.to.eql({
|
|
|
|
|
httpCode: 401,
|
|
|
|
|
message: i18n.t('groupPolicyCannotGetGems'),
|
|
|
|
|
name: 'NotAuthorized',
|
|
|
|
|
});
|
2017-12-14 15:59:45 +00:00
|
|
|
user.canGetGems.restore();
|
|
|
|
|
});
|
|
|
|
|
|
Fall Festival Gem Promo (#138)
* content: add gems blocks
* gemsBlocks: include ios and android identifiers
* wip: promo code
* split common constants into multiple files
* add second promo part
* geCurrentEvent, refactor promo
* fix lint
* fix exports, use world state api
* start adding world state tests
* remove console.log
* use gems block for purchases
* remove comments
* fix most unit tests
* restore comment
* fix lint
* prevent apple/google gift tests from breaking other tests when stub is not reset
* fix unit tests, clarify tests names
* iap: use gift object when gifting gems
* allow gift object with less data
* fix iap tests, remove findById stubs
* iap: require less data from the mobile apps
* apply discounts
* add missing worldState file
* fix lint
* add test event
* start removing 20 gems option for web
* start adding support for all gems packages on web
* fix unit tests for apple, stripe and google
* amazon: support all gems blocks
* paypal: support all gems blocks
* fix payments unit tests, add tests for getGemsBlock
* web: add gems plans with discounts, update stripe
* fix amazon and paypal clients, payments success modals
* amazon pay: disabled state
* update icons, start abstracting payments buttons
* begin redesign
* redesign gems modal
* fix buttons
* fix hover color for gems modal close icon
* add key to world state current event
* extend test event length
* implement gems modals designs
* early test fall2020
* fix header banner position
* add missing files
* use iso 8601 for dates, minor ui fixes
* fix time zones
* events: fix ISO8601 format
* fix css indentation
* start abstracting banners
* refactor payments buttons
* test spooky, fix group plans box
* implement gems promo banners, refactor banners, fixes
* fix lint
* fix dates
* remove unused i18n strings
* fix stripe integration test
* fix world state integration tests
* the current active event
* add missing unit tests
* add storybook story for payments buttons component
* fix typo
* fix(stripe): correct label when gifting subscriptions
2020-09-21 14:22:13 +00:00
|
|
|
it('should error if gems block is not valid', async () => {
|
|
|
|
|
await expect(amzLib.checkout({
|
|
|
|
|
user, orderReferenceId, headers, gemsBlock: 'invalid',
|
|
|
|
|
}))
|
|
|
|
|
.to.eventually.be.rejected.and.to.eql({
|
|
|
|
|
httpCode: 400,
|
|
|
|
|
message: apiError('invalidGemsBlock'),
|
|
|
|
|
name: 'BadRequest',
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2017-12-14 15:59:45 +00:00
|
|
|
it('should gift gems', async () => {
|
2019-10-08 18:45:38 +00:00
|
|
|
const receivingUser = new User();
|
2017-12-14 15:59:45 +00:00
|
|
|
await receivingUser.save();
|
2019-10-08 18:45:38 +00:00
|
|
|
const gift = {
|
2017-12-14 15:59:45 +00:00
|
|
|
type: 'gems',
|
|
|
|
|
uuid: receivingUser._id,
|
|
|
|
|
gems: {
|
|
|
|
|
amount: 16,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
amount = 16 / 4;
|
2019-10-08 18:45:38 +00:00
|
|
|
await amzLib.checkout({
|
|
|
|
|
gift, user, orderReferenceId, headers,
|
|
|
|
|
});
|
2017-12-14 15:59:45 +00:00
|
|
|
|
|
|
|
|
expectBuyGemsStub(amzLib.constants.PAYMENT_METHOD_GIFT, gift);
|
|
|
|
|
expectAmazonStubs();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should gift a subscription', async () => {
|
2019-10-08 18:45:38 +00:00
|
|
|
const receivingUser = new User();
|
2017-12-14 15:59:45 +00:00
|
|
|
receivingUser.save();
|
2019-10-08 18:45:38 +00:00
|
|
|
const gift = {
|
2017-12-14 15:59:45 +00:00
|
|
|
type: 'subscription',
|
|
|
|
|
subscription: {
|
|
|
|
|
key: subKey,
|
|
|
|
|
uuid: receivingUser._id,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
amount = common.content.subscriptionBlocks[subKey].price;
|
|
|
|
|
|
2019-10-08 18:45:38 +00:00
|
|
|
await amzLib.checkout({
|
|
|
|
|
user, orderReferenceId, headers, gift,
|
|
|
|
|
});
|
2017-12-14 15:59:45 +00:00
|
|
|
|
|
|
|
|
gift.member = receivingUser;
|
2023-01-23 04:30:48 +00:00
|
|
|
expect(paymentCreateSubscriptionStub).to.be.calledOnce;
|
|
|
|
|
expect(paymentCreateSubscriptionStub).to.be.calledWith({
|
2017-12-14 15:59:45 +00:00
|
|
|
user,
|
|
|
|
|
paymentMethod: amzLib.constants.PAYMENT_METHOD_GIFT,
|
|
|
|
|
headers,
|
|
|
|
|
gift,
|
Fall Festival Gem Promo (#138)
* content: add gems blocks
* gemsBlocks: include ios and android identifiers
* wip: promo code
* split common constants into multiple files
* add second promo part
* geCurrentEvent, refactor promo
* fix lint
* fix exports, use world state api
* start adding world state tests
* remove console.log
* use gems block for purchases
* remove comments
* fix most unit tests
* restore comment
* fix lint
* prevent apple/google gift tests from breaking other tests when stub is not reset
* fix unit tests, clarify tests names
* iap: use gift object when gifting gems
* allow gift object with less data
* fix iap tests, remove findById stubs
* iap: require less data from the mobile apps
* apply discounts
* add missing worldState file
* fix lint
* add test event
* start removing 20 gems option for web
* start adding support for all gems packages on web
* fix unit tests for apple, stripe and google
* amazon: support all gems blocks
* paypal: support all gems blocks
* fix payments unit tests, add tests for getGemsBlock
* web: add gems plans with discounts, update stripe
* fix amazon and paypal clients, payments success modals
* amazon pay: disabled state
* update icons, start abstracting payments buttons
* begin redesign
* redesign gems modal
* fix buttons
* fix hover color for gems modal close icon
* add key to world state current event
* extend test event length
* implement gems modals designs
* early test fall2020
* fix header banner position
* add missing files
* use iso 8601 for dates, minor ui fixes
* fix time zones
* events: fix ISO8601 format
* fix css indentation
* start abstracting banners
* refactor payments buttons
* test spooky, fix group plans box
* implement gems promo banners, refactor banners, fixes
* fix lint
* fix dates
* remove unused i18n strings
* fix stripe integration test
* fix world state integration tests
* the current active event
* add missing unit tests
* add storybook story for payments buttons component
* fix typo
* fix(stripe): correct label when gifting subscriptions
2020-09-21 14:22:13 +00:00
|
|
|
gemsBlock: undefined,
|
2023-01-23 04:30:48 +00:00
|
|
|
sku: undefined,
|
2017-12-14 15:59:45 +00:00
|
|
|
});
|
|
|
|
|
expectAmazonStubs();
|
|
|
|
|
});
|
|
|
|
|
});
|