Announcement

Collapse
No announcement yet.

Best way to add a payment method in Salesforce

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Best way to add a payment method in Salesforce

    Hi guys,

    What would be the best way to add a payment method to C&P from Salesforce? so we can reuse it as a referral transaction on another transaction. We are currently trying to implement a transaction of $0 to store the card info and then use that as the referral.

    this is our current code:

    Code:
            Map<String, Object> result = new Map<String,Object>();
    
            CnP_IaaS.PaaS_Class cnpxmlstring = new CnP_IaaS.PaaS_Class();
            CnP_IaaS.PaaS_Class.Operation Operation = new CnP_IaaS.PaaS_Class.Operation();
            CnP_IaaS.PaaS_Class.Order Order = new CnP_IaaS.PaaS_Class.Order();
            CnP_IaaS.PaaS_Class.Authentication Authentication = new CnP_IaaS.PaaS_Class.Authentication();
            CnP_IaaS.PaaS_Class.BillingInformation BillingInfo = new CnP_IaaS.PaaS_Class.BillingInformation();
            CnP_IaaS.PaaS_Class.BillingAddress BillingAddress = new CnP_IaaS.PaaS_Class.BillingAddress();
            CnP_IaaS.PaaS_Class.PaymentMethod PaymentMethod = new CnP_IaaS.PaaS_Class.PaymentMethod();
            CnP_IaaS.PaaS_Class.Receipt Receipt = new CnP_IaaS.PaaS_Class.Receipt();
    
            CnP_IaaS.PaaS_Class.cnpTransaction trans = new CnP_IaaS.PaaS_Class.cnpTransaction();
            trans.TransactionType = 'Authorize';
    
            Authentication.AccountID = 'xxx';//Replace with your Click & Pledge account number.
            Authentication.AccountGuid = 'xxx';//Replace with your Click & Pledge account GUID.
    
            Order.OrderMode='Test';
    
            cnpxmlstring.ItemsList = new List<CnP_IaaS.Paas_Class.Items>();
            CnP_IaaS.Paas_Class.Items i = new CnP_IaaS.Paas_Class.Items();
            i.ItemName = 'Add Card';
            i.UnitPrice = 0.0;
            cnpxmlstring.ItemsList.add(i);
            BillingInfo.BillingFirstName = (String)payMethod.get('firstName');
            BillingInfo.BillingLastName = (String)payMethod.get('lastName');
            BillingAddress.BillingStateProvince = (String)payMethod.get('billingState');
    
            PaymentMethod.NameOnCard = (String)payMethod.get('cardName');
            PaymentMethod.CardNumber = (String)payMethod.get('cardNumber');
            PaymentMethod.Cvv2 = (String)payMethod.get('cvv2');
            PaymentMethod.ExpirationMonth = (String)payMethod.get('expirationMonth');
            PaymentMethod.ExpirationYear = (String)payMethod.get('expirationYear');
    
            Operation.IPAddress = '0.0.0.0'; //test IP, can apex get browser IP?
    
            cnpxmlstring.getOperation_node(Operation);
            cnpxmlstring.getOrder_node(Order);
            cnpxmlstring.getAuthentication_node(Authentication);
            cnpxmlstring.getBillingInformation_node(BillingInfo);
            cnpxmlstring.getBillingAddress_node(BillingAddress);
            cnpxmlstring.getItemslist_node(cnpxmlstring.getItemsList());
            cnpxmlstring.getTransactionDetails_node(trans);
            cnpxmlstring.getPaymentMethod_node(PaymentMethod);
            cnpxmlstring.getreceipt_node(Receipt);
            cnpxmlstring.getgeneratexml(cnpxmlstring);
    
            if(!payMethod.containsKey('testMode')){
                cnpxmlstring.Send_Transaction_api(cnpxmlstring.xmlfile);
                result.put('TransactionResultCode',cnpxmlstring.TransactionResultCode);
                result.put('ErrorData',cnpxmlstring.ErrorData);
                result.put('TransactionNumber',cnpxmlstring.TransactionNumber);
            }   
    
            return result;

  • #2
    Good day @dgarcia

    In case of using the reference payment method you NO need to pass creditcard info.

    PaymentMethod.PaymentType = ‘ReferenceTransaction’
    PaymentMethod.vaultguid = VaultGUID of the Reference Transaction
    PaymentMethod.Ordernumber = Reference Transaction Ordernumber

    Hope that helps.
    Regards,
    Click & Pledge Support Department

    On Salesforce? Help us by rating our app: Click & Pledge Donor Management on AppExchange

    Join us @ the educational webinars: https://clickandpledge.com/webinars/
    Live Support available Join between 3:00 - 3:30 p.m. ET Monday - Thursday: https://clickandpledge.com/webinars/
    Are you on Salesforce? Join us at the Power of Us Hub: https://powerofus.force.com/0F980000000CjpC

    Comment

    Working...
    X