Insert voucherify order source id

This commit is contained in:
Dillon
2023-07-31 19:05:27 +08:00
parent c61acc26fe
commit 0bc501b35d
3 changed files with 17 additions and 2 deletions
@@ -9,6 +9,9 @@ class RedeemVoucherifyVoucherObject implements DataTransferObject
/** @var int */
private $companyId;
/** @var int */
private $transactionId;
/** @var string */
private $promoCode;
@@ -21,13 +24,15 @@ class RedeemVoucherifyVoucherObject implements DataTransferObject
/**
* RedeemVoucherifyVoucherObject constructor.
* @param int $companyId
* @param int $transactionId
* @param string $name
* @param string $email
* @param object $employee
*/
public function __construct(int $companyId, string $promoCode, string $amount, object $employee)
public function __construct(int $companyId, int $transactionId, string $promoCode, string $amount, object $employee)
{
$this->companyId = $companyId;
$this->transactionId = $transactionId;
$this->promoCode = $promoCode;
$this->amount = $amount;
$this->employee = $employee;
@@ -42,6 +47,15 @@ class RedeemVoucherifyVoucherObject implements DataTransferObject
}
/**
* @return int
*/
public function getTransactionId(): int
{
return $this->transactionId;
}
/**
* @return string
*/
@@ -82,7 +82,7 @@ class BookingToVoucherifyProcessor
$voucherify_customer_id = "";
$voucherify_order_id = "";
if($voucherCode){
$redeemVoucherifyVoucherObject = new RedeemVoucherifyVoucherObject($companyId, $voucherCode, $amount, $user);
$redeemVoucherifyVoucherObject = new RedeemVoucherifyVoucherObject($companyId, $transaction->id, $voucherCode, $amount, $user);
$redeemVoucherResult = $this->redeemsVoucherifyVoucher->execute($redeemVoucherifyVoucherObject);
$redeemedVoucher = $redeemVoucherResult->voucher;
$redemptionId = $redeemVoucherResult->id;
@@ -29,6 +29,7 @@ class RedeemsVoucherifyVoucher
{
try {
$result = $this->voucherifyClient->redemptions->redeem($redeemVoucherifyVoucherObject->getPromoCode(), [
"source_id" => $redeemVoucherifyVoucherObject->getTransactionId(),
"customer" => [
"source_id" => $redeemVoucherifyVoucherObject->getEmployee()->id,
"name" => $redeemVoucherifyVoucherObject->getEmployee()->name,