iqnection-modules/paypalpayment

SilverStripe PayPal Payment

2.0.0.1 2018-08-17 14:16 UTC

This package is auto-updated.

Last update: 2024-09-29 04:19:48 UTC


README

#IQnection PayPal Payment

extends IQnection\Payment\Payment

When using PayPal Payment, you must implement a page and controller

in your model page file, declare the extension

 class MyPayPalPage extends Page
 {
 	private static $extensions = [
		IQnection\PayPalPayment\PayPalPage\PageExtension::class
	];
 }

in your page controller file, declare the handler as an extension

 class MyPayPalPageController extends PageController
 {
 	private static $extensions = [
		IQnection\PayPalPayment\Controller\PaymentHandler::class
	];
 }

the handler methods are now a part of your page controller

In your template, create your PayPal form and specify your IPN add some JavaScript to auto-submit the form


when PayPal sends the IPN response, it will be send to the same page the payment was submitted from you can implement OnSuccessfulPayment method in your page controller to handle the payment upon success eg:

public function OnSuccessfulPayment($Payment,$data)
{
	if ( (isset($data['item_number'])) && ($submission = MyPageSubmission()->byID($data['item_number'])) )
   {
   	$submission->PaymentID = $Payment->ID;
   	$submission->write();
   }
}

upon successful payment from PayPal, the user will be redirected back to your page calling action /thanks