Re: New payment method integration

How can I integrate Prometeo's A2A payments into my website?

fcalvette
Visitor
2 0 0

Hello, how are community? 

 

I need to integrate a new payment method. That is Prometeo's  A2A payments. 

For the integration, I need an embedded JavaScript code in a button's call function. 

 

Do you know how could I do this integration? or can you share with me the documentation? 

 

Best regards,

Federico C.

Replies 2 (2)

Yeady123
Explorer
61 7 9

To integrate Prometeo's A2A payments, you will need to follow these steps:

  1. First, you will need to create an account with Prometeo and obtain your API credentials. You can do this by contacting Prometeo's support team.

  2. Once you have your API credentials, you can use the following code to create a button that will call the A2A payments method:

 

<button onclick="makeA2APayment()">Pay with A2A</button>

<script>
function makeA2APayment() {
  // Use Prometeo's API to process the payment
}
</script>

 

  • In the makeA2APayment function, you will need to make a call to Prometeo's API to process the payment. You can use the following code as a starting point:

 

function makeA2APayment() {
  // Replace with your own API key
  const apiKey = 'YOUR_API_KEY';

  // Replace with the amount to be charged
  const amount = 10.00;

  // Call Prometeo's API to process the payment
  fetch('https://api.prometeo.it/payments/a2a', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': `Bearer ${apiKey}`,
    },
    body: JSON.stringify({ amount }),
  })
    .then(response => response.json())
    .then(data => {
      console.log(data);
      // Handle the response from Prometeo's API
    })
    .catch(error => console.error(error));
}

 

  • You will need to replace YOUR_API_KEY with your actual API key, and 10.00 with the actual amount you want to charge.

  • You can customize the makeA2APayment function to handle the response from Prometeo's API. The response will contain information about the payment status and any errors that occurred.

I hope this helps you get started with integrating Prometeo's A2A payments method!

- Was my reply helpful? Click "Like" to let me know!
- ----Was your question answered? Mark it as an Accepted Solution
You can get in touch with me via WhatsApp on +88013-13075440
Email: shahinkhan2424ft@gmail.com
fcalvette
Visitor
2 0 0

Yeady123, thank you very much for your help, I really appreciate it.
The problem I have is that the A2A payment method of Prometeo is not an API, but it is a widget. When you click a button it opens: https://docs.prometeoapi.com/docs/widget-de-integraci%C3%B3n-a-nuestras-apis
Could I configure that when I click that payment button the Prometeo widget opens?
The call is made with JS and the Prometeo's CDN.
Something like this:

 

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Sample Widget Usage</title>
    <script src="https://cdn.prometeoapi.com/widget/1.0.0/static/js/init.js"></script>
  </head>
  <body>
    <button onclick="openWidget()">SHOW WIDGET</button>
    <script>
      var widget = Prometeo.init('widget-id');

      widget.on(Prometeo.Messaging.CLOSE, () => {
        console.log('Event: CLOSE');
      });

      widget.on(Prometeo.Messaging.LOGIN, (session) => {
        console.log('Event: LOGIN');
        session.getOwnerInfo();
        session.getAccounts();
      });

      widget.on(Prometeo.Messaging.GET_OWNER_INFO, (ownerInfo) => {
        console.log('Event: GET_OWNER_INFO');
        console.log(`ownerInfo: ${ownerInfo}`);
      });

      widget.on(Prometeo.Messaging.GET_ACCOUNTS, (accounts) => {
        console.log('Event: GET_ACCOUNTS');
        console.log(`accounts: ${accounts}`);
      });

      widget.on(Prometeo.Messaging.ERROR, (error) => {
        console.log('Event: ERROR');
        console.log(`error: ${error}`);
      });

      widget.on(Prometeo.Messaging.PAYMENT_SUCCESS, (payload) => {
        console.log('Event: PAYMENT_SUCCESS');
        console.log(`payload: ${payload}`);
      });

      const openWidget = () => {
        widget.open({allowedFeatureLevel: 2, currency: 'PEN', amount: 1, concept: "Order 1234"});
      }
    </script>
  </body>
</html>