Skip to content

Commit

Permalink
Fixed insufficient IdempotencyKey uniqness in PurchaseRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
SilverFire committed Aug 5, 2019
1 parent 380c990 commit 8d15076
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Message/PurchaseRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,16 @@ public function sendData($data)
'metadata' => [
'transactionId' => $data['transactionId'],
],
], 'create-' . $data['transactionId']);
], $this->makeIdempotencyKey());

return $this->response = new PurchaseResponse($this, $paymentResponse);
} catch (Throwable $e) {
throw new InvalidRequestException('Failed to request purchase: ' . $e->getMessage(), 0, $e);
}
}

private function makeIdempotencyKey(): string
{
return md5(implode(',', array_merge(['create'], $this->getData())));
}
}

0 comments on commit 8d15076

Please sign in to comment.