![Maven Central Adds Sigstore Signature Validation](https://cdn.sanity.io/images/cgdhsj6q/production/7da3bc8a946cfb5df15d7fcf49767faedc72b483-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
The AgilePay Node node.js SDK provides a convenient access to the AgilePay API from applications written in server-side JavaScript.
This package is promise based with promises in mind instead of callback approach.
You can use the promise
style or async
await
style.
Please keep in mind that this package is for use with server-side Node that uses AgilePay secret keys. This package should not be used on the client side. Also note that this package is still in development.
See the Node API docs.
Install the package with:
npm install agile-pay --save
const agilePay = require('agile-pay')
const client = new agilePay({
'api_key': 'key',
'api_secret': 'secret'
});
promise
example:
agilePay.gateway().create('stripe', { 'secret_key': 'stripe-secret-key' })
.then(res => res.getBody())
.catch(err => err.getStatusCode()));
async
await
examples:
(async function () {
try {
const response = await agilePay.gateway().create('stripe', { 'secret_key': 'stripe-secret-key' });
console.log(response.getStatusCode());
} catch (error) {
console.log(error.getStatusCode());
}
})();
or
async function gateway() {
try {
const response = await agilePay.gateway().create('stripe', { 'secret_key': 'stripe-secret-key' });
console.log(response.getStatusCode());
} catch (error) {
console.log(error.getStatusCode());
}
}
gateway();
In this case the payment method will be retained with the provided gateway, please check the availability of transaction store in the gateways
Gateways list -> http://docs.agilepay.io/#!/gateway
Gateway token -> http://docs.agilepay.io/#!/payment-method-create-gateway-token
promise
example:
agilePay.paymentMethod().createGatewayToken('gateway-reference', {
number: '4111111111111111',
expiry_year: 17,
expiry_month: 12,
cvv: 123,
holder_name: 'John Smith',
})
.then(res => res.getBody().token)
.catch(res => {
// something went wrong
});
async
await
examples:
(async function () {
try {
const gatewayToken = await agilePay.paymentMethod().createGatewayToken('gateway-reference', {
number: '4111111111111111',
expiry_year: 17,
expiry_month: 12,
cvv: 123,
holder_name: 'John Smith',
});
// The response will contain a payment method **token** which is used to perform transactions against the payment method
const token = gatewayToken.getBody().token;
} catch (err) {
// something went wrong
}
})();
or
async function gatewayToken() {
try {
const gatewayToken = await agilePay.paymentMethod().createGatewayToken('gateway-reference', {
number: '4111111111111111',
expiry_year: 17,
expiry_month: 12,
cvv: 123,
holder_name: 'John Smith',
});
// The response will contain a payment method **token** which is used to perform transactions against the payment method
const token = gatewayToken.getBody().token;
return token;
} catch (err) {
// something went wrong
}
}
gatewayToken();
promise
example:
agilePay.transaction()
.setPaymentMethod('payment-method-token')
.auth(5000, 'GBP')
.then(res => {
if (res.getBody().successful) {
// the authorisationwas successful
} else {
// the gateway responded with some errors
res.getBody().errors;
}
})
.catch(res => {
// something went wrong
});
async
await
example:
async function transactionReference() {
try {
const transaction = await agilePay.transaction()
.setPaymentMethod('payment-method-token')
.auth(5000, 'GBP');
if (transaction.getBody().successful) {
const transaction = transaction.getBody().successful;
return transaction;
} else {
const error = transaction.getBody().errors;
return error
}
} catch (err) {
// something went wrong
}
}
// The response will contain a **reference** which can be used for second steps transactions such as **void**, **capture** and **refund**
transactionReference();
agilePay.transaction('authorised-transaction-reference').void()
.then(res => {
if (res.getBody().successful) {
// the pre-authorisation has been successfully cancelled
}
}).catch(res => {
// something went wrong
});
agilePay.transaction('authorised-transaction-reference').capture()
.then(res => {
if (res.getBody().successful) {
// the pre-authorisation has been successfully cancelled
}
}).catch(res => {
// something went wrong
});
agilePay.transaction('authorised-transaction-reference').credit()
.then(res => {
if (res.getBody().successful) {
// the pre-authorisation has been successfully cancelled
}
}).catch(res => {
// something went wrong
});
Below the response object available methods.
Retrieves the entire response
Retrieves the response body
Retrieves the response status code
A big thanks to Ary Homebrew for the huge contribution he has given to this package.
FAQs
AgilePay node sdk
The npm package agile-pay receives a total of 1 weekly downloads. As such, agile-pay popularity was classified as not popular.
We found that agile-pay demonstrated a not healthy version release cadence and project activity because the last version was released 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
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.