TS design patterns: Adapter.

by Rodwyn Moreno

TypeScript

interface IPayment {
	id: string,
  total: number,
  SubmitPayment: Function
}

class Payment implements IPayment {
	public id: string;
  public total: number;
  
  constructor(id:string, total:number) {
  	this.id = id;
    this.total = total;
  }
  
  public SubmitPayment() {
  	console.log('Proprietary Payment Amount: ' + this.total + ' - ID: '+ this.id);
  }
}

const payment:IPayment = new Payment("123", 47.99);
payment.SubmitPayment();