Skip to content
This repository has been archived by the owner on Aug 16, 2022. It is now read-only.

A very simple wrapper for Adaptive Payments in PHP that is simpler to use for those that do not use Composer

Notifications You must be signed in to change notification settings

braintreedev/paypal-adaptive-payments-wrapper-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

This repo is on a path to being archived, checkout our other resources in github.com/paypal

PayPal Adaptive Payments Wrapper

A simple wrapper around the PayPal Adaptive Payments API.

Used in this sample.

Basic usage

Configuration

require('adaptive-payments.php'); # change to correct path if needed

$config = array(
  "environment" => "sandbox", # or live
  "userid" => "info-facilitator_api1.commercefactory.org",
  "password" => "1399139964",
  "signature" => "AFcWxV21C7fd0v3bYYYRCpSSRl31ABA-4mmfZiu.G30Dl3DKyBo9-GF8",
  // "appid" => "", # You can set this when you go live
);

$paypal = new PayPal($config);

Setup payment

This shows how to use the Pay command (more details here).

You can make any call as specified in the API specification with this method.

$result = $paypal->call(
  array(
    'actionType'  => 'PAY',
    'currencyCode'  => 'USD',
    'feesPayer'  => 'EACHRECEIVER',
    'memo'  => 'Order number #123',
    'cancelUrl' => 'cancel.php',
    'returnUrl' => 'success.php',
    'receiverList' => array(
      'receiver' => array(
        array(
          'amount'  => '100.00',
          'email'  => 'info-facilitator@commercefactory.org',
          'primary'  => 'true',
        ),
        array(
          'amount'  => '45.00',
          'email'  => 'us-provider@commercefactory.org',
        ),
        array(
          'amount'  => '45.00',
          'email'  => 'us-provider2@commercefactory.org',
        ),
      ),
    ),
  ), 'Pay'
);

In other words:

$result = $paypal->call(
  array_of_options, 'SomeCommand'
);

Redirecting the user

Most API calls are made with call but for convenience there's a simple way to build the correct redirec URL:

$paypal->redirect($result);

Finalising the payment

We can again just use the call method to make a PaymentDetails command:

$paypal->call(
  array(
    'actionType'  => 'Pay',
    'payKey'  => 'some pay key',
  ), "PaymentDetails"
);

About

A very simple wrapper for Adaptive Payments in PHP that is simpler to use for those that do not use Composer

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages