Technology + People + Process

Integrating Adaptive Payments with Yii Framework - By Pradeepkumar Namburu
Feb 03
2015

Integrating Adaptive Payments with Yii Framework - By Pradeepkumar Namburu

Integrating Adaptive Payments with Yii Framework - By Pradeepkumar Namburu

Introduction about Adaptive Payments:

Adaptive payments handle payments between a sender of a payment and one or more receivers of the payments. We have three types of payments:

Simple Payments - Simple payments enable a sender to send a single payment to a single receiver.

Parallel Payments - A parallel payment is a payment from a sender that is split directly among 2-6 receivers. Technically, a parallel payment is a set of multiple payments made in a single Pay request.

Chained Payments - A chained payment is a payment from a sender that is indirectly split among multiple receivers. It is an extension of a typical payment from a sender to a receiver, in which a receiver, known as the primary receiver, passes part of the payment to other receivers, who are called secondary receivers.

Process to Integrate with Yii-Framework:

Step 1: Download paypal.php from https://github.com/urmaul/paypal and keep it in components folder

Step 2: Do paypal settings in yii configuration file i.e protected/config/main.php as below:

'Paypal' => array(
             'class' => 'application.components.Paypal',
            'username' => '', //APP User Name required
            'password' => '', //APP Password required
        'signature'=>'', //APP Signature required
               'appid' => '', //APP Id required
            'sandbox' => false, // live or sandbox mode
            'returnUrl' => '', //regardless of url management component
            'cancelUrl' => '', //regardless of url management component
            // Default currency to use, if not set USD is the default
            'currencyCode' => 'USD', // currencyCode Required
        ),

Calling Paypal Methods in our controller We have different API operations in adaptive payments. Following table give brief information about few methods that are available in Paypal API:

API Operation Description
Pay Transfers funds from a sender's PayPal account to one or more receivers' PayPal accounts (up to 6 receivers)
PaymentDetails Obtains information about a payment created with the Pay API operation
ExecutePayment Executes a payment
GetPaymentOptions Obtain the settings specified with the SetPaymentOptions API operation
GetPrePaymentDisclosure Provide pre-payment Remittance Transfer Rule disclosure information
SetPaymentOptions Sets payment alternative
Refund Refunds all or part of a payment
 

Calling pay pal payment method operation using API Pay Operation by passing API parameters

$params = array(
                    'clientDetails.applicationId'=> '', # App Id
                    'feesPayer' => '', #The payer of PayPal fees. Allowable values are: SENDER, PRIMARY RECEIVER, EACH RECEIVER & SECONDARY ONLY
                    'receiverList.receiver(0).amount'=> ,    #Amount to be credited to the primary receiver's account
                    'receiverList.receiver(0).email'=> , # Primary receiver's E-mail account
                    'receiverList.receiver(0).primary'=> true,
                    'receiverList.receiver(1).amount'=> , #Secondary receiver's E-mail  account
                    'receiverList.receiver(1).email'=> ,
                    'receiverList.receiver(1).primary'=> false ,
                   'returnUrl' => ,
                   'cancelUrl' => $cancelUrl,
                
$response = Yii::app()->Paypal->pay($params);

 

Pay-pal checks API authentication and then creates an PayKey with success status, need to have condition based on status, if the status is success then only user will get connect to paypal to do payments using pay pal account or else using credit card.

This is process to follow for payments paying purposes.

Refunds in Adaptive Payments:

PayPal supports refunds made manually, via the PayPal account interface, or with the Refund Transaction API. The terms sender and receiver refer to sender and receivers of the original payment using the Pay API operation. When making a refund, the sender's account receives the refund and the receivers' accounts are the source of the refund. Refunds are made from one or more receivers to a sender.

To make a refund using the Refund API operation, you must:

Have made a Pay request for which payment you want to refund the payment, or you must have received the part of the payment you want to refund, and

Have permission to make a refund on behalf of the receiver, unless you are also the receiver; in other words, each receiver whose account is the source of the refund must have granted you third-party access permission to call the Refund API operation.

Note: A receiver with a business or premier account can grant you third-party access (to make a refund) by logging in to PayPal, choosing API Access on the Profile page, clicking the link to Grant API permission, and selecting Refund after clicking Configure a custom API authorization.

Note: The Adaptive Payments Refund API call does not support pay keys generated by the Mobile Payment Library (MPL). For each kind of refund, you must specify values for the following fields:

$params = array(
             'payKey' => , #The key used to create the payment that you want to refund
             'receiverList.receiver(0).email'=>'' ,  #Primary Receiver Email Address
             'receiverList.receiver(0).amount'=>'' , #Primary Receiver Amount
             'receiverList.receiver(1).email'=> '',  #Secondary Receiver Email Address  
             'receiverList.receiver(1).amount'=> '', #Secondary Receiver Amount  
            );
  $response = Yii::app()->Paypal->refund($params);

 


Request for Quote

Drop us a line and we'll get in touch with you as quick as we can