PayPalCheckoutSdk - return fetch server response error 500

harris82
Contributor
Contributor

The PayPalSdk works fine on SANDBOX but in Live I keep receiving error 500.
I followed the paypal guide really can not see where is my mistake. Please help..

 

2022-09-27_9-42-18.jpg

public function paypal_capture()
{
$gateway_data = $this->billing->gateway(4);

$orderId = $this->input->post('orderID', true);
$itype = $this->input->post('itype', true);


$clientId =$gateway_data['key1']; //$paypal_conf['client_id'];
$clientSecret =$gateway_data['key2'];//$paypal_conf['secret'];

if($gateway_data['dev_mode'] == true)
{
$environment = new \PayPalCheckoutSdk\Core\SandboxEnvironment($clientId, $clientSecret);

} else {
$environment = new \PayPalCheckoutSdk\Core\ProductionEnvironment($clientId, $clientSecret);
}

$client = new \PayPalCheckoutSdk\Core\PayPalHttpClient($environment);

$request = new \PayPalCheckoutSdk\Orders\OrdersCaptureRequest($orderId);
$request->prefer('return=representation');
try {

$response = $client->execute($request);

echo json_encode($response);

$response = json_decode(json_encode($response), true);

if (isset($response['result']) and $response['result']['intent'] == 'CAPTURE' and $response['result']['status'] == 'COMPLETED') {

$note = 'INV '.$response['result']['purchase_units'][0]['reference_id'].' Paypal Payment #' . $response['result']['id'];

 


$this->billing->paynow($response['result']['purchase_units'][0]['reference_id'], $response['result']['purchase_units'][0]['amount']['value'], $note, 'Card',$itype);

}
}
catch (HttpException $ex) {

echo json_encode(array('status'=>'Error','message'=>'Code '.$ex->statusCode.' Contact to seller.'));

}
}

 

Login to Me Too
2 REPLIES 2

harris82
Contributor
Contributor

Similar issue: this topic says https://stackoverflow.com/questions/40641560/basic-paypal-checkout-button-giving-a-500-internal-serv...   the issue is from paypal server. I been trying to reach paypal support but no luck even the live support  no Customer Support Agents are available. How so i contact paypal tech support?

Login to Me Too

harris82
Contributor
Contributor

I am successfully authorizing credit card payments using the SDK but an error message when deserializing JSON.

throw new Error("Promise serialization is not implemented; nothing to deserialize")

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.