@hyperse/paypal-node-sdk
Version:
NodeJS SDK for PayPal Checkout APIs
548 lines (547 loc) • 12.9 kB
TypeScript
/**
* Docs: https://developer.paypal.com/docs/api/orders/v2/
*/
import { type BaseHeaders } from '../core/HttpRequestBase.js';
export interface AchDebit {
account_holder_name: string;
account_number: string;
account_type?: AccountType;
routing_number: string;
}
export type AccountType = 'CHECKING' | 'SAVINGS';
export interface ActivityTimestamps {
create_time: string;
update_time: string;
}
export interface AddressDetails {
building_name: string;
delivery_service: string;
street_name: string;
street_number: string;
street_type: string;
sub_building: string;
}
export interface AddressPortable {
address_details?: AddressDetails;
address_line_1?: string;
address_line_2?: string;
address_line_3?: string;
admin_area_1?: string;
admin_area_2?: string;
admin_area_3?: string;
admin_area_4?: string;
country_code: string;
postal_code?: string;
}
export interface AmountBreakdown {
discount?: Money;
handling?: Money;
insurance?: Money;
item_total?: Money;
shipping_discount?: Money;
shipping?: Money;
tax_total?: Money;
}
export interface Authorization extends ActivityTimestamps, AuthorizationStatus {
amount: Money;
custom_id: string;
expiration_time: string;
id: string;
invoice_id: string;
links: LinkDescription[];
seller_protection: SellerProtection;
}
export type Status = 'CANCELLED' | 'CAPTURED' | 'COMPLETED' | 'CREATED' | 'DECLINED' | 'DENIED' | 'ELIGIBLE' | 'EXPIRED' | 'FAILED' | 'NOT_ELIGIBLE' | 'PARTIALLY_CAPTURED' | 'PARTIALLY_CREATED' | 'PARTIALLY_ELIGIBLE' | 'PARTIALLY_REFUNDED' | 'PENDING' | 'REFUNDED' | 'VOIDED';
export interface AuthorizationStatus {
readonly status_details: AuthorizationStatusDetails;
readonly status: Status;
}
export interface AuthorizationStatusDetails {
reason: Reason;
}
export type Reason = 'BUYER_COMPLAINT' | 'CHARGEBACK' | 'ECHECK' | 'INTERNATIONAL_WITHDRAWAL' | 'OTHER' | 'PENDING_REVIEW' | 'RECEIVING_PREFERENCE_MANDATES_MANUAL_ACTION' | 'REFUNDED' | 'TRANSACTION_APPROVED_AWAITING_FUNDING' | 'UNILATERAL' | 'VERIFICATION_REQUIRED';
export interface Capture extends ActivityTimestamps, CaptureStatus {
amount: Money;
custom_id: string;
disbursement_mode: DisbursementMode;
final_capture: boolean;
id: string;
invoice_id: string;
links: LinkDescription[];
processor_response: ProcessorResponse;
seller_protection: SellerProtection;
seller_receivable_breakdown: SellerReceivableBreakdown;
}
export interface CaptureRequest {
amount: Money;
final_capture: boolean;
invoice_id: string;
note_to_payer: string;
payment_instruction?: PaymentInstruction;
soft_descriptor: string;
}
export interface CaptureStatus {
readonly status_details: CaptureStatusDetails;
readonly status: Status;
}
export interface CaptureStatusDetails {
reason: Reason;
}
export interface Card {
billing_address?: {
address_line_1?: string;
address_line_2?: string;
admin_area_1?: string;
admin_area_2?: string;
country_code: string;
postal_code?: string;
};
brand?: CardBrand;
card_type?: CardBrand;
expiry: string;
id?: string;
last_digits?: string;
name?: string;
number: string;
security_code?: string;
type?: CardType;
}
export type CardBrand = 'AMEX' | 'CB_NATIONALE' | 'CETELEM' | 'CHINA_UNION_PAY' | 'CONFIDIS' | 'CONFIGOGA' | 'DELTA' | 'DISCOVER' | 'ELECTRON' | 'JCB' | 'MAESTRO' | 'MASTERCARD' | 'SOLO' | 'STAR' | 'SWITCH' | 'VISA';
export type CardType = 'CREDIT' | 'DEBIT' | 'PREPAID' | 'STORE' | 'UNKNOWN';
export type DisbursementMode = 'DELAYED' | 'INSTANT';
export type DisputeCategory = 'ITEM_NOT_RECEIVED' | 'UNAUTHORIZED_TRANSACTION';
export interface Error {
debug_id: string;
details?: ErrorDetails[];
information_link?: string;
links?: LinkDescription[];
message: string;
name: string;
}
export interface ErrorDetails {
description?: string;
field?: string;
issue: string;
location?: string;
value?: string;
}
export interface ExchangeRate {
source_currency: string;
target_currency: string;
value: string;
}
export interface LinkDescription {
href: string;
method?: Method;
rel: string;
}
export type Method = 'CONNECT' | 'DELETE' | 'GET' | 'HEAD' | 'OPTIONS' | 'PATCH' | 'POST' | 'PUT';
export interface Money {
currency_code: string;
value: string;
}
export interface Name {
alternate_full_name: string;
full_name: string;
given_name: string;
middle_name: string;
prefix: string;
suffix: string;
surname: string;
}
export interface NetAmountBreakdown {
converted_amount: Money;
exchange_rate: ExchangeRate;
payable_amount: Money;
}
export interface Payee {
email_address?: string;
merchant_id?: string;
}
export type PayeeBase = Payee;
export interface PaymentInstruction {
disbursement_mode: DisbursementMode;
payee_pricing_tier_id: string;
platform_fees: PlatformFee[];
}
export interface Phone {
country_code: string;
extension_number?: string;
national_number: string;
}
export interface PlatformFee {
amount: Money;
payee?: PayeeBase;
}
export interface ProcessorResponse {
readonly avs_code: AVSCode;
readonly cvv_code: CVVCode;
readonly payment_advice_code: PaymentAdviceCode;
readonly response_code: ResponseCode;
}
export type AVSCode = 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'I' | 'M' | 'N' | 'P' | 'R' | 'S' | 'U' | 'W' | 'X' | 'Y' | 'Z'
/** MAESTRO_NOT_RESPONSE */
| 'Null'
/** MAESTRO_ALL_MATCHES */
| '0'
/** MAESTRO_NONE_MATCHES */
| '1'
/** MAESTRO_PART_MATCHES */
| '2'
/** MAESTRO_NOT_PROCESSED */
| '3'
/** MAESTRO_NOT_AVAILABLE */
| '4';
export type CVVCode = 'E' | 'I' | 'M' | 'N' | 'P' | 'S' | 'U' | 'X'
/** ALL_OTHERS */
| 'All others'
/** Maestro_matched */
| '0'
/** Maestro_not_match */
| '1'
/** Maestro_not_implemented */
| '2'
/** Maestro_not_present */
| '3'
/** Maestro_not_available */
| '4';
export type ResponseCode =
/** APPROVED */
'0000'
/** REFERRAL */
| '0100'
/** BAD_RESPONSE_REVERSAL_REQUIRED */
| '0800'
/** PARTIAL_AUTHORIZATION */
| '1000'
/** INVALID_DATA_FORMAT */
| '1300'
/** INVALID_AMOUNT */
| '1310'
/** INVALID_TRANSACTION_CARD_ISSUER_ACQUIRER */
| '1312'
/** INVALID_CAPTURE_DATE */
| '1317'
/** INVALID_CURRENCY_CODE */
| '1320'
/** INVALID_ACCOUNT */
| '1330'
/** INVALID_ACCOUNT_RECURRING */
| '1335'
/** INVALID_TERMINAL */
| '1340'
/** INVALID_MERCHANT */
| '1350'
/** BAD_PROCESSING_CODE */
| '1360'
/** INVALID_MCC */
| '1370'
/** INVALID_EXPIRATION */
| '1380'
/** INVALID_CARD_VERIFICATION_VALUE */
| '1382'
/** INVALID_LIFE_CYCLE_OF_TRANSACTION */
| '1384'
/** INVALID_ORDER */
| '1390'
/** TRANSACTION_CANNOT_BE_COMPLETED */
| '1393'
/** DO_NOT_HONOR */
| '0500'
/** GENERIC_DECLINE */
| '5100'
/** CVV2_FAILURE */
| '5110'
/** INSUFFICIENT_FUNDS */
| '5120'
/** INVALID_PIN */
| '5130'
/** CARD_CLOSED */
| '5140'
/** PICKUP_CARD_SPECIAL_CONDITIONS */
| '5150'
/** UNAUTHORIZED_USER */
| '5160'
/** AVS_FAILURE */
| '5170'
/** INVALID_OR_RESTRICTED_CARD */
| '5180'
/** SOFT_AVS */
| '5190'
/** DUPLICATE_TRANSACTION */
| '5200'
/** INVALID_TRANSACTION */
| '5210'
/** EXPIRED_CARD */
| '5400'
/** INCORRECT_PIN_REENTER */
| '5500'
/** TRANSACTION_NOT_PERMITTED */
| '5700'
/** REVERSAL_REJECTED */
| '5800'
/** INVALID_ISSUE */
| '5900'
/** ISSUER_NOT_AVAILABLE_NOT_RETRIABLE */
| '5910'
/** ISSUER_NOT_AVAILABLE_RETRIABLE */
| '5920'
/** ACCOUNT_NOT_ON_FILE */
| '6300'
/** APPROVED_NON_CAPTURE */
| '7600'
/** ERROR_3DS */
| '7700'
/** AUTHENTICATION_FAILED */
| '7710'
/** BIN_ERROR */
| '7800'
/** PIN_ERROR */
| '7900'
/** PROCESSOR_SYSTEM_ERROR */
| '8000'
/** HOST_KEY_ERROR */
| '8010'
/** CONFIGURATION_ERROR */
| '8020'
/** UNSUPPORTED_OPERATION */
| '8030'
/** FATAL_COMMUNICATION_ERROR */
| '8100'
/** RETRIABLE_COMMUNICATION_ERROR */
| '8110'
/** SYSTEM_UNAVAILABLE */
| '8220'
/** DECLINED_PLEASE_RETRY */
| '9100'
/** SUSPECTED_FRAUD */
| '9500'
/** SECURITY_VIOLATION */
| '9510'
/** LOST_OR_STOLEN */
| '9520'
/** HOLD_CALL_CENTER */
| '9530'
/** REFUSED_CARD */
| '9540'
/** UNRECOGNIZED_RESPONSE_CODE */
| '9600'
/** CARD_NOT_ACTIVATED */
| '5930'
/** PPMD */
| 'PPMD'
/** CE_REGISTRATION_INCOMPLETE */
| 'PPCE'
/** NETWORK_ERROR */
| 'PPNT'
/** CARD_TYPE_UNSUPPORTED */
| 'PPCT'
/** TRANSACTION_TYPE_UNSUPPORTED */
| 'PPTT'
/** CURRENCY_USED_INVALID */
| 'PPCU'
/** QUASI_CASH_UNSUPPORTED */
| 'PPQC'
/** VALIDATION_ERROR */
| 'PPVE'
/** VIRTUAL_TERMINAL_UNSUPPORTED */
| 'PPVT'
/** DCC_UNSUPPORTED */
| 'PPDC'
/** INTERNAL_SYSTEM_ERROR */
| 'PPER'
/** ID_MISMATCH */
| 'PPIM'
/** H1_ERROR */
| 'PPH1'
/** STATUS_DESCRIPTION */
| 'PPSD'
/** ADULT_GAMING_UNSUPPORTED */
| 'PPAG'
/** LARGE_STATUS_CODE */
| 'PPLS'
/** COUNTRY */
| 'PPCO'
/** BILLING_ADDRESS */
| 'PPAD'
/** MCC_CODE */
| 'PPAU'
/** CURRENCY_CODE_UNSUPPORTED */
| 'PPUC'
/** UNSUPPORTED_REVERSAL */
| 'PPUR'
/** VALIDATE_CURRENCY */
| 'PPVC'
/** BANKAUTH_ROW_MISMATCH */
| 'PPS0'
/** BANKAUTH_ROW_SETTLED */
| 'PPS1'
/** BANKAUTH_ROW_VOIDED */
| 'PPS2'
/** BANKAUTH_EXPIRED */
| 'PPS3'
/** CURRENCY_MISMATCH */
| 'PPS4'
/** CREDITCARD_MISMATCH */
| 'PPS5'
/** AMOUNT_MISMATCH */
| 'PPS6'
/** INVALID_PARENT_TRANSACTION_STATUS */
| 'PPRF'
/** EXPIRY_DATE */
| 'PPEX'
/** AMOUNT_EXCEEDED */
| 'PPAX'
/** AUTH_MESSAGE */
| 'PPDV'
/** DINERS_REJECT */
| 'PPDI'
/** AUTH_RESULT */
| 'PPAR'
/** BAD_GAMING */
| 'PPBG'
/** GAMING_REFUND_ERROR */
| 'PPGR'
/** CREDIT_ERROR */
| 'PPCR'
/** AMOUNT_INCOMPATIBLE */
| 'PPAI'
/** IDEMPOTENCY_FAILURE */
| 'PPIF'
/** BLOCKED_Mastercard */
| 'PPMC'
/** AMEX_DISABLED */
| 'PPAE'
/** FIELD_VALIDATION_FAILED */
| 'PPFV'
/** INVALID_INPUT_FAILURE */
| 'PPII'
/** INVALID_PAYMENT_METHOD */
| 'PPPM'
/** USER_NOT_AUTHORIZED */
| 'PPUA'
/** INVALID_FUNDING_INSTRUMENT */
| 'PPFI'
/** EXPIRED_FUNDING_INSTRUMENT */
| 'PPEF'
/** RESTRICTED_FUNDING_INSTRUMENT */
| 'PPFR'
/** EXCEEDS_FREQUENCY_LIMIT */
| 'PPEL'
/** CVV_FAILURE */
| 'PCVV'
/** INVALID_VERIFICATION_TOKEN */
| 'PPTV'
/** VERIFICATION_TOKEN_EXPIRED */
| 'PPTE'
/** INVALID_PRODUCT */
| 'PPPI'
/** INVALID_TRACE_ID */
| 'PPIT'
/** INVALID_TRACE_REFERENCE */
| 'PPTF'
/** FUNDING_SOURCE_ALREADY_EXISTS */
| 'PPFE'
/** VERIFICATION_TOKEN_REVOKED */
| 'PPTR'
/** INVALID_TRANSACTION_ID */
| 'PPTI'
/** SECURE_ERROR_3DS */
| 'PPD3'
/** NO_PHONE_FOR_DCC_TRANSACTION */
| 'PPPH'
/** ARC_AVS */
| 'PPAV'
/** ARC_CVV */
| 'PPC2'
/** LATE_REVERSAL */
| 'PPLR'
/** NOT_SUPPORTED_NRC */
| 'PPNC'
/** MERCHANT_NOT_REGISTERED */
| 'PPRR'
/** ARC_SCORE */
| 'PPSC'
/** AMEX_DENIED */
| 'PPSE'
/** UNSUPPORT_ENTITY */
| 'PPUE'
/** UNSUPPORT_INSTALLMENT */
| 'PPUI'
/** UNSUPPORT_POS_FLAG */
| 'PPUP'
/** UNSUPPORT_REFUND_ON_PENDING_BC */
| 'PPRE';
export type PaymentAdviceCode =
/** MASTERCARD_EXPIRED */
'01'
/** MASTERCARD_CREDIT_LIMIT */
| '02'
/** MASTERCARD_ACCOUNT_CLOSED */
| '03'
/** MASTERCARD_UNSUCCESSFUL */
| '21';
export interface ReauthorizeRequest {
amount: Money;
}
export interface Refund extends ActivityTimestamps, RefundStatus {
amount: Money;
id: string;
invoice_id: string;
links: LinkDescription[];
note_to_payer: string;
seller_payable_breakdown: SellerPayableBreakdown;
}
export interface RefundRequest {
amont: Money;
invoice_id: string;
note_to_payer: string;
}
export interface RefundStatus {
readonly status_details: RefundStatusDetails;
readonly status: Status;
}
export interface RefundStatusDetails {
reason: Reason;
}
export interface SellerPayableBreakdown {
gross_amount: Money;
net_amount_breakdown: NetAmountBreakdown[];
net_amount_in_receivable_currency: Money;
net_amount: Money;
paypal_fee_in_receivable_currency: Money;
paypal_fee: Money;
platform_fees: PlatformFee[];
total_refunded_amount: Money;
}
export interface SellerProtection {
readonly dispute_categories: DisputeCategory[];
readonly status: Status;
}
export interface SellerReceivableBreakdown {
exchange_rate?: ExchangeRate;
gross_amount: Money;
net_amount?: Money;
paypal_fee_in_receivable_currency?: Money;
paypal_fee?: Money;
platform_fees?: PlatformFee[];
receivable_amount?: Money;
}
export type ShippingType = 'PICKUP' | 'PICKUP_IN_PERSON' | 'SHIPPING';
export interface SupplementaryPurchaseData {
invoice_id: string;
note_to_payer: string;
}
export interface TaxInfo {
tax_id_type: TaxIdType;
tax_id: string;
}
export type TaxIdType = 'BR_CNPJ' | 'BR_CPF';
export interface Token {
id: string;
type: TokenType;
}
export type TokenType = 'BILLING_AGREEMENT';
export interface BasePaymentHeaders extends BaseHeaders {
'Content-Type': 'application/json';
}