Build 545032stable
Module 786953
1,442 characters · in 9094e5c3f3a7d7fa.jsDependencies
Source Raw
function(e,t,r){r.d(t,{Bf:()=>u,J$:()=>R});var n=r(636537),a=r(228366),l=r(913122),i=r(626584),s=r(977445),c=r(67480),h=r(38405),_=r(652215);let d=new i.A("VirtualCurrencyActionCreators");async function u(){a.h.wait(()=>{a.h.dispatch({type:"VIRTUAL_CURRENCY_BALANCE_FETCH"})});try{let e=await n.Bo.get({url:_.Rsh.VIRTUAL_CURRENCY_USER_BALANCE,rejectWithError:!1}),t=e.body.balance;return a.h.dispatch({type:"VIRTUAL_CURRENCY_BALANCE_FETCH_SUCCESS",balance:t}),e.body}catch(t){let e=t instanceof l.Ey?t:new l.Ey(t);a.h.dispatch({type:"VIRTUAL_CURRENCY_BALANCE_FETCH_FAIL",error:e})}}async function R(e){let{skuId:t,loadId:r,onRedeemStart:i,onRedeemSucceed:R,onRedeemFail:E,shouldRefetchBalance:C=!0}=e;a.h.wait(()=>{a.h.dispatch({type:"VIRTUAL_CURRENCY_REDEEM_START",skuId:t})}),i?.();try{let e=c.A.get(t),l=e?.applicationId,i=null!=l&&(0,s.F)(l),E={checkout_session_id:r};i&&(E.test_mode=!0);let o=(await n.Bo.post({url:_.Rsh.VIRTUAL_CURRENCY_SKU_REDEEM(t),body:E,rejectWithError:!1})).body;if(null==o||!Array.isArray(o)){let e="Could not read entitlements from Virtual Currency redemption response. Response: ",t=Error(e,o);throw d.error(e,o),h.A.captureException(t,{tags:{app_context:"virtual_currency"}}),t}return a.h.dispatch({type:"VIRTUAL_CURRENCY_REDEEM_SUCCESS",skuId:t,entitlements:o}),C&&u(),R?.(o),o}catch(r){let e=r instanceof l.Ey?r:new l.Ey(r);a.h.dispatch({type:"VIRTUAL_CURRENCY_REDEEM_FAIL",skuId:t,error:e}),C&&u(),E?.(e)}}}