Giter Club home page Giter Club logo

alipay-global-sdk-php's Issues

Payment Notify Verify is 0

We use alipay global's public key:(sandbox)
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtOcJhqk3mKhcGC0ARNjdFoZtYGEhfcgrUEUe9CF+sDzIJZMMVypRY67GoDQEdZTmHBPnVtsBRKNGSq4/h8r4BZ3XNE81K8CqwX0YzwqEvd0qlhyn9KzGCQF3Ps9wQRkPKdFzvmYcrW4WXmMOVMDg+XxuzNpXygqpxOJ++7Dpi8E6Ste0/ZtrJ2ACLIZVKCh951Cko25ePd2QyJpXq1g2jyWMRQVIapPp+t+UHG/4affBYI5GNREsxcXukg+SeymMlR2TwZvbyGYMlEb34icznLeD4jdkXOnU3pmkxYg2FmVCg0YujqrUL6yjQ648WkGruKFAyMkXC9inj9eZJwn8eQIDAQAB

And the notify verification is always 0.
Could you help to figure out the verify testing use case and we can check if code is correct?

e.g.

<?php

function verify($httpMethod, $path, $clientId, $rspTime, $rspBody, $signature, $alipayPublicKey)
{
    $rspContent = genSignContent($httpMethod, $path, $clientId, $rspTime, $rspBody);
    return verifySignatureWithSHA256RSA($rspContent, $signature, $alipayPublicKey);
}

function genSignContent($httpMethod, $path, $clientId, $timeString, $content)
{
    $payload = $httpMethod . " " . $path . "\n" . $clientId . "." . $timeString . "." . $content;
    return $payload;
}
function verifySignatureWithSHA256RSA($rspContent, $rspSignValue, $alipayPublicKey)
{
    $pubKey = "-----BEGIN PUBLIC KEY-----\n" .
        wordwrap($alipayPublicKey, 64, "\n", true) .
        "\n-----END PUBLIC KEY-----";
    if (
        strstr($rspSignValue, "=")
        || strstr($rspSignValue, "+")
        || strstr($rspSignValue, "/")
        || $rspSignValue == base64_encode(base64_decode($rspSignValue))
    ) {
        $originalRspSignValue = base64_decode($rspSignValue);
    } else {
        $originalRspSignValue = base64_decode(urldecode($rspSignValue));
    }
    $verifyResult = openssl_verify($rspContent, $originalRspSignValue, $pubKey, OPENSSL_ALGO_SHA256);
    return $verifyResult;
}
$httpMethod = "POST";
$path = "";
$clientId = "SANDBOX_5Y606G2YJPQB00270";
$rspTime = "2022-04-26T04:39:22Z";

$signature = "bc6MuaBUCbIgxG6fbGh6MHJP%2FqiI6lrosdnN8mEEunDRR3k5j8cjRbGI8fAeE%2Bibhu%2FN4JxjGGCY7c%2B%2FTM8kUdv8nTdHU2MERsBn3mRcFe4eBW%2BxtFLL2brYaKSc%2Bb3mwIA0icHoUpwirVbfl9RrUviMsEJtSFW14rzKVjqBvwNo4iqzkh%2B2UIjzx%2FI7pbrSinZcJNZdjmMRRReQAMsYcrGGrzR%2BPtUjS%2FwNtA8NVHHk2LUeTuwtDVt%2F2ZxrsVm6C%2FufIZ3dz4yInSoR6fRms2%2FP67lb9PSTq0LGNM9EcXhtb3gCWmfdPPrUUuqxuBgDFno7%2F2%2BaPcht3GKP%2FPNrAg%3D%3D";
$alipayPublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAi1ltikGrnsmknSD/OYNQSMw485C/OF7Y9MVxHIDkbIWZm8JC9cuhdZbduTmx2AKeDmkYK73dbF1xZnZQGd38sSKAkiWOSbz15a0bfd/XMlcx5ICqjkWi6gMWYOgUBp1RLuHvisjicwb4fBIN7IPySGMvSFFgPspUUc6gY3HKJgP59KAUJR1WA7B7tPw0C/xhcRFKln0nsU7wzk7R4HhYzKua0BxV6mYYDxGbVepH5tJ5ZzSNVR3IGJRQc6c7+gU1F6z5Jc3V4NT7EHOmu7T888A+Uhec+4XymTVNkRZ+u6ZEj03oMwtv7NcQf2z8Kcp1/VeyOg7toXoQjNtH2oEIWQIDAQAB";
$rspBody = '{
    "notifyType": "PAYMENT_RESULT",
    "result": {
        "resultCode": "SUCCESS",
        "resultStatus": "S",
        "resultMessage": "success"
    },
    "paymentRequestId": "20200101234567890444",
    "paymentId": "20200101234567890132",
    "paymentAmount": {
        "value": "8000",
        "currency": "EUR"
    },
    "actualPaymentAmount": {
        "value": "8000",
        "currency": "EUR"
    },
    "paymentCreateTime": "2020-01-01T12:01:00+08:30",
    "paymentTime": "2020-01-01T12:01:01+08:30"
}';
echo (int) verify($httpMethod, $path, $clientId, $rspTime, $rspBody, $signature, $alipayPublicKey);

the above data is from alipay global's inotify testing data.
All fields is copied at alipay's console except path field, according to the API document notify need to fill the path filed. Could you help me to check if path is needed and how to fill this field when we verify the notification from the payment transaction(async) .

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.