Skip to content

Instantly share code, notes, and snippets.

@janhartigan
Last active August 29, 2015 13:57
Show Gist options
  • Save janhartigan/9654077 to your computer and use it in GitHub Desktop.
Save janhartigan/9654077 to your computer and use it in GitHub Desktop.
/**
* Begins the bank account verification process
*
* @param string $account_token
* @param string $verification_id
* @param int $amount1
* @param int $amount2
*
* @return mixed int (# attempts left) | true //be sure to use strict === check against true
*/
public function confirmBankAccountVerification($account_token, $verification_id, $amount1, $amount2)
{
//grab the verification
if (!$verification = $this->getBankAccountVerification($account_token, $verification_id))
return 0;
//get the nested details (necessary due to balanced api object inconsistency)
$verification_details = $verification->bank_account_verifications[0];
//if there are no attempts left, return 0
if (!$verification_details->attempts_remaining)
return 0;
try
{
$verification->confirm($amount1, $amount2);
return true;
}
catch (BalancedError $e)
{
return $verification_details->attempts_remaining - 1;
}
}
the account token is: BA3VqgVLEcT2wb8HH6gbgXjq
Here's the request information:
Request body
{
"amount_1": 0,
"amount_2": 0,
"bank_account_verifications": [
{
"verification_status": "pending",
"links": {
"bank_account": "BA3VqgVLEcT2wb8HH6gbgXjq"
},
"created_at": "2014-03-12T21:37:30.977103Z",
"attempts_remaining": 3,
"updated_at": "2014-03-12T21:37:31.419490Z",
"deposit_status": "succeeded",
"attempts": 0,
"href": "/verifications/BZ40VVfLEw76Jj2MMtYYkiYw",
"meta": {},
"id": "BZ40VVfLEw76Jj2MMtYYkiYw"
}
],
"links": {
"bank_account_verifications.bank_account": "/bank_accounts/{bank_account_verifications.bank_account}"
}
}
Response body
{
"errors": [
{
"status": "Method Not Allowed",
"category_code": "method-not-allowed",
"description": "Your request id is OHM5b9c4438afbf11e3bed2026ba7c1aba6.",
"status_code": 405,
"category_type": "request",
"request_id": "OHM5b9c4438afbf11e3bed2026ba7c1aba6"
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment