I am having two problems. The workflow: I want to payout third party people based on their credit / debit cards (who has not any registrations at all). The first problem is that I cannot find my account balance Id. The second problem is that when I run $service = new TransfersApi($client); $service->transferFunds($transferInfo);
I get 401. My API key is okay, it can’t be the problem. I think I simply don’t have permission, since I am on test account (and using symfony). TransfersApi transferFunds
method throws. Sorry, I am new to Ayden.
Code snippet:
#[Route('/payment/process-withdraw', name: 'process_withdraw', methods: ['POST'])]
public function processWithdraw(Request $request): Response
{
$client = new Client();
$client->setXApiKey('api key'); //i change this..
$client->setEnvironment(Environment::TEST);
$cardNumber = $request->get('cardNumber');
$expiryMonth = $request->get('expiryMonth');
$expiryYear = $request->get('expiryYear');
$cardHolderName = $request->get('holderName');
$currency = $request->get('currency', 'USD');
$value = 1000;
$address = new Address();
$address
->setCountry('US')
->setStateOrProvince('CA')
->setCity('San Francisco')
->setPostalCode('94107')
->setLine1('274 Brannan St');
$cardHolder = new PartyIdentification();
$cardHolder
->setFirstName(explode(' ', $cardHolderName)[0])
->setLastName(explode(' ', $cardHolderName)[1] ?? '')
->setAddress($address)
->setType('individual');
$cardIdentification = new CardIdentification();
$cardIdentification
->setNumber($cardNumber)
->setExpiryMonth($expiryMonth)
->setExpiryYear($expiryYear);
$card = new Card();
$card
->setCardHolder($cardHolder)
->setCardIdentification($cardIdentification);
$amount = new Amount();
$amount
->setCurrency($currency)
>setValue($value);
$counterpartyInfo = new CounterpartyInfoV3();
$counterpartyInfo
->setCard($card);
$transferInfo = new TransferInfo();
$transferInfo
->setBalanceAccountId('BA00000000000000000000001') // ? Maybe this causes the error.
->setReference('Reference for the transfer')
->setAmount($amount)
->setCounterparty($counterpartyInfo)
->setDescription('Transfer Description')
->setCategory('card');
$service = new TransfersApi($client);
$response = $service->transferFunds($transferInfo);
return new JsonResponse(['status' => 'success', 'response' => $response]);
}
I should be able to payout third parties via debit card.
Olivér Jankó is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.