
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
univapay-node
Advanced tools
[node]: https://nodejs.org/ [npm]: https://www.npmjs.com/ [yarn]: https://yarnpkg.com/ [webpack]: https://webpack.js.org/ [rollup]: https://rollupjs.org/ [univapay-url]: https://univapay.com/ [npm-url]: https://www.npmjs.com/package/univapay-node [build-u
Node.jsがUnivaPayAPI を使用するための SDK ライブラリです。
# npm (推奨)
npm install --save univapay-node
# yarn
yarn add univapay-node
ストアアプリケーショントークンがない場合は、まず以下の手順で作成してください。
店舗 > 店舗を選択 > 開発 > アプリトークン ページに移動追加 をクリックimport SDK from "univapay-node";
// Node.JSなど、fetchが提供されない環境では
// import "cross-fetch/polyfill"
// import "isomorphic-form-data"
// を使ってください
const apiEndpoint = "https://api.univapay.com";
const storeJwt = jwt; // `準備`を参照
const storeJwtSecret = secret; // `準備`を参照
const sdk = new SDK({
endpoint: apiEndpoint,
jwt: storeJwt,
secret: storeJwtSecret,
});
import SDK, { PaymentType, TransactionTokenType, ResponseError } from "univapay-node";
const sdk = new SDK({ endpoint, jwt, secret });
// 課金用のトークンを作成
let transactionToken;
try {
const transactionToken = await sdk.transactionTokens.create({
type: TransactionTokenType.ONE_TIME, // 1回のみ利用可
paymentType: PaymentType.CARD,
// データの型は決済方法によって異なります
data: { cardholder, cardNumber, expMonth, expYear, cvv }
});
} catch (tokenCreateError: ResponseError) {
handleError(tokenCreateError);
}
// 課金を作成
try {
const charge = await sdk.charges.create({
amount: 1000;
currency: "JPY",
transactionTokenId: transactionToken.id,
});
} catch (chargeCreateError: ResponseError) {
// 未使用のトークンをクリーンアップして、次の課金のために別のトークンを再作成します
await sdk.transactionTokens.delete(transactionToken.id);
handleError(chargeCreateError);
}
課金を作成した後、ステータスはpendingに初期化されます。 API が完全に処理し終わると、successfulまたはfailedになります。課金がfailedまたはsuccessfulになったタイミングを知る必要がある場合は、課金をポーリングすることができます。
import SDK, {
PaymentType,
TransactionTokenType,
ResponseError,
} from "univapay-node";
const sdk = new SDK({ endpoint, jwt, secret });
const transactionToken = await sdk.transactionTokens.create(/* */);
const createdCharge = await sdk.charges.create(/* */); // Pending ステータス
const charge = await sdk.charges.poll(
createdCharge.storeId,
createdCharge.id,
null,
null,
null,
// ポーリングが停止してnullを返す条件
// 任意: (charge:ResponseCharge) => boolean
cancelCondition,
// ポーリングが成功する条件。デフォルトは、statusがpendingではないこと
// 任意: (charge: ResponseCharge) => boolean
successCondition,
);
デフォルトでは、課金を作成するとそのままキャプチャされます。そうではなく、認証する必要がある場合は、captureプロパティを falseに設定し、任意のcaptureAtプロパティを指定して特定の日付で自動的にキャプチャするようにすることができます。
const charge = await sdk.charges.create({
amount: 1000;
currency: "JPY",
transactionTokenId: transactionToken.id,
capture: false, // 課金を直接はキャプチャしない
captureAt: "2020-08-12", // 任意
});
ChargesやStoresなどの、PaymentsSDKおよびResourceベースのクラスはEventEmitterです。次のイベントをサブスクライブできます。
const sdk = new SDK();
sdk.on('request', (req: Request) => void)
sdk.on('response', (res: Response) => void)
RequestとResponseはfetchAPIの型です。
このモジュールは主にNode.js用に設計されていますが、WebpackやRollupなどのバンドラによってトランスパイルされたときに、ブラウザで使用することができます。
univapay-nodeの開発に寄与するには、このリポジトリをローカルで clone し、コードを別のブランチとして commit します。その際、コードの単体テストを記述し、プルリクエストを作成する前に Lint を実行してください。
npm run lint -- --fix
npm run format
npm test
univapay-nodeは、MITライセンスの下で配布されています。
Copyright © 2019, UnivaPay Team
FAQs
[node]: https://nodejs.org/ [npm]: https://www.npmjs.com/ [yarn]: https://yarnpkg.com/ [webpack]: https://webpack.js.org/ [rollup]: https://rollupjs.org/ [univapay-url]: https://univapay.com/ [npm-url]: https://www.npmjs.com/package/univapay-node [build-u
The npm package univapay-node receives a total of 945 weekly downloads. As such, univapay-node popularity was classified as not popular.
We found that univapay-node demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.