fourello-devs/paymaya-wrapper

This package is not installable via Composer 1.x, please make sure you upgrade to Composer 2+. Read more about our Composer 1.x deprecation policy.
This package is abandoned and no longer maintained. The author suggests using the fourello-devs/paymaya package instead.

Laravel-flavored Wrapper for Paymaya SDK

dev-master 2021-05-06 22:23 UTC

This package is auto-updated.

Last update: 2021-05-18 22:33:03 UTC


README

Latest Version on Packagist Total Downloads Build Status StyleCI

This is where your description should go. Take a look at contributing.md to see a to do list.

Installation

Via Composer

$ composer require fourello-devs/paymayawrapper

Usage

This package offers two convenient way to directly use PaymayaSDK.

  • PaymayaWrapper facade
  • paymaya() helper function

Setup Environment Variables

PAYMAYA_CHECKOUT_PUBLIC_KEY=
PAYMAYA_CHECKOUT_SECRET_KEY=
PAYMAYA_CHECKOUT_ENVIRONMENT=SANDBOX
PAYMAYA_PAYMENT_PUBLIC_KEY=
PAYMAYA_PAYMENT_SECRET_KEY=
PAYMAYA_PAYMENT_ENVIRONMENT=SANDBOX
PAYMAYA_LOGO_URL=
PAYMAYA_ICON_URL=
PAYMAYA_APPLE_TOUCH_ICON_URL=
PAYMAYA_CUSTOM_TITLE=AppName
PAYMAYA_COLOR_SCHEME='#368d5c'

Demonstration

use PayMaya\API\Checkout;
use PayMaya\Model\Checkout\Address;
use PayMaya\Model\Checkout\Buyer;
use PayMaya\Model\Checkout\Contact;
use PayMaya\Model\Checkout\Item;
use PayMaya\Model\Checkout\ItemAmount;
use PayMaya\Model\Checkout\ItemAmountDetails;

public function checkoutTest(): array
{
    // Initialize PaymayaSDK
    paymaya();
    
    // Create Checkout
    $itemCheckout = new Checkout();

    // Checkout Address
    $address = new Address();
    $address->line1 = "9F Robinsons Cybergate 3";
    $address->line2 = "Pioneer Street";
    $address->city = "Mandaluyong City";
    $address->state = "Metro Manila";
    $address->zipCode = "12345";
    $address->countryCode = "PH";

    // Checkout Buyer
    $buyer = new Buyer();
    $buyer->firstName = 'James Carlo';
    $buyer->middleName = 'Sebial';
    $buyer->lastName = 'Luchavez';

    // Contact
    $contact = new Contact();
    $contact->phone = "09061886959";
    $contact->email = "carlo.luchavez@fourello.com";

    $buyer->contact = $contact;

    $buyer->shippingAddress = $address;
    $buyer->billingAddress = $address;

    $itemCheckout->buyer = $buyer;

    // Item
    $itemAmountDetails = new ItemAmountDetails();
    $itemAmountDetails->shippingFee = "14.00";
    $itemAmountDetails->tax = "5.00";
    $itemAmountDetails->subtotal = "50.00";
    $itemAmount = new ItemAmount();
    $itemAmount->currency = "PHP";
    $itemAmount->value = "100.00";
    $itemAmount->details = $itemAmountDetails;
    $item = new Item();
    $item->name = "Leather Belt";
    $item->code = "pm_belt";
    $item->description = "Medium-sized belt made from authentic leather";
    $item->quantity = "1";
    $item->amount = $itemAmount;
    $item->totalAmount = $itemAmount;

    $itemCheckout->items = array($item);
    $itemCheckout->totalAmount = $itemAmount;
    $itemCheckout->requestReferenceNumber = "123456789";
    $itemCheckout->redirectUrl = array(
        "success" => url()->to('/api/paymaya/success'),
        "failure" => url()->to('/api/paymaya/failure'),
        "cancel" => url()->to('/api/paymaya/cancel')
    );

    $itemCheckout->execute();

    return [
        'id' => $itemCheckout->id,
        'url' => $itemCheckout->url,
    ];
}

Change log

Please see the changelog for more information on what has changed recently.

Testing

$ composer test

Contributing

Please see contributing.md for details and a todolist.

Security

If you discover any security related issues, please email carlo.luchavez@fourello.com instead of using the issue tracker.

Credits

License

MIT. Please see the license file for more information.