Skip to content

Commit

Permalink
chore: minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Manuel Cabarcos Baulina committed Apr 27, 2023
1 parent 28a6c83 commit 06a627a
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
39 changes: 39 additions & 0 deletions examples/server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,45 @@ const hmacSHA256 = require('crypto-js/hmac-sha256')
const Hex = require('crypto-js/enc-hex')
const app = express()

// In a separate file
exports.createFormToken = async paymentConf => {
// format: 123456789
const username = '~~CHANGE_ME_USER~~'

// format: testprivatekey_XXXXXXX
const password = '~~CHANGE_ME_PASSWORD~~'

// format: api.my.psp.domain.name without https
const endpoint = '~~CHANGE_ME_ENDPOINT_NO_HTTPS~~'

const createPaymentEndpoint = `https://${username}:${password}@${endpoint}/api-payment/V4/Charge/CreatePayment`

try {
const response = await axios.post(createPaymentEndpoint, paymentConf, {
headers: {
'Content-Type': 'application/json'
}
})
if (!response?.data?.answer?.formToken) throw response
return response.data.answer.formToken
} catch (error) {
throw error
}
}
/**
* Generates a payment token for the given configuration
*/
app.post('/createPayment', async (req, res) => {
const paymentConf = req.body.paymentConf

try {
const formToken = await createFormToken(paymentConf)
res.send(formToken)
} catch (error) {
res.status(500).send(error)
}
})

(...)
// Validates the given payment data (hash)
app.post('/validatePayment', (req, res) => {
Expand Down
6 changes: 3 additions & 3 deletions examples/vue/options/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ export default {
await KR.setFormConfig({ /* set the minimal configuration */
formToken: formToken,
'kr-language': 'en-US', /* to update initialization parameter */
}))
const { result } = await KR.attachForm('#myPaymentForm')) /* create a payment form */
await KR.showForm(result.formId)); /* show the payment form */
})
const { result } = await KR.attachForm('#myPaymentForm') /* create a payment form */
await KR.showForm(result.formId); /* show the payment form */
}
(...)
}
Expand Down

0 comments on commit 06a627a

Please sign in to comment.