blob: 8579812adafbd60aaaa10274aedd6101c9af086f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
import { action, observable, computed } from 'mobx';
import Store from './lib/Store';
import CachedRequest from './lib/CachedRequest';
import Request from './lib/Request';
export default class PaymentStore extends Store {
@observable plansRequest = new CachedRequest(this.api.payment, 'plans');
@observable createHostedPageRequest = new Request(this.api.payment, 'getHostedPage');
constructor(...args) {
super(...args);
this.actions.payment.createHostedPage.listen(this._createHostedPage.bind(this));
}
@computed get plan() {
if (this.plansRequest.isError) {
return {};
}
return this.plansRequest.execute().result || {};
}
@action _createHostedPage({ planId }) {
const request = this.createHostedPageRequest.execute(planId);
return request;
}
}
|