Skip to content

Commit

Permalink
Merge pull request #945 from golemfactory/mgordel/payment-options-fix
Browse files Browse the repository at this point in the history
fix(payment): added the possibility to define partial payment options
  • Loading branch information
SewerynKras authored May 28, 2024
2 parents a5099e5 + d5dffbb commit ed33d45
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/lease-process/lease-process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface LeaseProcessEvents {

export interface LeaseProcessOptions {
activity?: ExecutionOptions;
payment?: PaymentProcessOptions;
payment?: Partial<PaymentProcessOptions>;
networkNode?: NetworkNode;
}

Expand Down
10 changes: 6 additions & 4 deletions src/payment/agreement_payment_process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,22 @@ export class AgreementPaymentProcess {
* Example of a rule: you shouldn't accept a debit note if an invoice is already in place
*/
private lock: AsyncLock = new AsyncLock();
private options: PaymentProcessOptions;

public readonly logger: Logger;

constructor(
public readonly agreement: Agreement,
public readonly allocation: Allocation,
public readonly paymentApi: IPaymentApi,
public readonly options: PaymentProcessOptions = {
invoiceFilter: () => true,
debitNoteFilter: () => true,
},
options?: Partial<PaymentProcessOptions>,
logger?: Logger,
) {
this.logger = logger || defaultLogger("payment");
this.options = {
invoiceFilter: options?.invoiceFilter || (() => true),
debitNoteFilter: options?.debitNoteFilter || (() => true),
};
}

/**
Expand Down

0 comments on commit ed33d45

Please sign in to comment.