|
| 1 | +# Charge via Card |
| 2 | + |
| 3 | +This document describes how to collect payments via Card. |
| 4 | + |
| 5 | +```php |
| 6 | +<?php |
| 7 | + |
| 8 | +$tx_ref = Flutterwave::generateReference(); |
| 9 | +$order_id = Flutterwave::generateReference('card'); |
| 10 | + |
| 11 | +$data = [ |
| 12 | + 'amount' => 100, |
| 13 | + |
| 14 | + 'redirect_url' => route('callback') |
| 15 | + 'tx_ref' => $tx_ref, |
| 16 | + 'card_number' => '5399670123490229', |
| 17 | + 'cvv' => 123, |
| 18 | + 'expiry_month' => '05', |
| 19 | + 'expiry_year' => '45', |
| 20 | + 'subaccounts' => [ |
| 21 | + ["id" => "RS_D87A9EE339AE28BFA2AE86041C6DE70E"], |
| 22 | + ["id" => "RS_B45A9VV221HQ28UYA2AE97681C6DR44R"] |
| 23 | + ] |
| 24 | +]; |
| 25 | + |
| 26 | +$charge = Flutterwave::payments()->card($data); |
| 27 | + |
| 28 | +if ($charge['status'] === 'success') { |
| 29 | + # code... |
| 30 | + //Handle Authorization Mode |
| 31 | + if($charge['data']['mode'] == 'redirect'){ |
| 32 | + // Redirect to the charge url |
| 33 | + return redirect($charge['data']['redirect']); |
| 34 | + |
| 35 | + }elseif($charge['data']['mode'] == 'otp'){ |
| 36 | + // Validate with OTP and FLW_REF |
| 37 | + |
| 38 | + }elseif($charge['data']['mode'] == 'avs_noauth'){ |
| 39 | + //Charge again with the following data city, address, state, country, and zipcode |
| 40 | + |
| 41 | + }elseif($charge['data']['mode'] == 'pin'){ |
| 42 | + //Charge again with the card PIN |
| 43 | + |
| 44 | + } |
| 45 | + |
| 46 | +} |
| 47 | +``` |
| 48 | + |
| 49 | +## Parameters |
| 50 | + |
| 51 | +| Parameter | Required | Description | |
| 52 | +| ------------------ | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
| 53 | +| amount | True | This is the amount to be charged. Expected value is ZMW | |
| 54 | +| card_number | True | This is the number on the cardholders card. E.g. 5399 6701 2349 0229 | |
| 55 | +| cvv | True | Card security code. This is 3/4 digit code at the back of the customers card, used for web payments. | |
| 56 | +| expiry_month | True | Two-digit number representing the card's expiration month. It is usually the first two digits of the expiry date on the card. | |
| 57 | +| expiry_year | True | Unique ref for the mobilemoney transaction to be provided by the merchant. | |
| 58 | +| email | True | Two-digit number representing the card's expiration year. It is the last two digits of the expiry date on the card. | |
| 59 | +| tx_ref | True | This is a unique reference peculiar to the transaction being carried out. | |
| 60 | +| currency | False | This is the specified currency to charge in. | |
| 61 | +| phone_number | False | This is the phone number linked to the customer's Bank account or mobile money account | |
| 62 | +| fullname | False | This is the name of the customer making the payment. | |
| 63 | +| preauthoize | False | This should be set to true for preauthoize card transactions. | |
| 64 | +| redirect_url | False | URL to redirect to when a transaction is completed. | |
| 65 | +| client_ip | False | IP - Internet Protocol. This represents the current IP address of the customer carrying out the transaction | |
| 66 | +| device_fingerprint | False | This is the fingerprint for the device being used. It can be generated using a library on whatever platform is being used. | |
| 67 | +| meta | False | This is used to include additional payment information` | |
| 68 | +| subaccounts | False | This is an array of objects containing the subaccount IDs to split the payment into. Check our Split Payment page for more info. eg `[ ["id" => "RS_D87A9EE339AE28BFA2AE86041C6DE70E"]]` | |
| 69 | +| meta | False | This is an object that helps you include additional payment information to your request e.g ['consumer_id'=>23, 'consumer_mac'=>'92a3-912ba-1192a'] | |
| 70 | + |
| 71 | + |
0 commit comments