Created
October 5, 2022 22:57
-
-
Save Shaxadhere/5907cca8c72be6d7a35795825224055c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { Checkout } = require('checkout-sdk-node') | |
require("dotenv").config() | |
const cko = new Checkout(process.env.CHECKOUT_SECRET_KEY, { pk: process.env.CHECKOUT_PUBLIC_KEY }); | |
module.exports = makeAPayment = async (token, addressLine1, addressLine2, city, state, zip, amount, country="PK", phone, currency, paymentType, reference, description, customerEmail, customerName) => { | |
const countryCode = phone.slice(0,3) | |
const phoneNumber = phone.slice(3,-1) | |
const payment = await cko.payments.request({ | |
source: { | |
token: token, // Generated by Checkout.Frames | |
billing_address: { | |
address_line1: addressLine1, | |
address_line2: addressLine2, | |
city: city, | |
state: state, | |
zip: zip, | |
country: country, | |
}, | |
phone: { | |
country_code: countryCode, | |
number: phoneNumber, | |
}, | |
}, | |
currency: currency, | |
amount: amount*100, | |
payment_type: paymentType, | |
reference: reference, | |
description: description, | |
customer: { | |
email: customerEmail, | |
name: customerName, | |
}, | |
metadata: { | |
value: 'none', | |
}, | |
}); | |
return payment | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment