Skip to content
This repository has been archived by the owner on Jul 20, 2020. It is now read-only.

Update PHP to allow caller to set curl options #140

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion php/PaypalIPN.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ class PaypalIPN
private $use_sandbox = false;
/** @var bool Indicates if the local certificates are used. */
private $use_local_certs = true;
/** @var curl handler */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is missing a type.

private $curl_handler = null;

/** Production Postback URL */
const VERIFY_URI = 'https://ipnpb.paypal.com/cgi-bin/webscr';
Expand All @@ -17,6 +19,11 @@ class PaypalIPN
/** Response from PayPal indicating validation failed */
const INVALID = 'INVALID';

public function __construct($curl_handler = null)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docblock on the function please

{
$this->curl_handler = $curl_handler;
}

/**
* Sets the IPN verification to sandbox mode (for use when testing,
* should not be enabled in production).
Expand Down Expand Up @@ -96,7 +103,8 @@ public function verifyIPN()
}

// Post the data back to PayPal, using curl. Throw exceptions if errors occur.
$ch = curl_init($this->getPaypalUri());
$ch = isset($this->curl_handler) ? $this->curl_handler : curl_init();
curl_setopt($ch, CURLOPT_URL, $this->getPaypalUri());
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
Expand Down