Shashank
Shashank

Reputation: 107

PayPal Rest API PHP Service endpoint error

I am trying to implement PayPal's REST API to checkout from my PHP website.

I studied various examples given by developers and selected to implement this one - http://www.sanwebe.com/2014/09/paypal-rest-api-payment-system

I have downloaded the Paypal PHP SDK and configured my sdk_config.ini file as follows

[Account]
acct1.ClientId = AYSq3RDGsmBLJE-otTkBtM-jBRd1TCQwFf9RGfwddNXWz0uFU9ztymylOhRS
acct1.ClientSecret = EGnHDxD_qRPdaLdZz8iCr8N7_MzF-YHPTkjs6NKYQvQSBngp4PTTVWkPZRbL


;Connection Information
[Http]
http.ConnectionTimeOut = 30
http.Retry = 1
;http.Proxy=http://[username:password]@hostname[:port]

;Service Configuration
[Service]
mode=sandbox ; can be set to sandbox / live 

[Log]
log.LogEnabled=true
log.FileName=../PayPal.log

log.LogLevel=FINE

[validation]
validation.level=strict

Everything looks good, but i get an error saying You must set one of service.endpoint or mode parameters in your configuration on this page PayPal\Rest\RestHandler.php

I tried looking how to define endpoints and in which file do i define them, but in vain!

Any help for where to look for answers would be great!

Please tell me if I am doing anything wrong in the above code.

Upvotes: 0

Views: 1269

Answers (3)

alex
alex

Reputation: 4914

I am following the same article on sanwebe.com. In my case to make the demo work i had to create an app on https://developer.paypal.com/webapps/developer/applications/createapp

and use the client ID and Secret

hope this help

Upvotes: 0

Jay Patel - PayPal
Jay Patel - PayPal

Reputation: 1489

My first guess is, even though you have defined sdk_config.ini and has the configuration for Mode, it is not able to pick up the sdk_configs.

As the file based configuration is one of the possible ways to add configuration, if it wont find the configs, it would silently move on, hoping for dynamic configuration using 'setConfig' method.

If you are using sdk_config.ini in your system, you need to define where the location of it is.

you can do that by adding this before/immediately after including the vendor autoload files.

if(!defined("PP_CONFIG_PATH")) {
    define("PP_CONFIG_PATH", __DIR__);
}

Replace DIR with the actual directory where you file is. Make sure you include the directory location, and not file itself.

e.g. C:\User\japatel\PayPal\ is valid C:\User\japatel\PayPal\sdk_config.ini is invalid

Upvotes: 0

Bhavya Shaktawat
Bhavya Shaktawat

Reputation: 2512

Refer to document explaining what Paypal service endpoint is.

And here is the list of all the classic API endpoints.

And refer this for REST API Reference

Sandbox (for testing) : https://api.sandbox.paypal.com
Live (production) : https://api.paypal.com

Upvotes: 1

Related Questions