$attempts = $attempts - 1;
 }
 if (!$connected) {
     exit("Failed to establish a connection with the OpenACH server.");
 }
 // Load payment profile using either an external_account_id or a payment_profile_id
 // Make sure you pick an ID that actually exists in your account!
 // NOTE:  To find one, log into your OpenACH account, and find a payment profile by clicking on:
 //   Your originator -> Your Bank -> Your Origination Account -> Payment Profiles
 // A very common use case is for end users to have a 1:1 correlation with payment profiles
 #echo "Retrieving Payment Profile ID from a custom defined app identifier" . PHP_EOL;
 $stored_user_profile_id = 'secret_agent_man';
 // This could be the user's internal app id, email, or whatever
 // NOTE: The use of OAConnection::IDTYPE_APP/OAConnection::IDTYPE_API to identify which type of ID is being provided.
 try {
     $paymentProfile = $oaConn->getPaymentProfile($stored_user_profile_id, OAConnection::IDTYPE_APP);
 } catch (Exception $e) {
 }
 if (!isset($paymentProfile->payment_profile_id)) {
     print "Failed to retrieve Payment Profile, trying another Profile ID..." . PHP_EOL;
     //$paymentProfile = $oaConn->getPaymentProfile('535fee85-3fbe-4873-8bb0-82dac008e979', OAConnection::IDTYPE_API );
     $paymentProfile = $oaConn->getPaymentProfile('3f65a649-7666-4209-9b55-b1c307e01aaf', OAConnection::IDTYPE_API);
 }
 if (!isset($paymentProfile->payment_profile_id)) {
     print "Failed to retrieve Payment Profile" . PHP_EOL;
 } else {
     print "Retrived Payment Profile ..." . PHP_EOL;
     printObj($paymentProfile, 1);
     // Now that we have the PaymentProfile we can set the API Payment Profile ID so it can be used by default on other calls
     echo "Setting the default Payment Profile ID for the connection" . PHP_EOL;
     $oaConn->setPaymentProfileId($paymentProfile->payment_profile_id, OAConnection::IDTYPE_API);
Пример #2
0
}
if (!$connected) {
    exit("Failed to establish a connection with the OpenACH server.");
}
try {
    // Load payment profile using either an external_account_id or a payment_profile_id
    // Make sure you pick an ID that actually exists in your account!
    // NOTE:  To find one, log into your OpenACH account, and find a payment profile by clicking on:
    //   Your originator -> Your Bank -> Your Origination Account -> Payment Profiles
    // A very common use case is for end users to have a 1:1 correlation with payment profiles
    // echo "Retrieving Payment Profile ID from a custom defined app identifier" . PHP_EOL;
    $stored_user_profile_id = '106-profilesim';
    // This could be the user's internal userid, email, or whatever
    $stored_user_profile_id = 'dbeecdd4118c153ecfef8b8bd6d40f85489582e663';
    // This could be the user's internal userid, email, or whatever
    $paymentProfile = $oaConn->getPaymentProfile($stored_user_profile_id, OAConnection::IDTYPE_APP);
    printObj($paymentProfile, 1);
    if (!isset($paymentProfile->payment_profile_id)) {
        // The external_account_id lookup failed, for this demo, use this hard coded payment_profile_id
        // NOTE:  You will want to update this with a valid payment profile id
        $paymentProfile = $oaConn->getPaymentProfile('6ed8cab4-9f66-47fb-9774-e1eeb49f5612', OAConnection::IDTYPE_API);
        //$oaConn->setPaymentProfileId('789937d2-429f-426d-9508-1efb61ac41fb', OAConnection::IDTYPE_API );
        //$oaConn->getPaymentProfile();
    }
    if (isset($paymentProfile->payment_profile_id)) {
        // Now that we have the PaymentProfile we can set the API Payment Profile ID so it can be used by default on other calls
        echo "Setting the default Payment Profile ID for the connection" . PHP_EOL;
        $oaConn->setPaymentProfileId($paymentProfile->payment_profile_id, OAConnection::IDTYPE_API);
        // External accounts represent the user's bank accounts
        // Retrieve the external accounts on this profile
        echo "\tGetting External Accounts..." . PHP_EOL;
 // Create a new Payment Profile
 //payment_profile_id = 			//Should leave these blank for a brand new Profile
 //payment_profile_external_id =		//Should put something here to retrieve later
 //payment_profile_first_name =
 //payment_profile_last_name =
 //payment_profile_email_address =
 //payment_profile_password =
 //payment_profile_security_question_1 =
 //payment_profile_security_question_2 =
 //payment_profile_security_question_3 =
 //payment_profile_security_answer_1 =
 //payment_profile_security_answer_2 =
 //payment_profile_security_answer_3 =
 //payment_profile_status = enabled
 // First retrieve a Payment Profile without an id field, this will create a new empty Payment Profile; then fill it and save it.
 $newPaymentProfile = $oaConn->getPaymentProfile('', OAConnection::IDTYPE_API);
 $newPaymentProfile->payment_profile_first_name = 'Jane' . rand();
 $newPaymentProfile->payment_profile_last_name = 'Eyre' . rand();
 $newPaymentProfile->payment_profile_email_address = 'janeeyre' . rand() . '@thornfield.hall';
 $newPaymentProfile->payment_profile_password = '******';
 $newPaymentProfile->payment_profile_external_id = $newPaymentProfile->payment_profile_email_address;
 print "Saving Payment Profile..." . PHP_EOL;
 printObj($newPaymentProfile, 1);
 $paymentProfile = $oaConn->savePaymentProfile($newPaymentProfile);
 if (isset($paymentProfile->payment_profile_id)) {
     print "Saved Payment Profile to confirm save retrieve it using an identifier..." . PHP_EOL;
     // The reponse from savePaymentProfile was actually the new Profile;
     // we retrieve it here separately and just to demonstrate it worked let's query using the APP Id (instead of the API ID).
     $response = $oaConn->getPaymentProfile($paymentProfile->payment_profile_external_id, OAConnection::IDTYPE_APP);
     printObj($response, 1);
 } else {
 while (!$connected and $attempts > 0) {
     echo "Connecting: {$attempts} remaining" . PHP_EOL;
     $oaConn->connect();
     $connected = $oaConn->isConnected();
     if ($connected) {
         echo "Successfully connected!" . PHP_EOL;
     }
     $attempts = $attempts - 1;
 }
 if (!$connected) {
     exit("Failed to establish a connection with the OpenACH server.");
 }
 // Pretty much everything requires a Payment Profile; optionally retrieve the PaymentProfile to ensure it still exists.
 //$payment_profile_id ='535fee85-3fbe-4873-8bb0-82dac008e979';
 $payment_profile_id = '3f65a649-7666-4209-9b55-b1c307e01aaf';
 $paymentProfile = $oaConn->getPaymentProfile($payment_profile_id, OAConnection::IDTYPE_API);
 if (!isset($paymentProfile->payment_profile_id)) {
     exit("Failed to retrieve payment profile.");
 }
 // Now create a new External Bank Account for this Payment Profile
 print "Creating new External Account for this Payment Profile..." . PHP_EOL;
 // Create a new External Account
 //external_account_id =
 //external_account_payment_profile_id =
 //external_account_type =
 //external_account_name =
 //external_account_bank =
 //external_account_holder =
 //external_account_country_code =
 //external_account_dfi_id =
 //external_account_number =