|
| 1 | +# VaahStripe |
| 2 | +> Small Laravel Helpers |
| 3 | +
|
| 4 | +### Installation |
| 5 | + |
| 6 | +VaahStripe provides an expressive, fluent interface to Stripe's One Time Payment |
| 7 | +and subscription billing services. |
| 8 | + |
| 9 | +For extra fraud protection, 3D Secure (3DS) requires customers to complete an |
| 10 | +additional verification step with the card issuer when paying. |
| 11 | +Typically, you direct the customer to an authentication page on their bank’s |
| 12 | +website, and they enter a password associated with the card or a |
| 13 | +code sent to their phone. This process is familiar to customers |
| 14 | +through the card networks’ brand names, such as Visa Secure and |
| 15 | +Mastercard Identity Check. |
| 16 | + |
| 17 | +### Dependencies |
| 18 | +- [STRIPE BY CARTALYST](https://github.com/cartalyst/stripe-laravel) |
| 19 | + |
| 20 | +### Installation |
| 21 | + |
| 22 | +```shell script |
| 23 | +composer require cartalyst/stripe-laravel |
| 24 | +``` |
| 25 | + |
| 26 | +Add Facade in `config/app.php`: |
| 27 | +```php |
| 28 | +'aliases' => [ |
| 29 | +... |
| 30 | +'VaahStripe' => WebReinvent\VaahExtend\Facades\VaahStripe::class, |
| 31 | +... |
| 32 | +] |
| 33 | +``` |
| 34 | + |
| 35 | +Add env configuration: |
| 36 | +``` |
| 37 | +
|
| 38 | +... |
| 39 | +STRIPE_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
| 40 | +... |
| 41 | +
|
| 42 | +``` |
| 43 | + |
| 44 | +Reference url: https://stripe.com/docs/api |
| 45 | + |
| 46 | +### Methods |
| 47 | + |
| 48 | +- Stripe One Time Payment |
| 49 | + |
| 50 | +``` |
| 51 | +
|
| 52 | + $customer => [ |
| 53 | + 'name' => 'xxxxxx', |
| 54 | + |
| 55 | + ]; |
| 56 | + |
| 57 | + $card => [ |
| 58 | + 'number' => 'xxxx-xxxx-xxxx-xxxx', |
| 59 | + 'exp_month' => '01', // 01-12 |
| 60 | + 'exp_year' => '2021', |
| 61 | + 'cvc' => 'xxx' |
| 62 | + ]; |
| 63 | + |
| 64 | + $package => [ |
| 65 | + 'currency' => 'usd', // usd / USD |
| 66 | + 'amount' => '01', |
| 67 | + 'description' => 'xxxxxx' |
| 68 | + ]; |
| 69 | + |
| 70 | + $address => [ |
| 71 | + 'city' => 'xxxxxx', // optional |
| 72 | + 'country' => 'xxxxxx', |
| 73 | + 'line1' => 'xxxxxx', |
| 74 | + 'line2' => 'xxxxxx', // optional |
| 75 | + 'postal_code' => '123456', // optional |
| 76 | + 'state' => 'xxxxxx' // optional |
| 77 | + ]; |
| 78 | + |
| 79 | + $return_url // URL to redirect your customer back to after they authenticate or cancel their payment |
| 80 | +
|
| 81 | + \VaahStripe::pay($customer, $card, $package, $address, $return_url); |
| 82 | +
|
| 83 | +``` |
| 84 | + |
| 85 | +- Stripe Subscription |
| 86 | +```php |
| 87 | + |
| 88 | + $customer => [ |
| 89 | + 'name' => 'xxxxxx', |
| 90 | + |
| 91 | + ]; |
| 92 | + |
| 93 | + $card => [ |
| 94 | + 'number' => 'xxxx-xxxx-xxxx-xxxx', |
| 95 | + 'exp_month' => '01', // 01-12 |
| 96 | + 'exp_year' => '2021', |
| 97 | + 'cvc' => 'xxx' |
| 98 | + ]; |
| 99 | + |
| 100 | + $address => [ |
| 101 | + 'city' => 'xxxxxx', // optional |
| 102 | + 'country' => 'xxxxxx', |
| 103 | + 'line1' => 'xxxxxx', |
| 104 | + 'line2' => 'xxxxxx', // optional |
| 105 | + 'postal_code' => '123456', // optional |
| 106 | + 'state' => 'xxxxxx' // optional |
| 107 | + ]; |
| 108 | + |
| 109 | + $price_id // Price define the unit cost, currency, and (optional) billing cycle for Subcription |
| 110 | + |
| 111 | + $return_url // URL to redirect your customer back to after they authenticate or cancel their payment |
| 112 | + |
| 113 | + \VaahStripe::subscription($customer, $card, $address, $price_id, $return_url); |
| 114 | + |
| 115 | +``` |
| 116 | + |
| 117 | +- Create Product |
| 118 | +```php |
| 119 | + |
| 120 | + $request => [ |
| 121 | + 'name' => 'xxxxxx', |
| 122 | + 'description' => 'xxxxxx' |
| 123 | + ]; |
| 124 | + |
| 125 | + \VaahStripe::createProduct($request); |
| 126 | + |
| 127 | +``` |
| 128 | + |
| 129 | +- Create Price |
| 130 | +```php |
| 131 | + |
| 132 | + $request => [ |
| 133 | + 'product_id' => 'xxxxxx', |
| 134 | + 'currency' => 'usd', |
| 135 | + 'amount' => '01', |
| 136 | + 'interval' => '01' |
| 137 | + |
| 138 | + ]; |
| 139 | + |
| 140 | + \VaahStripe::createPrice($request); |
| 141 | + |
| 142 | +``` |
| 143 | + |
| 144 | +- Find Product |
| 145 | +```php |
| 146 | + |
| 147 | + \VaahStripe::findProductByName($name); |
| 148 | + |
| 149 | +``` |
| 150 | + |
| 151 | +- Find Price |
| 152 | +```php |
| 153 | + |
| 154 | + $product_id |
| 155 | + |
| 156 | + $value //optional |
| 157 | + |
| 158 | + $by //optional default = amount amount/currency/interval |
| 159 | + |
| 160 | + \VaahStripe::getProductPrice($product_id, $value, $by); |
| 161 | + |
| 162 | +``` |
0 commit comments