Add external order id query for paypal and klarna ids (#80)

This commit is contained in:
Niklas Fondberg
2021-10-28 11:05:38 +02:00
committed by GitHub
parent 7fe6414723
commit ee16ff44c6
3 changed files with 32 additions and 0 deletions
+18
View File
@@ -102,6 +102,24 @@ export class OrderAPI extends BaseSQLDataSource {
.then((row) => this.createOrderFromRow(row));
}
async getOrderByExternalId(
klarnaOrderId: string,
paypalTransactionId: string,
): Promise<Order> {
const column = paypalTransactionId
? 'paypal_transaction_id'
: 'klarna_order_id';
const value = paypalTransactionId ?? klarnaOrderId;
return this.knex
.select('*')
.from('orders')
.where(column, value)
.first()
.cache(MINUTE)
.then((row) => this.createOrderFromRow(row));
}
async getOrderRowFieldMapping(): Promise<any> {
// const fields = await this.knex.select('*').from('order-row_fields'); doesn't work becuase of string case...
const fieldsRes = await this.cachedRaw('SELECT * from "order-row_fields"')