Completed
Pull Request — master (#2)
by
unknown
01:13
created

Paymongo::payment()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Luigel\Paymongo;
4
5
use Luigel\Paymongo\Models\Source;
6
use Luigel\Paymongo\Models\Webhook;
7
use Luigel\Paymongo\Traits\Request;
8
use Luigel\Paymongo\Models\PaymentIntent;
9
use Luigel\Paymongo\Models\PaymentMethod;
10
use Luigel\Paymongo\Models\PaymentSource;
11
12
class Paymongo
13
{
14
    use Request;
15
16
    protected $method;
17
    protected $apiUrl = '';
18
    protected $payload;
19
    protected $returnModel = '';
20
21
    protected const BASE_API = 'https://api.paymongo.com/v1/';
22
    protected const ENPDPOINT_SOURCES = 'sources/';
23
    protected const ENPDPOINT_PAYMENTS = 'payments/';
24
    protected const ENDPOINT_WEBHOOKS = 'webhooks/';
25
    protected const ENDPOINT_PAYMENT_METHOD = 'payment_methods/';
26
    protected const ENDPOINT_PAYMENT_INTENT = 'payment_intents/';
27
    protected const SOURCE_GCASH = 'gcash';
28
    protected const SOURCE_GRAB_PAY = 'grab_pay';
29
30
    public function source()
31
    {
32
        $this->apiUrl = self::BASE_API . self::ENPDPOINT_SOURCES;
33
        $this->returnModel = Source::class;
34
        return $this;
35
    }
36
37
    public function webhook()
38
    {
39
        $this->apiUrl = self::BASE_API . self::ENDPOINT_WEBHOOKS;
40
        $this->returnModel = Webhook::class;
41
        return $this;
42
    }
43
44
    public function paymentMethod()
45
    {
46
        $this->apiUrl = self::BASE_API . self::ENDPOINT_PAYMENT_METHOD;
47
        $this->returnModel = PaymentMethod::class;
48
        return $this;
49
    }
50
51
    public function paymentIntent()
52
    {
53
        $this->apiUrl = self::BASE_API . self::ENDPOINT_PAYMENT_INTENT;
54
        $this->returnModel = PaymentIntent::class;
55
        return $this;
56
    }
57
58
    public function payment()
59
    {
60
        $this->apiUrl = self::BASE_API . self::ENPDPOINT_PAYMENTS;
61
        $this->returnModel = PaymentSource::class;
62
        return $this;
63
    }
64
}
65