Quantcast
Channel: Active questions tagged paypal - Stack Overflow
Viewing all articles
Browse latest Browse all 468

PayPal Smart Buttons Server Side Integration is failing on live mode

$
0
0

I am working on an application in php where I have to integrate PayPal Smart Buttons to my application. Everything is working fine in sandbox mode. But when I turn it to Live or Production Environment. It gives JSON error.

PayPal Smart Buttons returns me JSON error

This answer helped me alot while setting up my environment for sandbox and everything else, this is working really fine. but only for sandbox mode!

I checked with account on paypal, the transactions are created there, but no response is being sent to server for further processing. It indicates the API is setup successfully and keys are good. But only issue is I m unable to capture response and send it back to server here is my code

create-paypal-transaction.php

public static function createOrder($debug=false)  {    $request = new OrdersCreateRequest();    $request->prefer('return=representation');    $request->body = self::buildRequestBody();   // 3. Call PayPal to set up a transaction    $client = PayPalClient::client();    $response = $client->execute($request);    // 4. Return a successful response to the client.    $json_obj= array('id'=>$response->result->id);    $jsonstring = json_encode($json_obj);    echo $jsonstring;  }

on client side

createOrder: function() {      return fetch('payments/create-paypal-transaction.php', {        method: 'post',        headers: {'content-type': 'application/json'        },        body: JSON.stringify($('#form_add').serializeObject())      }).then(function(res) {        console.log(res);        return res.json();      }).then(function(data) {        console.log(data);        return data.id;      });

I used console.log() for debugging server response but it is always

{...ok: trueredirected: falsestatus: 200statusText: "OK"type: "basic"...}

also the console shows below errors

create_order_error click_initiate_payment_rejectUncaught SyntaxError: Unexpected token < in JSON at position 0

ANY HELP WOULD BE APPRECIATED :)


Viewing all articles
Browse latest Browse all 468

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>