Skip to content

Commit

Permalink
Update StripePaymentManager.php
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkIncognito85 authored Aug 10, 2021
1 parent 90acfa2 commit a4f3bff
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions src/Stripe/StripePaymentManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function process(Transaction $transaction, Request $request, User $user)
'price_data' =>
[
'currency' => $transaction->getCurrency(),
'unit_amount' => $item->priceWithTax() * 100,
'unit_amount' => round($item->priceWithTax() * 100),
'product_data' => ["name" => $item->getName()]
],
'quantity' => $item->getQuantity(),
Expand Down Expand Up @@ -92,7 +92,7 @@ public function execute(Transaction $transaction, Request $request, User $user)

}

public function confirm(Transaction $transaction, Request $request, User $user){
public function test(Transaction $transaction, Request $request, User $user){
$params = $request->getServerParams();
$signature = $params["HTTP_STRIPE_SIGNATURE"];
$webhook = $this->stripe->getWebhook($signature);
Expand All @@ -108,24 +108,37 @@ public function confirm(Transaction $transaction, Request $request, User $user){
$this->service->changeState($transaction);
$this->service->setReason($transaction);
} else {
$this->service->complete($transaction);

if ($this->service->isOrder($transaction)) {
$this->service->confirmOrder($transaction, $user->getId());
}
$transaction->setState($transaction::COMPLETED);
$this->service->changeState($transaction);
return $transaction;
}
} else if ($webhook->type === 'payment_intent.succeeded') {

$object = $webhook->data->object;
$id = $webhook->id;
$transaction->setTransactionId($id);
$this->service->updateTransactionId($transaction);
return $transaction;

}
}

public function success(Request $request){
public function confirm(Request $request)
{
$params = $request->getServerParams();
$signature = $params["HTTP_STRIPE_SIGNATURE"];
$webhook = $this->stripe->getWebhook($signature);
if ($webhook->type === 'payment_intent.succeeded'){

if ($webhook->type === 'payment_intent.succeeded') {
$transaction = $this->service->getLastTransaction();
$id = $webhook->id;

$object = $webhook->data->object;
$id = $object->id;
$transaction->setTransactionId($id);
$this->service->updateTransactionId($transaction);
return $transaction;
}
}

Expand Down

0 comments on commit a4f3bff

Please sign in to comment.