
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
@snag/payments-sdk
Advanced tools
This readme provides instructions on how to install and use the Payment SDK to facilitate online payments and retrieve session details based on session IDs.
This readme provides instructions on how to install and use the Payment SDK to facilitate online payments and retrieve session details based on session IDs.
To get started, follow these steps to install the Payment SDK:
Install Node.js and npm:
Ensure you have Node.js and npm (Node Package Manager) installed on your system. You can download and install them from the official Node.js website: Node.js Downloads
Install the Payment SDK:
Use npm to install the Payment SDK package:
npm install @snag-solutions/payments-sdk --save
Once you've installed the Payment SDK, you can use it to perform payment checkouts and retrieve session details based on session IDs.
To initiate a payment checkout, use the await new PaymentSDK().checkout()
method. Provide the necessary information for the payment, such as the name, description, amount, currency, and more. Here's an example:
const PaymentSDK = require('payment-sdk');
const sdkApiKey = 'sdk-api-key';
(async () => {
try {
await new PaymentSDK(sdkApiKey).checkout({
name: 'Sample Item',
description: 'A sample item description',
images: ['https://example.com/item-image.jpg'],
amount: 1999, // Amount in cents (e.g., $19.99)
currency: 'usd',
shippingRate: 'shipping_rate_id',
successUrl: 'https://example.com/success',
cancelUrl: 'https://example.com/cancel',
tokenId: 1,
});
} catch (error) {
console.error('Error initiating payment checkout:', error);
}
})();
The sessionId will be included as a query parameter (session_id) in the successUrl and cancelUrl, making it accessible on those pages for further processing.
To retrieve session details based on a session ID, use the await new PaymentSDK().sessionDetails(sessionId)
method. Replace sessionId
with the actual session ID you want to retrieve details for. Here's an example:
const PaymentSDK = require('payment-sdk');
const sdkApiKey = 'sdk-api-key';
(async () => {
try {
const sessionId = 'your-session-id'; // Replace with the actual session ID
const sessionDetails = await new PaymentSDK(sdkApiKey).sessionDetails(
sessionId,
);
console.log('Session Details:', sessionDetails);
} catch (error) {
console.error('Error retrieving session details:', error);
}
})();
Make sure to replace 'your-session-id'
with the actual session ID you want to retrieve details for.
FAQs
This readme provides instructions on how to install and use the Payment SDK to facilitate online payments and retrieve session details based on session IDs.
The npm package @snag/payments-sdk receives a total of 0 weekly downloads. As such, @snag/payments-sdk popularity was classified as not popular.
We found that @snag/payments-sdk demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers 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
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.