title: How to get customerpaymentrofileId from an existing customerprofileid in authorize.net
body: <p>How to get customerpaymentrofileId from an existing customerprofileid in authorize.net I am a novice in autorize.net . I need to get the customerpaymentrofileId of a customer's customerprofileid , ao that i can use them to charge for  a transaction in Authorize.net.  </p>
  
  <pre><code>$email="soumik@esolzmail.com";
          // Common setup for API credentials
        $merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
        $merchantAuthentication-&gt;setName("1212121");
        $merchantAuthentication-&gt;setTransactionKey("12121221");
        $refId = 'ref' . time();
  
          // Create the payment data for a credit card
         $creditCard = new AnetAPI\CreditCardType();
         $creditCard-&gt;setCardNumber("4111111111111111");
         $creditCard-&gt;setExpirationDate("2038-12");
         $paymentCreditCard = new AnetAPI\PaymentType();
         $paymentCreditCard-&gt;setCreditCard($creditCard);
  
    // Create the Bill To info
         $billto = new AnetAPI\CustomerAddressType();
         $billto-&gt;setFirstName("Ellen");
         $billto-&gt;setLastName("Johnson");
         $billto-&gt;setCompany("Souveniropolis");
         $billto-&gt;setAddress("14 Main Street");
         $billto-&gt;setCity("Pecan Springs");
         $billto-&gt;setState("TX");
         $billto-&gt;setZip("44628");
         $billto-&gt;setCountry("USA");
  
   // Create a Customer Profile Request
   //  1. create a Payment Profile
   //  2. create a Customer Profile   
   //  3. Submit a CreateCustomerProfile Request
   //  4. Validate Profiiel ID returned
  
          $paymentprofile = new AnetAPI\CustomerPaymentProfileType();
  
          $paymentprofile-&gt;setCustomerType('individual');
    $paymentprofile-&gt;setBillTo($billto);
    $paymentprofile-&gt;setPayment($paymentCreditCard);
    $paymentprofiles[] = $paymentprofile;
    $customerprofile = new AnetAPI\CustomerProfileType();
    $customerprofile-&gt;setDescription("Customer 2 Test PHP 1");
  
    //$customerprofile-&gt;setMerchantCustomerId("M_".time());
    $customerprofile-&gt;setEmail($email."d");
    $customerprofile-&gt;setPaymentProfiles($paymentprofiles);
  
    $request = new AnetAPI\CreateCustomerProfileRequest();
    $request-&gt;setMerchantAuthentication($merchantAuthentication);
    $request-&gt;setRefId( $refId);
    $request-&gt;setProfile($customerprofile);
    $controller = new AnetController\CreateCustomerProfileController($request);
    $response = $controller-&gt;executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX);
    if (($response != null) &amp;&amp; ($response-&gt;getMessages()-&gt;getResultCode() == "Ok") )
    {
        echo "Succesfully create customer profile : " . $response-&gt;getCustomerProfileId() . "\n";
        $paymentProfiles = $response-&gt;getCustomerPaymentProfileIdList();
        echo "SUCCESS: PAYMENT PROFILE ID : " . $paymentProfiles[0] . "\n";
     }
    else
    {
        echo "ERROR :  Invalid response\n";
        $errorMessages = $response-&gt;getMessages()-&gt;getMessage();
        echo "Response : " . $errorMessages[0]-&gt;getCode() . "  " .$errorMessages[0]-&gt;getText() . "\n";
    }
    //return $response;
  
    echo "response=&gt; &lt;pre&gt;"; print_r($response); echo "&lt;/pre&gt;";
  </code></pre>