1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-12 22:22:32 +01:00

Process merchantAccountId with Braintree transactions

This commit is contained in:
Benjamin Beganović 2021-09-05 12:31:17 +02:00
parent 535e0b93aa
commit 146cd8bc66
2 changed files with 19 additions and 2 deletions

View File

@ -88,14 +88,30 @@ class CreditCard
$token = $this->getPaymentToken($request->all(), $customer->id);
$result = $this->braintree->gateway->transaction()->sale([
$data = [
'amount' => $this->braintree->payment_hash->data->amount_with_fee,
'paymentMethodToken' => $token,
'deviceData' => $state['client-data'],
'options' => [
'submitForSettlement' => true
],
]);
];
if ($this->braintree->company_gateway->getConfigField('merchantAccountId')) {
/** https://developer.paypal.com/braintree/docs/reference/request/transaction/sale/php#full-example */
$data['merchantAccountId'] = $this->braintree->company_gateway->getConfigField('merchantAccountId');
}
try {
$result = $this->braintree->gateway->transaction()->sale($data);
} catch(\Exception $e) {
if ($e instanceof \Braintree\Exception\Authorization) {
throw new PaymentFailed(ctrans('texts.generic_gateway_error'), $e->getCode());
}
throw new PaymentFailed($e->getMessage(), $e->getCode());
}
if ($result->success) {
$this->braintree->logSuccessfulGatewayResponse(['response' => $request->server_response, 'data' => $this->braintree->payment_hash], SystemLog::TYPE_BRAINTREE);

View File

@ -4302,6 +4302,7 @@ $LANG = array(
'checking' => 'Checking',
'savings' => 'Savings',
'unable_to_verify_payment_method' => 'Unable to verify payment method.',
'generic_gateway_error' => 'Gateway configuration error. Please check your credentials.',
);
return $LANG;