This module provides a client for integrating the PayMaya payment system into Node.js applications.
🇹🇷 Türkçe versiyonu için tıklayın
npm install paymaya-integrationconst PayMaya = require('paymaya-integration');
const paymaya = new PayMaya({
publicKey: 'YOUR_PUBLIC_KEY',
secretKey: 'YOUR_SECRET_KEY',
environment: 'SANDBOX' // or 'PRODUCTION'
});const checkoutData = {
totalAmount: {
value: 100,
currency: 'PHP',
},
buyer: {
firstName: 'John',
lastName: 'Doe',
contact: {
phone: '09123456789',
email: 'john.doe@example.com'
},
shippingAddress: {
line1: '123 Street',
line2: 'Sample Barangay',
city: 'Manila',
state: 'Metro Manila',
zipCode: '1234',
countryCode: 'PH'
},
billingAddress: {
line1: '123 Street',
line2: 'Sample Barangay',
city: 'Manila',
state: 'Metro Manila',
zipCode: '1234',
countryCode: 'PH'
}
},
items: [
{
name: 'Product 1',
quantity: 1,
code: 'PROD1',
description: 'Product description',
amount: {
value: 100,
details: {
discount: 0,
serviceCharge: 0,
shippingFee: 0,
tax: 0,
subtotal: 100
}
},
totalAmount: {
value: 100,
details: {
discount: 0,
serviceCharge: 0,
shippingFee: 0,
tax: 0,
subtotal: 100
}
}
}
],
redirectUrl: {
success: 'https://example.com/success',
failure: 'https://example.com/failure',
cancel: 'https://example.com/cancel'
},
requestReferenceNumber: 'REF123456789'
};
// Create payment transaction
paymaya.checkout.create(checkoutData)
.then(response => {
console.log('Checkout URL:', response.redirectUrl);
})
.catch(error => {
console.error('Error:', error.message);
});// Express Application Example
const express = require('express');
const app = express();
app.use(express.json());
app.post('/webhook/payment', (req, res) => {
const isValid = paymaya.webhooks.verifyWebhook(req, 'YOUR_SECRET_KEY');
if (isValid) {
const event = req.body;
// Process webhook events
switch (event.type) {
case 'CHECKOUT_SUCCESS':
// Successful payment process
break;
case 'CHECKOUT_FAILURE':
// Failed payment process
break;
default:
console.log('Unknown event:', event.type);
}
res.status(200).send('OK');
} else {
res.status(400).send('Invalid webhook');
}
});paymaya.checkout.create(checkoutData): Creates a new payment transactionpaymaya.checkout.retrieve(id): Gets the details of a payment transactionpaymaya.checkout.setWebhooks(webhooks): Sets webhook URLspaymaya.checkout.getWebhooks(): Gets webhook URLs
paymaya.invoice.create(invoiceData): Creates a new invoicepaymaya.invoice.retrieve(id): Gets the details of an invoicepaymaya.invoice.cancel(id, reason): Cancels an invoice
paymaya.vault.createCustomer(customerData): Creates a new customerpaymaya.vault.updateCustomer(customerId, customerData): Updates customer informationpaymaya.vault.getCustomer(customerId): Gets customer informationpaymaya.vault.deleteCustomer(customerId): Deletes a customer recordpaymaya.vault.createCard(customerId, cardData): Adds a new cardpaymaya.vault.getCard(customerId, cardId): Gets a saved cardpaymaya.vault.deleteCard(customerId, cardId): Deletes a saved cardpaymaya.vault.createPayment(customerId, cardId, paymentData): Makes a payment with a saved card
paymaya.webhooks.verifyWebhook(request, secretKey): Verifies a webhookpaymaya.webhooks.register(webhooks): Registers webhook URLspaymaya.webhooks.list(): Lists registered webhook URLspaymaya.webhooks.update(id, webhookData): Updates webhook URLspaymaya.webhooks.delete(id): Deletes a webhook registration
| Sandbox Merchant | Public API Key | Secret API Key |
|---|---|---|
| Sandbox Party 1 | pk-Z0OSzLvIcOI2UIvDhdTGVVfRSSeiGStnceqwUE7n0Ah | sk-X8qolYjy62kIzEbr0QRK1h4b4KDVHaNcwMYk39jInSl |
| Sandbox Party 2 | pk-eo4sL393CWU5KmveJUaW8V730TTei2zY8zE4dHJDxkF | sk-KfmfLJXFdV5t1inYN8lIOwSrueC1G27SCAklBqYCdrU |
| Sandbox Party 3 | pk-lNAUk1jk7VPnf7koOT1uoGJoZJjmAxrbjpj6urB8EIA | sk-fzukI3GXrzNIUyvXY3n16cji8VTJITfzylz5o5QzZMC |
| Card Type | Number | Expiry Month | Expiry Year | CVV | 3D Secure |
|---|---|---|---|---|---|
| MASTERCARD | 5123456789012346 | 12 | 2025 | 111 | Not Active |
| MASTERCARD | 5453010000064154 | 12 | 2025 | 111 | secbarry1 |
| VISA | 4123450131001381 | 12 | 2025 | 123 | mctest1 |
- Username: 09193890579
- Password: Password@1
- OTP: 123456
- FastUptime
- GitHub Repository: Paymaya_NodeJS_Integration
Bu modül, PayMaya ödeme sistemini Node.js uygulamalarına entegre etmek için bir istemci sağlar.
npm install paymaya-integrationconst PayMaya = require('paymaya-integration');
const paymaya = new PayMaya({
publicKey: 'YOUR_PUBLIC_KEY',
secretKey: 'YOUR_SECRET_KEY',
environment: 'SANDBOX' // veya 'PRODUCTION'
});const checkoutData = {
totalAmount: {
value: 100,
currency: 'PHP',
},
buyer: {
firstName: 'John',
lastName: 'Doe',
contact: {
phone: '09123456789',
email: 'john.doe@example.com'
},
shippingAddress: {
line1: '123 Street',
line2: 'Sample Barangay',
city: 'Manila',
state: 'Metro Manila',
zipCode: '1234',
countryCode: 'PH'
},
billingAddress: {
line1: '123 Street',
line2: 'Sample Barangay',
city: 'Manila',
state: 'Metro Manila',
zipCode: '1234',
countryCode: 'PH'
}
},
items: [
{
name: 'Product 1',
quantity: 1,
code: 'PROD1',
description: 'Product description',
amount: {
value: 100,
details: {
discount: 0,
serviceCharge: 0,
shippingFee: 0,
tax: 0,
subtotal: 100
}
},
totalAmount: {
value: 100,
details: {
discount: 0,
serviceCharge: 0,
shippingFee: 0,
tax: 0,
subtotal: 100
}
}
}
],
redirectUrl: {
success: 'https://example.com/success',
failure: 'https://example.com/failure',
cancel: 'https://example.com/cancel'
},
requestReferenceNumber: 'REF123456789'
};
// Ödeme işlemi oluştur
paymaya.checkout.create(checkoutData)
.then(response => {
console.log('Checkout URL:', response.redirectUrl);
})
.catch(error => {
console.error('Error:', error.message);
});// Express Uygulaması Örneği
const express = require('express');
const app = express();
app.use(express.json());
app.post('/webhook/payment', (req, res) => {
const isValid = paymaya.webhooks.verifyWebhook(req, 'YOUR_SECRET_KEY');
if (isValid) {
const event = req.body;
// Webhook olaylarını işle
switch (event.type) {
case 'CHECKOUT_SUCCESS':
// Başarılı ödeme işlemi
break;
case 'CHECKOUT_FAILURE':
// Başarısız ödeme işlemi
break;
default:
console.log('Bilinmeyen olay:', event.type);
}
res.status(200).send('OK');
} else {
res.status(400).send('Invalid webhook');
}
});paymaya.checkout.create(checkoutData): Yeni bir ödeme işlemi oluştururpaymaya.checkout.retrieve(id): Bir ödeme işleminin detayını alırpaymaya.checkout.setWebhooks(webhooks): Webhook URL'lerini ayarlarpaymaya.checkout.getWebhooks(): Webhook URL'lerini alır
paymaya.invoice.create(invoiceData): Yeni bir fatura oluştururpaymaya.invoice.retrieve(id): Bir faturanın detaylarını alırpaymaya.invoice.cancel(id, reason): Bir faturayı iptal eder
paymaya.vault.createCustomer(customerData): Yeni bir müşteri oluştururpaymaya.vault.updateCustomer(customerId, customerData): Müşteri bilgilerini güncellerpaymaya.vault.getCustomer(customerId): Müşteri bilgilerini alırpaymaya.vault.deleteCustomer(customerId): Müşteri kaydını silerpaymaya.vault.createCard(customerId, cardData): Yeni bir kart eklerpaymaya.vault.getCard(customerId, cardId): Kaydedilmiş kartı alırpaymaya.vault.deleteCard(customerId, cardId): Kaydedilmiş kartı silerpaymaya.vault.createPayment(customerId, cardId, paymentData): Kaydedilmiş kart ile ödeme yapar
paymaya.webhooks.verifyWebhook(request, secretKey): Webhook doğrulaması yaparpaymaya.webhooks.register(webhooks): Webhook URL'lerini kaydederpaymaya.webhooks.list(): Kayıtlı webhook URL'lerini listelerpaymaya.webhooks.update(id, webhookData): Webhook URL'lerini güncellerpaymaya.webhooks.delete(id): Webhook kaydını siler
| Sandbox Merchant | Public API Key | Secret API Key |
|---|---|---|
| Sandbox Party 1 | pk-Z0OSzLvIcOI2UIvDhdTGVVfRSSeiGStnceqwUE7n0Ah | sk-X8qolYjy62kIzEbr0QRK1h4b4KDVHaNcwMYk39jInSl |
| Sandbox Party 2 | pk-eo4sL393CWU5KmveJUaW8V730TTei2zY8zE4dHJDxkF | sk-KfmfLJXFdV5t1inYN8lIOwSrueC1G27SCAklBqYCdrU |
| Sandbox Party 3 | pk-lNAUk1jk7VPnf7koOT1uoGJoZJjmAxrbjpj6urB8EIA | sk-fzukI3GXrzNIUyvXY3n16cji8VTJITfzylz5o5QzZMC |
| Kart Tipi | Numara | Son Kullanma Ay | Son Kullanma Yıl | CVV | 3D Secure |
|---|---|---|---|---|---|
| MASTERCARD | 5123456789012346 | 12 | 2025 | 111 | Aktif Değil |
| MASTERCARD | 5453010000064154 | 12 | 2025 | 111 | secbarry1 |
| VISA | 4123450131001381 | 12 | 2025 | 123 | mctest1 |
- Kullanıcı Adı: 09193890579
- Şifre: Password@1
- OTP: 123456
- FastUptime
- GitHub Repository: Paymaya_NodeJS_Integration