1

iPhoneのネイティブアプリにペイパルを実装します。しかし、私はその問題に直面しています。

PayKeyに関するトランザクションIDを取得したい。PayPalライブラリにPayKeyを取得するための直接メソッドがありますが、transactionIdを取得するためのメソッドはありません。

その方法は次のとおりです。

-(void)paymentSuccessWithKey:(NSString *)payKey andStatus:(PayPalPaymentStatus)paymentStatus;

IPN(即時支払い通知)がこの問題の解決に役立つと思っているのですが、アプリに実装する方法がわかりませんか?

この問題の解決にご協力ください。

ありがとう、チャンドラ・プラカシュ

4

3 に答える 3

2

同様の問題がありましたが、IPN に頼ることができなかったので、別の方法を共有すると思いました。

IPN を使用する必要はありません。payKey を使用してトランザクション ID を取得できます。これは、モバイル決済の検証に役立ちます。これは、payKey からすべてのトランザクション情報を取得する php ブロックです。モバイル アプリから呼び出す必要があります。iOS の場合、次のチュートリアルを使用できます: http://www.raywenderlich.com/13511/how-to-create-an-app-like-instagram-with-a-web-service-backend-part-12

<?
header("Content-Type: application/json");

//DEBUG TO CHECK PAYKEY
//turn php errors on
ini_set("track_errors", true);

//Example payKey (got from iOS app)
$payKey = "<snip>";

//set PayPal Endpoint to sandbox
$url = trim("https://svcs.sandbox.paypal.com/AdaptivePayments/PaymentDetails?payKey=".$payKey."&requestEnvelope.errorLanguage=en_US");

//PayPal API Credentials

//to do: change these for production credentials in the production app
$API_UserName = "<snip>";
$API_Password = "<snip>";
$API_Signature = "<snip>";

//Default App ID for Sandbox
$API_AppID = "APP-80W284485P519543T";

$API_RequestFormat = "NV";
$API_ResponseFormat = "NV";

try
{
    //Create payload for this query
    $bodyparams = array ("requestEnvelope.errorLanguage" => "en_US");
    // convert payload array into url encoded query string
    $body_data = http_build_query($bodyparams, "", chr(38));   // Generates body data

    //create request and add headers
    $params = array("http" => array(
        "method" => "POST",
        "content" => $body_data,
        "header" =>  "X-PAYPAL-SECURITY-USERID: " . $API_UserName . "\r\n" .
        "X-PAYPAL-SECURITY-PASSWORD: " . $API_Password . "\r\n" .
        "X-PAYPAL-SECURITY-SIGNATURE: " . $API_Signature . "\r\n" .
        "X-PAYPAL-APPLICATION-ID: " . $API_AppID . "\r\n" .
        "X-PAYPAL-REQUEST-DATA-FORMAT: " . $API_RequestFormat . "\r\n" .
        "X-PAYPAL-RESPONSE-DATA-FORMAT: " . $API_ResponseFormat
));


    //create stream context
    $ctx = stream_context_create($params);

    //open the stream and send request
    $fp = @fopen($url, "r", false, $ctx);

    //get response
    $response = stream_get_contents($fp);

    //check to see if stream is open
    if ($response === false) {
        throw new Exception("php error message = " . "$php_errormsg");
    }

    //close the stream
    fclose($fp);

    //parse the ap key from the response

    $keyArray = explode("&", $response);

    foreach ($keyArray as $rVal){
        list($qKey, $qVal) = explode ("=", $rVal);
        $kArray[$qKey] = $qVal;
    }

    //print the response to screen for testing purposes
    If ( $kArray["responseEnvelope.ack"] == "Success") 
    {

        foreach ($kArray as $key =>$value){
            echo $key . ": " .$value . "<br/>";
        }
    }
    else {
        echo 'ERROR Code: ' .  $kArray["error(0).errorId"] . " <br/>";
        echo 'ERROR Message: ' .  urldecode($kArray["error(0).message"]) . " <br/>";
    }
}


catch(Exception $e) 
{
    echo "Message: ||" .$e->getMessage()."||";
}

//End check paykey

?>

$kArray で取得できるすべてのフィールドを示す画像を添付したかったのですが、評判がありません。$kArray["paymentInfoList.paymentInfo(0).transactionId"]

注: サンドボックスに使用する API 資格情報は、developer.paypal.com の「サンドボックス アカウント」の下にあります。xxxfacilitator@xxx のプロファイルを展開して入手してください

于 2013-08-17T12:54:37.050 に答える
2

最後に、私は私の質問の解決策を得ました。

IPN を使用してトランザクション ID を取得しました。

PayPal アカウントからENABLE IPNオプションを選択すると、paypal から送信されたすべての詳細が、そこから指定した URL で受信され、すべての必須フィールドが取得されました。

ここにあなたを助けるためのいくつかのリンクがあります

IPN の概要: https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/howto_html_instantpaymentnotif

IPN ドキュメント: https://cms.paypal.com/cms_content/US/en_US/files/developer/IPNGuide.pdf

IPN 変数: https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_IPNandPDTVariables

IPN スクリプトの例: https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_admin_IPNImplementation

IPN スクリプト ジェネレーター: https://www.paypaltech.com/SG2/

ありがとう、CP

于 2012-04-23T13:43:54.020 に答える