Package: pyrecard
PyrecardA Python lib for brazilianWirecardpayment gateway.Wirecard works with a base64 hash made up of itsTOKEN:KEYin its operations. Pyrecard uses two environment variables with these setsSANDBOX_KEYandPRODUCTION_KEYand generates the necessary hash for an operation. This lib works in SANDBOX by default, to use PRODUCTION mode set environment variablePYRECARD_ENV=productionCurrently working withsubscriptionsonly.Table of ContentsInstallationUsageUsed byInstallationMinimal setup:$pipinstallpyrecard
$exportSANDBOX_KEY=TOKEN:KEY
$exportPRODUCTION_KEY=TOKEN:KEYSetup withpipenv(recomended):$pipenvinstallpyrecardCreate a.envfile with required data:SANDBOX_KEY=TOKEN:KEY
PRODUCTION_KEY=TOKEN:KEYUsagesubscriptions.planTheplanmodule performs the following operations:plan.create(json)plan.alter(plan_code, json)plan.activate(plan_code)plan.inactivate(plan_code)plan.fetch(plan_code)plan.fetch_all()All operations above returns a response.>>>frompyrecard.subscriptionimportplan>>>response=plan.fetch("plan101")>>>response<Response[200]>>>>response.json(){'setup_fee':500,'amount':990,'code':'plan101','name':'Plano Especial','billing_cycles':12,'description':'Descrição do PlanoEspecial','interval':{'unit':'MONTH','length':1},'creation_date':{'month':1,'hour':0,'year':2016,'day':8,'minute':0,'second':0},'payment_method':'CREDIT_CARD','max_qty':1,'trial':{'hold_setup_fee':True,'days':30,'enabled':True},'status':'ACTIVE'}>>>subscriptions.customerThecustomermodule performs the following operations:customer.create(json, new_vault=False)customer.alter(customer_code, json)customer.fetch(customer_code)customer.fetch_all()customer.change_card(customer_code, json)Setnew_vaultTrue to create a user with billing data.>>>frompyrecard.subscriptionimportcustomer>>>customer_data=customer.fetch('cliente01').json()>>>customer_data['address']['state']='MG'>>>response=customer.alter('cliente01',customer_data)>>>response<Response[200]>subscription.subscriptionThesubscriptionmodule performs the following operations:subscription.create(json, new_customer=False)subscription.alter(subscription_code, json)subscription.fetch(subscription_code)subscription.fetch_all()subscription.set_status(subscription_code, status)subscription.set_payment_method(subscription_code, method)subscription.fetch_all_invoices(subscription_code)Setnew_customerTrue to create a subscription with a new user.set_statusallowssuspend,activateorcancelset_payment_methodallowsCREDIT_CARDorBOLETO>>>frompyrecard.subscriptionimportsubscription>>>response=subscription.set_status('assinatura01','suspend')>>>response<Response[200]>More information check thesubscription documentationsubscription.paymentThepaymentmodule performs the following operations:payment.fetch_invoice(invoice_id)payment.fetch_invoice_payments(invoice_code)payment.payment_details(payment_code)payment.retry_invoice_payment(invoice_code)payment.generate_bank_slip(invoice_code, json)>>>frompyrecard.subscriptionimportpayment>>>response=payment.fetch_invoice('1025240')>>>response<Response[200]>>>>response.json(){'subscription_code':'assinatura01','amount':0,'id':1025240,'creation_date':{'month':1,'hour':14,'year':2016,'day':8,'minute':28,'second':52},'occurrence':1,'plan':{'code':'plan101','name':'Plano Especial'},'items':[{'amount':0,'type':'Período de trial'},'customer':{'code':'cliente03','fullname':'Nome Sobrenome','email':'nome@exemplo.com.br'},'status':{'code':3,'description':'Pago'}subscription.couponThecouponmodule performs the following operations:coupon.create(json)coupon.apply(subscription_code, coupon_code)coupon.fetch(coupon_code)coupon.fetch_all()coupon.set_status(coupon_code, status)coupon.remove(coupon_code)>>>frompyrecard.subscriptionimportcoupon>>>response=coupon.set_status('coupon-0001','active')>>>response<Response[400]>>>>response.json(){'errors':[{'code':'MA174','description':'Coupon expirado.'}]}More information check thecoupon documentationUsed by: