All files / app/order getPaymentInstructions.ts

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22    3x 3x             5x       6x 6x   6x     3x  
import { GatewayOrderPayment, Order, OrderPayment } from '@bigcommerce/checkout-sdk';
 
import { isGiftCertificatePayment } from '../giftCertificate';
import { isStoreCreditPayment } from '../payment/storeCredit';
 
export interface PaymentInstructionsProps {
    order: Order;
}
 
function isDefaultOrderPayment(payment: OrderPayment): payment is GatewayOrderPayment {
    return !isGiftCertificatePayment(payment) && !isStoreCreditPayment(payment);
}
 
function getPaymentInstructions(order: Order): string {
    const gatewayPayment = (order.payments || []).find(isDefaultOrderPayment);
    const instructions = gatewayPayment && gatewayPayment.detail.instructions;
 
    return instructions || '';
}
 
export default getPaymentInstructions;