feat(ui): wire the chip-pack purchase to Robokassa
Replace the disabled "Soon" pack action with a real purchase: the Wallet opens a money order (wallet.order) and sends the player to the provider's hosted-payment page (window.open via openExternalUrl); the chips are credited later by the verified server callback. Add a public-offer link under the packs (paying accepts the offer). Codec order round-trip unit test + a mock-e2e purchase test; the Google Play stub and the chip-spend paths are unchanged.
This commit is contained in:
@@ -17,6 +17,8 @@ import {
|
||||
decodeWallet,
|
||||
decodeCatalog,
|
||||
encodeWalletBuy,
|
||||
encodeWalletOrder,
|
||||
decodeWalletOrder,
|
||||
decodeSession,
|
||||
decodeFeedbackState,
|
||||
decodeFeedbackUnread,
|
||||
@@ -73,6 +75,25 @@ describe('codec', () => {
|
||||
expect(w.hints).toBe(5);
|
||||
});
|
||||
|
||||
it('round-trips the wallet order request and response', () => {
|
||||
// order request: pack id survives the wire
|
||||
const req = fb.WalletOrderRequest.getRootAsWalletOrderRequest(new ByteBuffer(encodeWalletOrder('pack-7')));
|
||||
expect(req.productId()).toBe('pack-7');
|
||||
|
||||
// order response: the created id and the provider launch URL decode back
|
||||
const b = new Builder(64);
|
||||
const oid = b.createString('order-123');
|
||||
const url = b.createString('https://pay.example/abc');
|
||||
fb.WalletOrderResponse.startWalletOrderResponse(b);
|
||||
fb.WalletOrderResponse.addOrderId(b, oid);
|
||||
fb.WalletOrderResponse.addRedirectUrl(b, url);
|
||||
b.finish(fb.WalletOrderResponse.endWalletOrderResponse(b));
|
||||
|
||||
const order = decodeWalletOrder(b.asUint8Array());
|
||||
expect(order.orderId).toBe('order-123');
|
||||
expect(order.redirectUrl).toBe('https://pay.example/abc');
|
||||
});
|
||||
|
||||
it('round-trips the catalog view (value + pack)', () => {
|
||||
const b = new Builder(256);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user