fourello-devs / paymaya-wrapper

此包已被放弃,不再维护。作者建议使用 fourello-devs/paymaya 包。

Paymaya SDK 的 Laravel 风格包装器

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

This package is auto-updated.

Last update: 2023-03-22 02:41:36 UTC


README

Latest Version on Packagist Total Downloads Build Status StyleCI

这里应该是您的描述。请查看 contributing.md 了解待办事项列表。

安装

通过 Composer

$ composer require fourello-devs/paymayawrapper

使用

此包提供了两种方便的方式直接使用 PaymayaSDK。

  • PaymayaWrapper 门面
  • paymaya() 辅助函数

设置环境变量

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'

演示

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,
    ];
}

变更日志

请参阅 changelog 了解最近更改的详细信息。

测试

$ composer test

贡献

请参阅 contributing.md 了解详细信息及待办事项列表。

安全

如果您发现任何安全相关的问题,请发送电子邮件至 carlo.luchavez@fourello.com 而不是使用问题跟踪器。

鸣谢

许可

MIT。请参阅 许可文件 了解更多信息。