Skip to content

Instantly share code, notes, and snippets.

@orenagiv
Last active May 9, 2023 09:40
Show Gist options
  • Select an option

  • Save orenagiv/eefb7f573a33b074034d987d2650a242 to your computer and use it in GitHub Desktop.

Select an option

Save orenagiv/eefb7f573a33b074034d987d2650a242 to your computer and use it in GitHub Desktop.

Example FreedomPay XML Provider Response

<POSResponse>
  <RequestGuid>d1225c62-3017-41a5-8888-d6d231fd0558</RequestGuid>
  <TransactionId>00000000000000000597</TransactionId>
  <RequestId>01Z6L0FAOK97U6D4OGDNH2KH4HIUHMOZ</RequestId>
  <ApprovedAmount>10.00</ApprovedAmount>
  <ApprovalCode>178046</ApprovalCode>
  <MaskedCardNumber>541333XXXXXX0119</MaskedCardNumber>
  <CardType>credit</CardType>
  <IssuerName>MASTERCARD</IssuerName>
  <ExpiryDate>1224</ExpiryDate>
  <MerchantReferenceCode>C5FA845FEEE84FF1</MerchantReferenceCode>
  <DCCAccepted>false</DCCAccepted>
  <EntryMode>ricc</EntryMode>
  <ChipData>AMCEB6AAAAAEEBBfJAMkEjFfNAEBnwYHoAAAAAQQEJ8HAv8AnxoCCECfHggyNjc0NjI4Mp9uCQhAAAAwMAAAAIICGYCVBQQAAIABmgMjBQecAQBfKgIIQJ8CBgAAAAAQAJ8DBgAAAAAAAJ8JAgACnxASARCgAAMiIAAAAAAAAAmZYwD/nyYIQZYxhaxDuf2fJwGAnzMD4AjInzQDHwMCnzUBIp82AgM0nzcEY0OLF59ABWAA8LABn0EEAAABRYoCMDA=</ChipData>
  <ReceiptText>...</ReceiptText>
  <PinVerified>false</PinVerified>
  <DeviceVerified>false</DeviceVerified>
  <SignatureRequired>false</SignatureRequired>
  <CashBackAmount>0</CashBackAmount>
  <Decision>A</Decision>
  <ErrorCode>100</ErrorCode>
  <Message>APPROVED</Message>
  <Brand>MC</Brand>
</POSResponse>

Our current Kiosk client-side mapping

const parsedPayment: any = {
    transactionGuid: _.get(responseCamel, 'RequestGuid', ''),
    providerResponseCode: _.get(responseCamel, 'ErrorCode', ''),
    providerTransactionId: _.get(responseCamel, 'TransactionId', ''),
    providerTransactionTime: moment().format('MM/DD/YYYY h:mm a'),
    // cardName: _.get(responseCamel, 'IssuerName', '').trim(), // Check with Hoffman if this is required (and if it's the same as Brand)
    // cardNum: _.get(responseCamel, 'MaskedCardNumber', '').trim(), // Check with Hoffman if this required (because we have the 'masked' value)
    cardNumberMasked: _.get(responseCamel, 'MaskedCardNumber', '').trim(),
    merchantNumber: _get(responseCamel, '{{this should be the terminal id}}', ''), // Lior - this should be the terminal id
    providerTransactionGuidReference: _.get(responseCamel, 'RequestId', ''),
    // providerTransactionIdToBeRefunded: _.get(responseCamel, 'TransactionId', ''), // Lior - this should be passed ONLY when we're doing a refund
    // cardholderName: _.get(responseCamel, '', ''), // FreedomPay are not exposing this
    
    brandName: _.get(responseCamel, 'IssuerName', ''), // Check with Hoffman which is required
    brand: {
        name: _.get(responseCamel, 'IssuerName', '') // Check with Hoffman which is required
    },
    creditCardBrand: _.get(responseCamel, 'IssuerName', ''), // Check with Hoffman which is required
    
    emvData: _.get(responseCamel, 'ChipData', ''),
    confirmationNum: _.get(responseCamel, 'ApprovalCode', ''), 
    providerTransactionStatus: _.get(responseCamel, 'Message', ''), // Check with Hoffman why it used to be hardcoded for 'unknown'
    transType: 'purchase',
    EntryMethod: _.get(responseCamel, 'EntryMode', ''), // Check with Hoffman which is the correct one - `EntryMethod` or `entryMethod` and if the value is an `enum` on ROS side
    entryMethod: _.get(responseCamel, 'EntryMode', ''), // Check with Hoffman which is the correct one - `EntryMethod` or `entryMethod` and if the value is an `enum` on ROS side
    expMonth: _.get(responseCamel, 'ExpiryDate', '').length == 4 ? _.get(responseCamel, 'ExpiryDate', '').slice(-2) : '', // ??
    expYear: _.get(responseCamel, 'ExpiryDate', '').length == 4 ? '20' + _.get(responseCamel, 'ExpiryDate', '').slice(0, 2) : '', // ??
    last4: _.get(responseCamel, 'MaskedCardNumber', '') ? _.get(responseCamel, 'maskedCardNumber', '').slice(-4) : '', 
    amount: _.get(responseCamel, 'ApprovedAmount', ''),
    source: 'Kiosk',
    lastUpdated: new Date().toISOString(),
    accountName: 'FreedomPay',
    organization: this.appService?.$storage?.organization,
    providerResponse: responseCamel,
}

Required Kiosk client-side mapping

const parsedPayment: any = {
    organization: this.appService?.$storage?.organization,
    account: ? // ROS Account ID
    issuer: _.get(responseCamel, 'IssuerName', '').trim(),
    confirmationNum: _.get(responseCamel, 'ApprovalCode', ''), 
    cardNumberMasked: _.get(responseCamel, 'MaskedCardNumber', '').trim(),
    merchantNumber: _get(responseCamel, '{{this should be the terminal id}}', ''),
    tenderType: 'creditCard',
    providerResponseCode: _.get(responseCamel, 'ErrorCode', ''),
    providerTransactionId: _.get(responseCamel, 'TransactionId', ''),
    providerTransactionTime: moment().format('MM/DD/YYYY h:mm a'),
    providerResponse: responseCamel,
    providerTransactionStatus: _.get(responseCamel, 'Message', ''), // PAD sends "unknown"...
    EntryMethod: _.get(responseCamel, 'EntryMode', ''), // Check with Hoffman which is the correct one - `EntryMethod` or `entryMethod` and if the value is an `enum` on ROS side
    entryMethod: _.get(responseCamel, 'EntryMode', ''), // Check with Hoffman which is the correct one - `EntryMethod` or `entryMethod` and if the value is an `enum` on ROS side
    expMonth: _.get(responseCamel, 'ExpiryDate', '').length == 4 ? _.get(responseCamel, 'ExpiryDate', '').slice(-2) : '', // ??
    expYear: _.get(responseCamel, 'ExpiryDate', '').length == 4 ? '20' + _.get(responseCamel, 'ExpiryDate', '').slice(0, 2) : '', // ??
    last4: _.get(responseCamel, 'MaskedCardNumber', '') ? _.get(responseCamel, 'maskedCardNumber', '').slice(-4) : '', 
    amount: _.get(responseCamel, 'ApprovedAmount', ''),
    source: 'Kiosk',
    lastUpdated: new Date().toISOString(),
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment