Skip to content

Commit 09b9ea3

Browse files
axshaniilyamerman
andauthored
Foreign Currency (#347)
* RichMerchantData and CurrencyConversion added * lint --------- Co-authored-by: Ilya Merman <[email protected]>
1 parent c85a496 commit 09b9ea3

File tree

3 files changed

+96
-20
lines changed

3 files changed

+96
-20
lines changed

types/authorization.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CardNetwork, Merchant, Relationship, Tags, UnimplementedRelationships } from "./common"
1+
import { CardNetwork, CurrencyConversion, Merchant, Relationship, RichMerchantData, Tags, UnimplementedRelationships } from "./common"
22

33
export type AuthorizationStatus = "Authorized" | "Completed" | "Canceled" | "Declined"
44

@@ -86,6 +86,16 @@ export interface Authorization {
8686
* Optional. Summary of the authorization.
8787
*/
8888
summary?: string
89+
90+
/**
91+
* Optional. Full merchant information.
92+
*/
93+
richMerchantData?: RichMerchantData
94+
95+
/**
96+
* Optional. When original currency for transaction is not USD
97+
*/
98+
currencyConversion?: CurrencyConversion
8999
}
90100

91101
/**

types/common.ts

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,10 @@ export interface Officer extends BaseContactAttributes {
160160

161161

162162
export type BusinessContact = {
163-
/**
164-
* Optional. See (this)[https://docs.unit.co/customer-api-tokens/#customers-create-customer-bearer-token-jwt] section for more information.
165-
*/
166-
jwtSubject?: string
163+
/**
164+
* Optional. See (this)[https://docs.unit.co/customer-api-tokens/#customers-create-customer-bearer-token-jwt] section for more information.
165+
*/
166+
jwtSubject?: string
167167
} & Pick<BaseContactAttributes, "fullName" | "email" | "phone">
168168

169169
export type AuthorizedUser = Pick<BaseContactAttributes, "fullName" | "email" | "phone"> & {
@@ -400,12 +400,33 @@ export interface TrustContact extends Pick<BaseContactAttributes, "fullName" | "
400400
}
401401

402402
export type Industry = "Retail" | "Wholesale" | "Restaurants" | "Hospitals" | "Construction" | "Insurance" | "Unions" | "RealEstate" |
403-
"FreelanceProfessional" | "OtherProfessionalServices" | "OnlineRetailer" | "OtherEducationServices"
404-
403+
"FreelanceProfessional" | "OtherProfessionalServices" | "OnlineRetailer" | "OtherEducationServices"
404+
405405
export type Direction = "Credit" | "Debit"
406406

407407
export type CardNetwork = "Visa" | "Interlink" | "Accel" | "Allpoint" | "Other"
408408

409+
export interface RichMerchantData {
410+
logo?: string // URL of the merchant's logo.
411+
phone?: string // Phone number of the merchant.
412+
categories?: Array<{ name: string; icon: string; }> // Array of categories the merchant belongs to (from the least specific to the most specific).
413+
address?: { city: string; state: string; country: string; street?: string; } // Address of the merchant.
414+
coordinates?: Coordinates // Coordinates (latitude, longitude) of the merchant.
415+
facilitators?: Array<RichMerchantDataFacilitator> // The transaction facilitators.
416+
}
417+
418+
export interface RichMerchantDataFacilitator {
419+
name: string // Name of the facilitator.
420+
type?: "BuyNowPayLater" | "DeliveryService" | "Marketplace" | "PaymentProcessor" | "Platform" | "PointOfSale" // Optional. Type of the facilitator.
421+
logo?: string // Optional. URL of the facilitator.
422+
}
423+
424+
export interface CurrencyConversion {
425+
originalCurrency: string // ISO 4217 currency code of original currency.
426+
amountInOriginalCurrency: number // The amount in original currency in 'cents' (i.e. 50 euros will be written 5000)
427+
fxRate?: string // Optional. The conversion rate for the currency conversion to USD.
428+
}
429+
409430
export interface UnitResponse<T> {
410431
data: T
411432
}
@@ -430,15 +451,15 @@ export interface Meta extends UnimplementedFields {
430451
}
431452

432453
export interface BaseCreateRequestAttributes {
433-
/**
434-
* See [Tags](https://developers.unit.co/#tags).
435-
*/
436-
tags?: Tags
454+
/**
455+
* See [Tags](https://developers.unit.co/#tags).
456+
*/
457+
tags?: Tags
437458

438-
/**
439-
* See [Idempotency.](https://developers.unit.co/#intro-idempotency)
440-
*/
441-
idempotencyKey?: string
459+
/**
460+
* See [Idempotency.](https://developers.unit.co/#intro-idempotency)
461+
*/
462+
idempotencyKey?: string
442463
}
443464

444465
export interface UnitConfig {

types/transactions.ts

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { Address, CardNetwork, Coordinates, Counterparty, Direction, Merchant, Relationship, RelationshipsArray, Tags, UnimplementedFields } from "./common"
1+
import { Address, CardNetwork, Coordinates, Counterparty, CurrencyConversion, Direction, Merchant, Relationship, RelationshipsArray, RichMerchantData, Tags, UnimplementedFields } from "./common"
22

3-
export type Transaction = OriginatedAchTransaction | ReceivedAchTransaction | ReturnedAchTransaction | ReturnedReceivedAchTransaction | DishonoredAchTransaction | BookTransaction | PurchaseTransaction | AtmTransaction | FeeTransaction |
4-
CardReversalTransaction | CardTransaction | WireTransaction | ReleaseTransaction | AdjustmentTransaction | InterestTransaction | DisputeTransaction | CheckDepositTransaction | ReturnedCheckDepositTransaction | PaymentAdvanceTransaction |
5-
RepaidPaymentAdvanceTransaction | PaymentCanceledTransaction | RewardTransaction | NegativeBalanceCoverageTransaction | PushToCardTransaction | AccountLowBalanceClosureTransaction
3+
export type Transaction = OriginatedAchTransaction | ReceivedAchTransaction | ReturnedAchTransaction | ReturnedReceivedAchTransaction | DishonoredAchTransaction | BookTransaction | PurchaseTransaction | AtmTransaction | FeeTransaction |
4+
CardReversalTransaction | CardTransaction | WireTransaction | ReleaseTransaction | AdjustmentTransaction | InterestTransaction | DisputeTransaction | CheckDepositTransaction | ReturnedCheckDepositTransaction | PaymentAdvanceTransaction |
5+
RepaidPaymentAdvanceTransaction | PaymentCanceledTransaction | RewardTransaction | NegativeBalanceCoverageTransaction | PushToCardTransaction | AccountLowBalanceClosureTransaction
66

77
export interface BaseTransaction {
88
/**
@@ -396,8 +396,28 @@ export type PurchaseTransaction = BaseTransaction & {
396396
* Optional. The interchange share for this transaction. Calculated at the end of each day, see the transaction.updated event.
397397
*/
398398
interchange?: number
399+
400+
/**
401+
* Optional. The gross interchange share for this transaction.
402+
*/
403+
grossInterchange?: string
404+
405+
/**
406+
* Optional. Cash withdrawal amount
407+
*/
408+
cashWithdrawalAmount?: number
409+
410+
/**
411+
* Optional. Full merchant information.
412+
*/
413+
richMerchantData?: RichMerchantData
414+
415+
/**
416+
* Optional. When original currency for transaction is not USD.
417+
*/
418+
currencyConversion?: CurrencyConversion
399419
} & CardRelatedTransactionsBaseAttributes &
400-
BaseTransactionAttributes
420+
BaseTransactionAttributes
401421

402422
/**
403423
* Describes relationships between the transaction resource and other resources (account and customer).
@@ -455,6 +475,16 @@ export type AtmTransaction = BaseTransaction & {
455475
* Calculated at the end of each day, see the [transaction.updated](https://developers.unit.co/events/#transactionupdated) event.
456476
*/
457477
intercharge?: number
478+
479+
/**
480+
* Optional. The gross interchange share for this transaction.
481+
*/
482+
grossInterchange?: string
483+
484+
/**
485+
* Optional. When original currency for transaction is not USD.
486+
*/
487+
currencyConversion?: CurrencyConversion
458488
}
459489

460490
/**
@@ -531,6 +561,21 @@ export type CardTransaction = BaseTransaction & {
531561
* Optional. The interchange share for this transaction. Calculated at the end of each day, see the [transaction.updated](https://developers.unit.co/events/#transactionupdated) event.
532562
*/
533563
interchange?: number
564+
565+
/**
566+
* Optional. The gross interchange share for this transaction.
567+
*/
568+
grossInterchange?: string
569+
570+
/**
571+
* Optional. Full merchant information.
572+
*/
573+
richMerchantData?: RichMerchantData
574+
575+
/**
576+
* Optional. When original currency for transaction is not USD.
577+
*/
578+
currencyConversion?: CurrencyConversion
534579
} & CardRelatedTransactionsBaseAttributes
535580

536581
/**

0 commit comments

Comments
 (0)