mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
3ds payment flow
This commit is contained in:
parent
590616a780
commit
2e114692e7
@ -73,7 +73,7 @@ class CreditCard implements LivewireMethodInterface
|
||||
|
||||
$payload = array_merge($this->getCustomer(), [
|
||||
'token' => $payment_source,
|
||||
"vault_type" => "session",
|
||||
"vault_type" => "permanent",
|
||||
'store_ccv' => true,
|
||||
]);
|
||||
|
||||
@ -165,7 +165,9 @@ class CreditCard implements LivewireMethodInterface
|
||||
public function paymentResponse(PaymentResponseRequest $request)
|
||||
{
|
||||
nlog($request->all());
|
||||
$payment_hash = PaymentHash::where('hash', $request->payment_hash)->first();
|
||||
$this->powerboard->payment_hash->data = array_merge((array) $this->powerboard->payment_hash->data, ['response' => $request->all()]);
|
||||
$this->powerboard->payment_hash->save();
|
||||
|
||||
|
||||
// $token = $request->payment_source;
|
||||
$payload = [];
|
||||
@ -192,20 +194,22 @@ class CreditCard implements LivewireMethodInterface
|
||||
{
|
||||
$payment_source = $this->storePaymentSource($request);
|
||||
|
||||
nlog($payment_source);
|
||||
|
||||
return $this->get3dsToken($payment_source, $request);
|
||||
|
||||
}
|
||||
elseif($request->charge) {
|
||||
|
||||
$charge_request = json_decode($request->charge, true);
|
||||
|
||||
nlog("we have the charge request");
|
||||
nlog($charge_request);
|
||||
|
||||
$payload = [
|
||||
'_3ds' => [
|
||||
'id' => $charge_request['charge_3ds_id'],
|
||||
],
|
||||
"amount"=> $payment_hash->data->amount_with_fee,
|
||||
"amount"=> $this->powerboard->payment_hash->data->amount_with_fee,
|
||||
"currency"=> $this->powerboard->client->currency()->code,
|
||||
"store_cvv"=> true,
|
||||
];
|
||||
@ -219,49 +223,32 @@ class CreditCard implements LivewireMethodInterface
|
||||
|
||||
$charge = (new \App\PaymentDrivers\CBAPowerBoard\Models\Parse())->encode(Charge::class, $r->object()->resource->data) ?? $r->throw();
|
||||
|
||||
nlog($charge);
|
||||
|
||||
if ($charge->status == 'complete') {
|
||||
$this->powerboard->logSuccessfulGatewayResponse(['response' => $charge, 'data' => $this->powerboard->payment_hash], SystemLog::TYPE_POWERBOARD);
|
||||
|
||||
$vt = $charge->customer->payment_source->vault_token;
|
||||
// nlog($this->powerboard->payment_hash->data);
|
||||
|
||||
// $vt = $r->object()->resource->data->_3ds->id;
|
||||
|
||||
if($request->store_card){
|
||||
$data = [
|
||||
"payment_source" => [
|
||||
"vault_token" => $vt,
|
||||
],
|
||||
];
|
||||
|
||||
$customer = $this->powerboard->customer()->findOrCreateCustomer($data);
|
||||
}
|
||||
|
||||
return $this->processSuccessfulPayment($charge);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
nlog($request->all());
|
||||
|
||||
// else {
|
||||
|
||||
// $payload["customer"] = [
|
||||
// "payment_source" => [
|
||||
// "vault_token" => $cgt->token,
|
||||
// "gateway_id" => $cgt->meta->gateway_id
|
||||
// ]
|
||||
// ];
|
||||
|
||||
// }
|
||||
|
||||
// $uri = '/v1/charges';
|
||||
|
||||
// $payload_meta = [
|
||||
// "amount" => $payment_hash->data->amount_with_fee,
|
||||
// "currency" => $this->powerboard->client->currency()->code,
|
||||
// "description" => $this->powerboard->getDescription(),
|
||||
// ];
|
||||
|
||||
// $payload = array_merge($payload, $payload_meta);
|
||||
|
||||
// nlog($payload);
|
||||
|
||||
// $r = $this->powerboard->gatewayRequest($uri, (\App\Enum\HttpVerb::POST)->value, $payload, []);
|
||||
|
||||
// if($r->failed())
|
||||
// $r->throw();
|
||||
|
||||
// nlog($r->object());
|
||||
|
||||
// return $this->processUnsuccessfulPayment($r->body());
|
||||
}
|
||||
|
||||
public function processSuccessfulPayment(Charge $charge)
|
||||
|
@ -105,8 +105,6 @@ class Customer
|
||||
if($r->failed())
|
||||
$r->throw();
|
||||
|
||||
// $this->storePaymentMethod($r->object());
|
||||
|
||||
return (new \App\PaymentDrivers\CBAPowerBoard\Models\Parse())->encode(ModelsCustomer::class, $r->object()->resource->data) ?? $r->throw();
|
||||
|
||||
}
|
||||
|
@ -40,6 +40,8 @@ class Customer
|
||||
public ?bool $_check_expire_date;
|
||||
/** @var ?PaymentSource[] */
|
||||
public ?array $payment_sources;
|
||||
/** @var ?PaymentSource */
|
||||
public ?PaymentSource $payment_source;
|
||||
/** @var ?array */
|
||||
public ?array $payment_destinations;
|
||||
/** @var ?string */
|
||||
@ -60,7 +62,8 @@ class Customer
|
||||
?bool $_check_expire_date,
|
||||
?array $payment_sources,
|
||||
?array $payment_destinations,
|
||||
?string $company_id
|
||||
?string $company_id,
|
||||
?PaymentSource $payment_source
|
||||
) {
|
||||
$this->_id = $_id;
|
||||
$this->_source_ip_address = $_source_ip_address;
|
||||
@ -77,5 +80,6 @@ class Customer
|
||||
$this->payment_sources = $payment_sources;
|
||||
$this->payment_destinations = $payment_destinations;
|
||||
$this->company_id = $company_id;
|
||||
$this->payment_source = $payment_source;
|
||||
}
|
||||
}
|
@ -41,14 +41,14 @@ class PaymentSource
|
||||
public int $expire_month;
|
||||
/** @var int */
|
||||
public int $expire_year;
|
||||
/** @var string */
|
||||
public string $status;
|
||||
/** @var string */
|
||||
public string $created_at;
|
||||
/** @var string */
|
||||
public string $updated_at;
|
||||
/** @var string */
|
||||
public string $vault_type;
|
||||
/** @var ?string */
|
||||
public ?string $status;
|
||||
/** @var ?string */
|
||||
public ?string $created_at;
|
||||
/** @var ?string */
|
||||
public ?string $updated_at;
|
||||
/** @var ?string */
|
||||
public ?string $vault_type;
|
||||
/** @var ?string */
|
||||
public ?string $gateway_id;
|
||||
|
||||
@ -67,10 +67,10 @@ class PaymentSource
|
||||
?string $address_state,
|
||||
int $expire_month,
|
||||
int $expire_year,
|
||||
string $status,
|
||||
string $created_at,
|
||||
string $updated_at,
|
||||
string $vault_type,
|
||||
?string $status,
|
||||
?string $created_at,
|
||||
?string $updated_at,
|
||||
?string $vault_type,
|
||||
?string $gateway_id
|
||||
) {
|
||||
$this->_id = $_id;
|
||||
|
@ -171,6 +171,14 @@
|
||||
'input[name="charge"]'
|
||||
).value = JSON.stringify(data);
|
||||
|
||||
let storeCard = document.querySelector(
|
||||
'input[name=token-billing-checkbox]:checked'
|
||||
);
|
||||
|
||||
if (storeCard) {
|
||||
document.getElementById('store_card').value = storeCard.value;
|
||||
}
|
||||
|
||||
document.getElementById('server-response').submit();
|
||||
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user