Hitpay-Zahlungsintegration kann nicht in PHP implementiert werden

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Hitpay-Zahlungsintegration kann nicht in PHP implementiert werden

by Guest » 03 Jan 2025, 12:49

Ich versuche, das HitPay-Zahlungsgateway zu implementieren.
Ich kann die Antwort auf die Zahlungsanforderung erfolgreich erhalten.
Ich bin auch in der Lage, die Zahlung abzuschließen.
Nachdem die Zahlung erfolgt ist, muss ich jedoch die Transaktionsdetails speichern, wie zum Beispiel: Transaktions-ID, Transaktionsstatus und andere relevante Details.

Aus irgendeinem Grund funktioniert dieser Teil nicht wie erwartet .
Ich habe viele Ansätze ausprobiert, aber es gelingt mir nicht Identifizieren Sie das Problem.
Hier ist die Dokumentation.

Code: Select all

    



HitPay Checkout Drop-in Test Page





// Callback for successful payment
function onSuccess(data) {
console.log('onSuccess called:', data);

// Verify if valid data is received
if (!data) {
console.error('No data received in onSuccess');
const el = document.createElement('p');
el.innerHTML = 'Payment Success, but no data received.';
document.body.appendChild(el);
return;
}

// Display a success message
const el = document.createElement('p');
el.innerHTML = 'Payment Success';
document.body.appendChild(el);

// Send payment details to backend for storage
fetch('store_payment_details.php', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(data), // Sending received data
})
.then((response) => response.json())
.then((response) => {
console.log('Payment details stored successfully:', response);
})
.catch((error) => {
console.error('Error storing payment details:', error);
});
}

// Callback when payment is closed
function onClose(data) {
console.log('onClose called:', data);
const el = document.createElement('p');
el.innerHTML = 'Payment Closed';
document.body.appendChild(el);
}

// Callback for errors
function onError(error) {
console.error('onError called:', error);
const el = document.createElement('p');
el.innerHTML = 'Error: ' + (error.message || error);
document.body.appendChild(el);
}

// Function to initiate payment
function onClick() {
const carttotalValue = 1; // Dynamic total value (e.g., 100 for testing)
const paymentData = {
amount: carttotalValue, // Ensure amount matches cart total
currency: 'SGD',
email: '[email protected]',
phone: '1111',
order_id: '123',
};

// Make AJAX request to backend to create the payment request
fetch('hitpay_payment_request.php', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(paymentData), // Send dynamic data
})
.then((response) => response.json())
.then((response) => {
const data = response.data;
console.log("data=",data);
if (data &&  data.id) {
// Initialize HitPay only once
if (!window.HitPay.inited) {
window.HitPay.init(
'https://securecheckout.hit-pay.com/payment-request/@curvv-tech-private-limited',
{
domain: 'hit-pay.com',
apiDomain: 'hit-pay.com',
},
{
onClose: onClose,
onSuccess: onSuccess,
onError: onError,
}
);
}

// Trigger the payment gateway toggle with the provided payment_url
window.HitPay.toggle({
paymentRequest: data.id, // Dynamic payment ID
amount: carttotalValue,
name: 'Anbu',
phone: '93500239',
});
} else {
// Handle error if no payment URL is received
console.error('Error: Payment URL not received');
}
})
.catch((error) => {
console.error('AJAX Error:', error);
});
}


Pay


hitpay_zahlung_request.php:

Code: Select all

 
Antwort erhalten:

Code: Select all

    {
"data": {
"id": "9de0c639-c986-4743-a1ae-70b998068536",
"name": null,
"email": "[email protected]",
"phone": "1111",
"amount": "1.00",
"currency": "SGD",
"is_currency_editable": false,
"status": "pending",
"purpose": null,
"reference_number": "123",
"payment_methods": [
"card",
"paynow_online"
],
"url": "https:\/\/securecheckout.hit-pay.com\/payment-request\/@curvv-tech-private-limited\/9de0c639-c986-4743-a1ae-70b998068536\/checkout",
"redirect_url": "https:\/\/domain.sg\/hit-pay\/hitpay_payment_success.php",
"webhook": "https:\/\/domain.sg\/hit-pay\/hitpay_payment_details.php",
"send_sms": false,
"send_email": false,
"sms_status": "pending",
"email_status": "pending",
"allow_repeated_payments": false,
"expiry_date": null,
"address": null,
"line_items": null,
"executor_id": null,
"created_at": "2025-01-03T14:53:59",
"updated_at": "2025-01-03T14:53:59",
"staff_id": null,
"business_location_id": null
}
}
hitpay_zahlung_details.php: hitpay_zahlung_success.php

Top