2016-07-19 2 views
0

私のウェブサイトの製品販売に2checkout apiを使用しています。私は、次のような行項目の個々を設定しようとすると、2checkout api create saleをご希望の場合

try { 
    $charge = Twocheckout_Charge::auth(array(
     "merchantOrderId" => "123", 
     "token"  => $_POST['token'], 
     "currency" => 'USD', 
     "total"  => $first_bill['amount'], 
     "billingAddr" => array(
      "name" => $_POST['b_name'], 
      "addrLine1" => $_POST['b_address'], 
      "city" => 'Columbus', 
      "state" => 'OH', 
      "zipCode" => '43123', 
      "country" => $_POST['b_country'], 
      "email" => $_POST['b_emaill'], 
      "phoneNumber" => $_POST['b_phone'] 
      ), 
     "shippingAddr" => array(
      "name" => 'Testing Tester', 
      "addrLine1" => '123 Test St', 
      "city" => 'Columbus', 
      "state" => 'enter code hereOH', 
      "zipCode" => '43123', 
      "country" => 'USA', 
      "email" => '[email protected]', 
      "phoneNumber" => '555-555-5555' 
      ) 
     )); 
    if ($charge['response']['responseCode'] == 'APPROVED') { 

     echo $response;exit; 
     // echo "Thanks for your Order!"; 
     // echo "<h3>Return Parameters:</h3>"; 
     // echo "<pre>"; 
     // print_r($charge); 
     // echo "</pre>"; 
    } 
    else 
    { 
     $this->Registrationmodel->delete_account($accounts_id); 
     echo $charge['response']['responseCode']; 
     exit; 
    } 
} 
catch (Twocheckout_Error $e) 
{ 
    echo $e->getMessage(); 
    exit; 
} 

}

を、したがって:したがって、私は流れるような単一product.Itの表情で合計金額でAPIを呼び出すことができ、販売を作成する2checkout APIを呼び出しています:

try { 
    $charge = Twocheckout_Charge::auth(array(
     "merchantOrderId" => "123", 
     "token"  => $_POST['token'], 
     "currency" => 'USD', 
     //"total"  => $first_bill['amount'], 
     "billingAddr" => array(
      "name" => $_POST['b_name'], 
      "addrLine1" => $_POST['b_address'], 
      "city" => 'Columbus', 
      "state" => 'OH', 
      "zipCode" => '43123', 
      "country" => $_POST['b_country'], 
      "email" => $_POST['b_emaill'], 
      "phoneNumber" => $_POST['b_phone'] 
      ), 
     "LineItem" => array(
      "duration" => 'Forever', 
      "price" => '10', 
      "productId" =>'1235', 
      "quantity" => '1', 
      "recurrence" => '1 Month', 
      "tangible" => 'N', 
      "type"=>'product' 
      ), 
     "shippingAddr" => array(
      "name" => 'Testing Tester', 
      "addrLine1" => '123 Test St', 
      "city" => 'Columbus', 
      "state" => 'OH', 
      "zipCode" => '43123', 
      "country" => 'USA', 
      "email" => '[email protected]', 
      "phoneNumber" => '555-555-5555' 
      ) 
     )); 
    if ($charge['response']['responseCode'] == 'APPROVED') { 
     $response = $this->return_information($charge['response']['orderNumber']); 
     echo $response;exit; 
     // echo "Thanks for your Order!"; 
     // echo "<h3>Return Parameters:</h3>"; 
     // echo "<pre>"; 
     // print_r($charge); 
     // echo "</pre>"; 
    } 
    else 
    { 
     $this->Registrationmodel->delete_account($accounts_id); 
     echo $charge['response']['responseCode']; 
     exit; 
    } 
} 
catch (Twocheckout_Error $e) 
{ 
    $this->Registrationmodel->delete_account($accounts_id); 
    echo $e->getMessage(); 
    exit; 
} 

}

それは私にパラメータエラーを与えています。誰でも助けてくれますか? API呼び出しを使用して広告申込情報を設定する方法は?

答えて

0

lineitem配列に必須のパラメータである「名前」パラメータがありません。必要なパラメータの完全なリストはhereです。

また、ご使用の製品が無形であるため、出荷用アレイが不要なため、出荷用アレイを取り外すこともできます。

ここで私が使用して作業例です:

try { 
    $charge = Twocheckout_Charge::auth(array(
    "sellerId" => "xxxxxxxxx", 
    "li_0_merchant_order_id" => "1", 
    "type" => "product", 
    "token"  => $_POST['token'], 
    "currency" => "USD", 
    // "total" => "1.00",   //Only use when lineitems are not passed in 

     "lineItems" => array(
      "0" => array(
       "name" => $_POST['name'], 
       "price" => $_POST['price'], 
       "quantity" => $_POST['quantity'], 
       "startupFee" => $_POST['startupFee'], 
       "tangible" => $_POST['tangible'] 
       ) 
      ), 
     "billingAddr" => array(
      "name" => $_POST['customer'], 
      "addrLine1" => $_POST['addrLine1'], 
      "city" => $_POST['city'], 
      "state" => $_POST['state'], 
      "zipCode" => $_POST['zipCode'], 
      "country" => $_POST['country'], 
      "email" => $_POST['email'], 
      "phoneNumber" => '' 
      ) 
      )); 

    if ($charge['response']['responseCode'] == 'APPROVED') { 

より良い私は上記のコード内のLineItem配列に「継続」&「再発」キー&それぞれの値を追加し、あなたのアプリケーションを適合させるため。私が提供した例には、非有形の販売に必要なすべてのパラメータが含まれています。

関連する問題