dynamically add products to revere
This commit is contained in:
parent
618fbdc387
commit
e398bccf6a
@ -37,11 +37,10 @@ class ReverePayments extends Gateway
|
||||
|
||||
// Ensure the product exists in Revere Payments
|
||||
// This will create or update the product if needed
|
||||
// $this->createOrUpdateProduct($product);
|
||||
$this->createOrUpdateProduct($product);
|
||||
|
||||
// Use the generateProductSku method for consistency
|
||||
// $sku = $this->generateProductSku($product);
|
||||
$sku = 'abc-123';
|
||||
$sku = $this->generateProductSku($product);
|
||||
|
||||
$lineItems[] = [
|
||||
'sku' => $sku,
|
||||
@ -188,17 +187,16 @@ class ReverePayments extends Gateway
|
||||
// Check if product already exists
|
||||
$existingProduct = $this->getProductBySku($sku);
|
||||
|
||||
// Determine if we are adding or updating a product
|
||||
$action = $existingProduct ? 'update_product' : 'add_product';
|
||||
|
||||
// Product data to send to Revere Payments
|
||||
$productData = [
|
||||
'security_key' => $apiKey,
|
||||
'products' => $action,
|
||||
'product_sku' => $sku,
|
||||
'product_description' => $product->description ?? $product->name,
|
||||
'product_cost' => $product->price,
|
||||
'product_currency' => 'USD', // Assuming USD, adjust as needed
|
||||
// Add any other required product attributes here
|
||||
'product_currency' => 'USD',
|
||||
];
|
||||
|
||||
if ($existingProduct) {
|
||||
@ -226,9 +224,11 @@ class ReverePayments extends Gateway
|
||||
}
|
||||
|
||||
$responseData = json_decode($response, true);
|
||||
parse_str($response, $responseArray);
|
||||
|
||||
|
||||
if (!isset($responseData['success']) || !$responseData['success']) {
|
||||
throw new Exception('Invalid response from Revere Payments API: ' . $response);
|
||||
if (!isset($responseArray['response']) || $responseArray['response'] != "1") {
|
||||
throw new Exception('Invalid response from Revere Payments API: ' . $responseArray);
|
||||
}
|
||||
|
||||
return $responseData;
|
||||
|
Loading…
x
Reference in New Issue
Block a user