Comparing version 0.7.0 to 0.8.1
@@ -27,3 +27,3 @@ "use strict"; | ||
this.websocketUrl = options.websocketUrl || 'wss://ws.anypayx.com'; | ||
const shouldConnectWebsocket = options.connectWebsocket === false ? false : true; | ||
const shouldConnectWebsocket = options.connectWebsocket === true ? true : false; | ||
if (this.apiKey && shouldConnectWebsocket) { | ||
@@ -46,2 +46,3 @@ this.connectWebsocket(); | ||
headers: { | ||
'Authorization': `Bearer ${this.apiKey}`, | ||
'anypay-access-token': this.apiKey | ||
@@ -48,0 +49,0 @@ } |
@@ -19,1 +19,2 @@ import { PaymentRequest } from './payment_request'; | ||
export declare function request(params: any): Promise<PaymentRequest>; | ||
export { events, subscribe, SubscribeOptions } from './websockets'; |
@@ -12,3 +12,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.request = exports.demo = exports.cancel = exports.refresh = exports.app = exports.Confirmation = exports.Payment = exports.getInvoice = exports.Invoice = exports.schema = exports.PaymentOption = void 0; | ||
exports.subscribe = exports.events = exports.request = exports.demo = exports.cancel = exports.refresh = exports.app = exports.Confirmation = exports.Payment = exports.getInvoice = exports.Invoice = exports.schema = exports.PaymentOption = void 0; | ||
const schema_1 = require("./schema"); | ||
@@ -32,3 +32,4 @@ Object.defineProperty(exports, "schema", { enumerable: true, get: function () { return schema_1.schema; } }); | ||
apiKey: '1f2a4a55-85ed-4935-af60-1ec91e75e2fc', | ||
apiBase: 'https://api.anypayx.com' | ||
apiBase: 'https://api.anypayx.com', | ||
connectWebsocket: false | ||
}); | ||
@@ -56,2 +57,5 @@ exports.default = defaultApp; | ||
exports.request = request; | ||
var websockets_1 = require("./websockets"); | ||
Object.defineProperty(exports, "events", { enumerable: true, get: function () { return websockets_1.events; } }); | ||
Object.defineProperty(exports, "subscribe", { enumerable: true, get: function () { return websockets_1.subscribe; } }); | ||
//# sourceMappingURL=index.js.map |
@@ -15,17 +15,39 @@ "use strict"; | ||
const lib_1 = require("./src/lib"); | ||
const anypay = lib_1.app({ | ||
apiKey: process.env.anypay_api_key, | ||
websocketUrl: process.env.anypay_websocket_url || 'ws://localhost:5201' | ||
}); | ||
function main() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
anypay.on('websocket.message.received', ({ type, payload }) => { | ||
console.log('anypay.websocket.message.received.message', { type, payload }); | ||
const subscribeOptions = { | ||
websocket: { | ||
auth: { | ||
token: String(process.env.ANYPAY_AUTH_TOKEN) | ||
} | ||
} | ||
}; | ||
if (process.env.ANYPAY_WEBSOCKET_URL) { | ||
subscribeOptions.websocket.url = process.env.ANYPAY_WEBSOCKET_URL; | ||
} | ||
lib_1.subscribe(subscribeOptions) | ||
.onInvoiceCreated((event) => { | ||
console.log(JSON.stringify(event)); | ||
}) | ||
.onInvoiceCancelled((event) => { | ||
console.log(JSON.stringify(event)); | ||
}) | ||
.onInvoicePaid((event) => { | ||
console.log(JSON.stringify(event)); | ||
}) | ||
.onPaymentConfirming((event) => { | ||
console.log(JSON.stringify(event)); | ||
}) | ||
.onPaymentConfirmed((event) => { | ||
console.log(JSON.stringify(event)); | ||
}) | ||
.onPaymentFailed((event) => { | ||
console.log(JSON.stringify(event)); | ||
}) | ||
.onWebsocketConnected((event) => { | ||
console.log(JSON.stringify(event)); | ||
}) | ||
.onError((error) => { | ||
console.error(error); | ||
}); | ||
anypay.events.on('invoice.created', ({ type, payload }) => { | ||
console.log('Invoice Created', { type, payload }); | ||
}); | ||
anypay.events.on('invoice.paid', ({ type, payload }) => { | ||
console.log('Invoice Paid!', { type, payload }); | ||
}); | ||
}); | ||
@@ -32,0 +54,0 @@ } |
require('dotenv').config() | ||
import anypay from '.' | ||
import anypay from '@anypay/client' | ||
@@ -6,0 +6,0 @@ export async function main() { |
{ | ||
"name": "anypay", | ||
"version": "0.7.0", | ||
"version": "0.8.1", | ||
"description": "Anypay Enterprise Payments Platform", | ||
@@ -35,3 +35,4 @@ "main": "dist/src/lib/index.js", | ||
"typescript": "^4.0.2", | ||
"ws": "^8.13.0" | ||
"ws": "^8.13.0", | ||
"zod": "^3.22.4" | ||
}, | ||
@@ -38,0 +39,0 @@ "devDependencies": { |
@@ -60,3 +60,3 @@ | ||
const shouldConnectWebsocket = options.connectWebsocket === false ? false : true | ||
const shouldConnectWebsocket = options.connectWebsocket === true ? true : false | ||
@@ -83,2 +83,3 @@ if (this.apiKey && shouldConnectWebsocket) { | ||
headers: { | ||
'Authorization': `Bearer ${this.apiKey}`, | ||
'anypay-access-token': this.apiKey | ||
@@ -85,0 +86,0 @@ } |
@@ -32,3 +32,4 @@ | ||
apiKey: '1f2a4a55-85ed-4935-af60-1ec91e75e2fc', | ||
apiBase: 'https://api.anypayx.com' | ||
apiBase: 'https://api.anypayx.com', | ||
connectWebsocket: false | ||
}) | ||
@@ -56,1 +57,2 @@ | ||
export { events, subscribe, SubscribeOptions } from './websockets' |
{ | ||
"compilerOptions": { | ||
"target": "es6", | ||
"skipLibCheck": true, | ||
"lib": [ | ||
@@ -5,0 +6,0 @@ "es6", "ES2015", "ES2016", "ES2017", "dom" |
require('dotenv').config() | ||
import { app } from './src/lib' | ||
import { SubscribeOptions, subscribe, events } from './src/lib' | ||
import { Websocket } from 'ws' | ||
export async function main() { | ||
const anypay = app({ | ||
apiKey: process.env.anypay_api_key, | ||
websocketUrl: process.env.anypay_websocket_url || 'ws://localhost:5201' | ||
}) | ||
const subscribeOptions: SubscribeOptions = { | ||
websocket: { | ||
auth: { | ||
token: String(process.env.ANYPAY_AUTH_TOKEN) | ||
} | ||
} | ||
} | ||
export async function main() { | ||
if (process.env.ANYPAY_WEBSOCKET_URL) { | ||
anypay.on('websocket.message.received', ({type, payload}) => { | ||
subscribeOptions.websocket.url = process.env.ANYPAY_WEBSOCKET_URL | ||
console.log('anypay.websocket.message.received.message', {type, payload}) | ||
} | ||
subscribe(subscribeOptions) | ||
.onInvoiceCreated((event: events.InvoiceCreatedEvent) => { | ||
console.log(JSON.stringify(event)) | ||
}) | ||
.onInvoiceCancelled((event: events.InvoiceCancelledEvent) => { | ||
anypay.events.on('invoice.created', ({type,payload}) => { | ||
console.log(JSON.stringify(event)) | ||
}) | ||
.onInvoicePaid((event: events.InvoicePaidEvent) => { | ||
console.log('Invoice Created', {type, payload}) | ||
console.log(JSON.stringify(event)) | ||
}) | ||
.onPaymentConfirming((event: events.PaymentConfirmingEvent) => { | ||
console.log(JSON.stringify(event)) | ||
}) | ||
.onPaymentConfirmed((event: events.InvoiceCancelledEvent) => { | ||
anypay.events.on('invoice.paid', ({type,payload}) => { | ||
console.log(JSON.stringify(event)) | ||
}) | ||
.onPaymentFailed((event: events.PaymentFailedEvent) => { | ||
console.log('Invoice Paid!', {type, payload}) | ||
console.log(JSON.stringify(event)) | ||
}) | ||
.onWebsocketConnected((event: events.WebsocketConnectedEvent) => { | ||
console.log(JSON.stringify(event)) | ||
}) | ||
.onError((error: Error) => { | ||
console.error(error) | ||
}) | ||
} | ||
@@ -34,0 +58,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
164588
3577
12
17
95
+ Addedzod@^3.22.4
+ Addedzod@3.24.2(transitive)