带有perl脚本的Verif Receipt

时间:2012-09-28 14:35:41

标签: perl cordova in-app-purchase

我必须使用perl脚本连接到iOS上的App Purchase中的verifReceipt。 我也使用phoneGap 1.5.0

1 /当我尝试使用外部网址时,它不起作用。 2 /我尝试在phonegap html页面和itunes之间使用perl脚本接口。 我不明白如何发送数据。我试试这个:

$val contains JSON object with receiptvalue and password, receiving from phonegap.

my %transformfields = (
            "receipt-data"       => $val,
            );

my $ua = LWP::UserAgent->new;

my $req = POST($urlsend,
    Content_Type => 'application/json ; charset=UTF-8',
    Content => \%transformfields,
    #Content => $val,
    );



my $res = $ua->request($req);

我总是有这个错误:21002 java.lang.NullPointerException 我不明白如何使用perl脚本发送数据。

1 个答案:

答案 0 :(得分:0)

我遇到json编码问题,并了解如何从phonegap插件接收数据。

求助: Phongap插件在Base64中返回transactionReceipt。 不要在Base64中对密码进行编码。

my %transformfields = ("receipt-data" => $val , "password" => $sharedsecretpass ) ;
my $jsonval = encode_json (\%transformfields);

print "Content-Type: text/html \n\n";

#my $urlsend="https://buy.itunes.apple.com/verifyReceipt" ;
my $urlsend="https://sandbox.itunes.apple.com/verifyReceipt" ;

my $req = POST($urlsend,
    Content_Type => 'application/x-www-form-urlencoded ; charset=utf-8',
    Content => $jsonval,
    );

my $ua = LWP::UserAgent->new;
my $res = $ua->request($req);

if ($res->is_success)
{
    #print "cgi Content : " . $res->content . "<br />\n";
    my $retour = decode_json( $res->content );
    if ($retour->{'status'} eq "0")
    {
            print "--OK--<br />\n";
            print $retour->{receipt}->{product_id} . "<br />";
            print $retour->{receipt}->{transaction_id} . "<br />";
            print $retour->{receipt}->{purchase_date} . "<br />";
            print $retour->{receipt}->{expires_date} . "<br />";

            #$res->content
    }