mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -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();
|
$tokenResponse = $gateway->createCustomer(array('customerData' => array()))->send();
|
||||||
if ($tokenResponse->isSuccessful()) {
|
if ($tokenResponse->isSuccessful()) {
|
||||||
$customerReference = $tokenResponse->getCustomerData()->id;
|
$customerReference = $tokenResponse->getCustomerData()->id;
|
||||||
|
} else {
|
||||||
|
$this->lastError = $tokenResponse->getData()->message;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -366,7 +369,12 @@ class PaymentService extends BaseService
|
|||||||
$details['customerId'] = $customerReference;
|
$details['customerId'] = $customerReference;
|
||||||
|
|
||||||
$tokenResponse = $gateway->createPaymentMethod($details)->send();
|
$tokenResponse = $gateway->createPaymentMethod($details)->send();
|
||||||
|
if ($tokenResponse->isSuccessful()) {
|
||||||
$sourceReference = $tokenResponse->getData()->paymentMethod->token;
|
$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);
|
$paymentMethod = $this->convertPaymentMethodFromStripe($source, $accountGatewayToken);
|
||||||
}
|
}
|
||||||
} elseif ($accountGateway->gateway_id == GATEWAY_BRAINTREE) {
|
} 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') {
|
if ($transaction->paymentInstrumentType == 'credit_card') {
|
||||||
$card = $transaction->creditCardDetails;
|
$card = $transaction->creditCardDetails;
|
||||||
$paymentMethod->last4 = $card->last4;
|
$paymentMethod->last4 = $card->last4;
|
||||||
@ -473,8 +484,11 @@ class PaymentService extends BaseService
|
|||||||
$paymentMethod->payment_type_id = PAYMENT_TYPE_ID_PAYPAL;
|
$paymentMethod->payment_type_id = PAYMENT_TYPE_ID_PAYPAL;
|
||||||
$paymentMethod->email = $transaction->paypalDetails->payerEmail;
|
$paymentMethod->email = $transaction->paypalDetails->payerEmail;
|
||||||
}
|
}
|
||||||
|
|
||||||
$paymentMethod->setRelation('payment_type', Cache::get('paymentTypes')->find($paymentMethod->payment_type_id));
|
$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) {
|
if (!empty($paymentMethod) && $accountGatewayToken && $contactId) {
|
||||||
@ -722,13 +736,12 @@ class PaymentService extends BaseService
|
|||||||
// setup the gateway/payment info
|
// setup the gateway/payment info
|
||||||
$gateway = $this->createGateway($accountGateway);
|
$gateway = $this->createGateway($accountGateway);
|
||||||
$details = $this->getPaymentDetails($invitation, $accountGateway);
|
$details = $this->getPaymentDetails($invitation, $accountGateway);
|
||||||
|
$details['customerReference'] = $token;
|
||||||
|
|
||||||
if ($accountGateway->gateway_id == GATEWAY_STRIPE) {
|
if ($accountGateway->gateway_id == GATEWAY_STRIPE) {
|
||||||
$details['customerReference'] = $token;
|
$details['cardReference'] = $defaultPaymentMethod->source_reference;
|
||||||
$details['cardReference'] = $defaultPaymentMethod->sourceReference;
|
|
||||||
} elseif ($accountGateway->gateway_id == GATEWAY_BRAINTREE) {
|
} elseif ($accountGateway->gateway_id == GATEWAY_BRAINTREE) {
|
||||||
$details['customerId'] = $token;
|
$details['paymentMethodToken'] = $defaultPaymentMethod->source_reference;
|
||||||
$details['paymentMethodToken'] = $defaultPaymentMethod->sourceReference;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// submit purchase/get response
|
// submit purchase/get response
|
||||||
|
Loading…
x
Reference in New Issue
Block a user