Skip to content

How to pass callback for successful payment #42

Description

@alexander01202

Hello. I am trying to pass a callback or handle some sort of function when there is a successful or failed payment. Here is my code:

paystack.transaction.initialize({ email: ${req.query.email}, amount: req.query.amount * 100, interval: ${req.query.interval}`,
currency: 'NGN',
plan: response.data.plan_code,
callback: function(response) {

                        var reference = response.reference;
                        console.log('Payment complete! Reference: ' + reference);
                       
                      },
                })
                .then(response => {
                    if (response.status) {
                        res.send({ success:true, url: response.data.authorization_url })   
                    }else{
                        res.send({ success:false, url: null })
                    }
                }).catch(err => {
                    console.log(err)
                    res.send({ success:false,url:null })
                })`

The callback isn't working unfortunately. I have no idea why. I need to navigate to another screen after a cancelled or successful payment.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions