Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to integrate adaptive payment in php

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 260
    Comment on it

    Adaptive payment provides facility to allow payment between sender and multiple recievers.

    Steps for adaptive payment are as follows:-

    1 First need to create app for paypal.

    Get username,passsword,applicationid and signature recieved from paypal.

    for eg.:-

     public $api_user = "****************";
    public $api_pass = "***************";
    public $api_sig = "**************************";
    public $app_id = "******************";
    public $apiUrl = 'https://svcs.sandbox.paypal.com/AdaptivePayments/';
    

    2) Need to set the headers and pass envelope each and every time while hit request to paypal.

     $this->headers = array(
            "X-PAYPAL-SECURITY-USERID: ".$this->api_user,
            "X-PAYPAL-SECURITY-PASSWORD: ".$this->api_pass,
            "X-PAYPAL-SECURITY-SIGNATURE: ".$this->api_sig,
            "X-PAYPAL-REQUEST-DATA-FORMAT: JSON",
            "X-PAYPAL-RESPONSE-DATA-FORMAT: JSON",
            "X-PAYPAL-APPLICATION-ID: ".$this->app_id,
        );
    
        $this->envelope = array(
             "errorLanguage" => "en_US",
                "detailLevel" => "ReturnAll"
        );
    

    3) Create pay request for that we need to create packet where we need to pas envelop which generate paykey unique for each and every trasaction and then finally pass it to paypal url

     $createPacket = array(
            "actionType" =>"PAY",
            "currencyCode" => "USD",
            "receiverList" => array(
                "receiver" => array(
                    array(
                        "amount"=> "3.00",
                        "email"=>"kshitizmybusiness@evontech.com"
                    ),
                    array(
                        "amount"=> "4.00",
                        "email"=>$paypalemail
                    ),
                ),
            ),
            "returnUrl" => "http://52.4.234.191/apis/successpayment/doctorid/".$doctorid."/patientid/".$patientid."",
            "cancelUrl" => "http://52.4.234.191/apis/cancelpayment",
            //"ipnNotificationUrl" =>;"http://54.160.13.227/doctorsbookingapp/apis/notifyurl/",
            "requestEnvelope" => $this->envelope
        );
    
        $response = $this->_paypalSend($createPacket,"Pay");
    
        //echo  $response['payKey'];
        $payKey=$response['payKey'];
        //set payment details//
    
        $detailsPacket=array(
    
                 "requestEnvelope" =>$this->envelope,
            "payKey" => $payKey,
            "receiverOptions" => array(
    
                array(
                    "receiver" => array("email" => "kshitizmybusiness@evontech.com"),
                    "invoiceData" => array(
                            "item" => array(
                                array(
    
                                    "name" => "product1",
                                    "price" => "1.00",
                                    "identifier"  => "p1"
    
                                ),
                                array(
    
                                    "name" => "product2",
                                    "price" => "2.00",
                                    "identifier"  => "p2"
    
                                )
                            )
                    )
                ),
                array(
                    "receiver" => array("email" => $paypalemail),
                    "invoiceData" => array(
                            "item" => array(
                                array(
    
                                    "name" => "product1",
                                    "price" => "2.00",
                                    "identifier"  => "p1"
    
                                ),
                                array(
    
                                    "name" => "product2",
                                    "price" => "2.00",
                                    "identifier"  => "p2"
    
                                )
                            )
                    )
                ),
    
            )
    
        );
    
       $response = $this->_paypalSend($detailsPacket,"SetPaymentOptions");
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: