Get authorization code after clicking authorize button

In the Payments API Deep Dive A Hands on Guide to Integrating with Blackbaud Merchant Services in youtube , javascript file used to collect code value,

Need javascript which will collect authorization code and add it in redirect url after clicking the authorize button

<script type="text/javascript">
function getQueryParams(url) {
const queryString = url.split('?')[1];
const params = {};

if (queryString) {
queryString.split('&').forEach((param) => {
const [key, value] = param.split('=');
params[key] = decodeURIComponent(value);
});
}

return params;
}

const queryParams = getQueryParams(window.location.href);

console.log(queryParams.code); // Output: John
//console.log(queryParams.age); // Output:


window.alert([queryParams.code]);

I have tried adding the above javascript in default page but still it is not working

Comments

  • Michael Tims
    Michael Tims Blackbaud Employee
    Seventh Anniversary Kudos 2 Name Dropper Participant

    Hi @Muthusamy Nellaiappan - there are various tutorials/code samples that may help guide you through the authorization process, like this NodeJS tutorial. The full code for this sample can be found on GitHub. Hope this helps!

  • @Michael Tims

    Our problem is our application is 4.5 framework, none of these js files cant able to use, and it is also in vb , for this payment we have to upgrade our application itself, without converting the application into core or another latest framework we are trying to find a solution .

  • Michael Tims
    Michael Tims Blackbaud Employee
    Seventh Anniversary Kudos 2 Name Dropper Participant

    @Muthusamy Nellaiappan - yes, sorry I do not believe there are any examples in VB. But hopefully the general idea of making the authorization request and hosting a redirect URL within your application can be gathered from some of the existing tutorials. The tutorial in C# .Net Core may be the closest to give you an idea of how it should work. Hope that helps to get you going!

Categories