Add external order id query for paypal and klarna ids (#80)
This commit is contained in:
@@ -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"')
|
||||
|
||||
Reference in New Issue
Block a user