1

次のコードを使用しています

$customerProfile = new AuthorizeNetCustomer;
    $customerProfile->description = "Description of customer";
    $customerProfile->merchantCustomerId = "honululu27";
    $customerProfile->email = "user2@domain.com";

    // Add payment profile.
    $paymentProfile = new AuthorizeNetPaymentProfile;
    $paymentProfile->payment->creditCard->cardNumber = "4111111111111111";
    $paymentProfile->payment->creditCard->expirationDate = "2015-10";
    $customerProfile->paymentProfiles[] = $paymentProfile;

    //Check customer
    $request = new AuthorizeNetCIM;
    $response = $request->createCustomerProfile($customerProfile);
    echo $response->getCustomerProfileId(); //shows up only in case of success
    echo $response->xml->resultCode; //never shows up
        echo $response->xml->message->code; //never shows up
        echo $response->xml->customerProfileId; //shows up only in case of success

        // Confused about the portion below
    if($response->isOk())
    {
        echo "Success";
        echo $response->getCustomerProfileId();
    }
    else
    {
        echo "FAILED";
        echo $response->xml->resultCode;
    }

さて、おそらくおわかりのように、私はこれに慣れていないので、メッセージ テキストとコードを表示する方法がわかりません。機能しているのは顧客 ID だけで、成功した場合に表示されますが、メッセージなどの他のすべての xml フィールドはどうでしょうか?

4

1 に答える 1

0

echo $response->getCustomerProfileId(); //成功した場合にのみ表示されます
echo $response->xml->customerProfileId; //成功した場合のみ表示される

API呼び出しが成功した場合にのみプロファイルIDを取得するため、これは理にかなっています

echo $response->xml->resultCode; //決して現れない

試すecho $response->xml->messages->resultCode

echo $response->xml->message->code; //決して現れない

試すecho $response->xml->messages->message->code

CIM 応答の XML 構造を示すサンプル応答を次に示します。コードが機能しない理由を理解するのに役立ちます。

<?xml version="1.0" encoding="utf-8"?>
<createCustomerProfileResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
  <messages>
    <resultCode>Ok</resultCode>
    <message>
      <code>I00001</code>
      <text>Successful.</text>
    </message>
  </messages>
  <customerProfileId>5427896</customerProfileId>
  <customerPaymentProfileIdList>
    <numericString>4796541</numericString>
  </customerPaymentProfileIdList>
  <customerShippingAddressIdList>
    <numericString>4907537</numericString>
  </customerShippingAddressIdList>
  <validationDirectResponseList>
    <string>1,1,1,This transaction has been approved.,EY6CR8,Y,2165732750,none,Test transaction for ValidateCustomerPaymentProfile.,0.00,CC,auth_only,12345,John,Smith,,123 Main Street,Townsville,NJ,12345,,800-555-1234,,user@example.com,none,none,none,none,none,none,none,none,0.00,0.00,0.00,FALSE,none,72784EF27A4DD684150C39B923FC4478,,2,,,,,,,,,,,XXXX1111,Visa,,,,,,,,,,,,,,,,</string>
  </validationDirectResponseList>
</createCustomerProfileResponse>
于 2011-12-03T02:22:29.973 に答える