Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can one confirm payment status directly on your service from a different programming language? #34

Closed
steveify1 opened this issue Aug 24, 2020 · 1 comment

Comments

@steveify1
Copy link

steveify1 commented Aug 24, 2020

Hi. I'm working on a GoURL SDK for NodeJs and I've been able to successfully implement the get_json_values() (named createPayment() in the code) method that starts the payment process. Now, I'm trying to implement the check_payment_live() (named checkPaymentStatus()) to allow the user directly check the status of his/her payment on demand. But each time I make a POST request to the https://coins.gourl.io/result.php route with the required data parsed as a query string, I get the following response:

{
        "status": "error",
        "err": "Invalid data submitted",
        "box": "",
        "boxtype": "",
        "order": "",
        "user": "",
        "userformat": "",
        "period": "",
        "amount": "",
        "amountusd": "",
        "coinlabel": "",
        "coinname": "",
        "addr": "",
        "tx": "",
        "confirmed": "",
        "timestamp": "",
        "date": "",
        "datetime": ""
    }

Here is the data that gets converted to a query string and sent in the request:

{
      g: privateKeyHash,
      b: options.boxID,
      o: options.orderID,
      u: options.userID,
      l: options.language,
      e: period,
      i: options.ipAddress,
      h: hash,
    }

Below is the implementation:

static async checkPaymentStatus(options: PaymentStatusOptions): Promise<any> {
    const privateKeyHash = crypto
      .createHash('sha512')
      .update(options.privateKey!)
      .digest('hex');

    const period = formatExpiryPeriod(options.period);

    const toHash = `${options.boxID}${privateKeyHash}${options.userID}${options.orderID}${options.language}${period}${options.ipAddress}`;
    const hash = md5(toHash);

    const data = {
      g: privateKeyHash,
      b: options.boxID,
      o: options.orderID,
      u: options.userID,
      l: options.language,
      e: period,
      i: options.ipAddress,
      h: hash,
    };

    const url = `https://coins.gourl.io/result.php`;

    const res = await axios.post(url, null, {
      params: data, // converts and attaches data as a query string
      headers: {
        'User-Agent': options.userAgent,
      },
      timeout: 20000,
    });
    
    return res.data;
  }

This NodeJs implementation doesn't attempt to store/use sessions or store the data in any database. It only provides the user the JSON data returned from the GoUrl server. I don't know why I keep getting the Invalid data submitted error. The data I send in the POST request to check payment status matches the data I send when initiating the payment in the first place. Please, I need help to understand what I'm not doing right.

This is the link to the repo: https://github.com/steveify1/node-gourl/tree/ft-check-payment-status-%2326.
The link to the Cyptobox class: https://github.com/steveify1/node-gourl/blob/ft-check-payment-status-%2326/lib/Cryptobox.ts

I understand that this is the repo for the PHP implementation, but I couldn't send a DM on twitter. Thanks.

@cryptoapi
Copy link
Owner

Please send your paymentbox ID, we will activate debug mode for you.

https://gourl.io/view/contact/Contact_Us.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants