{"_id":"@andev2005/momo-sdk","_rev":"7-8bdabaddaaea29767a7e686d9dace74f","name":"@andev2005/momo-sdk","dist-tags":{"latest":"1.1.1"},"versions":{"1.0.0":{"name":"@andev2005/momo-sdk","version":"1.0.0","keywords":["momo","payment","sdk","typescript"],"license":"MIT","_id":"@andev2005/momo-sdk@1.0.0","maintainers":[{"name":"thaianthedev","email":"thaianthedev@gmail.com"}],"dist":{"shasum":"62b2f4aff0c5a56e434c4ef897cc52b5e0c2ed15","tarball":"https://registry.npmjs.org/@andev2005/momo-sdk/-/momo-sdk-1.0.0.tgz","fileCount":16,"integrity":"sha512-RCtsFGdSD4Y29IRq2nCokMTKg+Ip/qZcTY3EdPmX+NbAq2amkYGsv3JBNldxjzs8pAYo3lWyPaTZBvKiJLU/hg==","signatures":[{"sig":"MEUCIQDms1vwj00YZR9XcuMHhvSdzlUruOKH76pq8DTzr7LWTwIgebcHS57YY/jjM3j7ZAo3yhN/5M9xzN8czew7VJjyOeM=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":19668},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"gitHead":"0856dd1f06bf9684aefd422caf33387d1b20c24f","scripts":{"test":"node --test --enable-source-maps dist/test","build":"tsc -p tsconfig.json","clean":"rm -rf dist","pretest":"npm run build"},"_npmUser":{"name":"thaianthedev","email":"thaianthedev@gmail.com"},"_npmVersion":"11.10.0","description":"MoMo Payment API v2 SDK","directories":{},"_nodeVersion":"20.20.0","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.8.2","@types/node":"^22.13.0"},"_npmOperationalInternal":{"tmp":"tmp/momo-sdk_1.0.0_1773223426305_0.21984699856269407","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@andev2005/momo-sdk","version":"1.0.1","keywords":["momo","payment","sdk","typescript"],"license":"MIT","_id":"@andev2005/momo-sdk@1.0.1","maintainers":[{"name":"thaianthedev","email":"thaianthedev@gmail.com"}],"homepage":"https://github.com/thaiannguyen-05/momo-sdk#readme","bugs":{"url":"https://github.com/thaiannguyen-05/momo-sdk/issues"},"dist":{"shasum":"044bc1362d3fe74c5864eb4b2a3bfba4eb7868a1","tarball":"https://registry.npmjs.org/@andev2005/momo-sdk/-/momo-sdk-1.0.1.tgz","fileCount":2,"integrity":"sha512-1GhKgtlKUuSVZHdLIkYuujbENcasFeuEXV/0FHt7H1FIHeZ2eRjdw9/qmgLK6Ce3l/yo0DRKiEeFLY9yMr5nPw==","signatures":[{"sig":"MEQCIFaisioHYu8KbswV1dgG+6FI2etLMKPIeHhGQCrxSl1+AiAWxlqLQPuusiV4Ik30FIsgMY8F5F6IriMNp0b0Fx+dZw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":3749},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"gitHead":"83698a6101c3ea4d110cdfb91c84bfe635267eb8","scripts":{"test":"node --test --enable-source-maps dist/test","build":"tsc -p tsconfig.json","clean":"rm -rf dist","pretest":"npm run build"},"_npmUser":{"name":"thaianthedev","email":"thaianthedev@gmail.com"},"repository":{"url":"git+https://github.com/thaiannguyen-05/momo-sdk.git","type":"git"},"_npmVersion":"11.10.0","description":"MoMo Payment API v2 SDK","directories":{},"_nodeVersion":"20.20.0","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.8.2","@types/node":"^22.13.0"},"_npmOperationalInternal":{"tmp":"tmp/momo-sdk_1.0.1_1773223660387_0.4637518818388122","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@andev2005/momo-sdk","version":"1.0.2","keywords":["momo","payment","sdk","typescript"],"license":"MIT","_id":"@andev2005/momo-sdk@1.0.2","maintainers":[{"name":"thaianthedev","email":"thaianthedev@gmail.com"}],"homepage":"https://github.com/thaiannguyen-05/momo-sdk#readme","bugs":{"url":"https://github.com/thaiannguyen-05/momo-sdk/issues"},"dist":{"shasum":"a743a249b0226bdbe847fd99318d516298e207f9","tarball":"https://registry.npmjs.org/@andev2005/momo-sdk/-/momo-sdk-1.0.2.tgz","fileCount":14,"integrity":"sha512-rAQzGiMUWPXwYa4HZs3sOL53drxSt9sUkSv9ktRL2mnRpezrxtdZQa6bkSvPrcXITpwwtvBuRsPrBtkssW+tuA==","signatures":[{"sig":"MEUCIQDGwuT2hcA/Ne7z/ag6c0S05xoI+Dob0CSmLsduTKy3JwIgXsebXyxjnEgGUK5bBn1kEG02QFj19n6+wIrJdyL/e7Q=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":18027},"main":"./dist/src/index.js","type":"module","types":"./dist/src/index.d.ts","engines":{"node":">=18"},"exports":{".":{"types":"./dist/src/index.d.ts","default":"./dist/src/index.js"}},"gitHead":"83698a6101c3ea4d110cdfb91c84bfe635267eb8","scripts":{"test":"node --test --enable-source-maps dist/test","build":"tsc -p tsconfig.json","clean":"rm -rf dist","prepack":"npm run clean && npm run build","pretest":"npm run build","prepublishOnly":"npm run prepack"},"_npmUser":{"name":"thaianthedev","email":"thaianthedev@gmail.com"},"repository":{"url":"git+https://github.com/thaiannguyen-05/momo-sdk.git","type":"git"},"_npmVersion":"11.10.0","description":"MoMo Payment API v2 SDK","directories":{},"_nodeVersion":"20.20.0","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.8.2","@types/node":"^22.13.0"},"_npmOperationalInternal":{"tmp":"tmp/momo-sdk_1.0.2_1773224600423_0.39648744838102834","host":"s3://npm-registry-packages-npm-production"}},"1.0.3":{"name":"@andev2005/momo-sdk","version":"1.0.3","keywords":["momo","payment","sdk","typescript"],"license":"MIT","_id":"@andev2005/momo-sdk@1.0.3","maintainers":[{"name":"thaianthedev","email":"thaianthedev@gmail.com"}],"homepage":"https://github.com/thaiannguyen-05/momo-sdk#readme","bugs":{"url":"https://github.com/thaiannguyen-05/momo-sdk/issues"},"dist":{"shasum":"2b87f8a0a038be6dc52662e5fc718dae36dcc83f","tarball":"https://registry.npmjs.org/@andev2005/momo-sdk/-/momo-sdk-1.0.3.tgz","fileCount":14,"integrity":"sha512-Vx1EBXGzKlVAqv8dJd80EutfFUbJo9wRTUVsoAmQ1tjQlZcKmxWR4GT30qhSiqjDaccEgRgXriCw41Q+21DAXQ==","signatures":[{"sig":"MEUCIEi1TiydAbJk6hglR5qTx9xDb8obl4KBD3dwTFa7nlZMAiEA2IscDxE45PxXMLivxjBDaFhB3T2bwG1LAwqYrDC0KzQ=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":18343},"main":"./dist/src/index.js","type":"module","types":"./dist/src/index.d.ts","engines":{"node":">=18"},"exports":{".":{"types":"./dist/src/index.d.ts","default":"./dist/src/index.js"}},"gitHead":"83698a6101c3ea4d110cdfb91c84bfe635267eb8","scripts":{"test":"node --test --enable-source-maps dist/test","build":"tsc -p tsconfig.json","clean":"rm -rf dist","prepack":"npm run clean && npm run build","pretest":"npm run build","prepublishOnly":"npm run prepack"},"_npmUser":{"name":"thaianthedev","email":"thaianthedev@gmail.com"},"repository":{"url":"git+https://github.com/thaiannguyen-05/momo-sdk.git","type":"git"},"_npmVersion":"11.10.0","description":"MoMo Payment API v2 SDK","directories":{},"_nodeVersion":"20.20.0","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.8.2","@types/node":"^22.13.0"},"_npmOperationalInternal":{"tmp":"tmp/momo-sdk_1.0.3_1773229559613_0.5459450918909574","host":"s3://npm-registry-packages-npm-production"}},"1.0.4":{"name":"@andev2005/momo-sdk","version":"1.0.4","keywords":["momo","payment","sdk","typescript"],"license":"MIT","_id":"@andev2005/momo-sdk@1.0.4","maintainers":[{"name":"thaianthedev","email":"thaianthedev@gmail.com"}],"homepage":"https://github.com/thaiannguyen-05/momo-sdk#readme","bugs":{"url":"https://github.com/thaiannguyen-05/momo-sdk/issues"},"dist":{"shasum":"f650f1c02a419c520527de9784a36e8265747c61","tarball":"https://registry.npmjs.org/@andev2005/momo-sdk/-/momo-sdk-1.0.4.tgz","fileCount":14,"integrity":"sha512-uYfbp61ibdtDpARrT8ttM3oEcth85Z3jIqHZ+z5qn71WkZrvhHZxjHDOqpV1uM1bwUMX2jgql8pWxydutMkxvA==","signatures":[{"sig":"MEUCIBVl+9cxRmjv5UEj9AcY8d8kgyQDqWbVn1GQ2AHgXDbzAiEAuuap23w7gic+7XBl00GFcdgDWGcPPD43/0ddxLlfZrM=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":18450},"main":"./dist/src/index.js","type":"module","types":"./dist/src/index.d.ts","engines":{"node":">=18"},"exports":{".":{"types":"./dist/src/index.d.ts","default":"./dist/src/index.js"}},"gitHead":"83698a6101c3ea4d110cdfb91c84bfe635267eb8","scripts":{"test":"node --test --enable-source-maps dist/test","build":"tsc -p tsconfig.json","clean":"rm -rf dist","prepack":"npm run clean && npm run build","pretest":"npm run build","prepublishOnly":"npm run prepack"},"_npmUser":{"name":"thaianthedev","email":"thaianthedev@gmail.com"},"repository":{"url":"git+https://github.com/thaiannguyen-05/momo-sdk.git","type":"git"},"_npmVersion":"11.10.0","description":"MoMo Payment API v2 SDK","directories":{},"_nodeVersion":"20.20.0","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.8.2","@types/node":"^22.13.0"},"_npmOperationalInternal":{"tmp":"tmp/momo-sdk_1.0.4_1773229697114_0.25804068538522906","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"@andev2005/momo-sdk","version":"1.1.0","keywords":["momo","payment","sdk","typescript"],"license":"MIT","_id":"@andev2005/momo-sdk@1.1.0","maintainers":[{"name":"thaianthedev","email":"thaianthedev@gmail.com"}],"homepage":"https://github.com/thaiannguyen-05/momo-sdk#readme","bugs":{"url":"https://github.com/thaiannguyen-05/momo-sdk/issues"},"dist":{"shasum":"178c90c99aad832bc5877ab6c5ac7c9d988f94f5","tarball":"https://registry.npmjs.org/@andev2005/momo-sdk/-/momo-sdk-1.1.0.tgz","fileCount":14,"integrity":"sha512-zjmI2Owpn5f1cRs4cUXY+h7nVzHvJPLGi0IDseFWZSZzfvneIyQ21WtNAKrOlsmZMmErI/8uKLMxvihRBiAgvA==","signatures":[{"sig":"MEYCIQD7JvYLQ7Ba912rK7GM5q7TZcTmNvmz4+oACnaJ9uL2KQIhANw30w++j9fVANO7MH8Tj5LIXo/DJicq+zhMf/DndLCP","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":20059},"main":"./dist/src/index.js","type":"module","types":"./dist/src/index.d.ts","engines":{"node":">=18"},"exports":{".":{"types":"./dist/src/index.d.ts","default":"./dist/src/index.js"}},"gitHead":"fb458296e17163682c235f0396cfc47c0993bf71","scripts":{"test":"node --test --enable-source-maps dist/test","build":"tsc -p tsconfig.json","clean":"rm -rf dist","prepack":"npm run clean && npm run build","pretest":"npm run build","prepublishOnly":"npm run prepack"},"_npmUser":{"name":"thaianthedev","email":"thaianthedev@gmail.com"},"repository":{"url":"git+https://github.com/thaiannguyen-05/momo-sdk.git","type":"git"},"_npmVersion":"11.10.0","description":"MoMo Payment API v2 SDK","directories":{},"_nodeVersion":"20.20.0","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.8.2","@types/node":"^22.13.0"},"_npmOperationalInternal":{"tmp":"tmp/momo-sdk_1.1.0_1773493607233_0.902295009880947","host":"s3://npm-registry-packages-npm-production"}},"1.1.1":{"name":"@andev2005/momo-sdk","version":"1.1.1","description":"MoMo Payment API v2 SDK","type":"module","main":"./dist/src/index.js","types":"./dist/src/index.d.ts","repository":{"type":"git","url":"git+https://github.com/thaiannguyen-05/momo-sdk.git"},"exports":{".":{"types":"./dist/src/index.d.ts","default":"./dist/src/index.js"}},"scripts":{"build":"tsc -p tsconfig.json","clean":"rm -rf dist","prepack":"npm run clean && npm run build","prepublishOnly":"npm run prepack","test":"node --test --enable-source-maps dist/test","pretest":"npm run build"},"keywords":["momo","payment","sdk","typescript"],"license":"MIT","devDependencies":{"@types/node":"^22.13.0","typescript":"^5.8.2"},"engines":{"node":">=18"},"gitHead":"fb458296e17163682c235f0396cfc47c0993bf71","_id":"@andev2005/momo-sdk@1.1.1","bugs":{"url":"https://github.com/thaiannguyen-05/momo-sdk/issues"},"homepage":"https://github.com/thaiannguyen-05/momo-sdk#readme","_nodeVersion":"20.20.0","_npmVersion":"11.10.0","dist":{"integrity":"sha512-ptdN1rbsiuJ+eYIk76l8nMDz5GupVa3lMx2tIQ/xtYI+slIq4LGPi5q/dBTvGk99XUAzti27zODyF0jq+Y7pDw==","shasum":"1cd53910384fa2ba9ed1a217992e5179bd752158","tarball":"https://registry.npmjs.org/@andev2005/momo-sdk/-/momo-sdk-1.1.1.tgz","fileCount":14,"unpackedSize":19655,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCUPZPg2LDCbEEe6UNQw03y1y5iNe4uxSdMTJ4a7wPEmAIgBUAUd+aI2+TEu5hO5n0gGvH2WsIoqy8QCbHFdJGmYvQ="}]},"_npmUser":{"name":"thaianthedev","email":"thaianthedev@gmail.com"},"directories":{},"maintainers":[{"name":"thaianthedev","email":"thaianthedev@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/momo-sdk_1.1.1_1773494058529_0.544658993987388"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-11T10:03:46.179Z","modified":"2026-03-14T13:14:18.857Z","1.0.0":"2026-03-11T10:03:46.428Z","1.0.1":"2026-03-11T10:07:40.523Z","1.0.2":"2026-03-11T10:23:20.565Z","1.0.3":"2026-03-11T11:45:59.768Z","1.0.4":"2026-03-11T11:48:17.255Z","1.1.0":"2026-03-14T13:06:47.391Z","1.1.1":"2026-03-14T13:14:18.695Z"},"bugs":{"url":"https://github.com/thaiannguyen-05/momo-sdk/issues"},"license":"MIT","homepage":"https://github.com/thaiannguyen-05/momo-sdk#readme","keywords":["momo","payment","sdk","typescript"],"repository":{"type":"git","url":"git+https://github.com/thaiannguyen-05/momo-sdk.git"},"description":"MoMo Payment API v2 SDK","maintainers":[{"name":"thaianthedev","email":"thaianthedev@gmail.com"}],"readme":"# momo-sdk\n\nTypeScript SDK for MoMo Payment API v2 (`/v2/gateway/api/*`) with strict typing, HMAC signing, webhook signature verification, and production-ready error handling.\n\n## Features\n\n- Typed methods: `createPayment`, `queryTransaction`, `refund`, `queryRefundStatus`\n- HMAC SHA256 signing using official MoMo raw signature field order\n- Webhook/IPN signature verification helper\n- Built-in timeout and normalized errors (`MomoSdkError`, `MomoApiError`)\n- Works on Node.js >= 18\n\n## Install\n\n```bash\nnpm install momo-sdk\n```\n\nFor local development in this repo:\n\n```bash\nnpm install\nnpm run build\nnpm test\n```\n\n## Quick Start\n\n```ts\nimport { MomoClient } from \"momo-sdk\";\n\nconst momo = new MomoClient({\n  partnerCode: process.env.MOMO_PARTNER_CODE!,\n  accessKey: process.env.MOMO_ACCESS_KEY!,\n  secretKey: process.env.MOMO_SECRET_KEY!,\n  env: \"sandbox\" // or \"production\"\n});\n\nconst payment = await momo.createPayment({\n  amount: 150000,\n  orderId: `order-${Date.now()}`,\n  orderInfo: \"Thanh toan don hang #123\",\n  redirectUrl: \"https://your-site.com/payment/return\",\n  ipnUrl: \"https://your-api.com/payment/momo/ipn\",\n  extraData: \"\",\n  requestType: \"captureWallet\",\n  autoCapture: true,\n  lang: \"vi\"\n});\n\nconsole.log(payment.payUrl);\n```\n\n## API\n\n### `createPayment(request)`\n\n- Calls `POST /v2/gateway/api/create`\n- Auto-generates `requestId`\n- Signs payload with field order:\n  `accessKey,amount,extraData,ipnUrl,orderId,orderInfo,partnerCode,redirectUrl,requestId,requestType`\n\n### `queryTransaction(request)`\n\n- Calls `POST /v2/gateway/api/query`\n- Signature fields:\n  `accessKey,orderId,partnerCode,requestId`\n\n### `refund(request)`\n\n- Calls `POST /v2/gateway/api/refund`\n- Signature fields:\n  `accessKey,amount,description,orderId,partnerCode,requestId,transId`\n\n### `queryRefundStatus(request)`\n\n- Calls `POST /v2/gateway/api/refund/query`\n- Signature fields:\n  `accessKey,orderId,partnerCode,requestId`\n\n### `verifyWebhookSignature(payload)`\n\nValidate `signature` sent by MoMo webhook/IPN payload.\n\n```ts\napp.post(\"/payment/momo/ipn\", express.json(), (req, res) => {\n  if (!momo.verifyWebhookSignature(req.body)) {\n    res.status(400).json({ message: \"Invalid signature\" });\n    return;\n  }\n\n  // Process success/fail by resultCode and orderId\n  res.status(204).end();\n});\n```\n\n## Error Handling\n\n```ts\nimport { MomoApiError, MomoSdkError } from \"momo-sdk\";\n\ntry {\n  await momo.queryTransaction({ orderId: \"order-1\" });\n} catch (err) {\n  if (err instanceof MomoApiError) {\n    console.error(err.resultCode, err.message, err.requestId);\n  } else if (err instanceof MomoSdkError) {\n    console.error(err.code, err.message);\n  }\n}\n```\n\n## Endpoints\n\nDefault base URLs:\n\n- Sandbox: `https://test-payment.momo.vn`\n- Production: `https://payment.momo.vn`\n\nOverride with `baseUrl` if needed.\n\n## Notes\n\n- This SDK is server-side only because it needs `secretKey`.\n- Always verify webhook signature before updating payment status.\n","readmeFilename":"README.md"}