Skip to content

Commit cb82c7c

Browse files
committed
charge api
1 parent 27416ee commit cb82c7c

File tree

4 files changed

+68
-300
lines changed

4 files changed

+68
-300
lines changed

doc/charge.md

Lines changed: 20 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -1,144 +1,39 @@
1+
## Usage
12

2-
# Stripe charge
3+
Here are some common operations you can perform using the `StripeCharge` library:
34

4-
LaraStripeCharge has charge alias `LaraStripeCharge`.
5-
6-
7-
# Methods
8-
9-
## setup()
10-
11-
setup method has `secret_key,public_key,currency` .
12-
13-
```php
14-
LaraStripeCharge::setup([
15-
'secret_key' => '******',
16-
'public_key' => '******',
17-
'currency' => 'usd'
18-
])
19-
```
20-
21-
## card()
22-
23-
card method parameter will be card token which come from stripe.js with request.
24-
25-
```php
26-
LaraStripeCharge::card($token);
27-
```
28-
29-
or direct card
30-
31-
```php
32-
LaraStripeCharge::card([
33-
'number' => '4242424242424242'
34-
'exp_month' => '11',
35-
'exp_year' => '22',
36-
'cvc' => '222'
37-
]);
38-
```
39-
40-
## amount()
41-
42-
amount method set charge amount
43-
44-
```php
45-
LaraStripeCharge::amount(121.50);
46-
```
47-
48-
## metadata()
49-
50-
metadata methods array parameter you can declare here your `product id`, `customer id` or `similiar` data.
51-
52-
```php
53-
LaraStripeCharge::metadata(['product_id'=>'p-121','purchase_id' => 'pur-12321']);
54-
```
55-
56-
## description()
57-
58-
description method declare products/charge details.
59-
60-
```php
61-
LaraStripeCharge::description('LaraStripeCharge Laravel Stripe payment');
62-
```
63-
64-
## purchase()
65-
66-
purchase method create charge.
5+
### Creating a charge
676

687
```php
69-
LaraStripeCharge::purchase();
70-
```
71-
72-
## get()
8+
use Code4mk\LaraStripe\Lib\StripeCharge;
739

74-
get method return some data . `type object`
10+
$stripeCharge = new StripeCharge();
7511

76-
```php
77-
LaraStripeCharge::get();
12+
$stripeCharge->amount(10,'usd')
13+
//->chargeMethod('cus_OnESro2IB5rzv3', 'customer')
14+
->chargeMethod('tok_1O32CXAHZl11YnN0yj3', 'card_token')
15+
->metaData(['id' => '1234', 'name' => 'kamal'])
16+
->create();
7817
```
7918

80-
## getAll()
81-
82-
get method return all datas. `type object`
19+
### Retrieving a Charge
8320

8421
```php
85-
LaraStripeCharge::getAll();
86-
```
22+
use Code4mk\LaraStripe\Lib\StripeCharge;
8723

88-
# Full code
24+
$stripeCharge = new StripeCharge();
8925

90-
```php
91-
$charge = LaraStripeCharge::setup([
92-
'secret_key' => '******',
93-
'public_key' => '******',
94-
'currency' => 'usd'
95-
])
96-
->card($token)
97-
->amount(121.50)
98-
->metaData(['product_id'=>'p-121','purchase_id' => 'pur-12321'])
99-
->description('LaraStripeCharge Laravel Stripe payment')
100-
->purchase()
101-
->get()
102-
// or
103-
// ->getAll()
104-
# access response
105-
// $charge->metadata->product_id
106-
```
107-
108-
* response
26+
$id = 'charge_id_here';
10927

110-
```json
111-
{
112-
"charge_id": "ch_1FWHbuAHZl11YnL9fU2BALTS",
113-
"amount": 121.50,
114-
"currency": "usd",
115-
"balance_transaction": "txn_1FVAcYAHZl11YnL9Ld0Fq3lp",
116-
"description": "LaraStripeCharge Laravel Stripe payment",
117-
"paid": true,
118-
"status": "succeeded",
119-
"metadata": {
120-
"product_id": "p-121",
121-
"purchase_id": "pur-12321"
122-
},
123-
"created": 1571463416
124-
}
28+
$stripeCharge->retrieve($id);
12529
```
12630

127-
* access response
31+
### Listing Charge
12832

12933
```php
130-
# php file
131-
$charge->metadata->product_id
132-
```
34+
use Code4mk\LaraStripe\Lib\StripeCharge;
13335

134-
# refund
36+
$stripeCharge = new StripeCharge();
13537

136-
* store charge id when charge complete.
137-
138-
```php
139-
$refund = LaraStripeCharge::setup([
140-
'secret_key'=>'sk_test_mBGoFuccDy2KCD4pobbaixKK00qUW0ghu1',
141-
])
142-
->refund('charge id');
143-
return response()->json($refund);
144-
```
38+
$stripeCharge->lists();
39+
```

doc/coupon.md

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,4 @@ if ($result->isError === true) {
6363
echo "Error: " . $result->message;
6464
echo "Stripe Error: " . $result->stripe['message'];
6565
}
66-
```
67-
68-
## License
69-
70-
This library is open-source software licensed under the MIT License. You can find the full license text in the [LICENSE](LICENSE) file.
71-
72-
## Author
73-
74-
This library was created by [Your Name] and is maintained by [Your Organization]. Feel free to contribute by submitting issues or pull requests on the [GitHub repository](https://github.com/your-repo-link).
66+
```

0 commit comments

Comments
 (0)