示例#1
0
 public function getProfile($id)
 {
     $this->loadCreds();
     $request = new AnetAPI\GetCustomerPaymentProfileRequest();
     $request->setRefId($id);
     $request->setMerchantAuthentication($this->loadCreds());
     $controller = new AnetController\GetCustomerPaymentProfileController($request);
     $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX);
     if ($response != null) {
         if ($response->getMessages()->getResultCode() == "Ok") {
             echo "GetCustomerPaymentProfile SUCCESS: " . "\n";
             echo "Customer Payment Profile Id: " . $response->getPaymentProfile()->getCustomerPaymentProfileId() . "\n";
             echo "Customer Payment Profile Billing Address: " . $response->getPaymentProfile()->getbillTo()->getAddress() . "\n";
             echo "Customer Payment Profile Card Last 4 " . $response->getPaymentProfile()->getPayment()->getCreditCard()->getCardNumber() . "\n";
         } else {
             echo "GetCustomerPaymentProfile ERROR :  Invalid response\n";
             echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . "  " . $response->getMessages()->getMessage()[0]->getText() . "\n";
         }
     } else {
         echo "NULL Response Error";
     }
 }
$billto->setfaxNumber("999-999-9999");
$billto->setCountry("USA");
// Create the Customer Payment Profile object
$paymentprofile = new AnetAPI\CustomerPaymentProfileExType();
$paymentprofile->setCustomerPaymentProfileId("33211899");
$paymentprofile->setBillTo($billto);
$paymentprofile->setPayment($paymentCreditCard);
// Submit a UpdatePaymentProfileRequest
$request->setPaymentProfile($paymentprofile);
$controller = new AnetController\UpdateCustomerPaymentProfileController($request);
$response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX);
if ($response != null && $response->getMessages()->getResultCode() == "Ok") {
    echo "Update Customer Payment Profile SUCCESS: " . "\n";
    // Update only returns success or fail, if success
    // confirm the update by doing a GetCustomerPaymentProfile
    $getRequest = new AnetAPI\GetCustomerPaymentProfileRequest();
    $getRequest->setMerchantAuthentication($merchantAuthentication);
    $getRequest->setRefId($refId);
    $getRequest->setCustomerProfileId("36731856");
    $getRequest->setCustomerPaymentProfileId("33211899");
    $controller = new AnetController\GetCustomerPaymentProfileController($getRequest);
    $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX);
    if ($response != null) {
        if ($response->getMessages()->getResultCode() == "Ok") {
            echo "GetCustomerPaymentProfile SUCCESS: " . "\n";
            echo "Customer Payment Profile Id: " . $response->getPaymentProfile()->getCustomerPaymentProfileId() . "\n";
            echo "Customer Payment Profile Billing Address: " . $response->getPaymentProfile()->getbillTo()->getAddress() . "\n";
        } else {
            echo "GetCustomerPaymentProfile ERROR :  Invalid response\n";
            echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . "  " . $response->getMessages()->getMessage()[0]->getText() . "\n";
        }