Paypal payment integration for flutter.
How to use -
Step 1- Download the zip file. Add 'src' folder within your project 'lib' folder
Step 2 - Add this code from where you want to call Paypal API
Map<dynamic,dynamic> defaultCurrency = {"symbol": "USD ", "decimalDigits": 2, "symbolBeforeTheNumber": true, "currency": "USD"};
var orderDetails = {};
//For Sandbox
orderDetails['domain'] = 'https://api.sandbox.paypal.com';
//For real Payment API
//orderDetails['domain'] = 'https://api.paypal.com';
orderDetails['clientId'] = 'Your Client ID';
orderDetails['secret'] = 'Your Secret';
String itemName = 'Shoe';
String itemPrice = '2.99';
int quantity = 1;
List items = [
{
"name": itemName,
"quantity": quantity,
"price": itemPrice,
"currency": defaultCurrency["currency"]
}
];
orderDetails['items'] = items;
orderDetails['totalAmount'] = '2.99';
orderDetails['subTotalAmount'] = '2.99';
orderDetails['shippingCost'] = '0';
orderDetails['shippingDiscountCost'] = 0;
orderDetails['userFirstName'] = 'Nizam';
orderDetails['userLastName'] = 'Uddin';
orderDetails['addressCity'] = 'Dhaka';
orderDetails['addressStreet'] = 'Aftabnagar Main Road';
orderDetails['addressZipCode'] = '1212';
orderDetails['addressCountry'] = 'Bangladesh';
orderDetails['addressState'] = 'Dhaka';
orderDetails['addressPhoneNumber'] = '+8801949******';
// make PayPal payment
Navigator.of(context).push(
MaterialPageRoute(
builder: (BuildContext context) => PaypalPayment(
orderDetails: orderDetails,
onFinish: (paymentId) async {
// payment done
print('payment id: ' + paymentId);
},
),
),
);