PayPal Smart Subscribe server side
I'm not aware of a demo sample, but the createSubscription
portion can be be done via this API call: https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_create
For subscriptions, by default the subscription will be activated automatically on approval, before onApprove
is called.
You can set the application_context -> user_action to something other than SUBSCRIBE_NOW if you want to show a review step and activate with an API call.
PayPal Smart Payment Buttons integration with server-side REST API
You are looking for this front-end: https://developer.paypal.com/demo/checkout/#/pattern/server
For your backend, you should use the latest v2/orders SDK: https://github.com/paypal/Checkout-PHP-SDK
(Your v1/payments backend will work, but that SDK is deprecated and there is no reason to use it for a new integration)
PayPal Smart Button server side implementation - Problems with capturing transaction - PHP
This is your problem line:
CaptureOrder::captureOrder('$orderId', true);
You are literally sending the text string inside the single quotes: '$orderId
' to PayPal. The $
and those 7 letters are going to PayPal. You are not sending the contents of your $orderId variable.
Get rid of your string quotes:
CaptureOrder::captureOrder($orderId, true);
By the way, a detail about PHP (and incidentally, shell languages like bash) you may not be aware of:
Note: Unlike the double-quoted and heredoc syntaxes, variables and escape sequences for special characters will not be expanded when they occur in single quoted strings.
ref: https://www.php.net/manual/en/language.types.string.php#language.types.string.parsing
Basically, double quotes and single quotes behave differently in this respect.
Related Topics
How to Send Email with Attachment Using PHP
Query_Posts() Should Be Avoided
PHP Upload, Extract and Progressbar
How to Use PHP to Dynamically Publish an Ical File to Be Read by Google Calendar
Composer Killed While Updating
Why Is Textarea Filled with Mysterious White Spaces
Sanitizing User's Data in Get by PHP
How to Trim White Spaces of Array Values in PHP
Why am I Getting Mime-Type of .CSV File as "Application/Octet-Stream"
Access Variables from Parent Scope in Anonymous PHP Function
Php's JSON_Encode Does Not Escape All JSON Control Characters
Escape String to Use in Mail()
Soap-Error: Parsing Wsdl: Couldn't Load from <Url>
Pdostatement (Mysql): Inserting Value 0 into a Bit(1) Field Results in 1 Written in Table