I'd create a HTML document with a script tag and add this URL

<script src ="https://assets.pagar.me/pagarme-js/3.0/pagarme.min.js"></script>

so, call the global variable pagarme in console browser.

I got this response:

{client: {…}, postback: {…}, company: {…}, validate: ƒ, search: ƒ, …}

But in Magento 2, I always receive error messages.

Below some files with my configuration:


var config = {
    map: {
        '*': {
            pagarmeJs: 'https://assets.pagar.me/pagarme-js/3.0/pagarme.min.js'
    shim: {
        "pagarmeJs": {
            exports: "pagarme"

jsFileWithTheCallingCode.js - first try

    ['pagarmeJs'],function (pagarme) {...})

jsFileWithTheCallingCode.js - second try

    ['pagarmeJs'],function () {...})

As mentioned above, if I try to insert the pagarme variable on the console or use inside the require function I always get error messages.

Can anyone help me?

1 Answer 1


Got it!

Simply I use the code bellow in requirejs-config.js

var config = {
    paths: {
        pagarme: 'https://assets.pagar.me/pagarme-js/3.0/pagarme.min'

And the global variable works!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.