+ Start a Discussion
oj2131oj2131 

PaymentConnect Creating a Test PayPal Connection

RIght now, I'm programming a controller for a donation system that uses Payconnect and PayPal.

 

For testing purposes, I want to create a sample Payment Processor Connection object using 'new pymt__Processor_Connection__c'. However, I can't upsert the connection because a required PaymentConnect setup field (pymt__PaymentConnect_Setup__c) is missing. How am I supposed to properly create a new Payment Processor connection, if I can even create one at all?

 

I'm still new to APEX and the Developer Boards, so please feel tree to ask for any clarifications or for copies of my code.

 

Thanks!

Best Answer chosen by Admin (Salesforce Developers) 
LinvioIncLinvioInc

Hi Oliver -

 

Yes, you can create processor connection records.

 

For your test methods, use PaymentConnect's Gateway Simulation mode.  You'll probably want to first clear out any existing settings and processor connection records and build them from scratch at the beginning of each test scenario ....  First, create a new PaymentConnect settings record (populate it as you would when configuring the settings in your production account, and set the Gateway Simulation Mode field to 'checked').  Then add a PayPal processor connection record.  Configure it as you would in production, and make sure you've checked the Test Mode checkbox.  In Gateway simulation mode the processor connection does not have to have values for API keys, relay script url, or relay ID.

 

Hope that helps.  If you need additional help, you can always visit the product forum at the Linvio website, or contact us for professional services assistance.

 

~ Ron

All Answers

LinvioIncLinvioInc

Hi Oliver -

 

Yes, you can create processor connection records.

 

For your test methods, use PaymentConnect's Gateway Simulation mode.  You'll probably want to first clear out any existing settings and processor connection records and build them from scratch at the beginning of each test scenario ....  First, create a new PaymentConnect settings record (populate it as you would when configuring the settings in your production account, and set the Gateway Simulation Mode field to 'checked').  Then add a PayPal processor connection record.  Configure it as you would in production, and make sure you've checked the Test Mode checkbox.  In Gateway simulation mode the processor connection does not have to have values for API keys, relay script url, or relay ID.

 

Hope that helps.  If you need additional help, you can always visit the product forum at the Linvio website, or contact us for professional services assistance.

 

~ Ron

This was selected as the best answer
LinvioIncLinvioInc

PS - Linvio sells a donation management add-on and has a free Non-Profit pack that might save you some trouble too if you've building a donation management system.

oj2131oj2131

Hey Ron,

 

Thanks for your reply! I've created a new PaymentConnect Settings record and a new PayPal processor connection in the PaymentConnect SalesForce tab. However, whenever I try to find the connection in APEX with:


pymt__Processor_Connection__c connection = [SELECT Id,
pymt__Test_Mode__c, pymt__Enabled_Card_Types__c
FROM pymt__Processor_Connection__c
WHERE pymt__Processor_Id__c = 'PayPal'];

 

 my program returns a 'System.QueryException: List has no rows for assignment to SObject' error.

 

Is there some additional interfacing I have to do between PaymentConnect and APEX in order for my code to successfully query the connection? Or do I create the PaymentConnect settings and processor connection within the APEX code itself?

 

The PaymentConnect settings and processor connection that I created in SalesForce can be found here.

 

Thanks!

 

EDIT: I fixed it by creating a PaymentConnect Settings object in my APEX class instead of the SalesForce UI

LinvioIncLinvioInc

 

For those following this thread:

 

"For Apex code saved using Salesforce.comAPI version 24.0 and later, use the isTest(SeeAllData=true) annotation to grant test classes and individual test methods access to all data in the organization, including pre-existing data that the test didn’t create. Starting with Apex code saved using Salesforce.com API version 24.0, test methods don’t have access by default to pre-existing data in the organization. However, test code saved against Salesforce.com API version 23.0 or earlier continues to have access to all data in the organization and its data access is unchanged."

 

... so creating the PaymentConnect Settings record in your Apex test methods will be necessary if you don't use SeeAllData=true.

 

~ Ron