@@ -117,16 +117,22 @@ public function ipn(array $input){
117
117
public function pdt (array $ input ){
118
118
$ req = 'cmd=_notify-synch ' ;
119
119
$ tx_token = array_get ($ input , 'tx ' );
120
- $ auth_token = array_get ($ this ->config , 'auth ' );#'AHzOaZtWjQ7yNtBokHmpmrVfnpahZtiD3pr5HeKAiw9a_wxzPON14erlCDe';#
120
+ $ auth_token = array_get ($ this ->config , 'auth ' );
121
+
122
+ if (empty ($ auth_token )){
123
+ throw new TransactionException ('Invalid Paypal Auth Token ' );
124
+ }
125
+
121
126
$ req .= "&tx= $ tx_token&at= $ auth_token " ;
122
127
123
128
$ header = "POST /cgi-bin/webscr HTTP/1.0 \r\n" ;
124
129
$ header .= "Content-Type: application/x-www-form-urlencoded \r\n" ;
125
130
$ header .= "Content-Length: " .strlen ($ req )."\r\n\r\n" ;
126
131
$ fp = fsockopen ('www.paypal.com ' , 80 , $ errno , $ errstr , 30 );
132
+
127
133
128
134
if (!$ fp ) {
129
- throw new TransactionException ('Cannot Connect to Paypal ' , [ ' data ' => $ input ] );
135
+ throw new TransactionException ('Cannot Connect to Paypal ' );
130
136
} else {
131
137
fputs ($ fp , $ header .$ req );
132
138
$ res = '' ;
@@ -148,7 +154,7 @@ public function pdt(array $input){
148
154
149
155
$ keys = collect ([]);
150
156
151
- if (strcmp ($ lines [0 ], "SUCCESS " ) == 0 ) {
157
+ if (strcmp ($ lines [0 ], "SUCCESS " ) == 0 ) {
152
158
for ($ i = 1 ; $ i < count ($ lines ); $ i ++) {
153
159
@list ($ key , $ val ) = explode ("= " , $ lines [$ i ]);
154
160
$ keys ->put (urldecode ($ key ), urldecode ($ val ));
@@ -169,9 +175,9 @@ public function pdt(array $input){
169
175
$ action = 'signup ' ;
170
176
}
171
177
172
- return new TransactionResult ($ item_number , $ subscr_id , 0 , $ payment_status , $ action , $ keys ->get ());
178
+ return new TransactionResult ($ item_number , $ subscr_id , 0 , $ payment_status , $ action , $ keys ->get ());
173
179
} elseif (strcmp ($ lines [0 ], "FAIL " ) == 0 ) {
174
- throw new TransactionException ("Paypal check failed " , [ ' lines ' => $ lines , ' keys ' => $ keys ] );
180
+ throw new TransactionException ("Paypal check failed " );
175
181
}
176
182
}
177
183
}
0 commit comments