#littlejohn0308
1 messages · Page 1 of 1 (latest)
Sorry don't really follow your question. Could you elaborate on more details? Which Doc you are following and which code/request you have error?
The parameters returned after successful payment in test mode are different from those in formal mode, and payment cannot be obtained in formal mode_ The value of intent
yes live mode
How different do you mean?
Test mode callback has a return value, but Live mode has no return value
Test mode has a payload value Live mode has no value
payload is what you get from your browser request to your server, so I don't think it has anything to do with Test mode or Live mode
You can comment out all Stripe related logic and making sure payload always get a value first
public function successNotify(){
require_once './system/stripe-php-master/init.php';
$stripeSecretKey = $this->key();
\Stripe\Stripe::setApiKey($stripeSecretKey);
$payload = @file_get_contents('php://input');
$event = null;
try {
$event = \Stripe\Event::constructFrom(
json_decode($payload, true)
);
} catch(\UnexpectedValueException $e) {
// Invalid payload
http_response_code(400);
exit();
}
switch ($event->type) {
case 'charge.succeeded':
$succeeded = $event->data->object;
$srt = json_encode($succeeded);
if ($succeeded->status == 'succeeded'){
$payment_intent = $succeeded->payment_intent;
$order_info = $this->db->GetOne("select * from `@#_order` where `paymentIntent_id`='$payment_intent'");
if ($order_info['status'] != 0) {
return;
}
$money = $order_info['price'];
$uid = $order_info['uid'];
$sql="INSERT INTO `@#_log`(`title`,`content`)VALUES('回调返回钱','$money')";
$this->db->Query($sql);
$time = time();
$this->db->Query("UPDATE `@#_order` SET `status`='1',`pay_time`='$time' where `id`='$order_info[id]'");
$this->db->Query("UPDATE `@#_member` SET `money` = `money`+ $money WHERE `uid` ='$uid'");
}
break;
default:
echo 'Received unknown event type ' . $event->type;
}
http_response_code(200);
}
I'll send you my code to see where the problem is
Oh this is webhook
Webhook endpoints for Live mode and Test mode are different.
You need different endpoints, with different secret
Why did I not use the webhook key in my testing mode to successfully call back
What do I need to do now when using Live mode?
Sorry I explained, you need diffrent webhook endpoints setup for Test mode vs Live mode
https://dashboard.stripe.com/test/webhooks
vs
https://dashboard.stripe.com/webhooks
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
When you setup another Live mode endpoint, you will need to takes its secret into your code
Follow this example https://stripe.com/docs/webhooks/quickstart?lang=php
$event = \Stripe\Event::constructFrom(
json_decode($payload, true)
);
This part doesn't look correct to me btw
Hello, I have tested it. The test endpoint has parameter returns, but the Live endpoint has no parameter returns.
$event = \Stripe\Event::constructFrom(
json_decode($payload, true)
);
May I ask how is it correct?
ie. in the Doc above it should have the endpoint secret
try {
$event = \Stripe\Webhook::constructEvent(
$payload, $sig_header, $endpoint_secret
);
}
Okay, I'll give it a try
Does Payload not require JSON format?
json_decode($payload,true)
Still not correct
Are you still there? I need your help
Yes, I would recommend download the whole code example from above Doc
and run it first
Is this correct?
Can you try this first?
I have already tried it. The test mode is okay, but the Live mode is not
Did you update the Live mode endpoint secret into line 10?
yes
Okie, and do you observe your Live mode events come in?
Can you post here the Live mode event id? evt_xxx
Yes, the Live mode can successfully pay now, but it cannot return to a successful status. Can you understand what I mean?
The Live mode allows for normal payment, and the credit card displays pre authorization deduction, but the interface did not return success parameters to me and cannot be recalled.
evt_3NOEzIJ11z4DgEya1R9O8SLc
Looking at the event I see your server returns 500 error
Oh sorry yes you need both constructFrom and constructEvent
And yes secret is the one on the left, which has the format of whsec_xxx
and we_xxx on the right is not sig_header. sig_header comes from HTTP_STRIPE_SIGNATURE
But really you want to look at your server log and see where does it return 500
HTTP_ STRIPE_ Where to obtain the signature
There's a Stripe-Signature key in the HTTP request headers: https://stripe.com/docs/webhooks/signatures
I couldn't find HTTP_ STRIPE_ Signature
What do you mean 'couldn't find'? What have you tried?
Can you sapeak chinese
No, we can only offer English support here. If you need non-English support, please write in: https://support.stripe.com/contact
Find help and support for Stripe. Our support center provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
Yep, should be if you're using PHP
wow It has been resolved, thank you