kasirphp / kasir

Midtrans package for Laravel, in Laravel way.
https://kasirphp.com
MIT License
9 stars 0 forks source link

GoPay Account Link, Unlink, & Get Status #15

Closed risangbaskoro closed 1 year ago

risangbaskoro commented 1 year ago

In Midtrans, there are abilities to bind, unbind, and get status of a GoPay payment account. This allows gopay() method to receive tokenized GoPay account ID in $account_id parameter. This will be beneficial to backend engineers who needs to build a backend for a mobile or web app that can utilize GoPay Wallet or GoPay Paylater.

I am thinking of a class (may be called GoPay) with some properties like account_id and account_status.

This class will likely to have bind() method to link a GoPay account from Midtrans API, unbind() method to unlink an existing GoPay account from a given account_id, and status() method to receive an account status from a given account_id.

Since a "PENDING" binding account status response body will have 'actions' array as well, it will be powerfull to have some sort of action choosing method where this class can returns an array of a given action name (like MidtransResponse does).

The same also applies to 'metadata.payment_options' array. For example: wallet() method will returns an array of 'name'=>'GOPAY_WALLET' in the option, and paylaterBalance() will return an array of the users balance and currency from an option that has 'name'=>'PAY_LATER'.

interface GoPayAccount
{
    protected $account_id;
    protected $account_status;
    protected $actions;
    private $payment_options;

    public static function bind(string $phone_number, string $callback_url, string|int|null $country_code = 62);

    public function status();

    public function unbind();

    public function wallet();

    public function walletBalance();

    public function paylater();

    public function paylaterBalance();
}
risangbaskoro commented 1 year ago

bind() and undbind() method can be aliased to link() and unlink().

risangbaskoro commented 1 year ago

Closed in #26