Compare commits

..

1 Commits

Author SHA1 Message Date
Ricardo Ambrogi
7a025a0554 Change res.body to string 2020-06-05 13:35:28 +02:00
2066 changed files with 96203 additions and 105742 deletions

View File

@@ -1,22 +1,3 @@
/*
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
* 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.
*/
const path = require('path');
module.exports = {
@@ -37,21 +18,13 @@ module.exports = {
},
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
rules: {
quotes: ["error", "double"],
semi: ["error", "always"],
"@typescript-eslint/no-non-null-assertion": 0,
"@typescript-eslint/ban-types": [
"error",
{
"extendDefaults": true,
"types": {
"{}": false
}
}
]
"@typescript-eslint/no-non-null-assertion": 0
},
overrides: [
{

2
.github/CODEOWNERS vendored
View File

@@ -1 +1 @@
* @Adyen/javascript
* @KadoBOT @msilvagarcia @cyattilakiss @zaiddreakh @Aleffio @rikterbeek

View File

@@ -3,7 +3,7 @@ name: Bug report
about: Create a report to help us improve
title: '[BUG]'
labels: 'bug'
assignees: ''
assignees: 'KadoBOT'
---

View File

@@ -3,7 +3,7 @@ name: Feature request
about: Suggest an idea for this project
title: '[FEATURE]'
labels: 'feature'
assignees: ''
assignees: 'KadoBOT'
---

View File

@@ -1,7 +0,0 @@
**Description**
<!-- Please provide a description of the changes proposed in the Pull Request -->
**Tested scenarios**
<!-- Description of tested scenarios -->
**Fixed issue**: <!-- #-prefixed issue number -->

7
.github/stale.yml vendored
View File

@@ -3,13 +3,6 @@ daysUntilStale: 60
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 7
# Label to use when marking an issue as stale
# Issues with these labels will never be considered stale
exemptLabels:
- Validating request
- Bug report
- Bug
- Enhancement
- feature
staleLabel: wontfix
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >

View File

@@ -1,46 +0,0 @@
name: "Code scanning - action"
on:
push:
pull_request:
schedule:
- cron: '0 21 * * 4'
jobs:
CodeQL-Build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
# Override language selection by uncommenting this and choosing your languages
# with:
# languages: go, javascript, csharp, python, cpp, java
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
# Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
#- run: |
# make bootstrap
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2

View File

@@ -1,4 +1,4 @@
on: ["pull_request"]
on: ["push", "pull_request"]
name: Coveralls
@@ -9,12 +9,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v1
- name: Use Node.js 16.x
uses: actions/setup-node@v3
- name: Use Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: 16.x
node-version: 12.x
- name: npm install, npm test:coverage
run: |

View File

@@ -1,30 +0,0 @@
name: Node.js Models
on: [ workflow_dispatch ]
jobs:
generate:
runs-on: ubuntu-latest
name: Generate Models
steps:
- uses: actions/checkout@v3
- run: make models
- name: Set PR variables
id: vars
run: |
cd build/spec
echo ::set-output name=pr_title::"Update models"
echo ::set-output name=pr_body::"OpenAPI spec or templates produced new models on $(date +%d-%m-%Y) \
by [commit](https://github.com/Adyen/adyen-openapi/commit/$(git rev-parse HEAD))."
- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.ADYEN_AUTOMATION_BOT_ACCESS_TOKEN }}
committer: ${{ secrets.ADYEN_AUTOMATION_BOT_EMAIL }}
author: ${{ secrets.ADYEN_AUTOMATION_BOT_EMAIL }}
base: develop
branch: automation/models
title: ${{ steps.vars.outputs.pr_title }}
body: ${{ steps.vars.outputs.pr_body }}
add-paths: |
src/typings

View File

@@ -1,6 +1,6 @@
name: Node.js CI
on: [pull_request]
on: [push, pull_request]
jobs:
build:
@@ -9,12 +9,12 @@ jobs:
strategy:
matrix:
node-version: [12.x, 14.x, 16.x]
node-version: [10.x, 12.x, 13.x]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: npm install, lint and test

View File

@@ -1,24 +1,47 @@
name: Node.js Package
on:
workflow_dispatch:
release:
types: [published]
types: [created]
jobs:
publish-npm:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 14
registry-url: https://registry.npmjs.org/
- run: |
npm install
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc
npm run build
npm publish
node-version: 12
- run: yarn install --frozen-lockfile
- run: yarn run test
env:
CI: true
ADYEN_API_KEY: ${{ secrets.ADYEN_API_KEY }}
ADYEN_MERCHANT: ${{ secrets.ADYEN_MERCHANT }}
ADYEN_PASSWORD: ${{ secrets.ADYEN_PASSWORD }}
ADYEN_REVIEWPAYOUT_APIKEY: ${{ secrets.ADYEN_REVIEWPAYOUT_APIKEY }}
ADYEN_REVIEWPAYOUT_PASSWORD: ${{ secrets.ADYENREVIEWPAYOUT_PASSWORD }}
ADYEN_REVIEWPAYOUT_USER: ${{ secrets.ADYENREVIEWPAYOUT_USER }}
ADYEN_STOREPAYOUT_APIKEY: ${{ secrets.ADYEN_STOREPAYOUT_APIKEY }}
ADYEN_STOREPAYOUT_PASSWORD: ${{ secrets.ADYEN_STOREPAYOUT_PASSWORD }}
ADYEN_STOREPAYOUT_USER: ${{ secrets.ADYEN_STOREPAYOUT_USER }}
ADYEN_USER: ${{ secrets.ADYEN_USER }}
ADYEN_MARKETPLACE_USER: ${{ secrets.ADYEN_MARKETPLACE_USER }}
ADYEN_MARKETPLACE_PASSWORD: ${{ secrets.ADYEN_MARKETPLACE_PASSWORD }}
ADYEN_TERMINAL_APIKEY: ${{ secrets.ADYEN_TERMINAL_APIKEY }}
ADYEN_TERMINAL_POIID: ${{ secrets.ADYEN_TERMINAL_POIID }}
ADYEN_TERMINAL_MERCHANT: ${{ secrets.ADYEN_TERMINAL_MERCHANT }}
- run: yarn run build
publish-npm:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12
registry-url: https://registry.npmjs.org/
- run: npm publish
env:
GITHUB_TOKEN: ${{ secrets.USER_GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

View File

@@ -1,21 +0,0 @@
name: "Sonarcloud Analysis"
on: ["pull_request"]
jobs:
sonarcloud-analysis:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
# Disabling shallow clone to improve relevancy of SonarCloud reporting
fetch-depth: 0
- name: SonarCloud integration
uses: sonarsource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

4
.gitignore vendored
View File

@@ -11,6 +11,4 @@ node_modules
.ssh/
.viminfo
coverage/
.env
lib/
build/
.env

View File

@@ -1,16 +1,10 @@
src/
.babelrc
.eslintignore
.eslintrc.js
.eslintrc.json
.gitignore
.release-it.json
CODE_OF_CONDUCT.md
CONTRIBUTING.md
Makefile
config.ts
renovate.json
.travis.yml
tsconfig.json
jest.config.js
tslint.json
.github
/**/__mocks__/
/**/__tests__/
webpack.config.js

View File

@@ -1,20 +1,12 @@
{
"git": {
"tagName": "v${version}",
"changelog": "npx auto-changelog --hide-credit --stdout --commit-limit false --unreleased-only -t keepachangelog",
"commitMessage": "Release ${version}",
"tag": true,
"requireCleanWorkingDir": false
"changelog": "npx auto-changelog --stdout --commit-limit false -u"
},
"github": {
"release": true,
"releaseName": "Adyen Node API Library v${version}"
"release": true
},
"hooks": {
"after:bump": [
"npm run build",
"npx auto-changelog -p"
],
"after:release": "echo Successfully released ${name} v${version} to ${repo.repository}."
"after:bump": "npx auto-changelog -p"
}
}

View File

@@ -1,13 +1,10 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright Contributors to the ODPi Egeria project.
# General settings
sonar.organization=adyen
sonar.projectKey=Adyen_adyen-node-api-library
# Path to sources
#sonar.sources=.
sonar.exclusions=src/__mocks__/**/* , src/typings/**/* , src/__tests__/**/*
sonar.exclusions=src/__mocks__/*
sonar.exclusions=src/typings/*
#sonar.inclusions=
# Path to tests

View File

@@ -1,6 +1,6 @@
MIT License
Copyright (c) 2020 Adyen
Copyright (c) 2019 Adyen
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,74 +0,0 @@
generator:=typescript-node
openapi-generator-version:=5.4.0
openapi-generator-url:=https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/$(openapi-generator-version)/openapi-generator-cli-$(openapi-generator-version).jar
openapi-generator-jar:=build/openapi-generator-cli.jar
openapi-generator-cli:=java -jar $(openapi-generator-jar)
services:=balancePlatform binlookup checkout dataProtection legalEntityManagement management payments payouts platformsAccount platformsFund platformsHostedOnboardingPage platformsNotificationConfiguration recurring storedValue terminalManagement transfer
# Generate models (for each service)
models: $(services)
binlookup: spec=BinLookupService-v52
checkout: spec=CheckoutService-v69
dataProtection: spec=DataProtectionService-v1
storedValue: spec=StoredValueService-v46
terminalManagement: spec=TfmAPIService-v1
payments: spec=PaymentService-v68
recurring: spec=RecurringService-v68
payouts: spec=PayoutService-v68
management: spec=ManagementService-v1
managementapi: spec=ManagementService-v1
managementapi: service=management
legalEntityManagement: spec=LegalEntityService-v2
balancePlatform: spec=BalancePlatformService-v2
platformsAccount: spec=AccountService-v6
platformsFund: spec=FundService-v6
platformsNotificationConfiguration: spec=NotificationConfigurationService-v6
platformsHostedOnboardingPage: spec=HopService-v6
transfer: spec=TransferService-v3
$(services): build/spec $(openapi-generator-jar)
rm -rf src/typings/$@ build/model
$(openapi-generator-cli) generate \
-i build/spec/json/$(spec).json \
-g $(generator) \
-t templates/typescript \
-o build \
--global-property models,supportingFiles \
--additional-properties=serviceName=$@
mv build/model src/typings/$@
# Service
managementapi: build/spec $(openapi-generator-jar)
$(openapi-generator-cli) generate \
-i build/spec/json/$(spec).json \
-g $(generator) \
-t templates/typescript \
-o build \
--api-package $(service) \
--model-package typings/$(service) \
--global-property apis \
--additional-properties=serviceName=$(service)
cp build/$(service)/* src/services/$(service)
sed -i.bak '/RestServiceError/d' src/services/$(service)/*
rm src/services/$(service)/*.bak
# Checkout spec (and patch version)
build/spec:
git clone https://github.com/Adyen/adyen-openapi.git build/spec
perl -i -pe's/"openapi" : "3.[0-9].[0-9]"/"openapi" : "3.0.0"/' build/spec/json/*.json
# Extract templates (copy them for modifications)
templates: $(openapi-generator-jar)
$(openapi-generator-cli) author template -g $(generator) -o build/templates/typescript
# Download the generator
$(openapi-generator-jar):
wget --quiet -o /dev/null $(openapi-generator-url) -O $(openapi-generator-jar)
# Discard generated artifacts and changed models
clean:
git checkout src/typings src/services/management
git clean -f -d src/typings src/services/management
.PHONY: templates models $(services)

162
README.md
View File

@@ -1,47 +1,30 @@
![Node js](https://user-images.githubusercontent.com/62436079/207373079-9cf9377f-f530-4b02-a515-9b64ef7b06e7.png)
# Adyen Node.js API Library
![Node.js CI](https://github.com/Adyen/adyen-node-api-library/workflows/Node.js%20CI/badge.svg)
[![Coverage Status](https://coveralls.io/repos/github/Adyen/adyen-node-api-library/badge.svg?branch=main)](https://coveralls.io/github/Adyen/adyen-node-api-library?branch=main)
[![Coverage Status](https://coveralls.io/repos/github/Adyen/adyen-node-api-library/badge.svg?branch=master)](https://coveralls.io/github/Adyen/adyen-node-api-library?branch=master)
[![Downloads](https://img.shields.io/npm/dm/@adyen/api-library.svg)](https://www.npmjs.com/package/@adyen/api-library)
![npm bundle size (scoped)](https://img.shields.io/bundlephobia/minzip/@adyen/api-library.svg)
[![Version](https://img.shields.io/npm/v/@adyen/api-library.svg)](https://www.npmjs.com/package/@adyen/api-library)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=Adyen_adyen-node-api-library&metric=alert_status)](https://sonarcloud.io/dashboard?id=Adyen_adyen-node-api-library)
[![Total alerts](https://img.shields.io/lgtm/alerts/g/Adyen/adyen-node-api-library.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/Adyen/adyen-node-api-library/alerts/)
[![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/Adyen/adyen-node-api-library.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/Adyen/adyen-node-api-library/context:javascript)
This is the officially supported NodeJS library for using Adyen's APIs.
The Adyen API Library for NodeJS enables you to work with Adyen APIs.
## Supported API versions
## Integration
The Library supports all APIs under the following services:
| API | Description | Service Name | Supported version |
| --- | ----------- | ------------ | ----------------- |
|[BIN lookup API](https://docs.adyen.com/api-explorer/#/BinLookup/v52/overview) | The BIN Lookup API provides endpoints for retrieving information based on a given BIN. | BinLookup | **v52** |
| [Checkout API](https://docs.adyen.com/api-explorer/#/CheckoutService/v69/overview)| Our latest integration for accepting online payments. | CheckoutAPI | **v69** |
| [Configuration API](https://docs.adyen.com/api-explorer/#/balanceplatform/v2/overview)| The Configuration API enables you to create a platform where you can onboard your users as account holders and create balance accounts, cards, and business accounts. | BalancePlatform | **v2** |
| [DataProtection API](https://docs.adyen.com/development-resources/data-protection-api) | Adyen Data Protection API provides a way for you to process [Subject Erasure Requests](https://gdpr-info.eu/art-17-gdpr/) as mandated in GDPR. Use our API to submit a request to delete shopper's data, including payment details and other related information (for example, delivery address or shopper email) | DataProtection | **v1** |
| [Legal Entity Management API](https://docs.adyen.com/api-explorer/#/legalentity/v2/overview)| Manage legal entities that contain information required for verification. | LegalEntityManagement | **v2** |
| [Local/Cloud-based Terminal API](https://docs.adyen.com/point-of-sale/terminal-api-reference)| Our point-of-sale integration. | TerminalLocalAPI or TerminalCloudAPI | - |
| [Management API](https://docs.adyen.com/api-explorer/#/ManagementService/v1/overview)| Configure and manage your Adyen company and merchant accounts, stores, and payment terminals. | Management | **v1** |
| [Payments API](https://docs.adyen.com/api-explorer/#/Payment/v68/overview)| Our classic integration for online payments. | ClassicIntegrationAPI | **v68** |
| [Payouts API](https://docs.adyen.com/api-explorer/#/Payout/v68/overview)| Endpoints for sending funds to your customers. | Payout | **v68** |
| [Platforms APIs](https://docs.adyen.com/platforms/api)| Set of APIs when using Adyen for Platforms. This API is used for the classic integration. | Platforms | - |
| [Account API](https://docs.adyen.com/api-explorer/#/Account/v6/overview) | *Platforms subclass* | Account | **v6** |
| [Fund API](https://docs.adyen.com/api-explorer/#/Fund/v6/overview) | *Platforms subclass* | Fund | **v6** |
| [Hosted onboarding API](https://docs.adyen.com/api-explorer/#/Hop/v6/overview)| *Platforms subclass* | HostedOnboardingPage | **v6** |
| [Notification Configuration API](https://docs.adyen.com/api-explorer/#/NotificationConfigurationService/v6/overview) | *Platforms subclass* | NotificationConfiguration | **v6** |
| [Platforms Notifications Webhooks](https://docs.adyen.com/api-explorer/#/NotificationService/v6/overview) || *Models only* | **v6** |
| [POS Terminal Management API](https://docs.adyen.com/api-explorer/#/postfmapi/v1/overview)| Endpoints for managing your point-of-sale payment terminals. | TerminalManagement | **v1** |
| [Recurring API](https://docs.adyen.com/api-explorer/#/Recurring/v68/overview)| Endpoints for managing saved payment details. | Recurring | **v68** |
| [Stored Value API](https://docs.adyen.com/payment-methods/gift-cards/stored-value-api) | Manage both online and point-of-sale gift cards and other stored-value cards. | StoredValue | **v46** |
| [Transfers API](https://docs.adyen.com/api-explorer/transfers/3/overview) | The Transfers API provides endpoints that can be used to get information about all your transactions, move funds within your balance platform or send funds from your balance platform to a transfer instrument. | Transfers | **v3** |
| [Webhooks](https://docs.adyen.com/api-explorer/Webhooks/1/overview) | Adyen uses webhooks to send notifications about payment status updates, newly available reports, and other events that can be subscribed to. For more information, refer to our [documentation](https://docs.adyen.com/development-resources/webhooks). | *Models only* | **v1** |
For more information, refer to our [documentation](https://docs.adyen.com/) or the [API Explorer](https://docs.adyen.com/api-explorer/).
* [x] checkout
* [x] checkout utility
* [x] payments
* [x] modifications
* [x] payouts
* [x] recurring
* [x] notifications
* [x] BIN lookup
## Prerequisites
- [Adyen test account](https://docs.adyen.com/get-started-with-adyen). To start using Adyen APIs, you will need a Merchant Account.
- [API key](https://docs.adyen.com/development-resources/api-credentials#generate-api-key). For testing, your API credential needs to have the [API PCI Payments role](https://docs.adyen.com/development-resources/api-credentials#roles).
- Node 12 or higher
## Requirements
* Node 10 or higher
## Installation
@@ -53,100 +36,12 @@ You can use NPM to add our library to your project
npm install --save @adyen/api-library
```
Alternatively, you can download the [release on GitHub](https://github.com/Adyen/adyen-node-api-library/releases).
## Documentation
* https://docs.adyen.com/developers/development-resources/libraries
* https://docs.adyen.com/developers/checkout
## HTTP Client Configuration
## Using the library
### Client initialisation
#### General use with API key
Set up the client as a singleton resource; you can then use it to create service objects for the API calls that you make to Adyen:
```typescript
const { Client } = require('@adyen/api-library');
const client = new Client({apiKey: "YOUR_API_KEY", environment: "TEST"});
```
#### General use with API key for live environment
```typescript
const { Client } = require('@adyen/api-library');
const client = new Client({apiKey: "YOUR_API_KEY", environment: "LIVE"});
```
#### General use with basic auth
```typescript
const { Client } = require('@adyen/api-library');
const client = new Client({username: "YOUR_USERNAME", password: "YOUR_PASSWORD", environment: "TEST"});
```
### Consuming Services
Every API the library supports is represented by a service object. The name of the service matching the corresponding API is listed in the [Integrations](#supported-api-versions) section of this document.
```javascript
const { Client, CheckoutAPI } = require('@adyen/api-library');
const client = new Client({apiKey: "YOUR_API_KEY", environment: "TEST"});
const paymentRequest = {
amount: {
currency: "USD",
value: 1000 // value in minor units
},
reference: "Your order number",
paymentMethod: {
type: "scheme",
encryptedCardNumber: "test_4111111111111111",
encryptedExpiryMonth: "test_03",
encryptedExpiryYear: "test_2030",
encryptedSecurityCode: "test_737"
},
shopperReference: "YOUR_UNIQUE_SHOPPER_ID_IOfW3k9G2PvXFu2j",
storePaymentMethod: true,
shopperInteraction: "Ecommerce",
recurringProcessingModel: "CardOnFile",
returnUrl: "https://your-company.com/...",
merchantAccount: "YOUR_MERCHANT_ACCOUNT"
};
const checkoutAPI = new CheckoutAPI(client);
checkoutAPI.payments(paymentRequest)
.then( paymentResponse => console.log(paymentResponse.pspReference))
.catch(error => console.log(error));
```
Alternatively you can make use of the Types included in this library using Typescript, and/or use the async syntax:
```typescript
const { Client, CheckoutAPI } = require('@adyen/api-library');
const client = new Client({apiKey: "YOUR_API_KEY", environment: "TEST"});
import { Types } from '@adyen/api-library';
const doPaymentsRequest = async () => {
const paymentRequest : Types.checkout.PaymentRequest = {
amount: {
currency: "USD",
value: 1000 // value in minor units
},
reference: "Your order number",
paymentMethod: {
type: Types.checkout.CardDetails.TypeEnum.Scheme,
encryptedCardNumber: "test_4111111111111111",
encryptedExpiryMonth: "test_03",
encryptedExpiryYear: "test_2030",
encryptedSecurityCode: "test_737"
},
shopperReference: "YOUR_UNIQUE_SHOPPER_ID_IOfW3k9G2PvXFu2j",
storePaymentMethod: true,
shopperInteraction: Types.checkout.PaymentRequest.ShopperInteractionEnum.Ecommerce,
recurringProcessingModel: Types.checkout.PaymentRequest.RecurringProcessingModelEnum.CardOnFile,
returnUrl: "https://your-company.com/...",
merchantAccount: "YOUR_MERCHANT_ACCOUNT"
};
const checkoutAPI = new CheckoutAPI(client);
const paymentResponse : Types.checkout.PaymentResponse = await checkoutAPI.payments(paymentRequest);
console.log(paymentResponse.pspReference);
}
doPaymentsRequest();
```
### Custom HTTP Client Configuration
By default, NodeJS [https](https://nodejs.org/api/https.html) will be used to submit requests to the API. But you can change that by injecting your own HttpClient on your client instance. In the example below, we use `axios`:
```javascript
@@ -193,23 +88,18 @@ client.httpClient = httpClient;
...
```
### Example integration
For a closer look at how our NodeJS library works, clone our [example integration](https://github.com/adyen-examples/adyen-node-online-payments). This includes commented code, highlighting key features and concepts, and examples of API calls that can be made using the library.
## Support
## Contributing
If you have any problems, questions or suggestions, create an issue here or send your inquiry to support@adyen.com.
## Contributing
We strongly encourage you to join us in contributing to this repository so everyone can benefit from:
* New features and functionality
* Resolved bug fixes and issues
* Any general improvements
Read our [**contribution guidelines**](CONTRIBUTING.md) to find out how to create a pull request.
## Support
If you have a feature request, or spotted a bug or a technical problem, create a GitHub issue. For other questions, contact our [support team](https://www.adyen.help).
Read our [**contribution guidelines**](CONTRIBUTING.md) to find out how.
## Licence
This repository is available under the [MIT license](LICENSE).
## See also
* [example integration](https://github.com/adyen-examples/adyen-node-online-payments)
MIT license. For more information, see the LICENSE file.

View File

@@ -1,20 +1 @@
/*
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
* 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 "jest-ts-auto-mock"

2
dist/es5/main.js vendored Normal file

File diff suppressed because one or more lines are too long

2
dist/es5/vendors~main.js vendored Normal file

File diff suppressed because one or more lines are too long

68
dist/lib-esm/package.json vendored Normal file
View File

@@ -0,0 +1,68 @@
{
"name": "@adyen/api-library",
"version": "3.2.3",
"description": "The Adyen API Library for NodeJS enables you to work with Adyen APIs.",
"main": "dist/lib/src/index.js",
"types": "dist/lib/src/index.d.ts",
"module": "dist/lib-esm/src/index.js",
"engines": {
"node": ">=10"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Adyen/adyen-node-api-library.git"
},
"keywords": [
"adyen",
"api",
"nodejs"
],
"bugs": {
"url": "https://github.com/Adyen/adyen-node-api-library/issues"
},
"publishConfig": {
"access": "public"
},
"homepage": "https://github.com/Adyen/adyen-node-api-library#readme",
"scripts": {
"clean": "rm -rf ./dist",
"build": "npm run clean && tsc && tsc -m es6 --outDir dist/lib-esm && webpack",
"lint": "eslint 'src/**/*.ts'",
"lint:fix": "eslint --fix 'src/**/*.ts'",
"test": "jest",
"test:coverage": "jest --coverage",
"preversion": "npm test",
"version": "npm run build && git add -A dist",
"postversion": "git push && git push --tags && rm -rf build/temp",
"release": "release-it --no-npm.publish"
},
"author": "Ricardo Ambrogi",
"license": "MIT",
"devDependencies": {
"@types/jest": "25.2.1",
"@types/nock": "11.1.0",
"@typescript-eslint/eslint-plugin": "2.31.0",
"@typescript-eslint/parser": "2.31.0",
"acorn": "^7.1.1",
"coveralls": "3.1.0",
"dotenv": "^8.2.0",
"eslint": "6.8.0",
"jest": "25.5.4",
"jest-ts-auto-mock": "^1.0.11",
"kind-of": "^6.0.3",
"minimist": ">=1.2.3",
"nock": "12.0.3",
"release-it": "13.5.8",
"ts-auto-mock": "^1.6.0",
"ts-jest": "25.5.0",
"ts-loader": "7.0.2",
"ttypescript": "^1.5.10",
"typescript": "3.8.3",
"webpack": "4.43.0",
"webpack-cli": "3.3.11"
},
"dependencies": {
"@types/node": "13.13.5",
"https-proxy-agent": "5.0.0"
}
}

6
dist/lib-esm/src/__mocks__/base.d.ts vendored Normal file
View File

@@ -0,0 +1,6 @@
import Client from "../client";
import { TerminalApiRequest, TransactionIdentification } from "../typings/terminal";
export declare const createClient: (apiKey?: string | undefined) => Client;
export declare const createBasicAuthClient: () => Client;
export declare const createTerminalAPIPaymentRequest: () => TerminalApiRequest;
export declare const createTerminalAPIRefundRequest: (transactionIdentification: TransactionIdentification) => TerminalApiRequest;

110
dist/lib-esm/src/__mocks__/base.js vendored Normal file
View File

@@ -0,0 +1,110 @@
/*
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen NodeJS API Library
*
* Copyright (c) 2019 Adyen B.V.
* This file is open source and available under the MIT license.
* See the LICENSE file for more info.
*/
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
import Client from "../client";
import Config from "../config";
import { MessageCategoryType, MessageClassType, MessageType, ReversalReasonType, } from "../typings/terminal";
export var createClient = function (apiKey) {
if (apiKey === void 0) { apiKey = process.env.ADYEN_API_KEY; }
var config = new Config();
config.terminalApiCloudEndpoint = Client.TERMINAL_API_ENDPOINT_TEST;
config.terminalApiLocalEndpoint = "https://mocked_local_endpoint.com";
config.hmacKey = "DFB1EB5485895CFA84146406857104ABB4CBCABDC8AAF103A624C8F6A3EAAB00";
config.endpoint = Client.ENDPOINT_TEST;
config.checkoutEndpoint = Client.CHECKOUT_ENDPOINT_TEST;
config.marketPayEndpoint = Client.MARKETPAY_ENDPOINT_TEST;
config.apiKey = apiKey;
config.marketPayEndpoint = Client.MARKETPAY_ENDPOINT_TEST;
var client = new Client({ config: config });
return client;
};
export var createBasicAuthClient = function () {
var client = new Client({
username: process.env.ADYEN_USER,
password: process.env.ADYEN_PASSWORD,
environment: "TEST",
applicationName: "adyen-node-api-library"
});
return client;
};
var id = Math.floor(Math.random() * Math.floor(10000000)).toString();
var getMessageHeader = function (_a) {
var _b = (_a === void 0 ? {} : _a).messageCategory, messageCategory = _b === void 0 ? MessageCategoryType.Payment : _b;
return ({
messageCategory: messageCategory,
messageClass: MessageClassType.Service,
messageType: MessageType.Request,
poiid: process.env.ADYEN_TERMINAL_POIID,
protocolVersion: "3.0",
saleId: id,
serviceId: id,
});
};
var timestamp = function () { return new Date().toISOString(); };
var transactionIdentification = {
timeStamp: timestamp(),
transactionId: id,
};
var saleData = {
saleTransactionId: transactionIdentification,
};
var amountsReq = {
currency: "EUR",
requestedAmount: 1,
};
var paymentTransaction = {
amountsReq: amountsReq,
};
var paymentRequest = {
paymentTransaction: paymentTransaction,
saleData: saleData,
};
var getReversalRequest = function (poiTransaction) { return ({
originalPoiTransaction: {
poiTransactionId: {
transactionId: poiTransaction.transactionId,
timeStamp: poiTransaction.timeStamp
},
},
reversalReason: ReversalReasonType.MerchantCancel
}); };
var getSaleToPOIRequest = function (messageHeader, request) { return (__assign({ messageHeader: messageHeader }, request)); };
export var createTerminalAPIPaymentRequest = function () {
var messageHeader = getMessageHeader();
var saleToPOIRequest = getSaleToPOIRequest(messageHeader, { paymentRequest: paymentRequest });
return { saleToPoiRequest: saleToPOIRequest };
};
export var createTerminalAPIRefundRequest = function (transactionIdentification) {
var messageHeader = getMessageHeader({ messageCategory: MessageCategoryType.Reversal });
var saleToPOIRequest = getSaleToPOIRequest(messageHeader, { reversalRequest: getReversalRequest(transactionIdentification) });
return { saleToPoiRequest: saleToPOIRequest };
};
//# sourceMappingURL=base.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../src/__mocks__/base.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;;;;;;;;;;AAEH,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,MAAM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,CAGlH,CAAC;AAGH,MAAM,CAAC,IAAM,+BAA+B,GAAG;IAC3C,IAAM,aAAa,GAAG,gBAAgB,EAAE,CAAC;IACzC,IAAM,gBAAgB,GAAG,mBAAmB,CAAC,aAAa,EAAE,EAAE,cAAc,gBAAA,EAAE,CAAC,CAAC;IAChF,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,CAAC;AAClD,CAAC,CAAC;AAEF,MAAM,CAAC,IAAM,8BAA8B,GAAG,UAAC,yBAAoD;IAC/F,IAAM,aAAa,GAAG,gBAAgB,CAAC,EAAE,eAAe,EAAE,mBAAmB,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC1F,IAAM,gBAAgB,GAAG,mBAAmB,CAAC,aAAa,EAAE,EAAE,eAAe,EAAE,kBAAkB,CAAC,yBAAyB,CAAC,EAAE,CAAC,CAAC;IAChI,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,CAAC;AAClD,CAAC,CAAC"}

View File

@@ -0,0 +1 @@
export declare const paymentMethodsSuccess: string;

View File

@@ -0,0 +1,987 @@
/* tslint:disable */
export var paymentMethodsSuccess = JSON.stringify({
paymentMethods: [
{
name: "AliPay",
type: "alipay",
},
{
name: "AliPay",
type: "alipay_wap",
},
{
details: [
{
key: "additionalData.card.encrypted.json",
type: "cardToken",
},
],
name: "Credit Card",
type: "scheme",
},
{
name: "Credit Card via AsiaPay",
type: "asiapay",
},
{
name: "BancNet",
type: "bancnet",
},
{
name: "Bank Transfer (BE)",
type: "bankTransfer_BE",
},
{
name: "Bank Transfer (DE)",
type: "bankTransfer_DE",
},
{
name: "Bank Transfer (DK)",
type: "bankTransfer_DK",
},
{
name: "Bank Transfer (GB)",
type: "bankTransfer_GB",
},
{
name: "SEPA Bank Transfer",
type: "bankTransfer_IBAN",
},
{
name: "Bank Transfer (NL)",
type: "bankTransfer_NL",
},
{
name: "Bank Transfer (NO)",
type: "bankTransfer_NO",
},
{
name: "Bank Transfer (PL)",
type: "bankTransfer_PL",
},
{
name: "Bank Transfer (SE)",
type: "bankTransfer_SE",
},
{
name: "Russian Bank Transfer",
type: "bank_ru",
},
{
details: [
{
key: "additionalData.card.encrypted.json",
type: "cardToken",
},
],
name: "Bancontact card",
type: "bcmc",
},
{
name: "Boleto Bancario via HSBC",
type: "boletobancario_hsbc",
},
{
name: "Boleto Bancario via Itau",
type: "boletobancario_itau",
},
{
name: "Boleto Bancario via Santander",
type: "boletobancario_santander",
},
{
name: "c_cash",
type: "c_cash",
},
{
name: "CashU",
type: "cashu",
},
{
name: "Paiement en 3 fois par Cartes Bancaires",
type: "cofinoga_3xcb",
},
{
name: "DineroMail",
type: "dineromail",
},
{
name: "Online bank transfer.",
type: "directEbanking",
},
{
name: "Direct Debit Brazil - Banco do Brazil",
type: "directdebit_BR_bancodobrasil",
},
{
name: "Direct Debit Brazil - Bradesco",
type: "directdebit_BR_bradesco",
},
{
name: "Direct Debit Brazil - Caixa Economica Federal",
type: "directdebit_BR_caixa",
},
{
name: "Direct Debit Brazil - HSBC",
type: "directdebit_BR_hsbc",
},
{
name: "Direct Debit Brazil - Itau",
type: "directdebit_BR_itau",
},
{
name: "Direct Debit Brazil - Santander",
type: "directdebit_BR_santander",
},
{
name: "Eenmalige machtiging",
type: "directdebit_NL",
},
{
details: [
{
items: [
{
id: "11",
name: "Bank transfer / postal",
},
{
id: "74",
name: "Banki Spółdzielcze",
},
{
id: "73",
name: "BLIK",
},
{
id: "32",
name: "BNP Paribas",
},
{
id: "16",
name: "Credit Agricole",
},
{
id: "83",
name: "EnveloBank",
},
{
id: "55",
name: "erata - dotpay installment",
},
{
id: "93",
name: "eSKOK",
},
{
id: "56",
name: "eurobank płatności online",
},
{
id: "76",
name: "Getin Bank PBL",
},
{
id: "81",
name: "Idea Cloud",
},
{
id: "7",
name: "ING Corporate customers",
},
{
id: "35",
name: "Kantor Polski",
},
{
id: "44",
name: "Millennium - Płatności Internetowe",
},
{
id: "10",
name: "Millennium Corporate customers",
},
{
id: "68",
name: "mRaty",
},
{
id: "1",
name: "mTransfer",
},
{
id: "80",
name: "Noble Pay",
},
{
id: "50",
name: "Pay Way Toyota Bank",
},
{
id: "45",
name: "Pay with Alior Bank",
},
{
id: "65",
name: "Paylink Idea Bank",
},
{
id: "36",
name: "Pekao24Przelew",
},
{
id: "70",
name: "Pocztowy24",
},
{
id: "6",
name: "Przelew24",
},
{
id: "46",
name: "Płacę z Citi Handlowy",
},
{
id: "38",
name: "Płacę z ING",
},
{
id: "2",
name: "Płacę z Inteligo",
},
{
id: "4",
name: "Płacę z iPKO",
},
{
id: "72",
name: "Płacę z Orange",
},
{
id: "66",
name: "Płacę z PBS",
},
{
id: "75",
name: "Płacę z Plus Bank",
},
{
id: "51",
name: "Płać z BOŚ",
},
{
id: "48",
name: "R-Przelew",
},
{
id: "88",
name: "Raiffeisen",
},
{
id: "52",
name: "SkyCash",
},
{
id: "58",
name: "Szybkie Platnosci Internetowe z Deutsche Bank PBC",
},
{
id: "60",
name: "T-Mobile usługi bankowe",
},
{
id: "21",
name: "VIA - Moje Rachunki",
},
{
id: "84",
name: "Volkswagen Bank direct",
},
{
id: "31",
name: "Zaplac w Zabce i we Freshmarket",
},
{
id: "24",
name: "mPay",
},
],
key: "issuer",
type: "select",
},
],
name: "Local Polish Payment Methods",
type: "dotpay",
},
{
name: "Finnish E-Banking",
type: "ebanking_FI",
},
{
name: "Lastschrift (ELV)",
type: "elv",
},
{
details: [
{
items: [
{
id: "550",
name: "?eská spo?itelna",
},
{
id: "231",
name: "POP Pankki",
},
{
id: "551",
name: "Kb",
},
{
id: "232",
name: "Aktia",
},
{
id: "552",
name: "Raiffeisen",
},
{
id: "750",
name: "Swedbank",
},
{
id: "211",
name: "Nordea",
},
{
id: "233",
name: "Säästöpankki",
},
{
id: "553",
name: "Csob",
},
{
id: "751",
name: "SEB",
},
{
id: "234",
name: "S-Pankki",
},
{
id: "554",
name: "Moneta",
},
{
id: "752",
name: "Nordea",
},
{
id: "235",
name: "OmaSP",
},
{
id: "213",
name: "Op-Pohjola",
},
{
id: "555",
name: "UniCredit",
},
{
id: "753",
name: "LHV",
},
{
id: "556",
name: "Fio",
},
{
id: "557",
name: "mBank",
},
{
id: "216",
name: "Handelsbanken",
},
{
id: "260",
name: "Länsförsäkringar",
},
{
id: "240",
name: "BankDeposit",
},
{
id: "265",
name: "Sparbanken",
},
{
id: "640",
name: "BankDeposit",
},
{
id: "200",
name: "Ålandsbanken",
},
{
id: "720",
name: "Swedbank",
},
{
id: "940",
name: "Swedbank",
},
{
id: "204",
name: "Danske Bank",
},
{
id: "721",
name: "SEB",
},
{
id: "941",
name: "SEB",
},
{
id: "722",
name: "DNB",
},
{
id: "942",
name: "Citadele",
},
{
id: "205",
name: "Handelsbanken",
},
{
id: "723",
name: "Šiaulių Bankas",
},
{
id: "943",
name: "DNB",
},
{
id: "206",
name: "Nordea",
},
{
id: "724",
name: "Nordea",
},
{
id: "207",
name: "SEB",
},
{
id: "208",
name: "Skandiabanken",
},
{
id: "209",
name: "Swedbank",
},
],
key: "issuer",
type: "select",
},
],
name: "Bank Payment",
type: "entercash",
},
{
name: "Nationale Entertainment Card",
type: "entertainmentcard",
},
{
name: "Gall & Gall",
type: "gallgall",
},
{
name: "Generic GiftCard",
type: "genericgiftcard",
},
{
details: [
{
key: "bic",
type: "text",
},
],
name: "GiroPay",
type: "giropay",
},
{
name: "Globe GCash",
type: "globegcash",
},
{
name: "Hunkemoller Lingerie Card",
type: "hmlingerie",
},
{
details: [
{
items: [
{
id: "1121",
name: "Test Issuer",
},
{
id: "1154",
name: "Test Issuer 5",
},
{
id: "1153",
name: "Test Issuer 4",
},
{
id: "1152",
name: "Test Issuer 3",
},
{
id: "1151",
name: "Test Issuer 2",
},
{
id: "1162",
name: "Test Issuer Cancelled",
},
{
id: "1161",
name: "Test Issuer Pending",
},
{
id: "1160",
name: "Test Issuer Refused",
},
{
id: "1159",
name: "Test Issuer 10",
},
{
id: "1158",
name: "Test Issuer 9",
},
{
id: "1157",
name: "Test Issuer 8",
},
{
id: "1156",
name: "Test Issuer 7",
},
{
id: "1155",
name: "Test Issuer 6",
},
],
key: "idealIssuer",
type: "select",
},
],
name: "iDEAL",
type: "ideal",
},
{
name: "Phone Payment",
type: "ivr",
},
{
name: "Landline phone",
type: "ivrLandline",
},
{
name: "Mobile phone",
type: "ivrMobile",
},
{
details: [
{
details: [
{
key: "firstName",
type: "text",
},
{
key: "infix",
optional: "true",
type: "text",
},
{
key: "lastName",
type: "text",
},
{
items: [
{
id: "M",
name: "MALE",
},
{
id: "F",
name: "FEMALE",
},
],
key: "gender",
type: "radio",
},
{
key: "dateOfBirth",
type: "date",
},
{
key: "telephoneNumber",
type: "tel",
},
{
key: "socialSecurityNumber",
optional: "true",
type: "text",
},
{
key: "shopperEmail",
type: "emailAddress",
},
],
key: "personalDetails",
type: "fieldSet",
},
{
details: [
{
key: "street",
type: "text",
},
{
key: "houseNumberOrName",
type: "text",
},
{
key: "city",
type: "text",
},
{
key: "postalCode",
type: "text",
},
{
key: "stateOrProvince",
optional: "true",
type: "text",
},
{
items: [
{
id: "SE",
name: "SWEDEN",
},
{
id: "NO",
name: "NORWAY",
},
{
id: "FI",
name: "FINLAND",
},
{
id: "DK",
name: "DENMARK",
},
{
id: "AT",
name: "AUSTRIA",
},
{
id: "DE",
name: "GERMANY",
},
{
id: "NL",
name: "NETHERLANDS",
},
],
key: "country",
type: "select",
},
],
key: "billingAddress",
type: "address",
},
{
key: "separateDeliveryAddress",
optional: "true",
type: "boolean",
value: "false",
},
{
details: [
{
key: "street",
type: "text",
},
{
key: "houseNumberOrName",
type: "text",
},
{
key: "city",
type: "text",
},
{
key: "postalCode",
type: "text",
},
{
key: "stateOrProvince",
optional: "true",
type: "text",
},
{
items: [
{
id: "SE",
name: "SWEDEN",
},
{
id: "NO",
name: "NORWAY",
},
{
id: "FI",
name: "FINLAND",
},
{
id: "DK",
name: "DENMARK",
},
{
id: "AT",
name: "AUSTRIA",
},
{
id: "DE",
name: "GERMANY",
},
{
id: "NL",
name: "NETHERLANDS",
},
],
key: "country",
type: "select",
},
],
key: "deliveryAddress",
optional: "true",
type: "address",
},
],
name: "Pay later with Klarna.",
type: "klarna",
},
{
name: "Multibanco",
type: "multibanco",
},
{
name: "Russian Online Payments",
type: "online_RU",
},
{
name: "Invoice",
type: "openinvoice",
},
{
name: "PayPal",
type: "paypal",
},
{
name: "Paysafecard",
type: "paysafecard",
},
{
name: "POLi",
type: "poli",
},
{
details: [
{
items: [
{
id: "+7",
name: "RU",
},
{
id: "+9955",
name: "GE",
},
{
id: "+507",
name: "PA",
},
{
id: "+44",
name: "GB",
},
{
id: "+992",
name: "TJ",
},
{
id: "+370",
name: "LT",
},
{
id: "+972",
name: "IL",
},
{
id: "+996",
name: "KG",
},
{
id: "+380",
name: "UA",
},
{
id: "+84",
name: "VN",
},
{
id: "+90",
name: "TR",
},
{
id: "+994",
name: "AZ",
},
{
id: "+374",
name: "AM",
},
{
id: "+371",
name: "LV",
},
{
id: "+91",
name: "IN",
},
{
id: "+66",
name: "TH",
},
{
id: "+373",
name: "MD",
},
{
id: "+1",
name: "US",
},
{
id: "+81",
name: "JP",
},
{
id: "+998",
name: "UZ",
},
{
id: "+77",
name: "KZ",
},
{
id: "+375",
name: "BY",
},
{
id: "+372",
name: "EE",
},
{
id: "+40",
name: "RO",
},
{
id: "+82",
name: "KR",
},
],
key: "qiwiwallet.telephoneNumberPrefix",
type: "select",
},
{
key: "qiwiwallet.telephoneNumber",
type: "text",
},
],
name: "Qiwi Wallet",
type: "qiwiwallet",
},
{
name: "RatePay Invoice",
type: "ratepay",
},
{
name: "SafetyPay",
type: "safetypay",
},
{
details: [
{
key: "sepa.ownerName",
type: "text",
},
{
key: "sepa.ibanNumber",
type: "text",
},
],
name: "SEPA Direct Debit",
type: "sepadirectdebit",
},
{
name: "Premium SMS",
type: "sms",
},
{
name: "TenPay",
type: "tenpay",
},
{
name: "Russian Cash Terminal Payments",
type: "terminal_RU",
},
{
name: "Trustly Direct bank e-Payments",
type: "trustly",
},
{
name: "Online Banking by Trustpay",
type: "trustpay",
},
{
name: "UnionPay",
type: "unionpay",
},
{
name: "Russian Wallet Payments",
type: "wallet_RU",
},
{
name: "Webshop Giftcard",
type: "webshopgiftcard",
},
{
name: "Your Gift",
type: "yourgift",
},
],
});
//# sourceMappingURL=paymentMethodsSuccess.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,6 @@
export declare const paymentSessionError: {
statusCode: number;
errorCode: string;
message: string;
errorType: string;
};

View File

@@ -0,0 +1,8 @@
/* tslint:disable */
export var paymentSessionError = {
statusCode: 422,
errorCode: "14_012",
message: "The provided SDK token could not be parsed.",
errorType: "validation",
};
//# sourceMappingURL=paymentSessionErrorInvalidData422.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"paymentSessionErrorInvalidData422.js","sourceRoot":"","sources":["../../../../../src/__mocks__/checkout/paymentSessionErrorInvalidData422.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,MAAM,CAAC,IAAM,mBAAmB,GAAG;IAC/B,UAAU,EAAE,GAAG;IACf,SAAS,EAAE,QAAQ;IACnB,OAAO,EAAE,6CAA6C;IACtD,SAAS,EAAE,YAAY;CAC1B,CAAC"}

View File

@@ -0,0 +1,3 @@
export declare const paymentSessionSuccess: {
paymentSession: string;
};

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
{"version":3,"file":"paymentSessionSucess.js","sourceRoot":"","sources":["../../../../../src/__mocks__/checkout/paymentSessionSucess.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,MAAM,CAAC,IAAM,qBAAqB,GAAG;IACjC,cAAc,EAAE,k+YAAk+Y;CACr/Y,CAAC"}

View File

@@ -0,0 +1,6 @@
export declare const paymentMethodsError: {
errorCode: string;
errorType: string;
statusMessage: string;
statusCode: number;
};

View File

@@ -0,0 +1,7 @@
export var paymentMethodsError = {
errorCode: "901",
errorType: "security",
statusMessage: "Invalid Merchant Account",
statusCode: 403,
};
//# sourceMappingURL=paymentmethodsErrorForbidden403.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"paymentmethodsErrorForbidden403.js","sourceRoot":"","sources":["../../../../../src/__mocks__/checkout/paymentmethodsErrorForbidden403.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,IAAM,mBAAmB,GAAG;IAC/B,SAAS,EAAE,KAAK;IAChB,SAAS,EAAE,UAAU;IACrB,aAAa,EAAE,0BAA0B;IACzC,UAAU,EAAE,GAAG;CAClB,CAAC"}

View File

@@ -0,0 +1,6 @@
export declare const paymentDetailsError: {
statusCode: number;
errorCode: string;
message: string;
errorType: string;
};

View File

@@ -0,0 +1,8 @@
/* tslint:disable */
export var paymentDetailsError = {
statusCode: 422,
errorCode: "101",
message: "Invalid card number",
errorType: "validation",
};
//# sourceMappingURL=paymentsDetailsErrorInvalidData422.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"paymentsDetailsErrorInvalidData422.js","sourceRoot":"","sources":["../../../../../src/__mocks__/checkout/paymentsDetailsErrorInvalidData422.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,MAAM,CAAC,IAAM,mBAAmB,GAAG;IAC/B,UAAU,EAAE,GAAG;IACf,SAAS,EAAE,KAAK;IAChB,OAAO,EAAE,qBAAqB;IAC9B,SAAS,EAAE,YAAY;CAC1B,CAAC"}

View File

@@ -0,0 +1 @@
export declare const paymentDetailsSuccess: string;

View File

@@ -0,0 +1,10 @@
/* tslint:disable */
export var paymentDetailsSuccess = JSON.stringify({
pspReference: "8515232733321252",
resultCode: "Authorised",
additionalData: {
liabilityShift: "true",
refusalReasonRaw: "AUTHORISED",
},
});
//# sourceMappingURL=paymentsDetailsSuccess.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"paymentsDetailsSuccess.js","sourceRoot":"","sources":["../../../../../src/__mocks__/checkout/paymentsDetailsSuccess.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,MAAM,CAAC,IAAM,qBAAqB,GAAG,IAAI,CAAC,SAAS,CAAC;IAChD,YAAY,EAAE,kBAAkB;IAChC,UAAU,EAAE,YAAY;IACxB,cAAc,EAAE;QACZ,cAAc,EAAE,MAAM;QACtB,gBAAgB,EAAE,YAAY;KACjC;CACJ,CAAC,CAAC"}

View File

@@ -0,0 +1 @@
export declare const paymentsError: string;

View File

@@ -0,0 +1,8 @@
/* tslint:disable */
export var paymentsError = JSON.stringify({
statusCode: 422,
errorCode: "130",
statusMessage: "Reference Missing",
errorType: "validation",
});
//# sourceMappingURL=paymentsErrorInvalidData422.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"paymentsErrorInvalidData422.js","sourceRoot":"","sources":["../../../../../src/__mocks__/checkout/paymentsErrorInvalidData422.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,MAAM,CAAC,IAAM,aAAa,GAAG,IAAI,CAAC,SAAS,CAAC;IACxC,UAAU,EAAE,GAAG;IACf,SAAS,EAAE,KAAK;IAChB,aAAa,EAAE,mBAAmB;IAClC,SAAS,EAAE,YAAY;CAC1B,CAAC,CAAC"}

View File

@@ -0,0 +1 @@
export declare const paymentsResultError: string;

View File

@@ -0,0 +1,8 @@
/* tslint:disable */
export var paymentsResultError = JSON.stringify({
statusCode: 422,
errorCode: "14_018",
message: "Invalid payload provided",
errorType: "validation",
});
//# sourceMappingURL=paymentsResultErrorInvalidDataPayload422.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"paymentsResultErrorInvalidDataPayload422.js","sourceRoot":"","sources":["../../../../../src/__mocks__/checkout/paymentsResultErrorInvalidDataPayload422.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,MAAM,CAAC,IAAM,mBAAmB,GAAG,IAAI,CAAC,SAAS,CAAC;IAC9C,UAAU,EAAE,GAAG;IACf,SAAS,EAAE,QAAQ;IACnB,OAAO,EAAE,0BAA0B;IACnC,SAAS,EAAE,YAAY;CAC1B,CAAC,CAAC"}

View File

@@ -0,0 +1,14 @@
export declare const paymentsResultMultibancoSuccess: {
additionalData: {
cvcResult: string;
avsResult: string;
"comprafacil.deadline": string;
"comprafacil.reference": string;
paymentMethod: string;
paymentMethodVariant: string;
"comprafacil.entity": string;
"comprafacil.amount": string;
};
pspReference: string;
resultCode: string;
};

View File

@@ -0,0 +1,16 @@
/* tslint:disable */
export var paymentsResultMultibancoSuccess = {
additionalData: {
"cvcResult": "0",
"avsResult": "0",
"comprafacil.deadline": "3",
"comprafacil.reference": "123 123 123",
"paymentMethod": "multibanco",
"paymentMethodVariant": "multibanco",
"comprafacil.entity": "12345",
"comprafacil.amount": "101.01",
},
pspReference: "8111111111111111",
resultCode: "Received",
};
//# sourceMappingURL=paymentsResultMultibancoSuccess.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"paymentsResultMultibancoSuccess.js","sourceRoot":"","sources":["../../../../../src/__mocks__/checkout/paymentsResultMultibancoSuccess.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,MAAM,CAAC,IAAM,+BAA+B,GAAG;IAC3C,cAAc,EAAE;QACZ,WAAW,EAAE,GAAG;QAChB,WAAW,EAAE,GAAG;QAChB,sBAAsB,EAAE,GAAG;QAC3B,uBAAuB,EAAE,aAAa;QACtC,eAAe,EAAE,YAAY;QAC7B,sBAAsB,EAAE,YAAY;QACpC,oBAAoB,EAAE,OAAO;QAC7B,oBAAoB,EAAE,QAAQ;KACjC;IACD,YAAY,EAAE,kBAAkB;IAChC,UAAU,EAAE,UAAU;CACzB,CAAC"}

View File

@@ -0,0 +1 @@
export declare const paymentsResultSuccess: string;

View File

@@ -0,0 +1,6 @@
/* tslint:disable */
export var paymentsResultSuccess = JSON.stringify({
pspReference: "8535253563623704",
resultCode: "Authorised",
});
//# sourceMappingURL=paymentsResultSucess.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"paymentsResultSucess.js","sourceRoot":"","sources":["../../../../../src/__mocks__/checkout/paymentsResultSucess.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,MAAM,CAAC,IAAM,qBAAqB,GAAG,IAAI,CAAC,SAAS,CAAC;IAChD,YAAY,EAAE,kBAAkB;IAChC,UAAU,EAAE,YAAY;CAC3B,CAAC,CAAC"}

View File

@@ -0,0 +1 @@
export declare const paymentsSuccess: string;

View File

@@ -0,0 +1,100 @@
/* tslint:disable */
export var paymentsSuccess = JSON.stringify({
additionalData: {
expiryDate: "8/2018",
fraudResultType: "GREEN",
cardBin: "411111",
cardSummary: "1111",
fraudManualReview: "false",
aliasType: "Default",
alias: "H167852639363479",
cardPaymentMethod: "visa",
cardIssuingCountry: "NL",
"recurring.recurringDetailReference": "8415883203388055",
},
fraudResult: {
accountScore: 0,
results: [
{
FraudCheckResult: {
accountScore: 0,
checkId: 2,
name: "CardChunkUsage",
},
},
{
FraudCheckResult: {
accountScore: 0,
checkId: 3,
name: "PaymentDetailUsage",
},
},
{
FraudCheckResult: {
accountScore: 0,
checkId: 4,
name: "HolderNameUsage",
},
},
{
FraudCheckResult: {
accountScore: 0,
checkId: 1,
name: "PaymentDetailRefCheck",
},
},
{
FraudCheckResult: {
accountScore: 0,
checkId: 13,
name: "IssuerRefCheck",
},
},
{
FraudCheckResult: {
accountScore: 0,
checkId: 15,
name: "IssuingCountryReferral",
},
},
{
FraudCheckResult: {
accountScore: 0,
checkId: 27,
name: "PmOwnerRefCheck",
},
},
{
FraudCheckResult: {
accountScore: 0,
checkId: 10,
name: "HolderNameContainsNumber",
},
},
{
FraudCheckResult: {
accountScore: 0,
checkId: 11,
name: "HolderNameIsOneWord",
},
},
{
FraudCheckResult: {
accountScore: 0,
checkId: 82,
name: "CustomFieldCheck",
},
},
{
FraudCheckResult: {
accountScore: 0,
checkId: 25,
name: "CVCAuthResultCheck",
},
},
],
},
pspReference: "8535296650153317",
resultCode: "Authorised",
});
//# sourceMappingURL=paymentsSuccess.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"paymentsSuccess.js","sourceRoot":"","sources":["../../../../../src/__mocks__/checkout/paymentsSuccess.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB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AE,CAAC;oBACf,OAAO,EAAE,EAAE;oBACX,IAAI,EAAE,0BAA0B;iBACnC;aACJ;YACD;gBACI,gBAAgB,EAAE;oBACd,YAAY,EAAE,CAAC;oBACf,OAAO,EAAE,EAAE;oBACX,IAAI,EAAE,qBAAqB;iBAC9B;aACJ;YACD;gBACI,gBAAgB,EAAE;oBACd,YAAY,EAAE,CAAC;oBACf,OAAO,EAAE,EAAE;oBACX,IAAI,EAAE,kBAAkB;iBAC3B;aACJ;YACD;gBACI,gBAAgB,EAAE;oBACd,YAAY,EAAE,CAAC;oBACf,OAAO,EAAE,EAAE;oBACX,IAAI,EAAE,oBAAoB;iBAC7B;aACJ;SACJ;KACJ;IACD,YAAY,EAAE,kBAAkB;IAChC,UAAU,EAAE,YAAY;CAC3B,CAAC,CAAC"}

View File

@@ -0,0 +1 @@
export declare const originKeysSuccess: string;

View File

@@ -0,0 +1,8 @@
export var originKeysSuccess = JSON.stringify({
originKeys: {
"https://www.your-domain1.com": "pub.v2.7814286629520534.aHR0cHM6Ly93d3cueW91ci1kb21haW4xLmNvbQ.UEwIBmW9-c_uXo5wSEr2w8Hz8hVIpujXPHjpcEse3xI",
"https://www.your-domain2.com": "pub.v2.7814286629520534.aHR0cHM6Ly93d3cueW91ci1kb21haW4yLmNvbQ.EP6eXBJKk0t7-QIUl6e_b1qMuMHGepxG_SlUqxAYrfY",
"https://www.your-domain3.com": "pub.v2.7814286629520534.aHR0cHM6Ly93d3cueW91ci1kb21haW4zLmNvbQ.fUvflu-YIdZSsLEH8Qqmr7ksE4ag_NYiiMXK0s6aq_4",
},
});
//# sourceMappingURL=originkeysSuccess.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"originkeysSuccess.js","sourceRoot":"","sources":["../../../../../src/__mocks__/checkoutUtility/originkeysSuccess.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,IAAM,iBAAiB,GAAG,IAAI,CAAC,SAAS,CAAC;IAC5C,UAAU,EAAE;QACR,8BAA8B,EAAE,4GAA4G;QAC5I,8BAA8B,EAAE,4GAA4G;QAC5I,8BAA8B,EAAE,4GAA4G;KAC/I;CACJ,CAAC,CAAC"}

View File

@@ -0,0 +1,36 @@
{
"live": "false",
"notificationItems": [
{
"NotificationRequestItem": {
"additionalData": {
"expiryDate": "12\/2012",
" NAME1 ": "VALUE1",
"authCode": "1234",
"cardSummary": "7777",
"totalFraudScore": "10",
"hmacSignature": "OzDjCMZIsdtDqrZ+cl\/FWC+WdESrorctXTzAzW33dXI=",
"NAME2": " VALUE2 ",
"fraudCheck-6-ShopperIpUsage": "10"
},
"amount": {
"currency": "EUR",
"value": 10100
},
"eventCode": "AUTHORISATION",
"eventDate": "2017-01-19T16:42:03+01:00",
"merchantAccountCode": "MagentoMerchantTest2",
"merchantReference": "8313842560770001",
"operations": [
"CANCEL",
"CAPTURE",
"REFUND"
],
"paymentMethod": "visa",
"pspReference": "123456789",
"reason": "1234:7777:12\/2012",
"success": "true"
}
}
]
}

View File

@@ -0,0 +1,25 @@
{
"live": "false",
"notificationItems": [
{
"NotificationRequestItem": {
"additionalData": {
"hmacSignature": "KujHNqpyCAMdGefj7lfQ8AeD0Jke9Zs2bVAqScQDWi4="
},
"amount": {
"currency": "USD",
"value": 23623
},
"eventCode": "CAPTURE",
"eventDate": "2017-01-25T18:08:19+01:00",
"merchantAccountCode": "MagentoMerchantTest2",
"merchantReference": "00000001",
"originalReference": "ORIGINAL_PSP",
"paymentMethod": "visa",
"pspReference": "PSP_REFERENCE",
"reason": "Insufficient balance on payment",
"success": "false"
}
}
]
}

View File

@@ -0,0 +1,25 @@
{
"live": "false",
"notificationItems": [
{
"NotificationRequestItem": {
"additionalData": {
"hmacSignature": "qvS6I3Gdi1jx+jSh7IopAgcHtMoxvXlNL7DYQ+j1hd0="
},
"amount": {
"currency": "USD",
"value": 23623
},
"eventCode": "CAPTURE",
"eventDate": "2017-01-25T18:08:19+01:00",
"merchantAccountCode": "MagentoMerchantTest2",
"merchantReference": "00000001",
"originalReference": "ORIGINAL_PSP",
"paymentMethod": "visa",
"pspReference": "PSP_REFERENCE",
"reason": "",
"success": "true"
}
}
]
}

View File

@@ -0,0 +1,25 @@
{
"live": "false",
"notificationItems": [
{
"NotificationRequestItem": {
"additionalData": {
"hmacSignature": "HZXziBYopfDIzDhk49iC\/\/yCfxmy\/z0xWuvvTxFNUSA="
},
"amount": {
"currency": "EUR",
"value": 1500
},
"eventCode": "REFUND",
"eventDate": "2017-02-17T11:04:07+01:00",
"merchantAccountCode": "MagentoMerchantTest2",
"merchantReference": "payment-2017-1-17-11-refund",
"originalReference": "ORIGINAL_PSP",
"paymentMethod": "visa",
"pspReference": "PSP_REFERENCE",
"reason": "Insufficient balance on payment",
"success": "false"
}
}
]
}

View File

@@ -0,0 +1,25 @@
{
"live": "false",
"notificationItems": [
{
"NotificationRequestItem": {
"additionalData": {
"hmacSignature": "KJFhURWP8Pv9m8k+7NGHNJAupBj6X6J\/VWAikFxeWhA="
},
"amount": {
"currency": "EUR",
"value": 1500
},
"eventCode": "REFUND",
"eventDate": "2017-02-17T11:11:44+01:00",
"merchantAccountCode": "MagentoMerchantTest2",
"merchantReference": "payment-2017-1-17-11-refund",
"originalReference": "ORIGINAL_PSP",
"paymentMethod": "visa",
"pspReference": "PSP_REFERENCE",
"reason": "",
"success": "true"
}
}
]
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
{"version":3,"file":"documentContent.js","sourceRoot":"","sources":["../../../../../src/__mocks__/platforms/documentContent.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,IAAM,eAAe,GAAG,636LAA636L,CAAA"}

View File

@@ -0,0 +1,3 @@
export declare const disableSuccess: {
response: string;
};

View File

@@ -0,0 +1,4 @@
export var disableSuccess = {
response: "[detail-successfully-disabled]",
};
//# sourceMappingURL=disableSuccess.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"disableSuccess.js","sourceRoot":"","sources":["../../../../../src/__mocks__/recurring/disableSuccess.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,IAAM,cAAc,GAAG;IAC1B,QAAQ,EAAE,gCAAgC;CAC7C,CAAC"}

View File

@@ -0,0 +1,51 @@
export declare const listRecurringDetailsSuccess: {
creationDate: string;
details: ({
additionalData: {
cardBin: string;
};
alias: string;
aliasType: string;
card: {
expiryMonth: string;
expiryYear: string;
holderName: string;
number: string;
};
contractTypes: string[];
creationDate: string;
firstPspReference: string;
paymentMethodVariant: string;
recurringDetailReference: string;
variant: string;
billingAddress?: undefined;
tokenDetails?: undefined;
} | {
billingAddress: {
city: string;
country: string;
houseNumberOrName: string;
postalCode: string;
stateOrProvince: string;
street: string;
};
contractTypes: string[];
creationDate: string;
firstPspReference: string;
paymentMethodVariant: string;
recurringDetailReference: string;
tokenDetails: {
tokenData: {
BillingAgreementId: string;
EmailId: string;
"PayPal.PayerId": string;
};
tokenDataType: string;
};
variant: string;
additionalData?: undefined;
alias?: undefined;
aliasType?: undefined;
card?: undefined;
})[];
};

View File

@@ -0,0 +1,53 @@
export var listRecurringDetailsSuccess = {
creationDate: "2017-03-01T10:53:11.000",
details: [
{
additionalData: {
cardBin: "411111",
},
alias: "cardAlias",
aliasType: "Default",
card: {
expiryMonth: "8",
expiryYear: "2018",
holderName: "Holder",
number: "1111",
},
contractTypes: [
"ONECLICK",
],
creationDate: "2017-03-01T10:53:11.000",
firstPspReference: "8524888762135795",
paymentMethodVariant: "visa",
recurringDetailReference: "recurringReference",
variant: "visa",
},
{
billingAddress: {
city: "City",
country: "NL",
houseNumberOrName: "1",
postalCode: "2312aa",
stateOrProvince: "NA",
street: "Street",
},
contractTypes: [
"RECURRING",
],
creationDate: "2017-03-01T10:53:11.000",
firstPspReference: "8515076181707110",
paymentMethodVariant: "paypal",
recurringDetailReference: "8315076181982020",
tokenDetails: {
tokenData: {
"BillingAgreementId": "B-7MA42752FE774625C",
"EmailId": "tedtest@test.nl",
"PayPal.PayerId": "H95EPL8B2KFE6",
},
tokenDataType: "PayPal",
},
variant: "paypal",
},
],
};
//# sourceMappingURL=listRecurringDetailsSuccess.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"listRecurringDetailsSuccess.js","sourceRoot":"","sources":["../../../../../src/__mocks__/recurring/listRecurringDetailsSuccess.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,IAAM,2BAA2B,GAAG;IACvC,YAAY,EAAE,yBAAyB;IACvC,OAAO,EAAE;QACL;YACI,cAAc,EAAE;gBACZ,OAAO,EAAE,QAAQ;aACpB;YACD,KAAK,EAAE,WAAW;YAClB,SAAS,EAAE,SAAS;YACpB,IAAI,EAAE;gBACF,WAAW,EAAE,GAAG;gBAChB,UAAU,EAAE,MAAM;gBAClB,UAAU,EAAE,QAAQ;gBACpB,MAAM,EAAE,MAAM;aACjB;YACD,aAAa,EAAE;gBACX,UAAU;aACb;YACD,YAAY,EAAE,yBAAyB;YACvC,iBAAiB,EAAE,kBAAkB;YACrC,oBAAoB,EAAE,MAAM;YAC5B,wBAAwB,EAAE,oBAAoB;YAC9C,OAAO,EAAE,MAAM;SAClB;QACD;YACI,cAAc,EAAE;gBACZ,IAAI,EAAE,MAAM;gBACZ,OAAO,EAAE,IAAI;gBACb,iBAAiB,EAAE,GAAG;gBACtB,UAAU,EAAE,QAAQ;gBACpB,eAAe,EAAE,IAAI;gBACrB,MAAM,EAAE,QAAQ;aACnB;YACD,aAAa,EAAE;gBACX,WAAW;aACd;YACD,YAAY,EAAE,yBAAyB;YACvC,iBAAiB,EAAE,kBAAkB;YACrC,oBAAoB,EAAE,QAAQ;YAC9B,wBAAwB,EAAE,kBAAkB;YAC5C,YAAY,EAAE;gBACV,SAAS,EAAE;oBACP,oBAAoB,EAAE,qBAAqB;oBAC3C,SAAS,EAAE,iBAAiB;oBAC5B,gBAAgB,EAAE,eAAe;iBACpC;gBACD,aAAa,EAAE,QAAQ;aAC1B;YACD,OAAO,EAAE,QAAQ;SACpB;KACJ;CACJ,CAAC"}

View File

@@ -0,0 +1 @@
export declare const asyncRes = "ok";

View File

@@ -0,0 +1,2 @@
export var asyncRes = "ok";
//# sourceMappingURL=async.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"async.js","sourceRoot":"","sources":["../../../../../src/__mocks__/terminalApi/async.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,IAAM,QAAQ,GAAG,IAAI,CAAC"}

View File

@@ -0,0 +1,3 @@
export declare const localSecuredRes: string;
export declare const localEncRes: string;
export declare const wrongEncRes: string;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
export declare const syncRes: string;
export declare const syncRefund: string;

View File

@@ -0,0 +1,338 @@
export var syncRes = JSON.stringify({
SaleToPOIResponse: {
MessageHeader: {
MessageCategory: "Payment",
MessageClass: "Service",
MessageType: "Response",
POIID: process.env.ADYEN_TERMINAL_POIID,
ProtocolVersion: "3.0",
SaleID: "001",
ServiceID: "001",
},
PaymentResponse: {
POIData: {
POIReconciliationID: "1000",
POITransactionID: {
TimeStamp: "2019-04-29T00:00:00.000Z",
TransactionID: "4r7i001556529591000.8515565295894301",
},
},
PaymentReceipt: [
{
DocumentQualifier: "CashierReceipt",
OutputContent: {
OutputFormat: "Text",
OutputText: [
{
CharacterStyle: "Bold",
EndOfLineFlag: true,
Text: "key=header1",
},
{
CharacterStyle: "Bold",
EndOfLineFlag: true,
Text: "key=header2",
},
{
CharacterStyle: "Bold",
EndOfLineFlag: true,
Text: "name=MERCHANT%20COPY&key=merchantTitle",
},
{
EndOfLineFlag: true,
Text: "key=filler",
},
{
EndOfLineFlag: true,
Text: "name=Date&value=29%2f04%2f19&key=txdate",
},
{
EndOfLineFlag: true,
Text: "name=Time&value=10%3a19%3a51&key=txtime",
},
{
EndOfLineFlag: true,
Text: "key=filler",
},
{
EndOfLineFlag: true,
Text: "name=Card&value=%2a%2a%2a%2a%2a%2a%2a%2a%2a%2a%2a%2a3511&key=pan",
},
{
EndOfLineFlag: true,
Text: "name=Pref.%20name&value=MCC%20351%20v1%202&key=preferredName",
},
{
EndOfLineFlag: true,
Text: "name=Card%20type&value=mc&key=cardType",
},
{
EndOfLineFlag: true,
Text: "name=Payment%20method&value=mc&key=paymentMethod",
},
{
EndOfLineFlag: true,
Text: "name=Payment%20variant&value=mc&key=paymentMethodVariant",
},
{
EndOfLineFlag: true,
Text: "name=Entry%20mode&value=Contactless%20swipe&key=posEntryMode",
},
{
EndOfLineFlag: true,
Text: "key=filler",
},
{
EndOfLineFlag: true,
Text: "name=AID&value=A0000000041010&key=aid",
},
{
EndOfLineFlag: true,
Text: "name=MID&value=1000&key=mid",
},
{
EndOfLineFlag: true,
Text: "name=TID&value=P400Plus-275039202&key=tid",
},
{
EndOfLineFlag: true,
Text: "name=PTID&value=75039202&key=ptid",
},
{
EndOfLineFlag: true,
Text: "key=filler",
},
{
EndOfLineFlag: true,
Text: "name=Auth.%20code&value=123456&key=authCode",
},
{
EndOfLineFlag: true,
Text: "name=Tender&value=4r7i001556529591000&key=txRef",
},
{
EndOfLineFlag: true,
Text: "name=Reference&value=003&key=mref",
},
{
EndOfLineFlag: true,
Text: "key=filler",
},
{
EndOfLineFlag: true,
Text: "name=Type&value=GOODS_SERVICES&key=txtype",
},
{
CharacterStyle: "Bold",
EndOfLineFlag: true,
Text: "name=TOTAL&value=%e2%82%ac%c2%a01.00&key=totalAmount",
},
{
EndOfLineFlag: true,
Text: "key=filler",
},
{
CharacterStyle: "Bold",
EndOfLineFlag: true,
Text: "name=APPROVED&key=approved",
},
],
},
RequiredSignatureFlag: false,
},
{
DocumentQualifier: "CustomerReceipt",
OutputContent: {
OutputFormat: "Text",
OutputText: [
{
CharacterStyle: "Bold",
EndOfLineFlag: true,
Text: "key=header1",
},
{
CharacterStyle: "Bold",
EndOfLineFlag: true,
Text: "key=header2",
},
{
CharacterStyle: "Bold",
EndOfLineFlag: true,
Text: "name=CARDHOLDER%20COPY&key=cardholderHeader",
},
{
EndOfLineFlag: true,
Text: "key=filler",
},
{
EndOfLineFlag: true,
Text: "name=Date&value=29%2f04%2f19&key=txdate",
},
{
EndOfLineFlag: true,
Text: "name=Time&value=10%3a19%3a51&key=txtime",
},
{
EndOfLineFlag: true,
Text: "key=filler",
},
{
EndOfLineFlag: true,
Text: "name=Card&value=%2a%2a%2a%2a%2a%2a%2a%2a%2a%2a%2a%2a3511&key=pan",
},
{
EndOfLineFlag: true,
Text: "name=Pref.%20name&value=MCC%20351%20v1%202&key=preferredName",
},
{
EndOfLineFlag: true,
Text: "name=Card%20type&value=mc&key=cardType",
},
{
EndOfLineFlag: true,
Text: "name=Payment%20method&value=mc&key=paymentMethod",
},
{
EndOfLineFlag: true,
Text: "name=Payment%20variant&value=mc&key=paymentMethodVariant",
},
{
EndOfLineFlag: true,
Text: "name=Entry%20mode&value=Contactless%20swipe&key=posEntryMode",
},
{
EndOfLineFlag: true,
Text: "key=filler",
},
{
EndOfLineFlag: true,
Text: "name=AID&value=A0000000041010&key=aid",
},
{
EndOfLineFlag: true,
Text: "name=MID&value=1000&key=mid",
},
{
EndOfLineFlag: true,
Text: "name=TID&value=P400Plus-275039202&key=tid",
},
{
EndOfLineFlag: true,
Text: "name=PTID&value=75039202&key=ptid",
},
{
EndOfLineFlag: true,
Text: "key=filler",
},
{
EndOfLineFlag: true,
Text: "name=Auth.%20code&value=123456&key=authCode",
},
{
EndOfLineFlag: true,
Text: "name=Tender&value=4r7i001556529591000&key=txRef",
},
{
EndOfLineFlag: true,
Text: "name=Reference&value=003&key=mref",
},
{
EndOfLineFlag: true,
Text: "key=filler",
},
{
EndOfLineFlag: true,
Text: "name=Type&value=GOODS_SERVICES&key=txtype",
},
{
CharacterStyle: "Bold",
EndOfLineFlag: true,
Text: "name=TOTAL&value=%e2%82%ac%c2%a01.00&key=totalAmount",
},
{
EndOfLineFlag: true,
Text: "key=filler",
},
{
CharacterStyle: "Bold",
EndOfLineFlag: true,
Text: "name=APPROVED&key=approved",
},
{
EndOfLineFlag: true,
Text: "key=filler",
},
{
EndOfLineFlag: true,
Text: "name=Please%20retain%20for%20your%20records&key=retain",
},
{
EndOfLineFlag: true,
Text: "name=Thank%20you&key=thanks",
},
],
},
RequiredSignatureFlag: false,
},
],
PaymentResult: {
AmountsResp: {
AuthorizedAmount: 1,
Currency: "EUR",
},
OnlineFlag: true,
PaymentAcquirerData: {
AcquirerPOIID: "P400Plus-123456789",
AcquirerTransactionID: {
TimeStamp: "2019-04-29T09:19:51.000Z",
TransactionID: "8515565295894301",
},
ApprovalCode: "123456",
MerchantID: "TestMerchant",
},
PaymentInstrumentData: {
CardData: {
EntryMode: [
"Tapped",
],
MaskedPan: "411111 **** 1111",
PaymentBrand: "mc",
SensitiveCardData: {
ExpiryDate: "1225",
},
},
PaymentInstrumentType: "Card",
},
},
Response: {
AdditionalResponse: "tid=75039202&AID=A0000000041010&transactionType=GOODS_SERVICES&backendGiftcardIndi\n cator=false&expiryYear=2025&acquirerAccountCode=TestPmmAcquirerAccount&alias=M900978995070104&posOrigin\n alAmountCurrency=EUR&giftcardIndicator=false&authorisedAmountValue=100&pspReference=8515565295894301&pa\n ymentMethodVariant=mc&cardHolderName=N%2fA&refusalReasonRaw=APPROVED&authorisationMid=1000&expiryDate=1\n 2%2f2025&applicationPreferredName=MCC%20351%20v1%202&acquirerCode=TestPmmAcquirer&txtime=10%3a19%3a51&i\n so8601TxDate=2019-04-29T09%3a19%3a51.0000000%2b0000&cardType=mc&posOriginalAmountValue=100&offline=fals\n e&aliasType=Default&txdate=29-04-2019&paymentMethod=mc&cvcResult=0%20Unknown&avsResult=0%20Unknown&mid=\n 1000&merchantReference=003&transactionReferenceNumber=8515565295894301&expiryMonth=12&cardSummary=3511&\n posTotalAmountValue=100&posAuthAmountCurrency=EUR&cardHolderVerificationMethodResults=3F0300&authCode=1\n 23456&shopperCountry=NL&posEntryMode=CLESS_SWIPE&cardScheme=mc&cardBin=541333&posAuthAmountValue=100",
Result: "Success",
},
SaleData: {
SaleTransactionID: {
TimeStamp: "2019-04-29T00:00:00.000Z",
TransactionID: "001",
},
},
},
},
});
export var syncRefund = JSON.stringify({
SaleToPOIResponse: {
MessageHeader: {
MessageCategory: "Payment",
MessageClass: "Service",
MessageType: "Response",
POIID: process.env.ADYEN_TERMINAL_POIID,
ProtocolVersion: "3.0",
SaleID: "001",
ServiceID: "001",
},
ReversalResponse: {
Response: {
Result: "Success"
}
}
}
});
//# sourceMappingURL=sync.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1,181 @@
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
/*
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen NodeJS API Library
*
* Copyright (c) 2019 Adyen B.V.
* This file is open source and available under the MIT license.
* See the LICENSE file for more info.
*/
import nock from "nock";
import { createClient } from "../__mocks__/base";
import BinLookup from "../services/binLookup";
import Client from "../client";
import HttpClientException from "../httpClient/httpClientException";
var threeDSAvailabilitySuccess = {
binDetails: {
issuerCountry: "NL"
},
threeDS1Supported: true,
threeDS2CardRangeDetails: [],
threeDS2supported: false
};
var client;
var binLookup;
var scope;
beforeEach(function () {
if (!nock.isActive()) {
nock.activate();
}
client = createClient();
binLookup = new BinLookup(client);
scope = nock("" + client.config.endpoint + Client.BIN_LOOKUP_PAL_SUFFIX + Client.BIN_LOOKUP_API_VERSION);
});
afterEach(function () {
nock.cleanAll();
});
describe("Bin Lookup", function () {
test.each([false, true])("should succeed on get 3ds availability. isMock: %p", function (isMock) {
return __awaiter(this, void 0, void 0, function () {
var threeDSAvailabilityRequest, response;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
!isMock && nock.restore();
threeDSAvailabilityRequest = {
merchantAccount: process.env.ADYEN_MERCHANT,
brands: ["randomBrand"],
cardNumber: "4111111111111111"
};
scope.post("/get3dsAvailability")
.reply(200, threeDSAvailabilitySuccess);
return [4 /*yield*/, binLookup.get3dsAvailability(threeDSAvailabilityRequest)];
case 1:
response = _a.sent();
expect(response).toEqual(threeDSAvailabilitySuccess);
return [2 /*return*/];
}
});
});
});
test.each([false, true])("should fail with invalid merchant. isMock: %p", function (isMock) {
return __awaiter(this, void 0, void 0, function () {
var threeDSAvailabilityRequest, e_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
!isMock && nock.restore();
threeDSAvailabilityRequest = {
merchantAccount: undefined,
cardNumber: "4111111111111",
brands: []
};
scope.post("/get3dsAvailability")
.reply(403, JSON.stringify({ status: 403, message: "fail", errorCode: "171" }));
_a.label = 1;
case 1:
_a.trys.push([1, 3, , 4]);
return [4 /*yield*/, binLookup.get3dsAvailability(threeDSAvailabilityRequest)];
case 2:
_a.sent();
fail("Expected request to fail");
return [3 /*break*/, 4];
case 3:
e_1 = _a.sent();
expect(e_1 instanceof HttpClientException).toBeTruthy();
return [3 /*break*/, 4];
case 4: return [2 /*return*/];
}
});
});
});
test.each([false, true])("should succeed on get cost estimate. isMock: %p", function (isMock) {
return __awaiter(this, void 0, void 0, function () {
var expected, costEstimateRequest, response;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
!isMock && nock.restore();
expected = {
costEstimateAmount: {
currency: "EUR",
value: 10
},
resultCode: "Unsupported",
surchargeType: "ZERO"
};
costEstimateRequest = {
amount: { currency: "EUR", value: 1000 },
assumptions: {
assumeLevel3Data: true,
assume3DSecureAuthenticated: true
},
cardNumber: "411111111111",
merchantAccount: process.env.ADYEN_MERCHANT,
merchantDetails: {
countryCode: "NL",
mcc: "7411",
enrolledIn3DSecure: true
},
shopperInteraction: "Ecommerce"
};
scope.post("/getCostEstimate")
.reply(200, expected);
return [4 /*yield*/, binLookup.getCostEstimate(costEstimateRequest)];
case 1:
response = _a.sent();
expect(response).toEqual(expected);
return [2 /*return*/];
}
});
});
});
});
//# sourceMappingURL=binLookup.spec.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"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;;;;wBAC9F,CAAC,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;wBACpB,QAAQ,GAAG;4BACb,kBAAkB,EAAE;gCAChB,QAAQ,EAAE,KAAK;gCACf,KAAK,EAAE,EAAE;6BACZ;4BACD,UAAU,EAAE,aAAa;4BACzB,aAAa,EAAE,MAAM;yBACxB,CAAC;wBACI,mBAAmB,GAAmC;4BACxD,MAAM,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE;4BACxC,WAAW,EAAE;gCACT,gBAAgB,EAAE,IAAI;gCACtB,2BAA2B,EAAE,IAAI;6BACpC;4BACD,UAAU,EAAE,cAAc;4BAC1B,eAAe,EAAE,OAAO,CAAC,GAAG,CAAC,cAAe;4BAC5C,eAAe,EAAE;gCACb,WAAW,EAAE,IAAI;gCACjB,GAAG,EAAE,MAAM;gCACX,kBAAkB,EAAE,IAAI;6BAC3B;4BACD,kBAAkB,EAAE,WAAW;yBAClC,CAAC;wBAEF,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC;6BACzB,KAAK,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;wBAET,qBAAM,SAAS,CAAC,eAAe,CAAC,mBAAmB,CAAC,EAAA;;wBAA/D,QAAQ,GAAG,SAAoD;wBAErE,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;;;;;KACtC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1,78 @@
/* eslint-disable @typescript-eslint/camelcase */
import checkServerIdentity from "../helpers/checkServerIdentity";
var createMockedCertificate = function (CN) { return ({
subjectaltname: "Adyen B.V",
infoAccess: { mock: ["any"] },
subject: {
C: "AB",
ST: "AB",
L: "City",
O: "Company Name",
OU: "Mocked Value",
CN: CN,
},
issuer: {
C: "AB",
ST: "AB",
L: "City",
O: "Issuer Name",
OU: "Issuer",
CN: "Issuer CN",
},
modulus: "ABC123",
exponent: "01010101",
valid_from: "Nov 19 15:03:32 2018 GMT",
valid_to: "Nov 11 15:03:32 2048 GMT",
fingerprint: "MOCKED_FINGERPRINT",
fingerprint256: "MOCKED_FINGERPRINT_256",
ext_key_usage: ["1.2.3.4.5.6.7.8"],
serialNumber: "1000",
raw: Buffer.from("test")
}); };
describe("Certificate Server Identiy", function () {
test.each([
["legacy-terminal-certificate", "live"],
["legacy-terminal-certificate", "test"],
["P400-3123123", "live"],
["P400-3123123", "test"],
["MODEL-SN", "live"],
["MODEL-SN", "test"],
])("it should be valid: %s.%s", function (prefix, environment) {
var cn = prefix + "." + environment + ".terminal.adyen.com";
var mockedCertificate = createMockedCertificate(cn);
expect(checkServerIdentity("any", mockedCertificate)).toBeUndefined();
});
test.each([
"INVALID.adyen.com",
"terminal.INVALID.com",
"terminal.adyen.org",
"google.com",
"",
])("it should fail because invalid domain: %s", function (domain) {
var cn = "P400-123123.live." + domain;
var mockedCertificate = createMockedCertificate(cn);
expect(checkServerIdentity("any", mockedCertificate) instanceof Error).toBeTruthy();
});
test.each([
"liive", "teest", "lve", "tst", "ANY", "invalid",
])("it should fail because invalid environment: %s", function (environment) {
var cn = "P400-123123." + environment + ".terminal.adyen.com";
var mockedCertificate = createMockedCertificate(cn);
expect(checkServerIdentity("any", mockedCertificate) instanceof Error).toBeTruthy();
});
test.each([
"legacyy-terminal-certificate", "legacy-terminaal-certificate",
"legacy-terminal-certificatee", "P400-", "-123123", "P400--123123", "P400123123",
"ANY-ANY-ANY", "ANY", ""
])("it should fail because invalid prefix: %s", function (prefix) {
var cn = prefix + ".test.terminal.adyen.com";
var mockedCertificate = createMockedCertificate(cn);
expect(checkServerIdentity("any", mockedCertificate) instanceof Error).toBeTruthy();
});
it("should fail if no first part on CN", function () {
var cn = "live.terminal.adyen.com";
var mockedCertificate = createMockedCertificate(cn);
expect(checkServerIdentity("any", mockedCertificate) instanceof Error).toBeTruthy();
});
});
//# sourceMappingURL=checkServerIdentity.spec.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"checkServerIdentity.spec.js","sourceRoot":"","sources":["../../../../src/__tests__/checkServerIdentity.spec.ts"],"names":[],"mappings":"AAAA,iDAAiD;AAEjD,OAAO,mBAAmB,MAAM,gCAAgC,CAAC;AAGjE,IAAM,uBAAuB,GAAG,UAAC,EAAU,IAAsB,OAAA,CAAC;IAC9D,cAAc,EAAE,WAAW;IAC3B,UAAU,EAAE,EAAC,IAAI,EAAE,CAAC,KAAK,CAAC,EAAC;IAC3B,OAAO,EACH;QACI,CAAC,EAAE,IAAI;QACP,EAAE,EAAE,IAAI;QACR,CAAC,EAAE,MAAM;QACT,CAAC,EAAE,cAAc;QACjB,EAAE,EAAE,cAAc;QAClB,EAAE,IAAA;KACL;IACL,MAAM,EACF;QACI,CAAC,EAAE,IAAI;QACP,EAAE,EAAE,IAAI;QACR,CAAC,EAAE,MAAM;QACT,CAAC,EAAE,aAAa;QAChB,EAAE,EAAE,QAAQ;QACZ,EAAE,EAAE,WAAW;KAClB;IACL,OAAO,EAAE,QAAQ;IACjB,QAAQ,EAAE,UAAU;IACpB,UAAU,EAAE,0BAA0B;IACtC,QAAQ,EAAE,0BAA0B;IACpC,WAAW,EAAE,oBAAoB;IACjC,cAAc,EAAE,wBAAwB;IACxC,aAAa,EAAE,CAAC,iBAAiB,CAAC;IAClC,YAAY,EAAE,MAAM;IACpB,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;CAC3B,CAAC,EA9B+D,CA8B/D,CAAC;AAEH,QAAQ,CAAC,4BAA4B,EAAE;IACnC,IAAI,CAAC,IAAI,CAAC;QACN,CAAC,6BAA6B,EAAE,MAAM,CAAC;QACvC,CAAC,6BAA6B,EAAE,MAAM,CAAC;QACvC,CAAC,cAAc,EAAE,MAAM,CAAC;QACxB,CAAC,cAAc,EAAE,MAAM,CAAC;QACxB,CAAC,UAAU,EAAE,MAAM,CAAC;QACpB,CAAC,UAAU,EAAE,MAAM,CAAC;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AAC,MAAM;QACnD,IAAM,EAAE,GAAM,MAAM,6BAA0B,CAAC;QAC/C,IAAM,iBAAiB,GAAG,uBAAuB,CAAC,EAAE,CAAC,CAAC;QACtD,MAAM,CAAC,mBAAmB,CAAC,KAAK,EAAE,iBAAiB,CAAC,YAAY,KAAK,CAAC,CAAC,UAAU,EAAE,CAAC;IACxF,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,oCAAoC,EAAE;QACrC,IAAM,EAAE,GAAG,yBAAyB,CAAC;QACrC,IAAM,iBAAiB,GAAG,uBAAuB,CAAC,EAAE,CAAC,CAAC;QACtD,MAAM,CAAC,mBAAmB,CAAC,KAAK,EAAE,iBAAiB,CAAC,YAAY,KAAK,CAAC,CAAC,UAAU,EAAE,CAAC;IACxF,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}

View File

@@ -0,0 +1 @@
export declare function createPaymentsCheckoutRequest(): ICheckout.PaymentRequest;

View File

@@ -0,0 +1,335 @@
/*
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen NodeJS API Library
*
* Copyright (c) 2019 Adyen B.V.
* This file is open source and available under the MIT license.
* See the LICENSE file for more info.
*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
import nock from "nock";
import { createClient } from "../__mocks__/base";
import { paymentMethodsSuccess } from "../__mocks__/checkout/paymentMethodsSuccess";
import { paymentsSuccess } from "../__mocks__/checkout/paymentsSuccess";
import { paymentDetailsSuccess } from "../__mocks__/checkout/paymentsDetailsSuccess";
import { paymentSessionSuccess } from "../__mocks__/checkout/paymentSessionSucess";
import { paymentsResultMultibancoSuccess } from "../__mocks__/checkout/paymentsResultMultibancoSuccess";
import { paymentsResultSuccess } from "../__mocks__/checkout/paymentsResultSucess";
import Client from "../client";
import Checkout from "../services/checkout";
import HttpClientException from "../httpClient/httpClientException";
var merchantAccount = process.env.ADYEN_MERCHANT;
var reference = "Your order number";
function createAmountObject(currency, value) {
return {
currency: currency,
value: value,
};
}
function createPaymentsDetailsRequest() {
return {
details: {
MD: "mdValue",
PaRes: "paResValue",
},
paymentData: "Ab02b4c0!BQABAgCJN1wRZuGJmq8dMncmypvknj9s7l5Tj...",
};
}
export function createPaymentsCheckoutRequest() {
var paymentMethodDetails = {
cvc: "737",
expiryMonth: "03",
expiryYear: "2030",
holderName: "John Smith",
number: "4111111111111111",
type: "scheme",
};
return {
amount: createAmountObject("USD", 1000),
merchantAccount: merchantAccount,
paymentMethod: paymentMethodDetails,
reference: reference,
returnUrl: "https://your-company.com/...",
enableRecurring: true,
enableOneClick: true,
shopperReference: "shopperReference",
storePaymentMethod: true
};
}
function createPaymentSessionRequest() {
return {
amount: createAmountObject("USD", 1000),
countryCode: "NL",
merchantAccount: merchantAccount,
reference: reference,
returnUrl: "https://your-company.com/...",
channel: "Web",
sdkVersion: "3.7.0"
};
}
var client;
var checkout;
var scope;
beforeEach(function () {
if (!nock.isActive()) {
nock.activate();
}
client = createClient();
scope = nock(client.config.checkoutEndpoint + "/" + Client.CHECKOUT_API_VERSION);
checkout = new Checkout(client);
});
afterEach(function () {
nock.cleanAll();
});
describe("Checkout", function () {
test.each([false, true])("should make a payment. isMock: %p", function (isMock) { return __awaiter(void 0, void 0, void 0, function () {
var paymentsRequest, paymentsResponse;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
!isMock && nock.restore();
scope.post("/payments")
.reply(200, paymentsSuccess);
paymentsRequest = createPaymentsCheckoutRequest();
return [4 /*yield*/, checkout.payments(paymentsRequest)];
case 1:
paymentsResponse = _a.sent();
expect(paymentsResponse.pspReference).toBeTruthy();
return [2 /*return*/];
}
});
}); });
test.each([false, true])("should return correct Exception, isMock: %p", function (isMock) { return __awaiter(void 0, void 0, void 0, function () {
var paymentsRequest, e_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
!isMock && nock.restore();
_a.label = 1;
case 1:
_a.trys.push([1, 3, , 4]);
scope.post("/payments")
.reply(401);
paymentsRequest = createPaymentsCheckoutRequest();
return [4 /*yield*/, checkout.payments(paymentsRequest)];
case 2:
_a.sent();
return [3 /*break*/, 4];
case 3:
e_1 = _a.sent();
expect(e_1 instanceof HttpClientException).toBeTruthy();
return [3 /*break*/, 4];
case 4: return [2 /*return*/];
}
});
}); });
test.each([false, true])("should have valid payment methods, isMock: %p", function (isMock) { return __awaiter(void 0, void 0, void 0, function () {
var paymentMethodsRequest, paymentMethodsResponse;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
!isMock && nock.restore();
paymentMethodsRequest = { merchantAccount: "MagentoMerchantTest" };
scope.post("/paymentMethods")
.reply(200, paymentMethodsSuccess);
return [4 /*yield*/, checkout.paymentMethods(paymentMethodsRequest)];
case 1:
paymentMethodsResponse = _a.sent();
if (paymentMethodsResponse && paymentMethodsResponse.paymentMethods) {
expect(paymentMethodsResponse.paymentMethods.length).toBeGreaterThan(0);
}
else {
fail();
}
return [2 /*return*/];
}
});
}); });
test.each([false, true])("should have valid payment link, isMock: %p", function (isMock) { return __awaiter(void 0, void 0, void 0, function () {
var amount, expiresAt, paymentLinkRequest, paymentLinkSuccess, paymentSuccessLinkResponse;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
!isMock && nock.restore();
amount = createAmountObject("BRL", 1000);
expiresAt = "2019-12-17T10:05:29Z";
paymentLinkRequest = {
allowedPaymentMethods: ["scheme", "boletobancario"],
amount: amount,
countryCode: "BR",
merchantAccount: merchantAccount,
shopperReference: "shopperReference",
shopperEmail: "test@email.com",
shopperLocale: "pt_BR",
billingAddress: {
street: "Roque Petroni Jr",
postalCode: "59000060",
city: "São Paulo",
houseNumberOrName: "999",
country: "BR",
stateOrProvince: "SP"
},
deliveryAddress: {
street: "Roque Petroni Jr",
postalCode: "59000060",
city: "São Paulo",
houseNumberOrName: "999",
country: "BR",
stateOrProvince: "SP"
},
reference: reference
};
paymentLinkSuccess = {
amount: amount,
expiresAt: expiresAt,
reference: reference,
url: "paymentLinkResponse.url"
};
scope.post("/paymentLinks").reply(200, paymentLinkSuccess);
return [4 /*yield*/, checkout.paymentLinks(paymentLinkRequest)];
case 1:
paymentSuccessLinkResponse = _a.sent();
expect(paymentSuccessLinkResponse).toBeTruthy();
return [2 /*return*/];
}
});
}); });
test.each([false, true])("should have payment details, isMock: %p", function (isMock) { return __awaiter(void 0, void 0, void 0, function () {
var paymentsResponse;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!isMock) {
console.warn("Cannot perform /payments/details without manual user validation. Skipping test.");
return [2 /*return*/];
}
scope.post("/payments/details")
.reply(200, paymentDetailsSuccess);
return [4 /*yield*/, checkout.paymentsDetails(createPaymentsDetailsRequest())];
case 1:
paymentsResponse = _a.sent();
expect(paymentsResponse.resultCode).toEqual("Authorised");
return [2 /*return*/];
}
});
}); });
test.each([false, true])("should have payment session success, isMock: %p", function (isMock) { return __awaiter(void 0, void 0, void 0, function () {
var paymentSessionRequest, paymentSessionResponse;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
!isMock && nock.restore();
scope.post("/paymentSession")
.reply(200, paymentSessionSuccess);
paymentSessionRequest = createPaymentSessionRequest();
return [4 /*yield*/, checkout.paymentSession(paymentSessionRequest)];
case 1:
paymentSessionResponse = _a.sent();
expect(paymentSessionResponse.paymentSession).not.toBeUndefined();
return [2 /*return*/];
}
});
}); });
test.each([false, true])("should have payments result, isMock: %p", function (isMock) { return __awaiter(void 0, void 0, void 0, function () {
var paymentResultRequest, paymentResultResponse;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!isMock) {
console.warn("Cannot perform /payments/result without payload. Skipping test.");
return [2 /*return*/];
}
scope.post("/payments/result")
.reply(200, paymentsResultSuccess);
paymentResultRequest = {
payload: "This is a test payload",
};
return [4 /*yield*/, checkout.paymentResult(paymentResultRequest)];
case 1:
paymentResultResponse = _a.sent();
expect(paymentResultResponse.resultCode).toEqual("Authorised");
return [2 /*return*/];
}
});
}); });
test.each([false, true])("should have missing identifier on live, isMock: %p", function (isMock) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
!isMock && nock.restore();
client.setEnvironment("LIVE");
try {
new Checkout(client);
fail();
}
catch (e) {
expect(e.message).toEqual("Please provide your unique live url prefix on the setEnvironment() call on the Client or provide checkoutEndpoint in your config object.");
}
return [2 /*return*/];
});
}); });
test.each([false, true])("should succeed on multibanco payment, isMock: %p", function (isMock) { return __awaiter(void 0, void 0, void 0, function () {
var paymentsRequest, paymentsResponse;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
!isMock && nock.restore();
scope.post("/payments")
.reply(200, paymentsResultMultibancoSuccess);
paymentsRequest = createPaymentsCheckoutRequest();
return [4 /*yield*/, checkout.payments(paymentsRequest)];
case 1:
paymentsResponse = _a.sent();
expect(paymentsResponse.pspReference).toBeTruthy();
expect(paymentsResponse.additionalData).toBeTruthy();
return [2 /*return*/];
}
});
}); });
});
//# sourceMappingURL=checkout.spec.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1,89 @@
/*
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen NodeJS API Library
*
* Copyright (c) 2019 Adyen B.V.
* This file is open source and available under the MIT license.
* See the LICENSE file for more info.
*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
import nock from "nock";
import { createClient } from "../__mocks__/base";
import { originKeysSuccess } from "../__mocks__/checkoutUtility/originkeysSuccess";
import CheckoutUtility from "../services/checkoutUtility";
import Client from "../client";
describe("Checkout Utility", function () {
test.each([false, true])("should get origin keys. isMock: %p", function (isMock) { return __awaiter(void 0, void 0, void 0, function () {
var client, checkoutUtility, originKeysRequest, originKeysResponse;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
!isMock && nock.restore();
client = createClient();
checkoutUtility = new CheckoutUtility(client);
originKeysRequest = {
originDomains: ["https://www.your-domain.com"],
};
nock("" + client.config.checkoutEndpoint)
.post("/" + Client.CHECKOUT_UTILITY_API_VERSION + "/originKeys")
.reply(200, originKeysSuccess);
return [4 /*yield*/, checkoutUtility.originKeys(originKeysRequest)];
case 1:
originKeysResponse = _a.sent();
if (originKeysResponse.originKeys) {
return [2 /*return*/, expect(originKeysResponse.originKeys["https://www.your-domain.com"].startsWith("pub.v2")).toBeTruthy()];
}
fail("Error: originKeysResponse.originKeys is empty");
return [2 /*return*/];
}
});
}); });
});
//# sourceMappingURL=checkoutUtility.spec.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"checkoutUtility.spec.js","sourceRoot":"","sources":["../../../../src/__tests__/checkoutUtility.spec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAC,iBAAiB,EAAC,MAAM,gDAAgD,CAAC;AACjF,OAAO,eAAe,MAAM,6BAA6B,CAAC;AAC1D,OAAO,MAAM,MAAM,WAAW,CAAC;AAE/B,QAAQ,CAAC,kBAAkB,EAAE;IACzB,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,EAAC,IAAI,CAAC,CAAC,CAAC,oCAAoC,EAAE,UAAO,MAAM;;;;;oBACvE,CAAC,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;oBACpB,MAAM,GAAG,YAAY,EAAE,CAAC;oBACxB,eAAe,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC;oBAC9C,iBAAiB,GAA4C;wBAC/D,aAAa,EAAE,CAAC,6BAA6B,CAAC;qBACjD,CAAC;oBAEF,IAAI,CAAC,KAAG,MAAM,CAAC,MAAM,CAAC,gBAAkB,CAAC;yBACpC,IAAI,CAAC,MAAI,MAAM,CAAC,4BAA4B,gBAAa,CAAC;yBAC1D,KAAK,CAAC,GAAG,EAAE,iBAAiB,CAAC,CAAC;oBAER,qBAAM,eAAe,CAAC,UAAU,CAAC,iBAAiB,CAAC,EAAA;;oBAAxE,kBAAkB,GAAG,SAAmD;oBAC9E,IAAI,kBAAkB,CAAC,UAAU,EAAE;wBAC/B,sBAAO,MAAM,CAAC,kBAAkB,CAAC,UAAU,CAAC,6BAA6B,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,EAAE,EAAC;qBACjH;oBACD,IAAI,CAAC,+CAA+C,CAAC,CAAC;;;;SACzD,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1,64 @@
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var _a;
import HmacValidator from "../utils/hmacValidator";
import { ApiConstants } from "../constants/apiConstants";
var key = "DFB1EB5485895CFA84146406857104ABB4CBCABDC8AAF103A624C8F6A3EAAB00";
var expectedSign = "ipnxGCaUZ4l8TUW75a71/ghd2Fe5ffvX0pV4TLTntIc=";
var notificationRequestItem = {
pspReference: "pspReference",
originalReference: "originalReference",
merchantAccountCode: "merchantAccount",
merchantReference: "reference",
amount: { currency: "EUR", value: 1000 },
eventCode: "EVENT",
eventDate: new Date("01-01-1970"),
paymentMethod: "VISA",
reason: "reason",
success: "true",
additionalData: (_a = {}, _a[ApiConstants.HMAC_SIGNATURE] = expectedSign, _a),
};
describe("HMAC Validator", function () {
var hmacValidator;
beforeEach(function () {
hmacValidator = new HmacValidator();
});
it("should get correct data", function () {
var dataToSign = hmacValidator.getDataToSign({ merchantAccount: "ACC", currencyCode: "EUR" });
expect(dataToSign).toEqual("currencyCode:merchantAccount:EUR:ACC");
});
it("should get correct data with escaped characters", function () {
var dataToSign = hmacValidator.getDataToSign({ currencyCode: "EUR", merchantAccount: "ACC:\\", sessionValidity: "2019-09-21T11:45:24.637Z" });
expect(dataToSign).toEqual("currencyCode:merchantAccount:sessionValidity:EUR:ACC\\:\\\\:2019-09-21T11\\:45\\:24.637Z");
});
it("should encrypt correctly", function () {
var data = "countryCode:currencyCode:merchantAccount:merchantReference:paymentAmount:sessionValidity:skinCode:NL:EUR:MagentoMerchantTest2:TEST-PAYMENT-2017-02-01-14\\:02\\:05:199:2017-02-02T14\\:02\\:05+01\\:00:PKz2KML1";
var encrypted = hmacValidator.calculateHmac(data, "DFB1EB5485895CFA84146406857104ABB4CBCABDC8AAF103A624C8F6A3EAAB00");
expect(encrypted).toEqual("34oR8T1whkQWTv9P+SzKyp8zhusf9n0dpqrm9nsqSJs=");
});
it("should get correct data to sign", function () {
var data = hmacValidator.getDataToSign(notificationRequestItem);
expect(data).toEqual("pspReference:originalReference:merchantAccount:reference:1000:EUR:EVENT:true");
});
it("should have valid hmac", function () {
var encrypted = hmacValidator.calculateHmac(notificationRequestItem, key);
expect(expectedSign).toEqual(encrypted);
expect(hmacValidator.validateHMAC(notificationRequestItem, key)).toBeTruthy();
});
it("should have invalid hmac", function () {
var _a;
var invalidNotification = __assign(__assign({}, notificationRequestItem), { additionalData: (_a = {}, _a[ApiConstants.HMAC_SIGNATURE] = "notValidSign", _a) });
var result = hmacValidator.validateHMAC(invalidNotification, key);
expect(result).toBeFalsy();
});
});
//# sourceMappingURL=hmacValidator.spec.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"hmacValidator.spec.js","sourceRoot":"","sources":["../../../../src/__tests__/hmacValidator.spec.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,aAAa,MAAM,wBAAwB,CAAC;AAEnD,OAAO,EAA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