-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d4eb5ea
commit b914165
Showing
8 changed files
with
101 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
## [0.0.1] - TODO: Add release date. | ||
|
||
* TODO: Describe initial release. | ||
## [1.0.1] | ||
- added documentation for `Source` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,30 +65,29 @@ class _MyAppState extends State<MyApp> { | |
onPressed: () async { | ||
final _amount = _cart.fold<num>(0, | ||
(previousValue, element) => previousValue + element.amount); | ||
final source = PayMongoSDK(payMongoKey); | ||
final sdk = PayMongoSDK(payMongoKey); | ||
final url = 'google.com'; | ||
final result = await source.createSource( | ||
Source( | ||
type: "gcash", | ||
amount: _amount.toDouble(), | ||
currency: 'PHP', | ||
redirect: Redirect( | ||
success: "https://$url/success", | ||
failed: "https://$url/failed", | ||
), | ||
billing: PayMongoBilling( | ||
address: PayMongoAddress( | ||
city: "Cotabato City", | ||
country: "PH", | ||
state: "Mindanao", | ||
line1: "Secret Address", | ||
), | ||
name: "Anonymous", | ||
email: "[email protected]", | ||
phone: "09123456002", | ||
final _source = Source( | ||
type: "gcash", | ||
amount: _amount.toDouble(), | ||
currency: 'PHP', | ||
redirect: Redirect( | ||
success: "https://$url/success", | ||
failed: "https://$url/failed", | ||
), | ||
billing: PayMongoBilling( | ||
address: PayMongoAddress( | ||
city: "Cotabato City", | ||
country: "PH", | ||
state: "Mindanao", | ||
line1: "Secret Address", | ||
), | ||
name: "Anonymous", | ||
email: "[email protected]", | ||
phone: "09123456002", | ||
), | ||
); | ||
final result = await sdk.createSource(_source); | ||
final response = await Navigator.push<String>( | ||
context, | ||
CupertinoPageRoute( | ||
|
@@ -105,77 +104,6 @@ class _MyAppState extends State<MyApp> { | |
label: Text('Single Payment(${_cart?.length})'), | ||
icon: const Icon(Icons.credit_card), | ||
), | ||
// FloatingActionButton.extended( | ||
// onPressed: () async { | ||
// final _amount = _cart.fold<num>(0, | ||
// (previousValue, element) => previousValue + element.amount); | ||
// final _items = _cart.map((cart) { | ||
// return PaymayaItem( | ||
// name: cart.name, | ||
// quantity: 1, | ||
// code: 'ABP-797', | ||
// description: cart.description, | ||
// amount: PaymayaAmount( | ||
// value: cart.amount, | ||
// currency: cart.currency, | ||
// ), | ||
// totalAmount: PaymayaAmount( | ||
// value: cart.amount, | ||
// currency: cart.currency, | ||
// ), | ||
// ); | ||
// }).toList(); | ||
// final totalAmount = PaymayaAmount( | ||
// value: _amount, | ||
// currency: 'PHP', | ||
// ); | ||
// const _buyer = PaymayaBuyer( | ||
// firstName: 'John', | ||
// middleName: '', | ||
// lastName: 'Doe', | ||
// customerSince: '2020-01-01', | ||
// birthday: '1998-01-01', | ||
// contact: PaymayaContact( | ||
// email: '[email protected]', phone: '0912345678'), | ||
// billingAddress: PaymayaBillingAddress( | ||
// city: 'Davao City', | ||
// countryCode: 'PH', | ||
// zipCode: '8000', | ||
// state: 'Davao', | ||
// ), | ||
// shippingAddress: PaymayaShippingAddress( | ||
// city: 'Davao City', | ||
// countryCode: 'PH', | ||
// zipCode: '8000', | ||
// state: 'Davao', | ||
// firstName: 'John', | ||
// middleName: '', | ||
// lastName: 'Doe', | ||
// email: '[email protected]', | ||
// // ST - Standard | ||
// // SD - Same Day | ||
// shippingType: ShippingType.sd, | ||
// ), | ||
// ); | ||
// final redirectUrls = const PaymayaRedirectUrls( | ||
// success: '', | ||
// failure: '', | ||
// cancel: '', | ||
// ); | ||
// final _checkout = PaymayaCheckout( | ||
// totalAmount: totalAmount, | ||
// buyer: _buyer, | ||
// items: _items, | ||
// redirectUrl: redirectUrls, | ||
// requestReferenceNumber: '6319921'); | ||
// final result = await _payMayaSdk.createCheckOut( | ||
// _checkout, | ||
// ); | ||
// await _onRedirectUrl(result.redirectUrl); | ||
// }, | ||
// label: Text('Checkout Cart(${_cart.length})'), | ||
// icon: const Icon(Icons.shopping_basket), | ||
// ), | ||
], | ||
)); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,43 @@ | ||
import '../src.dart'; | ||
|
||
/// Instance of Source to provide a different payment gateway. | ||
/// Options allowed are GCash and GrabPay | ||
/// Link: https://developers.paymongo.com/docs/e-wallets-gcash-grabpay | ||
extension PayMongoSource on PayMongoSDK { | ||
/// A Source resource is used to generate GCash/GrabPay checkout URL to authorize | ||
/// a certain amount to be deducted from your customer's GCash account | ||
/// and send it to your PayMongo account. After completing the authorization, | ||
/// your integration uses the chargeable | ||
/// source to make a create payment request and receive the payment. | ||
/// | ||
/// https://developers.paymongo.com/docs/accepting-gcash-payments#1-create-a-source | ||
/// | ||
/// Example: | ||
/// ```dart | ||
/// final sdk = PayMongoSDK(payMongoKey); | ||
/// final url = 'your-url-callback'; | ||
/// final _source = Source( | ||
/// type: "gcash", | ||
/// amount: _amount.toDouble(), | ||
/// currency: 'PHP', | ||
/// redirect: Redirect( | ||
/// success: "https://$url/success", | ||
/// failed: "https://$url/failed", | ||
/// ), | ||
/// billing: PayMongoBilling( | ||
/// address: PayMongoAddress( | ||
/// city: "Cotabato City", | ||
/// country: "PH", | ||
/// state: "Mindanao", | ||
/// line1: "Secret Address", | ||
/// ), | ||
/// name: "Anonymous", | ||
/// email: "[email protected]", | ||
/// phone: "09123456002", | ||
/// ), | ||
/// ); | ||
/// final result = await sdk.createSource(_source); | ||
/// ``` | ||
Future<SourceResult> createSource(Source source) async { | ||
final options = PayMongoOptions( | ||
path: '/sources', | ||
|
@@ -13,10 +50,8 @@ extension PayMongoSource on PayMongoSDK { | |
return SourceResult.fromMap(response); | ||
} | ||
|
||
/// Retrieves the payment | ||
Future<SourceResult> retreiveSource(int id) async { | ||
if (id.runtimeType != int) { | ||
throw ArgumentError("ID is required"); | ||
} | ||
if (id <= 0) { | ||
throw ArgumentError("ID must be greater than 0"); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters