forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🤖 Merge PR DefinitelyTyped#61048 [node-barion] Add type definitions f…
…or node-barion by @aron123 * Add type definitions for node-barion * Update types/node-barion/node-barion-tests.ts Co-authored-by: Piotr Błażejewicz (Peter Blazejewicz) <[email protected]> * Apply suggestions from code review (node-barion) Co-authored-by: Piotr Błażejewicz (Peter Blazejewicz) <[email protected]> Co-authored-by: Piotr Błażejewicz (Peter Blazejewicz) <[email protected]>
- Loading branch information
1 parent
aeb3a3e
commit 3fe008f
Showing
4 changed files
with
324 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,265 @@ | ||
// Type definitions for node-barion 3.1 | ||
// Project: https://github.com/aron123/node-barion | ||
// Definitions by: Áron Kiss <https://github.com/aron123> | ||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
|
||
export = Barion; | ||
|
||
interface BankAccount { | ||
AccountNumber: string; | ||
Address?: string; | ||
BankAddress?: string; | ||
BankName?: string; | ||
Country: string; | ||
Format: 'Unknown' | 'Giro' | 'IBAN' | 'Czech' | 'Other'; | ||
SwiftCode?: string; | ||
} | ||
|
||
interface BankTransferRequest { | ||
Amount: number; | ||
BankAccount: BankAccount; | ||
Comment?: string; | ||
Currency: 'CZK' | 'EUR' | 'HUF' | 'USD'; | ||
Password: string; | ||
RecipientName: string; | ||
UserName: string; | ||
} | ||
|
||
interface BillingAddress { | ||
City?: string; | ||
Country?: string; | ||
Region?: string; | ||
Street?: string; | ||
Street2?: string; | ||
Street3?: string; | ||
Zip?: string; | ||
} | ||
|
||
interface CancelAuthorizationRequest { | ||
POSKey: string; | ||
PaymentId: string; | ||
} | ||
|
||
interface CapturePaymentRequest { | ||
POSKey: string; | ||
PaymentId: string; | ||
Transactions: TransactionToFinish[]; | ||
} | ||
|
||
interface CompletePaymentRequest { | ||
POSKey: string; | ||
PaymentId: string; | ||
} | ||
|
||
interface EmailTransferRequest { | ||
Amount: Money; | ||
Comment?: string; | ||
Password: string; | ||
SourceAccountId: string; | ||
TargetEmail: string; | ||
UserName: string; | ||
} | ||
|
||
interface FinishReservationRequest { | ||
POSKey: string; | ||
PaymentId: string; | ||
Transactions: TransactionToFinish[]; | ||
} | ||
|
||
interface GetAccountsRequest { | ||
Password: string; | ||
UserName: string; | ||
} | ||
|
||
interface GetPaymentStateRequest { | ||
POSKey: string; | ||
PaymentId: string; | ||
} | ||
|
||
interface GiftCardPurchase { | ||
Amount?: number; | ||
Count?: number; | ||
} | ||
|
||
interface InitialOptions { | ||
Currency?: 'CZK' | 'EUR' | 'HUF' | 'USD'; | ||
Environment?: 'test' | 'prod'; | ||
FundingSources?: Array<'All' | 'Balance' | 'BankCard' | 'GooglePay' | 'ApplePay' | 'BankTransfer'>; | ||
GuestCheckOut?: boolean; | ||
Locale?: 'cs-CZ' | 'de-DE' | 'en-US' | 'es-ES' | 'fr-FR' | 'hu-HU' | 'sk-SK' | 'sl-SI'; | ||
POSKey: string; | ||
Secure?: boolean; | ||
} | ||
|
||
interface Item { | ||
Description: string; | ||
ImageUrl?: string; | ||
ItemTotal: number; | ||
Name: string; | ||
Quantity: number; | ||
SKU?: string; | ||
Unit: string; | ||
UnitPrice: number; | ||
} | ||
|
||
interface Money { | ||
Currency: 'CZK' | 'EUR' | 'HUF' | 'USD'; | ||
Value: number; | ||
} | ||
|
||
interface PayeeTransaction { | ||
Comment?: string; | ||
POSTransactionId: string; | ||
Payee: string; | ||
Total: number; | ||
} | ||
|
||
interface PayerAccountInformation { | ||
AccountChangeIndicator?: 'ChangedDuringThisTransaction' | 'LessThan30Days' | 'Between30And60Days' | 'MoreThan60Days'; | ||
AccountCreated?: Date; | ||
AccountCreationIndicator?: 'NoAccount' | 'CreatedDuringThisTransaction' | 'LessThan30Days' | 'Between30And60Days' | 'MoreThan60Days'; | ||
AccountId?: string; | ||
AccountLastChanged?: Date; | ||
PasswordChangeIndicator?: 'NoChange' | 'ChangedDuringThisTransaction' | 'LessThan30Days' | 'Between30And60Days' | 'MoreThan60Days'; | ||
PasswordLastChanged?: Date; | ||
PaymentMethodAdded?: Date; | ||
ProvisionAttempts?: number; | ||
PurchasesInTheLast6Months?: number; | ||
ShippingAddressAdded?: Date; | ||
ShippingAddressUsageIndicator?: 'ThisTransaction' | 'LessThan30Days' | 'Between30And60Days' | 'MoreThan60Days'; | ||
SuspiciousActivityIndicator?: 'NoSuspiciousActivityObserved' | 'SuspiciousActivityObserved'; | ||
TransactionalActivityPerDay?: number; | ||
TransactionalActivityPerYear?: number; | ||
} | ||
|
||
interface PaymentRefundRequest { | ||
POSKey: string; | ||
PaymentId: string; | ||
TransactionsToRefund: TransactionToRefund[]; | ||
} | ||
|
||
interface PaymentTransaction { | ||
Comment?: string; | ||
Items?: Item[]; | ||
POSTransactionId: string; | ||
Payee: string; | ||
PayeeTransactions?: PayeeTransaction[]; | ||
Total: number; | ||
} | ||
|
||
interface PurchaseInformation { | ||
AvailabilityIndicator?: 'MerchandiseAvailable' | 'FutureAvailability'; | ||
DeliveryEmailAddress?: string; | ||
DeliveryTimeframe?: 'ElectronicDelivery' | 'SameDayShipping' | 'OvernightShipping' | 'TwoDayOrMoreShipping'; | ||
GiftCardPurchase?: GiftCardPurchase; | ||
PreOrderDate?: Date; | ||
PurchaseDate?: Date; | ||
PurchaseType?: 'GoodsAndServicePurchase' | 'CheckAcceptance' | 'AccountFunding' | 'QuasiCashTransaction' | 'PrePaidVacationAndLoan'; | ||
ReOrderIndicator?: 'FirstTimeOrdered' | 'Reordered'; | ||
RecurringExpiry?: Date; | ||
RecurringFrequency?: number; | ||
ShippingAddressIndicator?: 'ShipToCardholdersBillingAddress' | 'ShipToAnotherVerifiedAddress' | 'ShipToDifferentAddress' | 'ShipToStore' | 'DigitalGoods' | 'TravelAndEventTickets' | 'Other'; | ||
} | ||
|
||
interface ShippingAddress { | ||
City?: string; | ||
Country?: string; | ||
FullName?: string; | ||
Region?: string; | ||
Street?: string; | ||
Street2?: string; | ||
Street3?: string; | ||
Zip?: string; | ||
} | ||
|
||
interface StartPaymentRequest { | ||
BillingAddress?: BillingAddress; | ||
CallbackUrl: string; | ||
CardHolderNameHint?: string; | ||
ChallengePreference?: 'NoPreference' | 'ChallengeRequired' | 'NoChallengeNeeded'; | ||
Currency: 'CZK' | 'EUR' | 'HUF' | 'USD'; | ||
DelayedCapturePeriod?: string; | ||
FundingSources: Array<'All' | 'Balance' | 'BankCard' | 'GooglePay' | 'ApplePay' | 'BankTransfer'>; | ||
GuestCheckOut: boolean; | ||
InitiateRecurrence?: boolean; | ||
Locale: 'cs-CZ' | 'de-DE' | 'en-US' | 'es-ES' | 'fr-FR' | 'hu-HU' | 'sk-SK' | 'sl-SI'; | ||
OrderNumber?: string; | ||
POSKey: string; | ||
PayerAccount?: PayerAccountInformation; | ||
PayerHint?: string; | ||
PayerHomeNumber?: string; | ||
PayerPhoneNumber?: string; | ||
PayerWorkPhoneNumber?: string; | ||
PaymentRequestId: string; | ||
PaymentType: 'Immediate' | 'Reservation' | 'DelayedCapture'; | ||
PaymentWindow?: string; | ||
PurchaseInformation?: PurchaseInformation; | ||
RecurrenceId?: string; | ||
RecurrenceType?: 'OneClickPayment' | 'MerchantInitiatedPayment' | 'RecurringPayment'; | ||
RedirectUrl: string; | ||
ReservationPeriod?: string; | ||
ShippingAddress?: ShippingAddress; | ||
TraceId?: string; | ||
Transactions: PaymentTransaction[]; | ||
} | ||
|
||
interface StatementDownloadRequest { | ||
Currency: 'CZK' | 'EUR' | 'HUF' | 'USD'; | ||
Day?: number; | ||
Month: number; | ||
Password: string; | ||
UserName: string; | ||
Year: number; | ||
} | ||
|
||
interface TransactionToFinish { | ||
Comment?: string; | ||
Items?: Item[]; | ||
PayeeTransactions?: PayeeTransaction[]; | ||
Total: number; | ||
TransactionId: string; | ||
} | ||
|
||
interface TransactionToRefund { | ||
AmountToRefund: number; | ||
Comment?: string; | ||
POSTransactionId: string; | ||
TransactionId: string; | ||
} | ||
|
||
declare class Barion { | ||
constructor(options: InitialOptions); | ||
|
||
bankTransfer(options: Partial<BankTransferRequest>, callback: (err: Error, data: any) => void): void; | ||
bankTransfer(options: Partial<BankTransferRequest>): Promise<any>; | ||
|
||
cancelAuthorizedPayment(options: Partial<CancelAuthorizationRequest>, callback: (err: Error, data: any) => void): void; | ||
cancelAuthorizedPayment(options: Partial<CancelAuthorizationRequest>): Promise<any>; | ||
|
||
captureAuthorizedPayment(options: Partial<CapturePaymentRequest>, callback: (err: Error, data: any) => void): void; | ||
captureAuthorizedPayment(options: Partial<CapturePaymentRequest>): Promise<any>; | ||
|
||
completePayment(options: Partial<CompletePaymentRequest>, callback: (err: Error, data: any) => void): void; | ||
completePayment(options: Partial<CompletePaymentRequest>): Promise<any>; | ||
|
||
downloadStatement(options: Partial<StatementDownloadRequest>, callback: (err: Error, data: any) => void): void; | ||
downloadStatement(options: Partial<StatementDownloadRequest>): Promise<any>; | ||
|
||
emailTransfer(options: Partial<EmailTransferRequest>, callback: (err: Error, data: any) => void): void; | ||
emailTransfer(options: Partial<EmailTransferRequest>): Promise<any>; | ||
|
||
finishReservation(options: Partial<FinishReservationRequest>, callback: (err: Error, data: any) => void): void; | ||
finishReservation(options: Partial<FinishReservationRequest>): Promise<any>; | ||
|
||
getAccounts(options: Partial<GetAccountsRequest>, callback: (err: Error, data: any) => void): void; | ||
getAccounts(options: Partial<GetAccountsRequest>): Promise<any>; | ||
|
||
getPaymentState(options: Partial<GetPaymentStateRequest>, callback: (err: Error, data: any) => void): void; | ||
getPaymentState(options: Partial<GetPaymentStateRequest>): Promise<any>; | ||
|
||
refundPayment(options: Partial<PaymentRefundRequest>, callback: (err: Error, data: any) => void): void; | ||
refundPayment(options: Partial<PaymentRefundRequest>): Promise<any>; | ||
|
||
startPayment(options: Partial<StartPaymentRequest>, callback: (err: Error, data: any) => void): void; | ||
startPayment(options: Partial<StartPaymentRequest>): Promise<any>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import Barion = require('node-barion'); | ||
|
||
const barion = new Barion({ | ||
Environment: 'test', | ||
POSKey: '9b652eac8f034674902b5cf0c3e2a984' | ||
}); | ||
|
||
const transfer = { | ||
UserName: '[email protected]', | ||
Password: 'someRlyStrongP4ss#!', | ||
SourceAccountId: 'bdf45c1d-bb98-4fee-bbf1-62411fb26b86', | ||
TargetEmail: '[email protected]', | ||
Amount: { | ||
Currency: 'HUF' as 'HUF', | ||
Value: 404 | ||
}, | ||
Comment: 'Buy me 1 EUR please.' | ||
}; | ||
|
||
barion.emailTransfer(transfer, (err, data) => { | ||
if (err && err.name === 'BarionModelError') { | ||
return; | ||
} else if (err) { | ||
return; | ||
} | ||
}); | ||
|
||
async function sendOrder() { | ||
try { | ||
const data = await barion.emailTransfer(transfer); | ||
} catch (err) { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"lib": [ | ||
"es6" | ||
], | ||
"noImplicitAny": true, | ||
"noImplicitThis": true, | ||
"strictNullChecks": true, | ||
"strictFunctionTypes": true, | ||
"baseUrl": "../", | ||
"typeRoots": [ | ||
"../" | ||
], | ||
"types": [], | ||
"noEmit": true, | ||
"forceConsistentCasingInFileNames": true | ||
}, | ||
"files": [ | ||
"index.d.ts", | ||
"node-barion-tests.ts" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "@definitelytyped/dtslint/dt.json" | ||
} |