Browse Source

Create plugin for payments-example

Signed-off-by: trojanh <rajan.tiwari@kiprosh.com>
trunk
trojanh 1 year ago
parent
commit
0a102c762d
40 changed files with 14808 additions and 0 deletions
  1. +50
    -0
      .circleci/bin/docker-tags
  2. +66
    -0
      .circleci/config.yml
  3. +61
    -0
      .gitignore
  4. +1
    -0
      .nvmrc
  5. +3
    -0
      index.js
  6. +13672
    -0
      package-lock.json
  7. +92
    -0
      package.json
  8. +27
    -0
      src/i18n/ar.json
  9. +27
    -0
      src/i18n/bg.json
  10. +27
    -0
      src/i18n/cs.json
  11. +27
    -0
      src/i18n/de.json
  12. +27
    -0
      src/i18n/el.json
  13. +27
    -0
      src/i18n/en.json
  14. +27
    -0
      src/i18n/es.json
  15. +27
    -0
      src/i18n/fr.json
  16. +26
    -0
      src/i18n/he.json
  17. +27
    -0
      src/i18n/hr.json
  18. +27
    -0
      src/i18n/hu.json
  19. +58
    -0
      src/i18n/index.js
  20. +27
    -0
      src/i18n/it.json
  21. +27
    -0
      src/i18n/my.json
  22. +6
    -0
      src/i18n/nb.json
  23. +27
    -0
      src/i18n/nl.json
  24. +27
    -0
      src/i18n/pl.json
  25. +27
    -0
      src/i18n/pt.json
  26. +27
    -0
      src/i18n/ro.json
  27. +27
    -0
      src/i18n/ru.json
  28. +27
    -0
      src/i18n/sl.json
  29. +27
    -0
      src/i18n/sv.json
  30. +27
    -0
      src/i18n/tr.json
  31. +27
    -0
      src/i18n/vi.json
  32. +27
    -0
      src/i18n/zh.json
  33. +38
    -0
      src/index.js
  34. +5
    -0
      src/schemas/index.js
  35. +20
    -0
      src/schemas/schema.graphql
  36. +9
    -0
      src/startup.js
  37. +12
    -0
      src/util/exampleCapturePayment.js
  38. +49
    -0
      src/util/exampleCreateAuthorizedPayment.js
  39. +22
    -0
      src/util/exampleCreateRefund.js
  40. +24
    -0
      src/util/exampleListRefunds.js

+ 50
- 0
.circleci/bin/docker-tags View File

@ -0,0 +1,50 @@
#!/bin/bash
# outputs each tag we're attaching to this docker image
set -e
SHA=$1
BRANCH=$2
SHA1=$(git rev-parse --verify "${SHA}")
# Echo to stderr
echoerr() { echo "$@" 1>&2; }
# Ensure that git SHA was provided
if [[ -x "${SHA1}" ]]; then
echoerr "Error, no git SHA provided"
exit 1;
fi
# tag with the branch
if [[ -n "${BRANCH}" ]]; then
echo "${BRANCH}"
fi
# Tag with each git tag
git show-ref --tags -d | grep "^${SHA1}" | sed -e 's,.* refs/tags/,,' -e 's/\^{}//' 2> /dev/null \
| xargs -I % \
echo "%"
# Tag with latest if certain conditions are met
if [[ "$BRANCH" == "master" ]]; then
# Check to see if we have a valid `vX.X.X` tag and assign to CURRENT_TAG
CURRENT_TAG=$( \
git show-ref --tags -d \
| grep "^${SHA1}" \
| sed -e 's,.* refs/tags/,,' -e 's/\^{}//' \
| grep "^v[0-9]\\+\\.[0-9]\\+\\.[0-9]\\+$" \
| sort \
)
# Find the highest tagged version number
HIGHEST_TAG=$(git --no-pager tag | grep "^v[0-9]\\+\\.[0-9]\\+\\.[0-9]\\+$" | sort -r | head -n 1)
# We tag :latest only if
# 1. We have a current tag
# 2. The current tag is equal to the highest tag, OR the highest tag does not exist
if [[ -n "${CURRENT_TAG}" ]]; then
if [[ "${CURRENT_TAG}" == "${HIGHEST_TAG}" ]] || [[ -z "${HIGHEST_TAG}" ]]; then
echo "latest"
fi
fi
fi

+ 66
- 0
.circleci/config.yml View File

@ -0,0 +1,66 @@
version: 2
jobs:
build:
docker:
- image: node:12
dependencies:
pre:
- echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
steps:
- checkout
- run: npm ci
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}
# deploy:
# docker:
# - image: node:12
# steps:
# - checkout
# - restore_cache:
# keys:
# - v1-dependencies-{{ checksum "package.json" }}
# # fallback to using the latest cache if no exact match is found
# - v1-dependencies-
# - run: npx semantic-release
lint:
docker:
- image: node:12
steps:
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run: npm run lint
workflows:
version: 2
build_deploy:
jobs:
- build:
context: reaction-publish-semantic-release
- lint:
requires:
- build
# - deploy:
# context: reaction-publish-semantic-release
# requires:
# - lint
# filters:
# branches:
# only: trunk

+ 61
- 0
.gitignore View File

@ -0,0 +1,61 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
# next.js build output
.next

+ 1
- 0
.nvmrc View File

@ -0,0 +1 @@
12.14.1

+ 3
- 0
index.js View File

@ -0,0 +1,3 @@
import register from "./src/index.js";
export default register;

+ 13672
- 0
package-lock.json
File diff suppressed because it is too large
View File


+ 92
- 0
package.json View File

@ -0,0 +1,92 @@
{
"name": "@reactioncommerce/plugin-payments-example",
"description": "Example Payments plugin for the Reaction API",
"version": "1.0.0",
"main": "index.js",
"type": "module",
"engines": {
"node": ">=12.14.1"
},
"homepage": "https://github.com/reactioncommerce/plugin-payments-example",
"url": "https://github.com/reactioncommerce/plugin-payments-example",
"email": "engineering@reactioncommerce.com",
"repository": {
"type": "git",
"url": "git+https://github.com/reactioncommerce/plugin-payments-example.git"
},
"author": {
"name": "Reaction Commerce",
"email": "engineering@reactioncommerce.com",
"url": "https://reactioncommerce.com"
},
"license": "GPL-3.0",
"bugs": {
"url": "https://github.com/reactioncommerce/plugin-payments-example/issues"
},
"sideEffects": false,
"dependencies": {
"@reactioncommerce/api-utils": "^1.7.2",
"@reactioncommerce/random": "~1.0.2"
},
"devDependencies": {
"@babel/core": "^7.7.7",
"@babel/preset-env": "^7.7.7",
"@reactioncommerce/babel-remove-es-create-require": "~1.0.0",
"@reactioncommerce/data-factory": "~1.0.1",
"@reactioncommerce/eslint-config": "~2.1.0",
"babel-eslint": "^10.0.3",
"babel-jest": "~25.1.0",
"babel-plugin-rewire-exports": "^2.0.0",
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
"babel-plugin-transform-import-meta": "~1.0.0",
"eslint": "^6.4.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jest": "^23.7.0",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-node": "^10.0.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-react": "^7.14.3",
"eslint-plugin-react-hooks": "^2.0.1",
"jest": "^25.1.0",
"semantic-release": "^17.0.4"
},
"scripts": {
"lint": "npm run lint:eslint",
"lint:eslint": "eslint .",
"test": "jest",
"test:watch": "jest --watch",
"test:file": "jest --no-cache --watch --coverage=false"
},
"eslintConfig": {
"extends": "@reactioncommerce",
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module",
"ecmaFeatures": {
"impliedStrict": true
}
},
"env": {
"es6": true,
"jasmine": true
},
"rules": {
"node/no-missing-import": "off",
"node/no-missing-require": "off",
"node/no-unsupported-features/es-syntax": "off",
"node/no-unpublished-import": "off",
"node/no-unpublished-require": "off"
}
},
"prettier": {
"arrowParens": "always"
},
"release": {
"branches": [
"trunk"
]
},
"publishConfig": {
"access": "public"
}
}

+ 27
- 0
src/i18n/ar.json View File

@ -0,0 +1,27 @@
[{
"language": "Arabic",
"i18n": "ar",
"ns": "example-paymentmethod",
"translation": {
"example-paymentmethod": {
"admin": {
"shortcut": {
"examplePaymentProviderLabel": "مثال الدفع",
"examplePaymentProviderTitle": "مثال الدفع"
},
"dashboard": {
"examplePaymentProviderLabel": "مثال الدفع",
"examplePaymentProviderTitle": "مثال الدفع",
"examplePaymentProviderDescription": "مثال طريقة الدفع"
},
"paymentSettings": {
"examplePaymentLabel": "مزود سبيل المثال",
"examplePaymentSettingsLabel": "مثال الدفع",
"exampleCredentials": "هذا هو إعداد سبيل المثال طريقة الدفع.",
"apiClientId": "معرف العميل API",
"supportedMethodsLabel": "طرق دعم مزود الدفع"
}
}
}
}
}]

+ 27
- 0
src/i18n/bg.json View File

@ -0,0 +1,27 @@
[{
"language": "Bulgarian",
"i18n": "bg",
"ns": "example-paymentmethod",
"translation": {
"example-paymentmethod": {
"admin": {
"shortcut": {
"examplePaymentProviderLabel": "Пример плащане",
"examplePaymentProviderTitle": "Пример плащане"
},
"dashboard": {
"examplePaymentProviderLabel": "Пример плащане",
"examplePaymentProviderTitle": "Пример плащане",
"examplePaymentProviderDescription": "Пример Начин на плащане"
},
"paymentSettings": {
"examplePaymentLabel": "Пример Provider",
"examplePaymentSettingsLabel": "Пример плащане",
"exampleCredentials": "Това е настройка за пример начина на плащане.",
"apiClientId": "API Client ID",
"supportedMethodsLabel": "Методи, поддържани от доставчика на плащания"
}
}
}
}
}]

+ 27
- 0
src/i18n/cs.json View File

@ -0,0 +1,27 @@
[{
"language": "Czech",
"i18n": "cs",
"ns": "example-paymentmethod",
"translation": {
"example-paymentmethod": {
"admin": {
"shortcut": {
"examplePaymentProviderLabel": "Příklad platba",
"examplePaymentProviderTitle": "Příklad platba"
},
"dashboard": {
"examplePaymentProviderLabel": "Příklad platba",
"examplePaymentProviderTitle": "Příklad platba",
"examplePaymentProviderDescription": "Příklad Způsob platby"
},
"paymentSettings": {
"examplePaymentLabel": "Příklad Poskytovatel",
"examplePaymentSettingsLabel": "Příklad platba",
"exampleCredentials": "Jedná se o nastavení příklad způsob platby.",
"apiClientId": "API ID klienta",
"supportedMethodsLabel": "Metody podporované poskytovatelem plateb"
}
}
}
}
}]

+ 27
- 0
src/i18n/de.json View File

@ -0,0 +1,27 @@
[{
"language": "German",
"i18n": "de",
"ns": "example-paymentmethod",
"translation": {
"example-paymentmethod": {
"admin": {
"shortcut": {
"examplePaymentProviderLabel": "Beispiel Zahlung",
"examplePaymentProviderTitle": "Beispiel Zahlung"
},
"dashboard": {
"examplePaymentProviderLabel": "Beispiel Zahlung",
"examplePaymentProviderTitle": "Beispiel Zahlung",
"examplePaymentProviderDescription": "Beispiel Zahlungsmethode"
},
"paymentSettings": {
"examplePaymentLabel": "Beispiel Provider",
"examplePaymentSettingsLabel": "Beispiel Zahlung",
"exampleCredentials": "Dies ist ein Beispiel Zahlungsmethode Einstellung.",
"apiClientId": "API-Client-ID",
"supportedMethodsLabel": "Zahlungsanbieter unterstützt Methoden"
}
}
}
}
}]

+ 27
- 0
src/i18n/el.json View File

@ -0,0 +1,27 @@
[{
"language": "Greek",
"i18n": "el",
"ns": "example-paymentmethod",
"translation": {
"example-paymentmethod": {
"admin": {
"shortcut": {
"examplePaymentProviderLabel": "παράδειγμα πληρωμής",
"examplePaymentProviderTitle": "παράδειγμα πληρωμής"
},
"dashboard": {
"examplePaymentProviderLabel": "παράδειγμα πληρωμής",
"examplePaymentProviderTitle": "παράδειγμα πληρωμής",
"examplePaymentProviderDescription": "Παράδειγμα Μέθοδος Πληρωμής"
},
"paymentSettings": {
"examplePaymentLabel": "παράδειγμα Provider",
"examplePaymentSettingsLabel": "παράδειγμα πληρωμής",
"exampleCredentials": "Αυτή είναι μια ρύθμιση παράδειγμα τη μέθοδο πληρωμής.",
"apiClientId": "API ID πελάτη",
"supportedMethodsLabel": "Οι μέθοδοι υποστήριξης του παρόχου πληρωμών"
}
}
}
}
}]

+ 27
- 0
src/i18n/en.json View File

@ -0,0 +1,27 @@
[{
"language": "English",
"i18n": "en",
"ns": "example-paymentmethod",
"translation": {
"example-paymentmethod": {
"admin": {
"shortcut": {
"examplePaymentProviderLabel": "Example Payment",
"examplePaymentProviderTitle": "Example Payment"
},
"dashboard": {
"examplePaymentProviderLabel": "Example Payment",
"examplePaymentProviderTitle": "Example Payment",
"examplePaymentProviderDescription": "Example Payment Method"
},
"paymentSettings": {
"examplePaymentLabel": "Example Provider",
"examplePaymentSettingsLabel": "Example Payment",
"exampleCredentials": "This is an example payment method setting.",
"apiClientId": "API Client ID",
"supportedMethodsLabel": "Payment provider supported methods"
}
}
}
}
}]

+ 27
- 0
src/i18n/es.json View File

@ -0,0 +1,27 @@
[{
"language": "Spanish",
"i18n": "es",
"ns": "example-paymentmethod",
"translation": {
"example-paymentmethod": {
"admin": {
"shortcut": {
"examplePaymentProviderLabel": "ejemplo de Pago",
"examplePaymentProviderTitle": "ejemplo de Pago"
},
"dashboard": {
"examplePaymentProviderLabel": "ejemplo de Pago",
"examplePaymentProviderTitle": "ejemplo de Pago",
"examplePaymentProviderDescription": "Ejemplo Forma de pago"
},
"paymentSettings": {
"examplePaymentLabel": "ejemplo de Proveedores",
"examplePaymentSettingsLabel": "ejemplo de Pago",
"exampleCredentials": "Este es un ejemplo de confirmación de pago.",
"apiClientId": "API ID de cliente",
"supportedMethodsLabel": "Métodos soportados por proveedores de pago"
}
}
}
}
}]

+ 27
- 0
src/i18n/fr.json View File

@ -0,0 +1,27 @@
[{
"language": "French",
"i18n": "fr",
"ns": "example-paymentmethod",
"translation": {
"example-paymentmethod": {
"admin": {
"shortcut": {
"examplePaymentProviderLabel": "Exemple de passerelle de paiement",
"examplePaymentProviderTitle": "Exemple de passerelle de paiement"
},
"dashboard": {
"examplePaymentProviderLabel": "Exemple de passerelle de paiement",
"examplePaymentProviderTitle": "Exemple de passerelle de paiement",
"examplePaymentProviderDescription": "Exemple de passerelle de paiement"
},
"paymentSettings": {
"examplePaymentLabel": "Exemple de passerelle de paiement",
"examplePaymentSettingsLabel": "Exemple de passerelle de paiement",
"exampleCredentials": "Ceci est un exemple de paramètre de plateforme de paiement.",
"apiClientId": "API ID client",
"supportedMethodsLabel": "Fonctions supportées par la passerelle de paiement"
}
}
}
}
}]

+ 26
- 0
src/i18n/he.json View File

@ -0,0 +1,26 @@
[{
"language": "Hebrew",
"i18n": "he",
"ns": "example-paymentmethod",
"translation": {
"example-paymentmethod": {
"admin": {
"shortcut": {
"examplePaymentProviderLabel": "תשלום לדוגמה",
"examplePaymentProviderTitle": "תשלום לדוגמה"
},
"dashboard": {
"examplePaymentProviderLabel": "תשלום לדוגמה",
"examplePaymentProviderTitle": "תשלום לדוגמה",
"examplePaymentProviderDescription": "שיטת תשלום לדוגמה"
},
"paymentSettings": {
"examplePaymentLabel": "ספק לדוגמה",
"examplePaymentSettingsLabel": "תשלום לדוגמה",
"exampleCredentials": "זוהי הגדרה של שיטת תשלום לדוגמה.",
"apiClientId": "מזהה לקוח API"
}
}
}
}
}]

+ 27
- 0
src/i18n/hr.json View File

@ -0,0 +1,27 @@
[{
"language": "Croatian",
"i18n": "hr",
"ns": "example-paymentmethod",
"translation": {
"example-paymentmethod": {
"admin": {
"shortcut": {
"examplePaymentProviderLabel": "Primjer plaćanja",
"examplePaymentProviderTitle": "Primjer plaćanja"
},
"dashboard": {
"examplePaymentProviderLabel": "Primjer plaćanja",
"examplePaymentProviderTitle": "Primjer plaćanja",
"examplePaymentProviderDescription": "Primjer Način plaćanja"
},
"paymentSettings": {
"examplePaymentLabel": "Primjer Provider",
"examplePaymentSettingsLabel": "Primjer plaćanja",
"exampleCredentials": "To je postavka primjer načina plaćanja.",
"apiClientId": "ID API klijenta",
"supportedMethodsLabel": "Metode plaćanja pružatelja usluga plaćanja"
}
}
}
}
}]

+ 27
- 0
src/i18n/hu.json View File

@ -0,0 +1,27 @@
[{
"language": "Hungarian",
"i18n": "hu",
"ns": "example-paymentmethod",
"translation": {
"example-paymentmethod": {
"admin": {
"shortcut": {
"examplePaymentProviderLabel": "példa Fizetési",
"examplePaymentProviderTitle": "példa Fizetési"
},
"dashboard": {
"examplePaymentProviderLabel": "példa Fizetési",
"examplePaymentProviderTitle": "példa Fizetési",
"examplePaymentProviderDescription": "Példa Fizetési mód"
},
"paymentSettings": {
"examplePaymentLabel": "példa Szolgáltató",
"examplePaymentSettingsLabel": "példa Fizetési",
"exampleCredentials": "Ez egy példa a fizetési módszer beállítást.",
"apiClientId": "API ügyfél azonosító",
"supportedMethodsLabel": "Fizetés szolgáltatója támogatott módszerekkel"
}
}
}
}
}]

+ 58
- 0
src/i18n/index.js View File

@ -0,0 +1,58 @@
import ar from "./ar.json";
import bg from "./bg.json";
import cs from "./cs.json";
import de from "./de.json";
import el from "./el.json";
import en from "./en.json";
import es from "./es.json";
import fr from "./fr.json";
import he from "./he.json";
import hr from "./hr.json";
import hu from "./hu.json";
import it from "./it.json";
import my from "./my.json";
import nb from "./nb.json";
import nl from "./nl.json";
import pl from "./pl.json";
import pt from "./pt.json";
import ro from "./ro.json";
import ru from "./ru.json";
import sl from "./sl.json";
import sv from "./sv.json";
import tr from "./tr.json";
import vi from "./vi.json";
import zh from "./zh.json";
//
// we want all the files in individual
// imports for easier handling by
// automated translation software
//
export default {
translations: [
...ar,
...bg,
...cs,
...de,
...el,
...en,
...es,
...fr,
...he,
...hr,
...hu,
...it,
...my,
...nb,
...nl,
...pl,
...pt,
...ro,
...ru,
...sl,
...sv,
...tr,
...vi,
...zh
]
};

+ 27
- 0
src/i18n/it.json View File

@ -0,0 +1,27 @@
[{
"language": "Italian",
"i18n": "it",
"ns": "example-paymentmethod",
"translation": {
"example-paymentmethod": {
"admin": {
"shortcut": {
"examplePaymentProviderLabel": "esempio di pagamento",
"examplePaymentProviderTitle": "esempio di pagamento"
},
"dashboard": {
"examplePaymentProviderLabel": "esempio di pagamento",
"examplePaymentProviderTitle": "esempio di pagamento",
"examplePaymentProviderDescription": "Esempio Metodo di pagamento"
},
"paymentSettings": {
"examplePaymentLabel": "Provider esempio",
"examplePaymentSettingsLabel": "esempio di pagamento",
"exampleCredentials": "Questo è un esempio di dichiarazione metodo di pagamento.",
"apiClientId": "API Client ID",
"supportedMethodsLabel": "I fornitori di pagamento hanno sostenuto metodi"
}
}
}
}
}]

+ 27
- 0
src/i18n/my.json View File

@ -0,0 +1,27 @@
[{
"language": "Burmese",
"i18n": "my",
"ns": "example-paymentmethod",
"translation": {
"example-paymentmethod": {
"admin": {
"shortcut": {
"examplePaymentProviderLabel": "ဥပမာအားငွေပေးချေမှုရမည့်",
"examplePaymentProviderTitle": "ဥပမာအားငွေပေးချေမှုရမည့်"
},
"dashboard": {
"examplePaymentProviderLabel": "ဥပမာအားငွေပေးချေမှုရမည့်",
"examplePaymentProviderTitle": "ဥပမာအားငွေပေးချေမှုရမည့်",
"examplePaymentProviderDescription": "ဥပမာအားငွေပေးချေမှုရမည့်နည်းလမ်း"
},
"paymentSettings": {
"examplePaymentLabel": "ဥပမာအားပေးသူ",
"examplePaymentSettingsLabel": "ဥပမာအားငွေပေးချေမှုရမည့်",
"exampleCredentials": "ဒါကဥပမာတစ်ခုပေးချေမှုနည်းလမ်း setting ကိုဖြစ်ပါတယ်။",
"apiClientId": "API ကိုလိုင်း ID ကို",
"supportedMethodsLabel": "ငွေပေးချေမှုရမည့်ပံ့ပိုးပေးနည်းလမ်းများကိုထောက်ခံ"
}
}
}
}
}]

+ 6
- 0
src/i18n/nb.json View File

@ -0,0 +1,6 @@
[{
"language": "Bokmål",
"i18n": "nb",
"ns": "example-paymentmethod",
"translation": { }
}]

+ 27
- 0
src/i18n/nl.json View File

@ -0,0 +1,27 @@
[{
"language": "Dutch",
"i18n": "nl",
"ns": "example-paymentmethod",
"translation": {
"example-paymentmethod": {
"admin": {
"shortcut": {
"examplePaymentProviderLabel": "voorbeeld Betaling",
"examplePaymentProviderTitle": "voorbeeld Betaling"
},
"dashboard": {
"examplePaymentProviderLabel": "voorbeeld Betaling",
"examplePaymentProviderTitle": "voorbeeld Betaling",
"examplePaymentProviderDescription": "Voorbeeld Payment Method"
},
"paymentSettings": {
"examplePaymentLabel": "voorbeeld Provider",
"examplePaymentSettingsLabel": "voorbeeld Betaling",
"exampleCredentials": "Dit is een voorbeeld betaalmethode setting.",
"apiClientId": "API Client ID",
"supportedMethodsLabel": "Betaalmethoden ondersteunde methoden"
}
}
}
}
}]

+ 27
- 0
src/i18n/pl.json View File

@ -0,0 +1,27 @@
[{
"language": "Polish",
"i18n": "pl",
"ns": "example-paymentmethod",
"translation": {
"example-paymentmethod": {
"admin": {
"shortcut": {
"examplePaymentProviderLabel": "Przykład Płatność",
"examplePaymentProviderTitle": "Przykład Płatność"
},
"dashboard": {
"examplePaymentProviderLabel": "Przykład Płatność",
"examplePaymentProviderTitle": "Przykład Płatność",
"examplePaymentProviderDescription": "Przykład Metoda płatności"
},
"paymentSettings": {
"examplePaymentLabel": "Przykład Provider",
"examplePaymentSettingsLabel": "Przykład Płatność",
"exampleCredentials": "czy jest to ustawienie przykładem formy płatności.",
"apiClientId": "API ID klienta",
"supportedMethodsLabel": "Metody obsługi obsługi dostawców płatności"
}
}
}
}
}]

+ 27
- 0
src/i18n/pt.json View File

@ -0,0 +1,27 @@
[{
"language": "Portuguese",
"i18n": "pt",
"ns": "example-paymentmethod",
"translation": {
"example-paymentmethod": {
"admin": {
"shortcut": {
"examplePaymentProviderLabel": "exemplo de pagamento",
"examplePaymentProviderTitle": "exemplo de pagamento"
},
"dashboard": {
"examplePaymentProviderLabel": "exemplo de pagamento",
"examplePaymentProviderTitle": "exemplo de pagamento",
"examplePaymentProviderDescription": "Método de pagamento Exemplo"
},
"paymentSettings": {
"examplePaymentLabel": "exemplo de Provedor",
"examplePaymentSettingsLabel": "exemplo de pagamento",
"exampleCredentials": "Esta é uma configuração exemplo do método de pagamento.",
"apiClientId": "API ID do cliente",
"supportedMethodsLabel": "Métodos suportados pelo provedor de pagamento"
}
}
}
}
}]

+ 27
- 0
src/i18n/ro.json View File

@ -0,0 +1,27 @@
[{
"language": "Romanian",
"i18n": "ro",
"ns": "example-paymentmethod",
"translation": {
"example-paymentmethod": {
"admin": {
"shortcut": {
"examplePaymentProviderLabel": "Exemplul de plată",
"examplePaymentProviderTitle": "Exemplul de plată"
},
"dashboard": {
"examplePaymentProviderLabel": "Exemplul de plată",
"examplePaymentProviderTitle": "Exemplul de plată",
"examplePaymentProviderDescription": "Exemplul Metoda de plată"
},
"paymentSettings": {
"examplePaymentLabel": "Exemplul Provider",
"examplePaymentSettingsLabel": "Exemplul de plată",
"exampleCredentials": "Aceasta este o setare exemplu metodă de plată.",
"apiClientId": "ID-ul client API",
"supportedMethodsLabel": "Metode acceptate de furnizor de plăți"
}
}
}
}
}]

+ 27
- 0
src/i18n/ru.json View File

@ -0,0 +1,27 @@
[{
"language": "Russian",
"i18n": "ru",
"ns": "example-paymentmethod",
"translation": {
"example-paymentmethod": {
"admin": {
"shortcut": {
"examplePaymentProviderLabel": "Пример оплаты",
"examplePaymentProviderTitle": "Пример оплаты"
},
"dashboard": {
"examplePaymentProviderLabel": "Пример оплаты",
"examplePaymentProviderTitle": "Пример оплаты",
"examplePaymentProviderDescription": "Пример Способ оплаты"
},
"paymentSettings": {
"examplePaymentLabel": "Пример Провайдер",
"examplePaymentSettingsLabel": "Пример оплаты",
"exampleCredentials": "Это установка пример способ оплаты.",
"apiClientId": "API идентификатор клиента",
"supportedMethodsLabel": "Поддерживаемые методы поставщика платежей"
}
}
}
}
}]

+ 27
- 0
src/i18n/sl.json View File

@ -0,0 +1,27 @@
[{
"language": "Slovenian",
"i18n": "sl",
"ns": "example-paymentmethod",
"translation": {
"example-paymentmethod": {
"admin": {
"shortcut": {
"examplePaymentProviderLabel": "Primer plačila",
"examplePaymentProviderTitle": "Primer plačila"
},
"dashboard": {
"examplePaymentProviderLabel": "Primer plačila",
"examplePaymentProviderTitle": "Primer plačila",
"examplePaymentProviderDescription": "Primer Način plačila"
},
"paymentSettings": {
"examplePaymentLabel": "Ponudnik Primer",
"examplePaymentSettingsLabel": "Primer plačila",
"exampleCredentials": "To je nastavitev metoda plačila primer.",
"apiClientId": "API ID odjemalca",
"supportedMethodsLabel": "ponudnik plačilnih podprte metode"
}
}
}
}
}]

+ 27
- 0
src/i18n/sv.json View File

@ -0,0 +1,27 @@
[{
"language": "Swedish",
"i18n": "sv",
"ns": "example-paymentmethod",
"translation": {
"example-paymentmethod": {
"admin": {
"shortcut": {
"examplePaymentProviderLabel": "exempel Betalning",
"examplePaymentProviderTitle": "exempel Betalning"
},
"dashboard": {
"examplePaymentProviderLabel": "exempel Betalning",
"examplePaymentProviderTitle": "exempel Betalning",
"examplePaymentProviderDescription": "Exempel betalningsmetod"
},
"paymentSettings": {
"examplePaymentLabel": "exempel Provider",
"examplePaymentSettingsLabel": "exempel Betalning",
"exampleCredentials": "Detta är ett exempel betalningsmetod inställning.",
"apiClientId": "API-klient-ID",
"supportedMethodsLabel": "Betalningsleverantörens stödda metoder"
}
}
}
}
}]

+ 27
- 0
src/i18n/tr.json View File

@ -0,0 +1,27 @@
[{
"language": "Turkish",
"i18n": "tr",
"ns": "example-paymentmethod",
"translation": {
"example-paymentmethod": {
"admin": {
"shortcut": {
"examplePaymentProviderLabel": "Örnek Ödeme",
"examplePaymentProviderTitle": "Örnek Ödeme"
},
"dashboard": {
"examplePaymentProviderLabel": "Örnek Ödeme",
"examplePaymentProviderTitle": "Örnek Ödeme",
"examplePaymentProviderDescription": "Örnek Ödeme Yöntemi"
},
"paymentSettings": {
"examplePaymentLabel": "Örnek Sağlayıcı",
"examplePaymentSettingsLabel": "Örnek Ödeme",
"exampleCredentials": "Bu örnek bir ödeme yöntemi ayarıdır.",
"apiClientId": "API İstemci Kimliği",
"supportedMethodsLabel": "Ödeme sağlayıcısı tarafından desteklenen yöntemler"
}
}
}
}
}]

+ 27
- 0
src/i18n/vi.json View File

@ -0,0 +1,27 @@
[{
"language": "Vietnamese",
"i18n": "vi",
"ns": "example-paymentmethod",
"translation": {
"example-paymentmethod": {
"admin": {
"shortcut": {
"examplePaymentProviderLabel": "Ví dụ thanh toán",
"examplePaymentProviderTitle": "Ví dụ thanh toán"
},
"dashboard": {
"examplePaymentProviderLabel": "Ví dụ thanh toán",
"examplePaymentProviderTitle": "Ví dụ thanh toán",
"examplePaymentProviderDescription": "Phương thức thanh toán Ví dụ"
},
"paymentSettings": {
"examplePaymentLabel": "Nhà cung cấp ví dụ",
"examplePaymentSettingsLabel": "Ví dụ thanh toán",
"exampleCredentials": "Đây là cài đặt phương thức thanh toán ví dụ.",
"apiClientId": "ID Client API",
"supportedMethodsLabel": "Phương thức hỗ trợ nhà cung cấp thanh toán"
}
}
}
}
}]

+ 27
- 0
src/i18n/zh.json View File

@ -0,0 +1,27 @@
[{
"language": "Chinese",
"i18n": "zh",
"ns": "example-paymentmethod",
"translation": {
"example-paymentmethod": {
"admin": {
"shortcut": {
"examplePaymentProviderLabel": "例如付款",
"examplePaymentProviderTitle": "例如付款"
},
"dashboard": {
"examplePaymentProviderLabel": "例如付款",
"examplePaymentProviderTitle": "例如付款",
"examplePaymentProviderDescription": "例如付款方法"
},
"paymentSettings": {
"examplePaymentLabel": "例如供应商",
"examplePaymentSettingsLabel": "例如付款",
"exampleCredentials": "这是一个例子付款方式设置。",
"apiClientId": "API客户端ID",
"supportedMethodsLabel": "付款提供商支持的方法"
}
}
}
}
}]

+ 38
- 0
src/index.js View File

@ -0,0 +1,38 @@
import i18n from "./i18n/index.js";
import schemas from "./schemas/index.js";
import exampleCapturePayment from "./util/exampleCapturePayment.js";
import exampleCreateAuthorizedPayment from "./util/exampleCreateAuthorizedPayment.js";
import exampleCreateRefund from "./util/exampleCreateRefund.js";
import exampleListRefunds from "./util/exampleListRefunds.js";
import startup from "./startup.js";
/**
* @summary Import and call this function to add this plugin to your API.
* @param {ReactionAPI} app The ReactionAPI instance
* @returns {undefined}
*/
export default async function register(app) {
await app.registerPlugin({
label: "ExamplePayment",
name: "example-paymentmethod",
version: app.context.appVersion,
i18n,
graphQL: {
schemas
},
functionsByType: {
startup: [startup]
},
paymentMethods: [{
name: "iou_example",
canRefund: true,
displayName: "IOU Example",
functions: {
capturePayment: exampleCapturePayment,
createAuthorizedPayment: exampleCreateAuthorizedPayment,
createRefund: exampleCreateRefund,
listRefunds: exampleListRefunds
}
}]
});
}

+ 5
- 0
src/schemas/index.js View File

@ -0,0 +1,5 @@
import importAsString from "@reactioncommerce/api-utils/importAsString.js";
const schema = importAsString("./schema.graphql");
export default [schema];

+ 20
- 0
src/schemas/schema.graphql View File

@ -0,0 +1,20 @@
"Data for an example IOU payment"
type ExampleIOUPaymentData {
"The name of the IOU payer entered by the shopper"
fullName: String!
}
extend union PaymentData = ExampleIOUPaymentData
"Data for an example IOU payment method"
type ExampleIOUPaymentMethodData {
"Example"
example: String!
}
extend union PaymentMethodData = ExampleIOUPaymentMethodData
extend enum PaymentMethodName {
"IOU Example payment method"
iou_example
}

+ 9
- 0
src/startup.js View File

@ -0,0 +1,9 @@
/**
* @summary Called on startup
* @param {Object} context Startup context
* @param {Object} context.collections Map of MongoDB collections
* @returns {undefined}
*/
export default function exampleIOUPaymentsStartup(context) {
context.collections.ExampleIOUPaymentRefunds = context.app.db.collection("ExampleIOUPaymentRefunds");
}

+ 12
- 0
src/util/exampleCapturePayment.js View File

@ -0,0 +1,12 @@
/**
* @name exampleCapturePayment
* @method
* @summary Capture payment for Example payment method
* @param {Object} context an object containing the per-request state
* @param {Object} payment object containing authorization ID
* @returns {Object} result for capturing a payment
* @private
*/
export default function exampleCapturePayment() {
return { saved: true, response: {} };
}

+ 49
- 0
src/util/exampleCreateAuthorizedPayment.js View File

@ -0,0 +1,49 @@
import Random from "@reactioncommerce/random";
const METHOD = "credit";
const PACKAGE_NAME = "example-paymentmethod";
const PAYMENT_METHOD_NAME = "iou_example";
// NOTE: The "processor" value is lowercased and then prefixed to various payment Meteor method names,
// so for example, if this is "Example", the list refunds method is expected to be named "example/refund/list"
const PROCESSOR = "Example";
/**
* @summary As an example and for demos, this non-production payment method creates a payment
* without charging any credit card
* @param {Object} context The request context
* @param {Object} input Input necessary to create a payment
* @returns {Object} The payment object in schema expected by the orders plugin
*/
export default async function exampleCreateAuthorizedPayment(context, input) {
const {
amount,
billingAddress,
shopId,
paymentData: {
fullName
}
} = input;
return {
_id: Random.id(),
address: billingAddress,
amount,
createdAt: new Date(),
data: {
fullName,
gqlType: "ExampleIOUPaymentData" // GraphQL union resolver uses this
},
displayName: `IOU from ${fullName}`,
method: METHOD,
mode: "authorize",
name: PAYMENT_METHOD_NAME,
paymentPluginName: PACKAGE_NAME,
processor: PROCESSOR,
riskLevel: "normal",
shopId,
status: "created",
transactionId: Random.id(),
transactions: []
};
}

+ 22
- 0
src/util/exampleCreateRefund.js View File

@ -0,0 +1,22 @@
/**
* @name exampleCreateRefund
* @method
* @summary Create a refund for an order for example payment method
* @param {Object} context an object containing the per-request state
* @param {Object} payment object containing transaction ID
* @param {Number} amount the amount to be refunded
* @param {String} [reason] the reason for the refund
* @returns {Object} refund result
* @private
*/
export default async function exampleCreateRefund(context, payment, amount, reason) {
const { currencyCode, transactionId } = payment;
await context.collections.ExampleIOUPaymentRefunds.insertOne({
amount,
createdAt: new Date(),
currencyCode,
reason,
transactionId
});
return { saved: true };
}

+ 24
- 0
src/util/exampleListRefunds.js View File

@ -0,0 +1,24 @@
/**
* @name exampleListRefunds
* @method
* @summary List refunds
* @param {Object} context an object containing the per-request state
* @param {Object} payment object containing transaction ID
* @returns {Object} refund result
* @private
*/
export default async function exampleListRefunds(context, payment) {
const { transactionId } = payment;
const refunds = await context.collections.ExampleIOUPaymentRefunds.find({ transactionId }).toArray();
return refunds.map((refund) => ({
_id: refund._id,
amount: refund.amount,
created: refund.createdAt.getTime(),
currency: refund.currencyCode,
raw: {},
reason: refund.reason,
type: "refund"
}));
}

Loading…
Cancel
Save