Add Payment Method

This commit is contained in:
= 2021-08-15 20:27:52 +10:00
parent 6cf3ef9b77
commit 60dd8d3b6c

View File

@ -73,6 +73,7 @@ class CreditCard
$result = $api_response->getBody(); $result = $api_response->getBody();
$payment = json_decode($result); $payment = json_decode($result);
nlog($payment);
} else { } else {
$errors = $api_response->getErrors(); $errors = $api_response->getErrors();
@ -178,7 +179,8 @@ Success response looks like this:
} }
*/ */
nlog("customer id = ".$result->getCustomer()->getId());
nlog("source_id = ".$payment->payment->id);
$card = new \Square\Models\Card(); $card = new \Square\Models\Card();
$card->setCardholderName($this->square_driver->client->present()->name()); $card->setCardholderName($this->square_driver->client->present()->name());
@ -197,9 +199,13 @@ Success response looks like this:
->getCardsApi() ->getCardsApi()
->createCard($body); ->createCard($body);
$card = false;
if ($api_response->isSuccess()) { if ($api_response->isSuccess()) {
$result = $api_response->getResult(); $card = $api_response->getBody();
nlog($result->getBody()); nlog($card);
$card = json_decode($card);
nlog("ressy"); nlog("ressy");
nlog($result); nlog($result);
} else { } else {
@ -239,22 +245,21 @@ Success response looks like this:
*/ */
$cgt = []; $cgt = [];
$cgt['token'] = $result->getId(); $cgt['token'] = $card->card->id;
$cgt['payment_method_id'] = GatewayType::CREDIT_CARD; $cgt['payment_method_id'] = GatewayType::CREDIT_CARD;
$payment_meta = new \stdClass; $payment_meta = new \stdClass;
$payment_meta->exp_month = $result->getExpMonth(); $payment_meta->exp_month = $card->card->exp_month;
$payment_meta->exp_year = $result->getExpYear(); $payment_meta->exp_year = $card->card->exp_year;
$payment_meta->brand = $result->getCardBrand(); $payment_meta->brand = $card->card->card_brand;
$payment_meta->last4 = $result->getLast4(); $payment_meta->last4 = $card->card->last_4;
$payment_meta->type = GatewayType::CREDIT_CARD; $payment_meta->type = GatewayType::CREDIT_CARD;
$cgt['payment_meta'] = $payment_meta; $cgt['payment_meta'] = $payment_meta;
$token = $this->square_driver->storeGatewayToken($cgt, []); $token = $this->square_driver->storeGatewayToken($cgt, []);
return redirect()->route('client.payment_methods.index');
return back();
} }
public function paymentView($data) public function paymentView($data)