Results 1 to 5 of 5
  1. #1
    Junior Member
    Join Date
    Jun 2016
    Posts
    0

    A few questions about JVZOO api

    Hey;

    This is api doc of JV zoo.

    I got a couple simple quetions about this api and my code.

    I use this script to update our database when there is a sale, refund etc etc.

    This is their original code:

    PHP Code:
    <?php
    function jvzipnVerification() {
    $secretKey = "MyJVZIPNSecretKey";
    $pop = "";
    $ipnFields = array();
    foreach (
    $_POST AS $key => $value) {
    if (
    $key == "cverify") {
    continue;
    }
    $ipnFields[] = $key;
    }
    sort($ipnFields);
    foreach (
    $ipnFields as $field) {
    // if Magic Quotes are enabled $_POST[$field] will need to be
    // un-escaped before being appended to $pop
    $pop = $pop . $_POST[$field] . "|";
    }
    $pop = $pop . $secretKey;
    if (
    'UTF-8' != mb_detect_encoding($pop))
    {
    $pop = mb_convert_encoding($pop, "UTF-8");
    }
    $calcedVerify = sha1($pop);
    $calcedVerify = strtoupper(substr($calcedVerify,0,8));
    return
    $calcedVerify == $_POST["cverify"];
    }
    ?>


  2. #2
    Junior Member
    Join Date
    May 2016
    Posts
    0

    A few questions about JVZOO api

    Question 1:
    Is it correct to assign variables in that part of the code in the loop?

    Question 2:
    How can I test this easily? I've done apis Stripe, Paypal and some others. There I can do api webhook test and see the responsise on screen on my dashboard. But with these guys can't really. I can do manual test purchase but seems a bit hard not to see responses.

    Question 3:
    Function in function? Why not do just this:PHP Code:
    <?php

    defined
    ('BASEPATH') OR exit('No direct script access allowed');

    class
    Jvzoo extends CI_Controller {

    public function
    index()
    {
    $secretKey = "1234567890";
    $pop = "";
    $ipnFields = array();
    foreach (
    $_POST AS $key => $value)
    {
    if (
    $key == "cverify")
    {
    continue;
    }
    $ipnFields[] = $key;

    //
    $email = $_POST['ccustemail'];
    /*ccustname
    cproditem
    cprodtitle
    cprodtype
    ctransaction
    ctransaffiliate
    ctransamount
    ctranspaymentmethod
    ctransvendor
    ctransreceipt
    cupsellreceipt
    caffitid*/
    //
    }
    sort($ipnFields);
    foreach (
    $ipnFields as $field) {
    // if Magic Quotes are enabled $_POST[$field] will need to be
    // un-escaped before being appended to $pop
    $pop = $pop . $_POST[$field] . "|";
    }
    $pop = $pop . $secretKey;
    if (
    'UTF-8' != mb_detect_encoding($pop))
    {
    $pop = mb_convert_encoding($pop, "UTF-8");
    }
    $calcedVerify = sha1($pop);
    $calcedVerify = strtoupper(substr($calcedVerify,0,8));
    return
    $calcedVerify == $_POST["cverify"];
    }
    ?>


  3. #3

    A few questions about JVZOO api

    Originally Posted by English Breakfast Tea
    I am thinking of assigning variables like this

    Why?


    Originally Posted by English Breakfast Tea
    Question 1:
    Is it correct to assign variables in that part of the code in the loop?


    Probably not. At the very least you don't want to do that inside the loop. With the code there the variables would only be available within that function, so unless you're adding more code I don't see the point.


    Originally Posted by English Breakfast Tea
    Question 2:
    How can I test this easily? I've done apis Stripe, Paypal and some others. There I can do api webhook test and see the responsise on screen on my dashboard. But with these guys can't really. I can do manual test purchase but seems a bit hard not to see responses.


    Simulate a request, either through their tools if they have them or on your own (for example with just a simple HTML form that posts to the file). If you can't see the output then log things to a file or use xdebug and a debugger to step through the code.

  4. #4

    A few questions about JVZOO api

    Originally Posted by English Breakfast Tea
    I am thinking of assigning variables like this

    Why?


    Originally Posted by English Breakfast Tea
    Question 1:
    Is it correct to assign variables in that part of the code in the loop?


    Probably not. At the very least you don't want to do that inside the loop. With the code there the variables would only be available within that function, so unless you're adding more code I don't see the point.


    Originally Posted by English Breakfast Tea
    Question 2:
    How can I test this easily? I've done apis Stripe, Paypal and some others. There I can do api webhook test and see the responsise on screen on my dashboard. But with these guys can't really. I can do manual test purchase but seems a bit hard not to see responses.


    Simulate a request, either through their tools if they have them or on your own (for example with just a simple HTML form that posts to the file). If you can't see the output then log things to a file or use xdebug and a debugger to step through the code.



    Originally Posted by English Breakfast Tea
    Question 3:
    Function in function? Why not do just this:


    They don't show a function within a function. Their intent is for you to copy that function to a file somewhere and include it, then just use it.
    eg:
    PHP Code:
    <?php
    defined
    ('BASEPATH') OR exit('No direct script access allowed');
    require
    'jvzipn.php';
    class
    Jvzoo extends CI_Controller {
    public function
    index(){
    if (
    jvzipnVerification()){
    }
    }
    }


    If you'd rather copy it over to another method on your class, you can do that instead.
    PHP Code:
    class Jvzoo extends CI_Controller {
    public function
    index()
    {
    if (
    $this->jvzipnVerification()){
    }
    }

    private function
    jvzipnVerification() {
    $secretKey = "1234567890";
    $pop = "";
    $ipnFields = array();
    foreach (
    $_POST AS $key => $value)
    {
    if (
    $key == "cverify")
    {
    continue;
    }
    $ipnFields[] = $key;
    }
    sort($ipnFields);
    foreach (
    $ipnFields as $field) {
    // if Magic Quotes are enabled $_POST[$field] will need to be
    // un-escaped before being appended to $pop
    $pop = $pop . $_POST[$field] . "|";
    }
    $pop = $pop . $secretKey;
    if (
    'UTF-8' != mb_detect_encoding($pop))
    {
    $pop = mb_convert_encoding($pop, "UTF-8");
    }
    $calcedVerify = sha1($pop);
    $calcedVerify = strtoupper(substr($calcedVerify,0,8));
    return
    $calcedVerify == $_POST["cverify"];
    }
    }



  5. #5
    Junior Member
    Join Date
    Jul 2016
    Location
    Peru
    Posts
    0

    A few questions about JVZOO api

    And at if I email these, I get these:

    PHP Code:
    mail('myemail@yahoo.com','JV ZOO REPORT',$calcedVerify);


    Emails me: 1841C348

    PHP Code:
    mail('myemail@yahoo.com','JV ZOO REPORT POST',$_POST["cverify"]);


    Emails me: 8FD0F1CD

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •