@fabriktor/fx 0.0.177 → 0.0.178
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PaymentEntityTypeBill, PaymentEntityTypePayroll, type Bill, type Payroll, PSPPaymentStatusPending, PSPPaymentStatusPartial, PSPPaymentStatusFull, type CreditLedgerEntry, type Payment, type PmtAccount, type PmtBankAccount, type PmtCard, type PmtCustomer, type PmtPublicSession, type PmtRefund, type SortStripeBalanceResult } from "@fabriktor/schema";
|
|
1
|
+
import { PaymentEntityTypeBill, PaymentEntityTypePayroll, type Bill, type Payroll, PSPPaymentStatusPending, PSPPaymentStatusPartial, PSPPaymentStatusFull, type CreditLedgerEntry, type CreditGrant, type Payment, type PmtAccount, type PmtBankAccount, type PmtCard, type PmtCustomer, type PmtPublicSession, type PmtRefund, type SortStripeBalanceResult } from "@fabriktor/schema";
|
|
2
2
|
import { type PaymentsOperator, type BillableOperator, type PayrollsOperator } from "@fabriktor/client";
|
|
3
3
|
import { PreActionBlocked } from "../core/pre-action.js";
|
|
4
4
|
import { type SearchOptions, type OwnerSearchOptions, type SearchPage } from "../core/search.js";
|
|
@@ -234,6 +234,7 @@ export interface PaymentsFXOperator {
|
|
|
234
234
|
createCreditLedgerEntry(opts: CreateCreditLedgerEntryOptions): Promise<CreditLedgerEntry>;
|
|
235
235
|
replaceCreditLedgerEntry(opts: ReplaceCreditLedgerEntryOptions): Promise<CreditLedgerEntry>;
|
|
236
236
|
searchCreditLedger(opts: SearchCreditLedgerOptions): Promise<SearchCreditLedgerPage>;
|
|
237
|
+
claimSignupCredits(): Promise<CreditGrant | undefined>;
|
|
237
238
|
purchaseAppleCredits(opts: PurchaseAppleCreditsOptions): Promise<void>;
|
|
238
239
|
purchaseGoogleCredits(opts: PurchaseGoogleCreditsOptions): Promise<void>;
|
|
239
240
|
prepareStripeCreditPurchase(opts: PrepareStripeCreditPurchaseOptions): Promise<PrepareStripeCreditPurchaseResult>;
|
|
@@ -285,6 +286,7 @@ export declare class PaymentsFX implements PaymentsFXOperator {
|
|
|
285
286
|
createCreditLedgerEntry(opts: CreateCreditLedgerEntryOptions): Promise<CreditLedgerEntry>;
|
|
286
287
|
replaceCreditLedgerEntry(opts: ReplaceCreditLedgerEntryOptions): Promise<CreditLedgerEntry>;
|
|
287
288
|
searchCreditLedger(opts: SearchCreditLedgerOptions): Promise<SearchCreditLedgerPage>;
|
|
289
|
+
claimSignupCredits(): Promise<CreditGrant | undefined>;
|
|
288
290
|
purchaseAppleCredits(opts: PurchaseAppleCreditsOptions): Promise<void>;
|
|
289
291
|
purchaseGoogleCredits(opts: PurchaseGoogleCreditsOptions): Promise<void>;
|
|
290
292
|
prepareStripeCreditPurchase(opts: PrepareStripeCreditPurchaseOptions): Promise<PrepareStripeCreditPurchaseResult>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CreditLedgerSourceAndroidIAP, CreditLedgerSourceAppleIAP, CreditLedgerSourceStripe, ZeroID, PaymentKindMain, PaymentEntityTypeBill, PaymentEntityTypePayroll, PSPActionableStatusSucceeded, PSPActionableStatusFailed, PSPActionableStatusCanceled, PSPPaymentStatusPending, PSPPaymentStatusPartial, PSPPaymentStatusFull, } from "@fabriktor/schema";
|
|
2
|
-
import { queryParams, } from "@fabriktor/client";
|
|
1
|
+
import { CreditGrantTypeSignup, CreditLedgerSourceAndroidIAP, CreditLedgerSourceAppleIAP, CreditLedgerSourceStripe, ZeroID, PaymentKindMain, PaymentEntityTypeBill, PaymentEntityTypePayroll, PSPActionableStatusSucceeded, PSPActionableStatusFailed, PSPActionableStatusCanceled, PSPPaymentStatusPending, PSPPaymentStatusPartial, PSPPaymentStatusFull, } from "@fabriktor/schema";
|
|
2
|
+
import { isHTTPClientErr, queryParams, } from "@fabriktor/client";
|
|
3
3
|
import { PreActionBlocked, isPreActionBlocked, runPreActionCheck, } from "../core/pre-action.js";
|
|
4
4
|
import { errResolveFailed, errValidation } from "../core/err.js";
|
|
5
5
|
import { normalizeIDs, requiredOperationID, resolvedID } from "../core/id.js";
|
|
@@ -27,9 +27,11 @@ const resourcePmtRefund = "pmt_refund";
|
|
|
27
27
|
const resourcePmtCustomer = "pmt_customer";
|
|
28
28
|
const resourcePmtPublicSession = "pmt_public_session";
|
|
29
29
|
const resourceCreditLedgerEntry = "credit_ledger_entry";
|
|
30
|
+
const resourceCreditGrant = "credit_grant";
|
|
30
31
|
const resourceStripeCreditPayment = "stripe credit payment";
|
|
31
32
|
const resourcePublicPaymentSession = "public payment session";
|
|
32
33
|
const msgPayableSourceMissing = "Payable entity source is unavailable.";
|
|
34
|
+
const msgCreditGrantMissing = "Credit grant response is incomplete.";
|
|
33
35
|
const msgPayableBalanceChanged = "Payment balance changed or a payment is still pending. Refresh before paying.";
|
|
34
36
|
const msgPaymentMethodRequired = "A payment method is required.";
|
|
35
37
|
const msgPayableUnavailable = "This entity is not available for payment.";
|
|
@@ -688,6 +690,25 @@ export class PaymentsFX {
|
|
|
688
690
|
search: (searchOpts) => this.payments.searchManyCreditLedger(searchOpts),
|
|
689
691
|
});
|
|
690
692
|
}
|
|
693
|
+
async claimSignupCredits() {
|
|
694
|
+
try {
|
|
695
|
+
const out = await this.payments.claimCredits({
|
|
696
|
+
type: CreditGrantTypeSignup,
|
|
697
|
+
});
|
|
698
|
+
if (!out.value) {
|
|
699
|
+
throw errResolveFailed({
|
|
700
|
+
resource: resourceCreditGrant,
|
|
701
|
+
msg: msgCreditGrantMissing,
|
|
702
|
+
});
|
|
703
|
+
}
|
|
704
|
+
return out.value;
|
|
705
|
+
}
|
|
706
|
+
catch (err) {
|
|
707
|
+
if (isHTTPClientErr(err) && err.status === 409)
|
|
708
|
+
return;
|
|
709
|
+
throw err;
|
|
710
|
+
}
|
|
711
|
+
}
|
|
691
712
|
async purchaseAppleCredits(opts) {
|
|
692
713
|
await this.payments.purchaseCredits({
|
|
693
714
|
src: CreditLedgerSourceAppleIAP,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fabriktor/fx",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.178",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
"typescript": "^6.0.3"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@fabriktor/client": "0.0.
|
|
20
|
+
"@fabriktor/client": "0.0.109",
|
|
21
21
|
"@fabriktor/fx": "0.0.94",
|
|
22
|
-
"@fabriktor/schema": "0.0.
|
|
22
|
+
"@fabriktor/schema": "0.0.81",
|
|
23
23
|
"convert": "8.0.2"
|
|
24
24
|
}
|
|
25
25
|
}
|