remove binlookup interface in favor of generated models (#965)

* remove binlookup interface in favor of generated models

* Update src/typings/index.ts

Fix typo in  typings index.ts

Co-authored-by: Michael Paul <michael@michaelpaul.com.br>

Co-authored-by: Michael Paul <michael@michaelpaul.com.br>
Co-authored-by: jillingk <93914435+jillingk@users.noreply.github.com>
This commit is contained in:
Wouter Boereboom
2022-08-19 13:56:48 +02:00
committed by GitHub
parent 71c697e102
commit 13309b073a
4 changed files with 21 additions and 365 deletions

View File

@@ -3,6 +3,11 @@ import { createClient } from "../__mocks__/base";
import BinLookup from "../services/binLookup";
import Client from "../client";
import HttpClientException from "../httpClient/httpClientException";
import {
ThreeDSAvailabilityRequest,
ThreeDSAvailabilityResponse,
CostEstimateRequest,
} from "../typings/binlookup/models";
const threeDSAvailabilitySuccess = {
binDetails: {
@@ -32,7 +37,7 @@ afterEach((): void => {
describe("Bin Lookup", function (): void {
test("should succeed on get 3ds availability", async function (): Promise<void> {
const threeDSAvailabilityRequest: IBinLookup.ThreeDSAvailabilityRequest = {
const threeDSAvailabilityRequest: ThreeDSAvailabilityRequest = {
merchantAccount: process.env.ADYEN_MERCHANT!,
brands: ["randomBrand"],
cardNumber: "4111111111111111"
@@ -43,7 +48,7 @@ describe("Bin Lookup", function (): void {
const response = await binLookup.get3dsAvailability(threeDSAvailabilityRequest);
expect(response).toEqual<IBinLookup.ThreeDSAvailabilityResponse>(threeDSAvailabilitySuccess);
expect(response).toEqual<ThreeDSAvailabilityResponse>(threeDSAvailabilitySuccess);
});
test.each([false, true])("should fail with invalid merchant. isMock: %p", async function (isMock): Promise<void> {
@@ -58,7 +63,7 @@ describe("Bin Lookup", function (): void {
.reply(403, JSON.stringify({status: 403, message: "fail", errorCode: "171"}));
try {
await binLookup.get3dsAvailability(threeDSAvailabilityRequest as unknown as IBinLookup.ThreeDSAvailabilityRequest);
await binLookup.get3dsAvailability(threeDSAvailabilityRequest as unknown as ThreeDSAvailabilityRequest);
fail("Expected request to fail");
} catch (e) {
expect(e instanceof HttpClientException).toBeTruthy();
@@ -84,7 +89,7 @@ describe("Bin Lookup", function (): void {
resultCode: "Unsupported",
surchargeType: "ZERO"
};
const costEstimateRequest: IBinLookup.CostEstimateRequest = {
const costEstimateRequest: CostEstimateRequest = {
amount: { currency: "EUR", value: 1000 },
assumptions: {
assumeLevel3Data: true,
@@ -97,7 +102,7 @@ describe("Bin Lookup", function (): void {
mcc: "7411",
enrolledIn3DSecure: true
},
shopperInteraction: "Ecommerce"
shopperInteraction: CostEstimateRequest.ShopperInteractionEnum.Ecommerce,
};
scope.post("/getCostEstimate")

View File

@@ -1,26 +1,14 @@
/*
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
* Adyen NodeJS API Library
* Copyright (c) 2020 Adyen B.V.
* This file is open source and available under the MIT license.
* See the LICENSE file for more info.
*/
import ApiKeyAuthenticatedService from "../apiKeyAuthenticatedService";
import Client from "../client";
import GetCostEstimate from "./resource/binLookup/getCostEstimate";
import Get3dsAvailability from "./resource/binLookup/get3dsAvailability";
import getJsonResponse from "../helpers/getJsonResponse";
import {
ThreeDSAvailabilityRequest,
ThreeDSAvailabilityResponse,
CostEstimateRequest,
CostEstimateResponse,
} from "../typings/binlookup/models";
class BinLookup extends ApiKeyAuthenticatedService {
private readonly _get3dsAvailability: Get3dsAvailability;
@@ -32,15 +20,15 @@ class BinLookup extends ApiKeyAuthenticatedService {
this._getCostEstimate = new GetCostEstimate(this);
}
public get3dsAvailability(request: IBinLookup.ThreeDSAvailabilityRequest): Promise<IBinLookup.ThreeDSAvailabilityResponse> {
return getJsonResponse<IBinLookup.ThreeDSAvailabilityRequest, IBinLookup.ThreeDSAvailabilityResponse>(
public get3dsAvailability(request: ThreeDSAvailabilityRequest): Promise<ThreeDSAvailabilityResponse> {
return getJsonResponse<ThreeDSAvailabilityRequest, ThreeDSAvailabilityResponse>(
this._get3dsAvailability,
request
);
}
public getCostEstimate(request: IBinLookup.CostEstimateRequest): Promise<IBinLookup.CostEstimateResponse> {
return getJsonResponse<IBinLookup.CostEstimateRequest, IBinLookup.CostEstimateResponse>(
public getCostEstimate(request: CostEstimateRequest): Promise<CostEstimateResponse> {
return getJsonResponse<CostEstimateRequest, CostEstimateResponse>(
this._getCostEstimate,
request
);

View File

@@ -1,337 +0,0 @@
/*
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
* Adyen NodeJS API Library
* Copyright (c) 2020 Adyen B.V.
* This file is open source and available under the MIT license.
* See the LICENSE file for more info.
*/
declare namespace IBinLookup {
export interface Amount {
/**
* The three-character [ISO currency code](https://docs.adyen.com/development-resources/currency-codes).
*/
currency: string;
/**
* The payable amount that can be charged for the transaction.
*
* The transaction amount needs to be represented in minor units according to the [following table](https://docs.adyen.com/development-resources/currency-codes).
*/
value: number; // int64
}
export interface BinDetail {
/**
* The country where the card was issued.
*/
issuerCountry?: string;
}
export interface CardBin {
/**
* The first 6 digit of the card number. Enable this field via merchant account settings.
*/
bin?: string;
/**
* If true, it indicates a commercial card. Enable this field via merchant account settings.
*/
commercial?: boolean;
/**
* The card funding source. Valid values are:
* * CHARGE
* * CREDIT
* * DEBIT
* * DEFERRED_DEBIT
* * PREPAID
* * PREPAID_RELOADABLE
* * PREPAID_NONRELOADABLE
* > Enable this field via merchant account settings.
*/
fundingSource?: string;
/**
* Indicates availability of funds.
*
* Visa:
* * "I" (fast funds are supported)
* * "N" (otherwise)
*
* Mastercard:
* * "I" (product type is Prepaid or Debit, or issuing country is in CEE/HGEM list)
* * "N" (otherwise)
* > Returned when you verify a card BIN or estimate costs, and only if `payoutEligible` is different from "N" or "U".
*/
fundsAvailability?: string;
/**
* The issuing bank of the card.
*/
issuingBank?: string;
/**
* The country where the card was issued from.
*/
issuingCountry?: string;
/**
* The currency of the card.
*/
issuingCurrency?: string;
/**
* The payment method associated with the card (e.g. visa, mc, or amex).
*/
paymentMethod?: string;
/**
* Indicates whether a payout is eligible or not for this card.
*
* Visa:
* * "Y"
* * "N"
*
* Mastercard:
* * "Y" (domestic and cross-border)
* * "D" (only domestic)
* * "N" (no MoneySend)
* * "U" (unknown)
* > Returned when you verify a card BIN or estimate costs, and only if `payoutEligible` is different from "N" or "U".
*/
payoutEligible?: string;
/**
* The last four digits of the card number.
*/
summary?: string;
}
export interface CostEstimateAssumptions {
/**
* If true, the cardholder is expected to successfully authorise via 3D Secure.
*/
assume3DSecureAuthenticated?: boolean;
/**
* If true, the transaction is expected to have valid Level 3 data.
*/
assumeLevel3Data?: boolean;
/**
* If not zero, the number of installments.
*/
installments?: number; // int32
}
export interface CostEstimateRequest {
/**
* The transaction amount used as a base for the cost estimation.
*/
amount: IBinLookup.Amount;
/**
* Assumptions made for the expected characteristics of the transaction, for which the charges are being estimated.
*/
assumptions?: IBinLookup.CostEstimateAssumptions;
/**
* The card number (4-19 characters) for PCI compliant use cases. Do not use any separators.
*
* > Either the `cardNumber` or `encryptedCard` field must be provided in a payment request.
*/
cardNumber?: string;
/**
* Encrypted data that stores card information for non PCI-compliant use cases. The encrypted data must be created with the Checkout Card Component or Secured Fields Component, and must contain the `encryptedCardNumber` field.
*
* > Either the `cardNumber` or `encryptedCard` field must be provided in a payment request.
*/
encryptedCard?: string;
/**
* The merchant account identifier you want to process the (transaction) request with.
*/
merchantAccount: string;
/**
* Additional data for merchants who don't use Adyen as the payment authorisation gateway.
*/
merchantDetails?: IBinLookup.MerchantDetails;
/**
* The recurring settings for the payment. Use this property when you want to enable [recurring payments](https://docs.adyen.com/checkout/tokenization).
*/
recurring?: IBinLookup.Recurring;
/**
* The `recurringDetailReference` you want to use for this cost estimate. The value `LATEST` can be used to select the most recently stored recurring detail.
*/
selectedRecurringDetailReference?: string;
/**
* Specifies the sales channel, through which the shopper gives their card details, and whether the shopper is a returning customer.
* For the web service API, Adyen assumes Ecommerce shopper interaction by default.
*
* This field has the following possible values:
* * `Ecommerce` - Online transactions where the cardholder is present (online). For better authorisation rates, we recommend sending the card security code (CSC) along with the request.
* * `ContAuth` - Card on file and/or subscription transactions, where the card holder is known to the merchant (returning customer). If the shopper is present (online), you can supply also the CSC to improve authorisation (one-click payment).
* * `Moto` - Mail-order and telephone-order transactions where the shopper is in contact with the merchant via email or telephone.
* * `POS` - Point-of-sale transactions where the shopper is physically present to make a payment using a secure payment terminal.
*/
shopperInteraction?: "Ecommerce" | "ContAuth" | "Moto" | "POS";
/**
* The shopper's reference to uniquely identify this shopper (e.g. user ID or account ID).
* > This field is required for recurring payments.
*/
shopperReference?: string;
}
export interface CostEstimateResponse {
/**
* Card BIN details.
*/
cardBin?: IBinLookup.CardBin;
/**
* The estimated cost (scheme fee + interchange) in the settlement currency. If the settlement currency cannot be determined, the fee in EUR is returned.
*/
costEstimateAmount?: IBinLookup.Amount;
/**
* The result of the cost estimation.
*/
resultCode?: string;
/**
* Indicates the way the charges can be passed on to the cardholder. The following values are possible:
* * `ZERO` - the charges are not allowed to pass on
* * `PASSTHROUGH` - the charges can be passed on
* * `UNLIMITED` - there is no limit on how much surcharge is passed on
*/
surchargeType?: string;
}
export interface DSPublicKeyDetail {
/**
* Card brand.
*/
brand?: string;
/**
* Directory Server (DS) identifier.
*/
directoryServerId?: string;
/**
* Public key. The 3D Secure 2 SDK encrypts the device information by using the DS public key.
*/
publicKey?: string; // byte
}
export interface MerchantDetails {
/**
* 2-letter ISO 3166 country code of the card acceptor location.
* > This parameter is required for the merchants who don't use Adyen as the payment authorisation gateway.
*/
countryCode?: string;
/**
* If true, indicates that the merchant is enrolled in 3D Secure for the card network.
*/
enrolledIn3DSecure?: boolean;
/**
* The merchant category code (MCC) is a four-digit number which relates to a particular market segment. This code reflects the predominant activity that is conducted by the merchant.
*
* The list of MCCs can be found [here](https://en.wikipedia.org/wiki/Merchant_category_code).
*/
mcc?: string;
}
namespace Post {
export type RequestBody = IBinLookup.CostEstimateRequest;
namespace Responses {
export type $200 = IBinLookup.CostEstimateResponse;
}
}
export interface Recurring {
/**
* The type of recurring contract to be used.
* Possible values:
* * `ONECLICK` Payment details can be used to initiate a one-click payment, where the shopper enters the [card security code (CVC/CVV)](https://docs.adyen.com/payments-fundamentals/payment-glossary#card-security-code-cvc-cvv-cid).
* * `RECURRING` Payment details can be used without the card security code to initiate [card-not-present transactions](https://docs.adyen.com/payments-fundamentals/payment-glossary#card-not-present-cnp).
* * `ONECLICK,RECURRING` Payment details can be used regardless of whether the shopper is on your site or not.
* * `PAYOUT` Payment details can be used to [make a payout](https://docs.adyen.com/checkout/online-payouts).
*/
contract?: "ONECLICK" | "RECURRING" | "PAYOUT";
/**
* A descriptive name for this detail.
*/
recurringDetailName?: string;
/**
* Date after which no further authorisations shall be performed. Only for 3D Secure 2.
*/
recurringExpiry?: string; // date-time
/**
* Minimum number of days between authorisations. Only for 3D Secure 2.
*/
recurringFrequency?: string;
/**
* The name of the token service.
*/
tokenService?: "VISATOKENSERVICE" | "MCTOKENSERVICE";
}
export interface ThreeDS2CardRangeDetail {
/**
* Card brand.
*/
brandCode?: string;
/**
* BIN end range.
*/
endRange?: string;
/**
* BIN start range.
*/
startRange?: string;
/**
* 3D Secure protocol version.
*/
threeDS2Version?: string;
/**
* In a 3D Secure 2 browser-based flow, this is the URL where you should send the device fingerprint to.
*/
threeDSMethodURL?: string;
}
export interface ThreeDSAvailabilityRequest {
/**
* This field contains additional data, which may be required for a particular request.
*
* The `additionalData` object consists of entries, each of which includes the key and value.
*/
additionalData?: {
};
/**
* List of brands.
*/
brands: string[];
/**
* Card number or BIN.
*/
cardNumber?: string;
/**
* The merchant account identifier.
*/
merchantAccount: string;
/**
* A recurring detail reference corresponding to a card.
*/
recurringDetailReference?: string;
/**
* The shopper's reference to uniquely identify this shopper (e.g. user ID or account ID).
*/
shopperReference?: string;
}
export interface ThreeDSAvailabilityResponse {
/**
* Bin Group Details
*/
binDetails?: IBinLookup.BinDetail;
/**
* List of Directory Server (DS) public keys.
*/
dsPublicKeys?: IBinLookup.DSPublicKeyDetail[];
/**
* Indicator if 3D Secure 1 is supported.
*/
threeDS1Supported?: boolean;
/**
* List of brand and card range pairs.
*/
threeDS2CardRangeDetails?: IBinLookup.ThreeDS2CardRangeDetail[];
/**
* Indicator if 3D Secure 2 is supported.
*/
threeDS2supported?: boolean;
}
}

View File

@@ -1,7 +1,6 @@
/// <reference path="amount.ts" />
/// <reference path="apiError.ts" />
/// <reference path="applicationInfo.ts" />
/// <reference path="binLookup.ts" />
/// <reference path="enums/environment.ts" />
/// <reference path="enums/vatCategory.ts" />
/// <reference path="nexo.ts" />
@@ -10,6 +9,7 @@
/// <reference path="platformsFund.ts" />
/// <reference path="platformsNotificationConfiguration.ts" />
export * as binlookup from './binlookup/models';
export * as checkout from './checkout/models';
export * as notification from './notification/models';
export * as payouts from './payouts/models';