Last active
July 22, 2022 04:19
-
-
Save mackignacio/73e8945d10177aba65828f8a20bf2e11 to your computer and use it in GitHub Desktop.
Payment Provider
This file contains 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 payload = { | |
// Optional amount if not set will show amount in UI | |
amount: 100.00, | |
// Optional description if not set will show currency dropdown in UI | |
currency: env.CURRENCY, | |
// Optional description if not set will show description in UI | |
description: "PayMongo Transaction", | |
// Optional email if not set will show email in UI | |
email: env.ADMIN_EMAIL, | |
// Optional provider if not set will show the dropdown selection for providers | |
provider: env.PAYMENT_PROVIDER, // i.e. GCash, BDO, PayMaya, PayPal | |
// Optional redirectToWeb if not set will not redirect and show success page | |
redirectToWeb: "", | |
// Optional redirectToApp if not set will use redirectToWeb value | |
redirectToApp: "", // for mobile application | |
// Optional custom params not defined on PayMongo API | |
// These params will be added when PayMongo redirects after a successful transaction | |
user: "", | |
video: "", | |
}; | |
const transactionID = uuid(); // This will be added on the redirect as query params | |
const url = `${env.PAYMONGO_CUSTOM_LINK_URL}/transactionID?api_key=${env.PAYMONGO_MERCHANT_API_KEY}`; | |
return http.post(url, payload); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://developers.paymongo.com/reference/create-a-link
const options = {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
Authorization: 'Basic
${base64(env.secretAPIkey)}
'},
body: JSON.stringify({
data: {
attributes: {
amount: 10000,
description: 'Your ',
remarks: 'custom_param1=<USER_ID>&custom_param2=<VIDEO_ID>'
}
}
})
};
fetch('https://api.paymongo.com/v1/links', options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));