Add Anypay token (#518)

* Add AnyPay token

for interacting with the AnyPay API for Cake Pay payments

* Add missing commas

Co-authored-by: mkyq <53115730+mkyq@users.noreply.github.com>
This commit is contained in:
Justin Ehrenhofer 2022-11-03 15:53:33 -05:00 committed by GitHub
parent 6e01bbb1a5
commit 30bac3cb6c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View file

@ -5,11 +5,13 @@ import 'package:http/http.dart';
import 'package:cw_core/crypto_currency.dart'; import 'package:cw_core/crypto_currency.dart';
import 'package:cake_wallet/anypay/any_pay_payment.dart'; import 'package:cake_wallet/anypay/any_pay_payment.dart';
import 'package:cake_wallet/anypay/any_pay_trasnaction.dart'; import 'package:cake_wallet/anypay/any_pay_trasnaction.dart';
import 'package:cake_wallet/.secrets.g.dart' as secrets;
class AnyPayApi { class AnyPayApi {
static const contentTypePaymentRequest = 'application/payment-request'; static const contentTypePaymentRequest = 'application/payment-request';
static const contentTypePayment = 'application/payment'; static const contentTypePayment = 'application/payment';
static const xPayproVersion = '2'; static const xPayproVersion = '2';
static const anypayToken = secrets.anypayToken;
static String chainByScheme(String scheme) { static String chainByScheme(String scheme) {
switch (scheme.toLowerCase()) { switch (scheme.toLowerCase()) {
@ -44,7 +46,9 @@ class AnyPayApi {
final headers = <String, String>{ final headers = <String, String>{
'Content-Type': contentTypePaymentRequest, 'Content-Type': contentTypePaymentRequest,
'X-Paypro-Version': xPayproVersion, 'X-Paypro-Version': xPayproVersion,
'Accept': '*/*',}; 'Accept': '*/*',
'x-wallet': 'cake',
'x-wallet-token': anypayToken,};
final body = <String, dynamic>{ final body = <String, dynamic>{
'chain': chainByScheme(scheme), 'chain': chainByScheme(scheme),
'currency': currencyByScheme(scheme).title}; 'currency': currencyByScheme(scheme).title};
@ -66,7 +70,9 @@ class AnyPayApi {
final headers = <String, String>{ final headers = <String, String>{
'Content-Type': contentTypePayment, 'Content-Type': contentTypePayment,
'X-Paypro-Version': xPayproVersion, 'X-Paypro-Version': xPayproVersion,
'Accept': '*/*',}; 'Accept': '*/*',
'x-wallet': 'cake',
'x-wallet-token': anypayToken,};
final body = <String, dynamic>{ final body = <String, dynamic>{
'chain': chain, 'chain': chain,
'currency': currency, 'currency': currency,

View file

@ -26,6 +26,7 @@ class SecretKey {
SecretKey('sideShiftAffiliateId', () => ''), SecretKey('sideShiftAffiliateId', () => ''),
SecretKey('sideShiftApiKey', () => ''), SecretKey('sideShiftApiKey', () => ''),
SecretKey('simpleSwapApiKey', () => ''), SecretKey('simpleSwapApiKey', () => ''),
SecretKey('anypayToken', () => ''),
SecretKey('onramperApiKey', () => ''), SecretKey('onramperApiKey', () => ''),
]; ];