hypejunction / payments
Payments API for Elgg
Installs: 118
Dependents: 5
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 2
Open Issues: 0
Type:elgg-plugin
Requires
- php: >=5.6
- composer/installers: ~1.0
- sebastian/money: ~1.6
README
Features
- Standardized API for handling payments and product sales
- Interface for logging and refunding payments
Usage
New payment
namespace hypeJunction\Payments; // First, we create an itemized order/invoice $order = new Order(); $order->setCurrency('EUR'); // Add a new product $order->add($product, 2); // Add additional fees and charges $shipping = Amount::fromString('25.25', 'EUR'); $charges[] = new ShippingFee('shipping', 0, $shipping); $charges[] = new ProcessingFee('paypal_fee', 3.9); $order->setCharges($charges); $address = new Address(); $address->street_address = 'Some street 25'; // add other address parts $address->country_code = 'CZ'; $order->setShippingAddress($address); // Now create a transaction $transaction = new Transaction(); $transaction->setOrder($order); $transaction->setPaymentMethod('paypal'); // Be sure to correctly set the owner and container and access id // to ensure that both the merchant and the customer have access // to the transaction entity $transaction->owner_guid = $payer->guid; $transaction->container_guid = $payee->guid; // You can use access_grant to give access to the merchant, // or create a new acccess collection that contains both the payer and the payee $transaction->access_id = ACCESS_PRIVATE; $transaction->save(); // Instantiate a gateway of choice $gateway = new \hypeJunction\PayPal\API\Adapter(); // What you do with response may depend on where you are executing // this code. From an action file, you can just return the $response. $response = $adapter->pay($transaction);