mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-07 10:34:30 -04:00
Store Braintree card summary locally
This commit is contained in:
parent
88ec714cd5
commit
cc5cb091d7
@ -359,6 +359,9 @@ class PaymentService extends BaseService
|
||||
$tokenResponse = $gateway->createCustomer(array('customerData' => array()))->send();
|
||||
if ($tokenResponse->isSuccessful()) {
|
||||
$customerReference = $tokenResponse->getCustomerData()->id;
|
||||
} else {
|
||||
$this->lastError = $tokenResponse->getData()->message;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -366,7 +369,12 @@ class PaymentService extends BaseService
|
||||
$details['customerId'] = $customerReference;
|
||||
|
||||
$tokenResponse = $gateway->createPaymentMethod($details)->send();
|
||||
if ($tokenResponse->isSuccessful()) {
|
||||
$sourceReference = $tokenResponse->getData()->paymentMethod->token;
|
||||
} else {
|
||||
$this->lastError = $tokenResponse->getData()->message;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -461,9 +469,12 @@ class PaymentService extends BaseService
|
||||
$paymentMethod = $this->convertPaymentMethodFromStripe($source, $accountGatewayToken);
|
||||
}
|
||||
} elseif ($accountGateway->gateway_id == GATEWAY_BRAINTREE) {
|
||||
$paymentMethod = $accountGatewayToken ? PaymentMethod::createNew($accountGatewayToken) : new PaymentMethod();
|
||||
$data = $gatewayResponse->getData();
|
||||
|
||||
$transaction = $sourceResponse->getData()->transaction;
|
||||
if (!empty($data->transaction)) {
|
||||
$transaction = $data->transaction;
|
||||
|
||||
$paymentMethod = $accountGatewayToken ? PaymentMethod::createNew($accountGatewayToken) : new PaymentMethod();
|
||||
if ($transaction->paymentInstrumentType == 'credit_card') {
|
||||
$card = $transaction->creditCardDetails;
|
||||
$paymentMethod->last4 = $card->last4;
|
||||
@ -473,8 +484,11 @@ class PaymentService extends BaseService
|
||||
$paymentMethod->payment_type_id = PAYMENT_TYPE_ID_PAYPAL;
|
||||
$paymentMethod->email = $transaction->paypalDetails->payerEmail;
|
||||
}
|
||||
|
||||
$paymentMethod->setRelation('payment_type', Cache::get('paymentTypes')->find($paymentMethod->payment_type_id));
|
||||
} elseif (!empty($data->paymentMethod)) {
|
||||
$paymentMethod = $this->convertPaymentMethodFromBraintree($data->paymentMethod, $accountGatewayToken);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!empty($paymentMethod) && $accountGatewayToken && $contactId) {
|
||||
@ -722,13 +736,12 @@ class PaymentService extends BaseService
|
||||
// setup the gateway/payment info
|
||||
$gateway = $this->createGateway($accountGateway);
|
||||
$details = $this->getPaymentDetails($invitation, $accountGateway);
|
||||
$details['customerReference'] = $token;
|
||||
|
||||
if ($accountGateway->gateway_id == GATEWAY_STRIPE) {
|
||||
$details['customerReference'] = $token;
|
||||
$details['cardReference'] = $defaultPaymentMethod->sourceReference;
|
||||
$details['cardReference'] = $defaultPaymentMethod->source_reference;
|
||||
} elseif ($accountGateway->gateway_id == GATEWAY_BRAINTREE) {
|
||||
$details['customerId'] = $token;
|
||||
$details['paymentMethodToken'] = $defaultPaymentMethod->sourceReference;
|
||||
$details['paymentMethodToken'] = $defaultPaymentMethod->source_reference;
|
||||
}
|
||||
|
||||
// submit purchase/get response
|
||||
|
Loading…
x
Reference in New Issue
Block a user